ListMenuPresenter.java
7.64 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
package android.support.v7.view.menu;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.RestrictTo;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder;
import android.support.v7.appcompat.R.layout;
import android.util.SparseArray;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import fu;
import java.util.ArrayList;
@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class ListMenuPresenter
implements MenuPresenter, AdapterView.OnItemClickListener
{
public static final String VIEWS_TAG = "android:menu:list";
Context a;
LayoutInflater b;
MenuBuilder c;
ExpandedMenuView d;
int e;
int f;
int g;
a h;
private MenuPresenter.Callback i;
private int j;
public ListMenuPresenter(int paramInt1, int paramInt2)
{
this.g = paramInt1;
this.f = paramInt2;
}
public ListMenuPresenter(Context paramContext, int paramInt)
{
this(paramInt, 0);
this.a = paramContext;
this.b = LayoutInflater.from(this.a);
}
public boolean collapseItemActionView(MenuBuilder paramMenuBuilder, MenuItemImpl paramMenuItemImpl)
{
return false;
}
public boolean expandItemActionView(MenuBuilder paramMenuBuilder, MenuItemImpl paramMenuItemImpl)
{
return false;
}
public boolean flagActionItems()
{
return false;
}
public ListAdapter getAdapter()
{
if (this.h == null) {
this.h = new a();
}
return this.h;
}
public int getId()
{
return this.j;
}
public MenuView getMenuView(ViewGroup paramViewGroup)
{
if (this.d == null)
{
this.d = ((ExpandedMenuView)this.b.inflate(R.layout.abc_expanded_menu_layout, paramViewGroup, false));
if (this.h == null) {
this.h = new a();
}
this.d.setAdapter(this.h);
this.d.setOnItemClickListener(this);
}
return this.d;
}
public void initForMenu(Context paramContext, MenuBuilder paramMenuBuilder)
{
if (this.f != 0)
{
this.a = new ContextThemeWrapper(paramContext, this.f);
this.b = LayoutInflater.from(this.a);
}
for (;;)
{
this.c = paramMenuBuilder;
if (this.h != null) {
this.h.notifyDataSetChanged();
}
return;
if (this.a != null)
{
this.a = paramContext;
if (this.b == null) {
this.b = LayoutInflater.from(this.a);
}
}
}
}
public void onCloseMenu(MenuBuilder paramMenuBuilder, boolean paramBoolean)
{
if (this.i != null) {
this.i.onCloseMenu(paramMenuBuilder, paramBoolean);
}
}
public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
{
this.c.performItemAction(this.h.a(paramInt), this, 0);
}
public void onRestoreInstanceState(Parcelable paramParcelable)
{
restoreHierarchyState((Bundle)paramParcelable);
}
public Parcelable onSaveInstanceState()
{
if (this.d == null) {
return null;
}
Bundle localBundle = new Bundle();
saveHierarchyState(localBundle);
return localBundle;
}
public boolean onSubMenuSelected(SubMenuBuilder paramSubMenuBuilder)
{
if (!paramSubMenuBuilder.hasVisibleItems()) {
return false;
}
fu localfu = new fu(paramSubMenuBuilder);
Object localObject = localfu.a;
AlertDialog.Builder localBuilder = new AlertDialog.Builder(((MenuBuilder)localObject).getContext());
localfu.c = new ListMenuPresenter(localBuilder.getContext(), R.layout.abc_list_menu_item_layout);
localfu.c.setCallback(localfu);
localfu.a.addMenuPresenter(localfu.c);
localBuilder.setAdapter(localfu.c.getAdapter(), localfu);
View localView = ((MenuBuilder)localObject).getHeaderView();
if (localView != null) {
localBuilder.setCustomTitle(localView);
}
for (;;)
{
localBuilder.setOnKeyListener(localfu);
localfu.b = localBuilder.create();
localfu.b.setOnDismissListener(localfu);
localObject = localfu.b.getWindow().getAttributes();
((WindowManager.LayoutParams)localObject).type = 1003;
((WindowManager.LayoutParams)localObject).flags |= 0x20000;
localfu.b.show();
if (this.i != null) {
this.i.onOpenSubMenu(paramSubMenuBuilder);
}
return true;
localBuilder.setIcon(((MenuBuilder)localObject).getHeaderIcon()).setTitle(((MenuBuilder)localObject).getHeaderTitle());
}
}
public void restoreHierarchyState(Bundle paramBundle)
{
paramBundle = paramBundle.getSparseParcelableArray("android:menu:list");
if (paramBundle != null) {
this.d.restoreHierarchyState(paramBundle);
}
}
public void saveHierarchyState(Bundle paramBundle)
{
SparseArray localSparseArray = new SparseArray();
if (this.d != null) {
this.d.saveHierarchyState(localSparseArray);
}
paramBundle.putSparseParcelableArray("android:menu:list", localSparseArray);
}
public void setCallback(MenuPresenter.Callback paramCallback)
{
this.i = paramCallback;
}
public void setId(int paramInt)
{
this.j = paramInt;
}
public void setItemIndexOffset(int paramInt)
{
this.e = paramInt;
if (this.d != null) {
updateMenuView(false);
}
}
public void updateMenuView(boolean paramBoolean)
{
if (this.h != null) {
this.h.notifyDataSetChanged();
}
}
final class a
extends BaseAdapter
{
private int b = -1;
public a()
{
a();
}
private void a()
{
MenuItemImpl localMenuItemImpl = ListMenuPresenter.this.c.getExpandedItem();
if (localMenuItemImpl != null)
{
ArrayList localArrayList = ListMenuPresenter.this.c.getNonActionItems();
int j = localArrayList.size();
int i = 0;
while (i < j)
{
if ((MenuItemImpl)localArrayList.get(i) == localMenuItemImpl)
{
this.b = i;
return;
}
i += 1;
}
}
this.b = -1;
}
public final MenuItemImpl a(int paramInt)
{
ArrayList localArrayList = ListMenuPresenter.this.c.getNonActionItems();
int i = ListMenuPresenter.this.e + paramInt;
paramInt = i;
if (this.b >= 0)
{
paramInt = i;
if (i >= this.b) {
paramInt = i + 1;
}
}
return (MenuItemImpl)localArrayList.get(paramInt);
}
public final int getCount()
{
int i = ListMenuPresenter.this.c.getNonActionItems().size() - ListMenuPresenter.this.e;
if (this.b < 0) {
return i;
}
return i - 1;
}
public final long getItemId(int paramInt)
{
return paramInt;
}
public final View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
{
if (paramView == null) {
paramView = ListMenuPresenter.this.b.inflate(ListMenuPresenter.this.g, paramViewGroup, false);
}
for (;;)
{
((MenuView.ItemView)paramView).initialize(a(paramInt), 0);
return paramView;
}
}
public final void notifyDataSetChanged()
{
a();
super.notifyDataSetChanged();
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/view/menu/ListMenuPresenter.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/