FragmentStatePagerAdapter.java
6.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package android.support.v13.app;
import android.annotation.TargetApi;
import android.app.Fragment;
import android.app.Fragment.SavedState;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.RequiresApi;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.Iterator;
@TargetApi(13)
@RequiresApi(13)
public abstract class FragmentStatePagerAdapter
extends PagerAdapter
{
private final FragmentManager a;
private FragmentTransaction b = null;
private ArrayList<Fragment.SavedState> c = new ArrayList();
private ArrayList<Fragment> d = new ArrayList();
private Fragment e = null;
public FragmentStatePagerAdapter(FragmentManager paramFragmentManager)
{
this.a = paramFragmentManager;
}
public void destroyItem(ViewGroup paramViewGroup, int paramInt, Object paramObject)
{
paramObject = (Fragment)paramObject;
if (this.b == null) {
this.b = this.a.beginTransaction();
}
while (this.c.size() <= paramInt) {
this.c.add(null);
}
ArrayList localArrayList = this.c;
if (((Fragment)paramObject).isAdded()) {}
for (paramViewGroup = this.a.saveFragmentInstanceState((Fragment)paramObject);; paramViewGroup = null)
{
localArrayList.set(paramInt, paramViewGroup);
this.d.set(paramInt, null);
this.b.remove((Fragment)paramObject);
return;
}
}
public void finishUpdate(ViewGroup paramViewGroup)
{
if (this.b != null)
{
this.b.commitAllowingStateLoss();
this.b = null;
this.a.executePendingTransactions();
}
}
public abstract Fragment getItem(int paramInt);
public Object instantiateItem(ViewGroup paramViewGroup, int paramInt)
{
if (this.d.size() > paramInt)
{
localFragment = (Fragment)this.d.get(paramInt);
if (localFragment != null) {
return localFragment;
}
}
if (this.b == null) {
this.b = this.a.beginTransaction();
}
Fragment localFragment = getItem(paramInt);
if (this.c.size() > paramInt)
{
Fragment.SavedState localSavedState = (Fragment.SavedState)this.c.get(paramInt);
if (localSavedState != null) {
localFragment.setInitialSavedState(localSavedState);
}
}
while (this.d.size() <= paramInt) {
this.d.add(null);
}
FragmentCompat.setMenuVisibility(localFragment, false);
FragmentCompat.setUserVisibleHint(localFragment, false);
this.d.set(paramInt, localFragment);
this.b.add(paramViewGroup.getId(), localFragment);
return localFragment;
}
public boolean isViewFromObject(View paramView, Object paramObject)
{
return ((Fragment)paramObject).getView() == paramView;
}
public void restoreState(Parcelable paramParcelable, ClassLoader paramClassLoader)
{
if (paramParcelable != null)
{
paramParcelable = (Bundle)paramParcelable;
paramParcelable.setClassLoader(paramClassLoader);
paramClassLoader = paramParcelable.getParcelableArray("states");
this.c.clear();
this.d.clear();
int i;
if (paramClassLoader != null)
{
i = 0;
while (i < paramClassLoader.length)
{
this.c.add((Fragment.SavedState)paramClassLoader[i]);
i += 1;
}
}
paramClassLoader = paramParcelable.keySet().iterator();
while (paramClassLoader.hasNext())
{
String str = (String)paramClassLoader.next();
if (str.startsWith("f"))
{
i = Integer.parseInt(str.substring(1));
Fragment localFragment = this.a.getFragment(paramParcelable, str);
if (localFragment != null)
{
while (this.d.size() <= i) {
this.d.add(null);
}
FragmentCompat.setMenuVisibility(localFragment, false);
this.d.set(i, localFragment);
}
else
{
Log.w("FragmentStatePagerAdapter", "Bad fragment at key " + str);
}
}
}
}
}
public Parcelable saveState()
{
Object localObject1 = null;
Object localObject2;
if (this.c.size() > 0)
{
localObject1 = new Bundle();
localObject2 = new Fragment.SavedState[this.c.size()];
this.c.toArray((Object[])localObject2);
((Bundle)localObject1).putParcelableArray("states", (Parcelable[])localObject2);
}
int i = 0;
while (i < this.d.size())
{
Fragment localFragment = (Fragment)this.d.get(i);
localObject2 = localObject1;
if (localFragment != null)
{
localObject2 = localObject1;
if (localFragment.isAdded())
{
localObject2 = localObject1;
if (localObject1 == null) {
localObject2 = new Bundle();
}
localObject1 = "f" + i;
this.a.putFragment((Bundle)localObject2, (String)localObject1, localFragment);
}
}
i += 1;
localObject1 = localObject2;
}
return (Parcelable)localObject1;
}
public void setPrimaryItem(ViewGroup paramViewGroup, int paramInt, Object paramObject)
{
paramViewGroup = (Fragment)paramObject;
if (paramViewGroup != this.e)
{
if (this.e != null)
{
FragmentCompat.setMenuVisibility(this.e, false);
FragmentCompat.setUserVisibleHint(this.e, false);
}
if (paramViewGroup != null)
{
FragmentCompat.setMenuVisibility(paramViewGroup, true);
FragmentCompat.setUserVisibleHint(paramViewGroup, true);
}
this.e = paramViewGroup;
}
}
public void startUpdate(ViewGroup paramViewGroup)
{
if (paramViewGroup.getId() == -1) {
throw new IllegalStateException("ViewPager with adapter " + this + " requires a view id");
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v13/app/FragmentStatePagerAdapter.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/