PagerTitleStrip.java
13 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
package android.support.v4.view;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.v4.widget.TextViewCompat;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.TextView;
import eh.a;
import java.lang.ref.WeakReference;
@ViewPager.DecorView
public class PagerTitleStrip
extends ViewGroup
{
private static final int[] n = { 16842804, 16842901, 16842904, 16842927 };
private static final int[] o = { 16843660 };
private static final b q = new c();
ViewPager a;
TextView b;
TextView c;
TextView d;
float e = -1.0F;
int f;
private int g = -1;
private int h;
private int i;
private boolean j;
private boolean k;
private final a l = new a();
private WeakReference<PagerAdapter> m;
private int p;
static
{
if (Build.VERSION.SDK_INT >= 14)
{
q = new d();
return;
}
}
public PagerTitleStrip(Context paramContext)
{
this(paramContext, null);
}
public PagerTitleStrip(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, paramAttributeSet);
TextView localTextView = new TextView(paramContext);
this.b = localTextView;
addView(localTextView);
localTextView = new TextView(paramContext);
this.c = localTextView;
addView(localTextView);
localTextView = new TextView(paramContext);
this.d = localTextView;
addView(localTextView);
paramAttributeSet = paramContext.obtainStyledAttributes(paramAttributeSet, n);
int i1 = paramAttributeSet.getResourceId(0, 0);
if (i1 != 0)
{
TextViewCompat.setTextAppearance(this.b, i1);
TextViewCompat.setTextAppearance(this.c, i1);
TextViewCompat.setTextAppearance(this.d, i1);
}
int i2 = paramAttributeSet.getDimensionPixelSize(1, 0);
if (i2 != 0) {
setTextSize(0, i2);
}
if (paramAttributeSet.hasValue(2))
{
i2 = paramAttributeSet.getColor(2, 0);
this.b.setTextColor(i2);
this.c.setTextColor(i2);
this.d.setTextColor(i2);
}
this.i = paramAttributeSet.getInteger(3, 80);
paramAttributeSet.recycle();
this.f = this.c.getTextColors().getDefaultColor();
setNonPrimaryAlpha(0.6F);
this.b.setEllipsize(TextUtils.TruncateAt.END);
this.c.setEllipsize(TextUtils.TruncateAt.END);
this.d.setEllipsize(TextUtils.TruncateAt.END);
if (i1 != 0)
{
paramAttributeSet = paramContext.obtainStyledAttributes(i1, o);
bool = paramAttributeSet.getBoolean(0, false);
paramAttributeSet.recycle();
}
if (bool)
{
setSingleLineAllCaps(this.b);
setSingleLineAllCaps(this.c);
setSingleLineAllCaps(this.d);
}
for (;;)
{
this.h = ((int)(paramContext.getResources().getDisplayMetrics().density * 16.0F));
return;
this.b.setSingleLine();
this.c.setSingleLine();
this.d.setSingleLine();
}
}
private static void setSingleLineAllCaps(TextView paramTextView)
{
q.a(paramTextView);
}
void a(int paramInt, float paramFloat, boolean paramBoolean)
{
int i4;
int i9;
int i3;
int i8;
int i5;
int i1;
int i7;
int i6;
int i2;
int i10;
int i12;
int i11;
int i13;
if (paramInt != this.g)
{
a(paramInt, this.a.getAdapter());
this.k = true;
i4 = this.b.getMeasuredWidth();
i9 = this.c.getMeasuredWidth();
i3 = this.d.getMeasuredWidth();
i8 = i9 / 2;
i5 = getWidth();
i1 = getHeight();
i7 = getPaddingLeft();
i6 = getPaddingRight();
paramInt = getPaddingTop();
i2 = getPaddingBottom();
i10 = i6 + i8;
float f2 = 0.5F + paramFloat;
float f1 = f2;
if (f2 > 1.0F) {
f1 = f2 - 1.0F;
}
i8 = i5 - i10 - (int)(f1 * (i5 - (i7 + i8) - i10)) - i8;
i9 = i8 + i9;
i12 = this.b.getBaseline();
i11 = this.c.getBaseline();
i10 = this.d.getBaseline();
i13 = Math.max(Math.max(i12, i11), i10);
i12 = i13 - i12;
i11 = i13 - i11;
i10 = i13 - i10;
i13 = this.b.getMeasuredHeight();
int i14 = this.c.getMeasuredHeight();
int i15 = this.d.getMeasuredHeight();
i13 = Math.max(Math.max(i13 + i12, i14 + i11), i15 + i10);
switch (this.i & 0x70)
{
default:
i2 = paramInt + i12;
i1 = paramInt + i11;
paramInt += i10;
}
}
for (;;)
{
this.c.layout(i8, i1, i9, this.c.getMeasuredHeight() + i1);
i1 = Math.min(i7, i8 - this.h - i4);
this.b.layout(i1, i2, i4 + i1, this.b.getMeasuredHeight() + i2);
i1 = Math.max(i5 - i6 - i3, this.h + i9);
this.d.layout(i1, paramInt, i1 + i3, this.d.getMeasuredHeight() + paramInt);
this.e = paramFloat;
this.k = false;
return;
if ((paramBoolean) || (paramFloat != this.e)) {
break;
}
return;
paramInt = (i1 - paramInt - i2 - i13) / 2;
i2 = paramInt + i12;
i1 = paramInt + i11;
paramInt += i10;
continue;
paramInt = i1 - i2 - i13;
i2 = paramInt + i12;
i1 = paramInt + i11;
paramInt += i10;
}
}
final void a(int paramInt, PagerAdapter paramPagerAdapter)
{
Object localObject2 = null;
int i1;
if (paramPagerAdapter != null)
{
i1 = paramPagerAdapter.getCount();
this.j = true;
if ((paramInt <= 0) || (paramPagerAdapter == null)) {
break label235;
}
}
label235:
for (Object localObject1 = paramPagerAdapter.getPageTitle(paramInt - 1);; localObject1 = null)
{
this.b.setText((CharSequence)localObject1);
TextView localTextView = this.c;
if ((paramPagerAdapter != null) && (paramInt < i1)) {}
for (localObject1 = paramPagerAdapter.getPageTitle(paramInt);; localObject1 = null)
{
localTextView.setText((CharSequence)localObject1);
localObject1 = localObject2;
if (paramInt + 1 < i1)
{
localObject1 = localObject2;
if (paramPagerAdapter != null) {
localObject1 = paramPagerAdapter.getPageTitle(paramInt + 1);
}
}
this.d.setText((CharSequence)localObject1);
i1 = View.MeasureSpec.makeMeasureSpec(Math.max(0, (int)((getWidth() - getPaddingLeft() - getPaddingRight()) * 0.8F)), Integer.MIN_VALUE);
int i2 = View.MeasureSpec.makeMeasureSpec(Math.max(0, getHeight() - getPaddingTop() - getPaddingBottom()), Integer.MIN_VALUE);
this.b.measure(i1, i2);
this.c.measure(i1, i2);
this.d.measure(i1, i2);
this.g = paramInt;
if (!this.k) {
a(paramInt, this.e, false);
}
this.j = false;
return;
i1 = 0;
break;
}
}
}
final void a(PagerAdapter paramPagerAdapter1, PagerAdapter paramPagerAdapter2)
{
if (paramPagerAdapter1 != null)
{
paramPagerAdapter1.unregisterDataSetObserver(this.l);
this.m = null;
}
if (paramPagerAdapter2 != null)
{
paramPagerAdapter2.registerDataSetObserver(this.l);
this.m = new WeakReference(paramPagerAdapter2);
}
if (this.a != null)
{
this.g = -1;
this.e = -1.0F;
a(this.a.getCurrentItem(), paramPagerAdapter2);
requestLayout();
}
}
int getMinHeight()
{
int i1 = 0;
Drawable localDrawable = getBackground();
if (localDrawable != null) {
i1 = localDrawable.getIntrinsicHeight();
}
return i1;
}
public int getTextSpacing()
{
return this.h;
}
protected void onAttachedToWindow()
{
super.onAttachedToWindow();
Object localObject = getParent();
if (!(localObject instanceof ViewPager)) {
throw new IllegalStateException("PagerTitleStrip must be a direct child of a ViewPager.");
}
localObject = (ViewPager)localObject;
PagerAdapter localPagerAdapter = ((ViewPager)localObject).getAdapter();
((ViewPager)localObject).a(this.l);
((ViewPager)localObject).addOnAdapterChangeListener(this.l);
this.a = ((ViewPager)localObject);
if (this.m != null) {}
for (localObject = (PagerAdapter)this.m.get();; localObject = null)
{
a((PagerAdapter)localObject, localPagerAdapter);
return;
}
}
protected void onDetachedFromWindow()
{
super.onDetachedFromWindow();
if (this.a != null)
{
a(this.a.getAdapter(), null);
this.a.a(null);
this.a.removeOnAdapterChangeListener(this.l);
this.a = null;
}
}
protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
float f1 = 0.0F;
if (this.a != null)
{
if (this.e >= 0.0F) {
f1 = this.e;
}
a(this.g, f1, true);
}
}
protected void onMeasure(int paramInt1, int paramInt2)
{
if (View.MeasureSpec.getMode(paramInt1) != 1073741824) {
throw new IllegalStateException("Must measure with an exact width");
}
int i2 = getPaddingTop() + getPaddingBottom();
int i3 = getChildMeasureSpec(paramInt2, i2, -2);
int i1 = View.MeasureSpec.getSize(paramInt1);
paramInt1 = getChildMeasureSpec(paramInt1, (int)(i1 * 0.2F), -2);
this.b.measure(paramInt1, i3);
this.c.measure(paramInt1, i3);
this.d.measure(paramInt1, i3);
if (View.MeasureSpec.getMode(paramInt2) == 1073741824) {}
for (paramInt1 = View.MeasureSpec.getSize(paramInt2);; paramInt1 = Math.max(getMinHeight(), i2 + paramInt1))
{
setMeasuredDimension(i1, ViewCompat.resolveSizeAndState(paramInt1, paramInt2, ViewCompat.getMeasuredState(this.c) << 16));
return;
paramInt1 = this.c.getMeasuredHeight();
}
}
public void requestLayout()
{
if (!this.j) {
super.requestLayout();
}
}
public void setGravity(int paramInt)
{
this.i = paramInt;
requestLayout();
}
public void setNonPrimaryAlpha(@FloatRange(from=0.0D, to=1.0D) float paramFloat)
{
this.p = ((int)(255.0F * paramFloat) & 0xFF);
int i1 = this.p << 24 | this.f & 0xFFFFFF;
this.b.setTextColor(i1);
this.d.setTextColor(i1);
}
public void setTextColor(@ColorInt int paramInt)
{
this.f = paramInt;
this.c.setTextColor(paramInt);
paramInt = this.p << 24 | this.f & 0xFFFFFF;
this.b.setTextColor(paramInt);
this.d.setTextColor(paramInt);
}
public void setTextSize(int paramInt, float paramFloat)
{
this.b.setTextSize(paramInt, paramFloat);
this.c.setTextSize(paramInt, paramFloat);
this.d.setTextSize(paramInt, paramFloat);
}
public void setTextSpacing(int paramInt)
{
this.h = paramInt;
requestLayout();
}
final class a
extends DataSetObserver
implements ViewPager.OnAdapterChangeListener, ViewPager.OnPageChangeListener
{
private int b;
a() {}
public final void onAdapterChanged(ViewPager paramViewPager, PagerAdapter paramPagerAdapter1, PagerAdapter paramPagerAdapter2)
{
PagerTitleStrip.this.a(paramPagerAdapter1, paramPagerAdapter2);
}
public final void onChanged()
{
float f = 0.0F;
PagerTitleStrip.this.a(PagerTitleStrip.this.a.getCurrentItem(), PagerTitleStrip.this.a.getAdapter());
if (PagerTitleStrip.this.e >= 0.0F) {
f = PagerTitleStrip.this.e;
}
PagerTitleStrip.this.a(PagerTitleStrip.this.a.getCurrentItem(), f, true);
}
public final void onPageScrollStateChanged(int paramInt)
{
this.b = paramInt;
}
public final void onPageScrolled(int paramInt1, float paramFloat, int paramInt2)
{
paramInt2 = paramInt1;
if (paramFloat > 0.5F) {
paramInt2 = paramInt1 + 1;
}
PagerTitleStrip.this.a(paramInt2, paramFloat, false);
}
public final void onPageSelected(int paramInt)
{
float f = 0.0F;
if (this.b == 0)
{
PagerTitleStrip.this.a(PagerTitleStrip.this.a.getCurrentItem(), PagerTitleStrip.this.a.getAdapter());
if (PagerTitleStrip.this.e >= 0.0F) {
f = PagerTitleStrip.this.e;
}
PagerTitleStrip.this.a(PagerTitleStrip.this.a.getCurrentItem(), f, true);
}
}
}
static abstract interface b
{
public abstract void a(TextView paramTextView);
}
static final class c
implements PagerTitleStrip.b
{
public final void a(TextView paramTextView)
{
paramTextView.setSingleLine();
}
}
static final class d
implements PagerTitleStrip.b
{
public final void a(TextView paramTextView)
{
paramTextView.setTransformationMethod(new eh.a(paramTextView.getContext()));
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/view/PagerTitleStrip.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/