BottomNavigationMenuView.java
10.2 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
package android.support.design.internal;
import a;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.os.Build.VERSION;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.design.R.dimen;
import android.support.v4.util.Pools.Pool;
import android.support.v4.util.Pools.SynchronizedPool;
import android.support.v4.view.ViewCompat;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.view.menu.MenuItemImpl;
import android.support.v7.view.menu.MenuView;
import android.util.AttributeSet;
import android.view.MenuItem;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import b;
@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class BottomNavigationMenuView
extends ViewGroup
implements MenuView
{
private static final Pools.Pool<BottomNavigationItemView> g = new Pools.SynchronizedPool(5);
private final int a;
private final int b;
private final int c;
private final int d;
private final View.OnClickListener e;
private final a f;
private boolean h = true;
private BottomNavigationItemView[] i;
private int j = 0;
private ColorStateList k;
private ColorStateList l;
private int m;
private int[] n;
private BottomNavigationPresenter o;
private MenuBuilder p;
public BottomNavigationMenuView(Context paramContext)
{
this(paramContext, null);
}
public BottomNavigationMenuView(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, paramAttributeSet);
paramContext = getResources();
this.a = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_max_width);
this.b = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_min_width);
this.c = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_item_max_width);
this.d = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_height);
if (Build.VERSION.SDK_INT >= 14) {}
for (this.f = new b();; this.f = new a())
{
this.e = new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
paramAnonymousView = (BottomNavigationItemView)paramAnonymousView;
int i = paramAnonymousView.getItemPosition();
if (!BottomNavigationMenuView.b(BottomNavigationMenuView.this).performItemAction(paramAnonymousView.getItemData(), BottomNavigationMenuView.a(BottomNavigationMenuView.this), 0)) {
BottomNavigationMenuView.a(BottomNavigationMenuView.this, i);
}
}
};
this.n = new int[5];
return;
}
}
private BottomNavigationItemView getNewItem()
{
BottomNavigationItemView localBottomNavigationItemView2 = (BottomNavigationItemView)g.acquire();
BottomNavigationItemView localBottomNavigationItemView1 = localBottomNavigationItemView2;
if (localBottomNavigationItemView2 == null) {
localBottomNavigationItemView1 = new BottomNavigationItemView(getContext());
}
return localBottomNavigationItemView1;
}
public void buildMenuView()
{
Object localObject1;
int i1;
if (this.i != null)
{
localObject1 = this.i;
int i2 = localObject1.length;
i1 = 0;
while (i1 < i2)
{
Object localObject2 = localObject1[i1];
g.release(localObject2);
i1 += 1;
}
}
removeAllViews();
if (this.p.size() == 0)
{
this.i = null;
return;
}
this.i = new BottomNavigationItemView[this.p.size()];
if (this.p.size() > 3) {}
for (boolean bool = true;; bool = false)
{
this.h = bool;
i1 = 0;
while (i1 < this.p.size())
{
this.o.setUpdateSuspended(true);
this.p.getItem(i1).setCheckable(true);
this.o.setUpdateSuspended(false);
localObject1 = getNewItem();
this.i[i1] = localObject1;
((BottomNavigationItemView)localObject1).setIconTintList(this.k);
((BottomNavigationItemView)localObject1).setTextColor(this.l);
((BottomNavigationItemView)localObject1).setItemBackground(this.m);
((BottomNavigationItemView)localObject1).setShiftingMode(this.h);
((BottomNavigationItemView)localObject1).initialize((MenuItemImpl)this.p.getItem(i1), 0);
((BottomNavigationItemView)localObject1).setItemPosition(i1);
((BottomNavigationItemView)localObject1).setOnClickListener(this.e);
addView((View)localObject1);
i1 += 1;
}
}
this.j = Math.min(this.p.size() - 1, this.j);
this.p.getItem(this.j).setChecked(true);
}
@Nullable
public ColorStateList getIconTintList()
{
return this.k;
}
public int getItemBackgroundRes()
{
return this.m;
}
public ColorStateList getItemTextColor()
{
return this.l;
}
public int getWindowAnimations()
{
return 0;
}
public void initialize(MenuBuilder paramMenuBuilder)
{
this.p = paramMenuBuilder;
}
protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
int i1 = getChildCount();
int i2 = paramInt3 - paramInt1;
paramInt4 -= paramInt2;
paramInt1 = 0;
paramInt2 = 0;
if (paramInt1 < i1)
{
View localView = getChildAt(paramInt1);
paramInt3 = paramInt2;
if (localView.getVisibility() != 8)
{
if (ViewCompat.getLayoutDirection(this) != 1) {
break label97;
}
localView.layout(i2 - paramInt2 - localView.getMeasuredWidth(), 0, i2 - paramInt2, paramInt4);
}
for (;;)
{
paramInt3 = paramInt2 + localView.getMeasuredWidth();
paramInt1 += 1;
paramInt2 = paramInt3;
break;
label97:
localView.layout(paramInt2, 0, localView.getMeasuredWidth() + paramInt2, paramInt4);
}
}
}
protected void onMeasure(int paramInt1, int paramInt2)
{
paramInt2 = View.MeasureSpec.getSize(paramInt1);
int i2 = getChildCount();
int i5 = View.MeasureSpec.makeMeasureSpec(this.d, 1073741824);
int i3;
int i4;
Object localObject;
int i1;
if (this.h)
{
paramInt1 = i2 - 1;
i3 = Math.min(paramInt2 - this.b * paramInt1, this.c);
i4 = Math.min((paramInt2 - i3) / paramInt1, this.a);
paramInt1 = paramInt2 - i3 - paramInt1 * i4;
paramInt2 = 0;
if (paramInt2 >= i2) {
break label228;
}
localObject = this.n;
if (paramInt2 == this.j)
{
i1 = i3;
label102:
localObject[paramInt2] = i1;
if (paramInt1 <= 0) {
break label333;
}
localObject = this.n;
localObject[paramInt2] += 1;
paramInt1 -= 1;
}
}
label228:
label333:
for (;;)
{
paramInt2 += 1;
break;
i1 = i4;
break label102;
if (i2 == 0) {}
for (paramInt1 = 1;; paramInt1 = i2)
{
i3 = Math.min(paramInt2 / paramInt1, this.c);
paramInt2 -= i3 * i2;
paramInt1 = 0;
while (paramInt1 < i2)
{
this.n[paramInt1] = i3;
i1 = paramInt2;
if (paramInt2 > 0)
{
localObject = this.n;
localObject[paramInt1] += 1;
i1 = paramInt2 - 1;
}
paramInt1 += 1;
paramInt2 = i1;
}
}
paramInt1 = 0;
for (paramInt2 = 0; paramInt1 < i2; paramInt2 = i1)
{
localObject = getChildAt(paramInt1);
i1 = paramInt2;
if (((View)localObject).getVisibility() != 8)
{
((View)localObject).measure(View.MeasureSpec.makeMeasureSpec(this.n[paramInt1], 1073741824), i5);
((View)localObject).getLayoutParams().width = ((View)localObject).getMeasuredWidth();
i1 = paramInt2 + ((View)localObject).getMeasuredWidth();
}
paramInt1 += 1;
}
setMeasuredDimension(ViewCompat.resolveSizeAndState(paramInt2, View.MeasureSpec.makeMeasureSpec(paramInt2, 1073741824), 0), ViewCompat.resolveSizeAndState(this.d, i5, 0));
return;
}
}
public void setIconTintList(ColorStateList paramColorStateList)
{
this.k = paramColorStateList;
if (this.i == null) {}
for (;;)
{
return;
BottomNavigationItemView[] arrayOfBottomNavigationItemView = this.i;
int i2 = arrayOfBottomNavigationItemView.length;
int i1 = 0;
while (i1 < i2)
{
arrayOfBottomNavigationItemView[i1].setIconTintList(paramColorStateList);
i1 += 1;
}
}
}
public void setItemBackgroundRes(int paramInt)
{
this.m = paramInt;
if (this.i == null) {}
for (;;)
{
return;
BottomNavigationItemView[] arrayOfBottomNavigationItemView = this.i;
int i2 = arrayOfBottomNavigationItemView.length;
int i1 = 0;
while (i1 < i2)
{
arrayOfBottomNavigationItemView[i1].setItemBackground(paramInt);
i1 += 1;
}
}
}
public void setItemTextColor(ColorStateList paramColorStateList)
{
this.l = paramColorStateList;
if (this.i == null) {}
for (;;)
{
return;
BottomNavigationItemView[] arrayOfBottomNavigationItemView = this.i;
int i2 = arrayOfBottomNavigationItemView.length;
int i1 = 0;
while (i1 < i2)
{
arrayOfBottomNavigationItemView[i1].setTextColor(paramColorStateList);
i1 += 1;
}
}
}
public void setPresenter(BottomNavigationPresenter paramBottomNavigationPresenter)
{
this.o = paramBottomNavigationPresenter;
}
public void updateMenuView()
{
int i2 = this.p.size();
if (i2 != this.i.length) {
buildMenuView();
}
for (;;)
{
return;
int i1 = 0;
while (i1 < i2)
{
this.o.setUpdateSuspended(true);
if (this.p.getItem(i1).isChecked()) {
this.j = i1;
}
this.i[i1].initialize((MenuItemImpl)this.p.getItem(i1), 0);
this.o.setUpdateSuspended(false);
i1 += 1;
}
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/design/internal/BottomNavigationMenuView.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/