gy.java
18.1 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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
import android.app.SearchManager;
import android.app.SearchableInfo;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.content.res.Resources.Theme;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.net.Uri;
import android.net.Uri.Builder;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.ResourceCursorAdapter;
import android.support.v7.appcompat.R.attr;
import android.support.v7.appcompat.R.id;
import android.support.v7.widget.SearchView;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.TextAppearanceSpan;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.WeakHashMap;
public final class gy
extends ResourceCursorAdapter
implements View.OnClickListener
{
public int a = 1;
private final SearchManager b = (SearchManager)this.mContext.getSystemService("search");
private final SearchView c;
private final SearchableInfo d;
private final Context e;
private final WeakHashMap<String, Drawable.ConstantState> f;
private final int g;
private boolean h = false;
private ColorStateList i;
private int j = -1;
private int k = -1;
private int l = -1;
private int m = -1;
private int n = -1;
private int o = -1;
public gy(Context paramContext, SearchView paramSearchView, SearchableInfo paramSearchableInfo, WeakHashMap<String, Drawable.ConstantState> paramWeakHashMap)
{
super(paramContext, paramSearchView.getSuggestionRowLayout(), null, true);
this.c = paramSearchView;
this.d = paramSearchableInfo;
this.g = paramSearchView.getSuggestionCommitIconResId();
this.e = paramContext;
this.f = paramWeakHashMap;
}
private Drawable a(ComponentName paramComponentName)
{
Object localObject = this.mContext.getPackageManager();
ActivityInfo localActivityInfo;
int i1;
try
{
localActivityInfo = ((PackageManager)localObject).getActivityInfo(paramComponentName, 128);
i1 = localActivityInfo.getIconResource();
if (i1 == 0) {
return null;
}
}
catch (PackageManager.NameNotFoundException paramComponentName)
{
Log.w("SuggestionsAdapter", paramComponentName.toString());
return null;
}
localObject = ((PackageManager)localObject).getDrawable(paramComponentName.getPackageName(), i1, localActivityInfo.applicationInfo);
if (localObject == null)
{
Log.w("SuggestionsAdapter", "Invalid icon resource " + i1 + " for " + paramComponentName.flattenToShortString());
return null;
}
return (Drawable)localObject;
}
private Drawable a(Uri paramUri)
{
try
{
boolean bool = "android.resource".equals(paramUri.getScheme());
if (bool) {
try
{
Drawable localDrawable1 = b(paramUri);
return localDrawable1;
}
catch (Resources.NotFoundException localNotFoundException)
{
throw new FileNotFoundException("Resource does not exist: " + paramUri);
}
}
localInputStream = this.e.getContentResolver().openInputStream(paramUri);
}
catch (FileNotFoundException localFileNotFoundException)
{
Log.w("SuggestionsAdapter", "Icon not found: " + paramUri + ", " + localFileNotFoundException.getMessage());
return null;
}
InputStream localInputStream;
if (localInputStream == null) {
throw new FileNotFoundException("Failed to open " + paramUri);
}
try
{
Drawable localDrawable2 = Drawable.createFromStream(localInputStream, null);
try
{
localInputStream.close();
return localDrawable2;
}
catch (IOException localIOException1)
{
Log.e("SuggestionsAdapter", "Error closing icon stream for " + paramUri, localIOException1);
return localDrawable2;
}
try
{
localIOException1.close();
throw ((Throwable)localObject);
}
catch (IOException localIOException2)
{
for (;;)
{
Log.e("SuggestionsAdapter", "Error closing icon stream for " + paramUri, localIOException2);
}
}
}
finally {}
}
private Drawable a(String paramString)
{
Object localObject1;
if ((paramString == null) || (paramString.length() == 0) || ("0".equals(paramString))) {
localObject1 = null;
}
for (;;)
{
return (Drawable)localObject1;
try
{
int i1 = Integer.parseInt(paramString);
String str = "android.resource://" + this.e.getPackageName() + "/" + i1;
localDrawable = b(str);
localObject1 = localDrawable;
if (localDrawable == null)
{
localObject1 = ContextCompat.getDrawable(this.e, i1);
a(str, (Drawable)localObject1);
return (Drawable)localObject1;
}
}
catch (NumberFormatException localNumberFormatException)
{
Drawable localDrawable = b(paramString);
Object localObject2 = localDrawable;
if (localDrawable == null)
{
localObject2 = a(Uri.parse(paramString));
a(paramString, (Drawable)localObject2);
return (Drawable)localObject2;
}
}
catch (Resources.NotFoundException localNotFoundException)
{
Log.w("SuggestionsAdapter", "Icon resource not found: " + paramString);
}
}
return null;
}
private static String a(Cursor paramCursor, int paramInt)
{
if (paramInt == -1) {
return null;
}
try
{
paramCursor = paramCursor.getString(paramInt);
return paramCursor;
}
catch (Exception paramCursor)
{
Log.e("SuggestionsAdapter", "unexpected error retrieving valid column from cursor, did the remote process die?", paramCursor);
}
return null;
}
public static String a(Cursor paramCursor, String paramString)
{
return a(paramCursor, paramCursor.getColumnIndex(paramString));
}
private static void a(Cursor paramCursor)
{
if (paramCursor != null) {}
for (paramCursor = paramCursor.getExtras();; paramCursor = null)
{
if ((paramCursor != null) && (paramCursor.getBoolean("in_progress"))) {}
return;
}
}
private static void a(ImageView paramImageView, Drawable paramDrawable, int paramInt)
{
paramImageView.setImageDrawable(paramDrawable);
if (paramDrawable == null)
{
paramImageView.setVisibility(paramInt);
return;
}
paramImageView.setVisibility(0);
paramDrawable.setVisible(false, false);
paramDrawable.setVisible(true, false);
}
private static void a(TextView paramTextView, CharSequence paramCharSequence)
{
paramTextView.setText(paramCharSequence);
if (TextUtils.isEmpty(paramCharSequence))
{
paramTextView.setVisibility(8);
return;
}
paramTextView.setVisibility(0);
}
private void a(String paramString, Drawable paramDrawable)
{
if (paramDrawable != null) {
this.f.put(paramString, paramDrawable.getConstantState());
}
}
private Drawable b(Uri paramUri)
throws FileNotFoundException
{
String str = paramUri.getAuthority();
if (TextUtils.isEmpty(str)) {
throw new FileNotFoundException("No authority: " + paramUri);
}
Resources localResources;
List localList;
try
{
localResources = this.mContext.getPackageManager().getResourcesForApplication(str);
localList = paramUri.getPathSegments();
if (localList == null) {
throw new FileNotFoundException("No path: " + paramUri);
}
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
throw new FileNotFoundException("No package found for authority: " + paramUri);
}
int i1 = localList.size();
if (i1 == 1) {}
for (;;)
{
try
{
i1 = Integer.parseInt((String)localList.get(0));
if (i1 != 0) {
break;
}
throw new FileNotFoundException("No resource found for: " + paramUri);
}
catch (NumberFormatException localNumberFormatException)
{
throw new FileNotFoundException("Single path segment is not a resource ID: " + paramUri);
}
if (i1 == 2) {
i1 = localResources.getIdentifier((String)localList.get(1), (String)localList.get(0), localNumberFormatException);
} else {
throw new FileNotFoundException("More than two path segments: " + paramUri);
}
}
return localResources.getDrawable(i1);
}
private Drawable b(String paramString)
{
paramString = (Drawable.ConstantState)this.f.get(paramString);
if (paramString == null) {
return null;
}
return paramString.newDrawable();
}
public final void bindView(View paramView, Context paramContext, Cursor paramCursor)
{
gy.a locala = (gy.a)paramView.getTag();
if (this.o != -1) {}
for (int i1 = paramCursor.getInt(this.o);; i1 = 0)
{
if (locala.a != null)
{
paramView = a(paramCursor, this.j);
a(locala.a, paramView);
}
if (locala.b != null)
{
paramContext = a(paramCursor, this.l);
if (paramContext != null)
{
if (this.i == null)
{
paramView = new TypedValue();
this.mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, paramView, true);
this.i = this.mContext.getResources().getColorStateList(paramView.resourceId);
}
paramView = new SpannableString(paramContext);
paramView.setSpan(new TextAppearanceSpan(null, 0, 0, this.i, null), 0, paramContext.length(), 33);
if (!TextUtils.isEmpty(paramView)) {
break label337;
}
if (locala.a != null)
{
locala.a.setSingleLine(false);
locala.a.setMaxLines(2);
}
label195:
a(locala.b, paramView);
}
}
else
{
if (locala.c != null)
{
ImageView localImageView = locala.c;
if (this.m != -1) {
break label366;
}
paramView = null;
label229:
a(localImageView, paramView, 4);
}
if (locala.d != null)
{
paramContext = locala.d;
if (this.n != -1) {
break label501;
}
}
}
label337:
label366:
label501:
for (paramView = null;; paramView = a(paramCursor.getString(this.n)))
{
a(paramContext, paramView, 8);
if ((this.a != 2) && ((this.a != 1) || ((i1 & 0x1) == 0))) {
break label519;
}
locala.e.setVisibility(0);
locala.e.setTag(locala.a.getText());
locala.e.setOnClickListener(this);
return;
paramView = a(paramCursor, this.k);
break;
if (locala.a == null) {
break label195;
}
locala.a.setSingleLine(true);
locala.a.setMaxLines(1);
break label195;
paramContext = a(paramCursor.getString(this.m));
paramView = paramContext;
if (paramContext != null) {
break label229;
}
paramView = this.d.getSearchActivity();
String str = paramView.flattenToShortString();
if (this.f.containsKey(str))
{
paramView = (Drawable.ConstantState)this.f.get(str);
if (paramView == null) {}
for (paramContext = null;; paramContext = paramView.newDrawable(this.e.getResources()))
{
paramView = paramContext;
if (paramContext != null) {
break;
}
paramView = this.mContext.getPackageManager().getDefaultActivityIcon();
break;
}
}
paramContext = a(paramView);
if (paramContext == null) {}
for (paramView = null;; paramView = paramContext.getConstantState())
{
this.f.put(str, paramView);
break;
}
}
label519:
locala.e.setVisibility(8);
return;
}
}
public final void changeCursor(Cursor paramCursor)
{
if (this.h)
{
Log.w("SuggestionsAdapter", "Tried to change cursor after adapter was closed.");
if (paramCursor != null) {
paramCursor.close();
}
}
for (;;)
{
return;
try
{
super.changeCursor(paramCursor);
if (paramCursor != null)
{
this.j = paramCursor.getColumnIndex("suggest_text_1");
this.k = paramCursor.getColumnIndex("suggest_text_2");
this.l = paramCursor.getColumnIndex("suggest_text_2_url");
this.m = paramCursor.getColumnIndex("suggest_icon_1");
this.n = paramCursor.getColumnIndex("suggest_icon_2");
this.o = paramCursor.getColumnIndex("suggest_flags");
return;
}
}
catch (Exception paramCursor)
{
Log.e("SuggestionsAdapter", "error changing cursor and caching columns", paramCursor);
}
}
}
public final CharSequence convertToString(Cursor paramCursor)
{
if (paramCursor == null) {}
do
{
do
{
return null;
String str = a(paramCursor, "suggest_intent_query");
if (str != null) {
return str;
}
if (this.d.shouldRewriteQueryFromData())
{
str = a(paramCursor, "suggest_intent_data");
if (str != null) {
return str;
}
}
} while (!this.d.shouldRewriteQueryFromText());
paramCursor = a(paramCursor, "suggest_text_1");
} while (paramCursor == null);
return paramCursor;
}
public final View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
{
try
{
paramView = super.getView(paramInt, paramView, paramViewGroup);
return paramView;
}
catch (RuntimeException paramView)
{
Log.w("SuggestionsAdapter", "Search suggestions cursor threw exception.", paramView);
paramViewGroup = newView(this.mContext, this.mCursor, paramViewGroup);
if (paramViewGroup != null) {
((gy.a)paramViewGroup.getTag()).a.setText(paramView.toString());
}
}
return paramViewGroup;
}
public final boolean hasStableIds()
{
return false;
}
public final View newView(Context paramContext, Cursor paramCursor, ViewGroup paramViewGroup)
{
paramContext = super.newView(paramContext, paramCursor, paramViewGroup);
paramContext.setTag(new gy.a(paramContext));
((ImageView)paramContext.findViewById(R.id.edit_query)).setImageResource(this.g);
return paramContext;
}
public final void notifyDataSetChanged()
{
super.notifyDataSetChanged();
a(getCursor());
}
public final void notifyDataSetInvalidated()
{
super.notifyDataSetInvalidated();
a(getCursor());
}
public final void onClick(View paramView)
{
paramView = paramView.getTag();
if ((paramView instanceof CharSequence)) {
this.c.setQuery((CharSequence)paramView);
}
}
public final Cursor runQueryOnBackgroundThread(CharSequence paramCharSequence)
{
if (paramCharSequence == null) {}
for (paramCharSequence = ""; (this.c.getVisibility() != 0) || (this.c.getWindowVisibility() != 0); paramCharSequence = paramCharSequence.toString()) {
return null;
}
Object localObject1;
for (;;)
{
try
{
localObject1 = this.d;
if (localObject1 != null) {
break label77;
}
paramCharSequence = null;
if (paramCharSequence != null)
{
paramCharSequence.getCount();
return paramCharSequence;
}
}
catch (RuntimeException paramCharSequence)
{
Log.w("SuggestionsAdapter", "Search suggestions query threw an exception.", paramCharSequence);
}
return null;
label77:
localObject2 = ((SearchableInfo)localObject1).getSuggestAuthority();
if (localObject2 != null) {
break;
}
paramCharSequence = null;
}
Object localObject2 = new Uri.Builder().scheme("content").authority((String)localObject2).query("").fragment("");
String str = ((SearchableInfo)localObject1).getSuggestPath();
if (str != null) {
((Uri.Builder)localObject2).appendEncodedPath(str);
}
((Uri.Builder)localObject2).appendPath("search_suggest_query");
str = ((SearchableInfo)localObject1).getSuggestSelection();
if (str != null)
{
localObject1 = new String[1];
localObject1[0] = paramCharSequence;
}
for (paramCharSequence = (CharSequence)localObject1;; paramCharSequence = null)
{
((Uri.Builder)localObject2).appendQueryParameter("limit", "50");
localObject1 = ((Uri.Builder)localObject2).build();
paramCharSequence = this.mContext.getContentResolver().query((Uri)localObject1, null, str, paramCharSequence, null);
break;
((Uri.Builder)localObject2).appendPath(paramCharSequence);
}
}
static final class a
{
public final TextView a;
public final TextView b;
public final ImageView c;
public final ImageView d;
public final ImageView e;
public a(View paramView)
{
this.a = ((TextView)paramView.findViewById(16908308));
this.b = ((TextView)paramView.findViewById(16908309));
this.c = ((ImageView)paramView.findViewById(16908295));
this.d = ((ImageView)paramView.findViewById(16908296));
this.e = ((ImageView)paramView.findViewById(R.id.edit_query));
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/gy.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/