FragmentTabHost.java
9.08 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
package android.support.v4.app;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.BaseSavedState;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabContentFactory;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import java.util.ArrayList;
public class FragmentTabHost
extends TabHost
implements TabHost.OnTabChangeListener
{
private final ArrayList<b> a = new ArrayList();
private FrameLayout b;
private Context c;
private FragmentManager d;
private int e;
private TabHost.OnTabChangeListener f;
private b g;
private boolean h;
public FragmentTabHost(Context paramContext)
{
super(paramContext, null);
a(paramContext, null);
}
public FragmentTabHost(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, paramAttributeSet);
a(paramContext, paramAttributeSet);
}
@Nullable
private FragmentTransaction a(@Nullable String paramString, @Nullable FragmentTransaction paramFragmentTransaction)
{
int j = this.a.size();
int i = 0;
b localb;
if (i < j)
{
localb = (b)this.a.get(i);
if (localb.a.equals(paramString))
{
label42:
paramString = paramFragmentTransaction;
if (this.g != localb)
{
paramString = paramFragmentTransaction;
if (paramFragmentTransaction == null) {
paramString = this.d.beginTransaction();
}
if ((this.g != null) && (this.g.d != null)) {
paramString.detach(this.g.d);
}
if (localb != null)
{
if (localb.d != null) {
break label174;
}
localb.d = Fragment.instantiate(this.c, localb.b.getName(), localb.c);
paramString.add(this.e, localb.d, localb.a);
}
}
}
}
for (;;)
{
this.g = localb;
return paramString;
i += 1;
break;
localb = null;
break label42;
label174:
paramString.attach(localb.d);
}
}
private void a()
{
if (this.b == null)
{
this.b = ((FrameLayout)findViewById(this.e));
if (this.b == null) {
throw new IllegalStateException("No tab content FrameLayout found for id " + this.e);
}
}
}
private void a(Context paramContext)
{
if (findViewById(16908307) == null)
{
LinearLayout localLinearLayout = new LinearLayout(paramContext);
localLinearLayout.setOrientation(1);
addView(localLinearLayout, new FrameLayout.LayoutParams(-1, -1));
Object localObject = new TabWidget(paramContext);
((TabWidget)localObject).setId(16908307);
((TabWidget)localObject).setOrientation(0);
localLinearLayout.addView((View)localObject, new LinearLayout.LayoutParams(-1, -2, 0.0F));
localObject = new FrameLayout(paramContext);
((FrameLayout)localObject).setId(16908305);
localLinearLayout.addView((View)localObject, new LinearLayout.LayoutParams(0, 0, 0.0F));
paramContext = new FrameLayout(paramContext);
this.b = paramContext;
this.b.setId(this.e);
localLinearLayout.addView(paramContext, new LinearLayout.LayoutParams(-1, 0, 1.0F));
}
}
private void a(Context paramContext, AttributeSet paramAttributeSet)
{
paramContext = paramContext.obtainStyledAttributes(paramAttributeSet, new int[] { 16842995 }, 0, 0);
this.e = paramContext.getResourceId(0, 0);
paramContext.recycle();
super.setOnTabChangedListener(this);
}
public void addTab(@NonNull TabHost.TabSpec paramTabSpec, @NonNull Class<?> paramClass, @Nullable Bundle paramBundle)
{
paramTabSpec.setContent(new a(this.c));
String str = paramTabSpec.getTag();
paramClass = new b(str, paramClass, paramBundle);
if (this.h)
{
paramClass.d = this.d.findFragmentByTag(str);
if ((paramClass.d != null) && (!paramClass.d.isDetached()))
{
paramBundle = this.d.beginTransaction();
paramBundle.detach(paramClass.d);
paramBundle.commit();
}
}
this.a.add(paramClass);
addTab(paramTabSpec);
}
protected void onAttachedToWindow()
{
super.onAttachedToWindow();
String str = getCurrentTabTag();
Object localObject1 = null;
int j = this.a.size();
int i = 0;
if (i < j)
{
b localb = (b)this.a.get(i);
localb.d = this.d.findFragmentByTag(localb.a);
Object localObject2 = localObject1;
if (localb.d != null)
{
localObject2 = localObject1;
if (!localb.d.isDetached())
{
if (!localb.a.equals(str)) {
break label114;
}
this.g = localb;
localObject2 = localObject1;
}
}
for (;;)
{
i += 1;
localObject1 = localObject2;
break;
label114:
localObject2 = localObject1;
if (localObject1 == null) {
localObject2 = this.d.beginTransaction();
}
((FragmentTransaction)localObject2).detach(localb.d);
}
}
this.h = true;
localObject1 = a(str, (FragmentTransaction)localObject1);
if (localObject1 != null)
{
((FragmentTransaction)localObject1).commit();
this.d.executePendingTransactions();
}
}
protected void onDetachedFromWindow()
{
super.onDetachedFromWindow();
this.h = false;
}
protected void onRestoreInstanceState(Parcelable paramParcelable)
{
if (!(paramParcelable instanceof SavedState))
{
super.onRestoreInstanceState(paramParcelable);
return;
}
paramParcelable = (SavedState)paramParcelable;
super.onRestoreInstanceState(paramParcelable.getSuperState());
setCurrentTabByTag(paramParcelable.a);
}
protected Parcelable onSaveInstanceState()
{
SavedState localSavedState = new SavedState(super.onSaveInstanceState());
localSavedState.a = getCurrentTabTag();
return localSavedState;
}
public void onTabChanged(String paramString)
{
if (this.h)
{
FragmentTransaction localFragmentTransaction = a(paramString, null);
if (localFragmentTransaction != null) {
localFragmentTransaction.commit();
}
}
if (this.f != null) {
this.f.onTabChanged(paramString);
}
}
public void setOnTabChangedListener(TabHost.OnTabChangeListener paramOnTabChangeListener)
{
this.f = paramOnTabChangeListener;
}
@Deprecated
public void setup()
{
throw new IllegalStateException("Must call setup() that takes a Context and FragmentManager");
}
public void setup(Context paramContext, FragmentManager paramFragmentManager)
{
a(paramContext);
super.setup();
this.c = paramContext;
this.d = paramFragmentManager;
a();
}
public void setup(Context paramContext, FragmentManager paramFragmentManager, int paramInt)
{
a(paramContext);
super.setup();
this.c = paramContext;
this.d = paramFragmentManager;
this.e = paramInt;
a();
this.b.setId(paramInt);
if (getId() == -1) {
setId(16908306);
}
}
static class SavedState
extends View.BaseSavedState
{
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator() {};
String a;
SavedState(Parcel paramParcel)
{
super();
this.a = paramParcel.readString();
}
SavedState(Parcelable paramParcelable)
{
super();
}
public String toString()
{
return "FragmentTabHost.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " curTab=" + this.a + "}";
}
public void writeToParcel(Parcel paramParcel, int paramInt)
{
super.writeToParcel(paramParcel, paramInt);
paramParcel.writeString(this.a);
}
}
static final class a
implements TabHost.TabContentFactory
{
private final Context a;
public a(Context paramContext)
{
this.a = paramContext;
}
public final View createTabContent(String paramString)
{
paramString = new View(this.a);
paramString.setMinimumWidth(0);
paramString.setMinimumHeight(0);
return paramString;
}
}
static final class b
{
@NonNull
final String a;
@NonNull
final Class<?> b;
@Nullable
final Bundle c;
Fragment d;
b(@NonNull String paramString, @NonNull Class<?> paramClass, @Nullable Bundle paramBundle)
{
this.a = paramString;
this.b = paramClass;
this.c = paramBundle;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/app/FragmentTabHost.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/