NavUtils.java
6.45 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
package android.support.v4.app;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.IntentCompat;
import android.util.Log;
public final class NavUtils
{
public static final String PARENT_ACTIVITY = "android.support.PARENT_ACTIVITY";
private static final a a = new b();
static
{
if (Build.VERSION.SDK_INT >= 16)
{
a = new c();
return;
}
}
public static Intent getParentActivityIntent(Activity paramActivity)
{
return a.a(paramActivity);
}
public static Intent getParentActivityIntent(Context paramContext, ComponentName paramComponentName)
throws PackageManager.NameNotFoundException
{
String str = getParentActivityName(paramContext, paramComponentName);
if (str == null) {
return null;
}
paramComponentName = new ComponentName(paramComponentName.getPackageName(), str);
if (getParentActivityName(paramContext, paramComponentName) == null) {
return IntentCompat.makeMainActivity(paramComponentName);
}
return new Intent().setComponent(paramComponentName);
}
public static Intent getParentActivityIntent(Context paramContext, Class<?> paramClass)
throws PackageManager.NameNotFoundException
{
paramClass = getParentActivityName(paramContext, new ComponentName(paramContext, paramClass));
if (paramClass == null) {
return null;
}
paramClass = new ComponentName(paramContext, paramClass);
if (getParentActivityName(paramContext, paramClass) == null) {
return IntentCompat.makeMainActivity(paramClass);
}
return new Intent().setComponent(paramClass);
}
@Nullable
public static String getParentActivityName(Activity paramActivity)
{
try
{
paramActivity = getParentActivityName(paramActivity, paramActivity.getComponentName());
return paramActivity;
}
catch (PackageManager.NameNotFoundException paramActivity)
{
throw new IllegalArgumentException(paramActivity);
}
}
@Nullable
public static String getParentActivityName(Context paramContext, ComponentName paramComponentName)
throws PackageManager.NameNotFoundException
{
paramComponentName = paramContext.getPackageManager().getActivityInfo(paramComponentName, 128);
return a.a(paramContext, paramComponentName);
}
public static void navigateUpFromSameTask(Activity paramActivity)
{
Intent localIntent = getParentActivityIntent(paramActivity);
if (localIntent == null) {
throw new IllegalArgumentException("Activity " + paramActivity.getClass().getSimpleName() + " does not have a parent activity name specified. (Did you forget to add the android.support.PARENT_ACTIVITY <meta-data> element in your manifest?)");
}
navigateUpTo(paramActivity, localIntent);
}
public static void navigateUpTo(Activity paramActivity, Intent paramIntent)
{
a.b(paramActivity, paramIntent);
}
public static boolean shouldUpRecreateTask(Activity paramActivity, Intent paramIntent)
{
return a.a(paramActivity, paramIntent);
}
static abstract interface a
{
public abstract Intent a(Activity paramActivity);
public abstract String a(Context paramContext, ActivityInfo paramActivityInfo);
public abstract boolean a(Activity paramActivity, Intent paramIntent);
public abstract void b(Activity paramActivity, Intent paramIntent);
}
static class b
implements NavUtils.a
{
public Intent a(Activity paramActivity)
{
String str = NavUtils.getParentActivityName(paramActivity);
if (str == null) {
return null;
}
ComponentName localComponentName = new ComponentName(paramActivity, str);
try
{
if (NavUtils.getParentActivityName(paramActivity, localComponentName) == null) {
return IntentCompat.makeMainActivity(localComponentName);
}
paramActivity = new Intent().setComponent(localComponentName);
return paramActivity;
}
catch (PackageManager.NameNotFoundException paramActivity)
{
Log.e("NavUtils", "getParentActivityIntent: bad parentActivityName '" + str + "' in manifest");
}
return null;
}
public String a(Context paramContext, ActivityInfo paramActivityInfo)
{
if (paramActivityInfo.metaData == null) {
paramActivityInfo = null;
}
String str;
do
{
return paramActivityInfo;
str = paramActivityInfo.metaData.getString("android.support.PARENT_ACTIVITY");
if (str == null) {
return null;
}
paramActivityInfo = str;
} while (str.charAt(0) != '.');
return paramContext.getPackageName() + str;
}
public boolean a(Activity paramActivity, Intent paramIntent)
{
paramActivity = paramActivity.getIntent().getAction();
return (paramActivity != null) && (!paramActivity.equals("android.intent.action.MAIN"));
}
public void b(Activity paramActivity, Intent paramIntent)
{
paramIntent.addFlags(67108864);
paramActivity.startActivity(paramIntent);
paramActivity.finish();
}
}
static final class c
extends NavUtils.b
{
public final Intent a(Activity paramActivity)
{
Intent localIntent2 = paramActivity.getParentActivityIntent();
Intent localIntent1 = localIntent2;
if (localIntent2 == null) {
localIntent1 = super.a(paramActivity);
}
return localIntent1;
}
public final String a(Context paramContext, ActivityInfo paramActivityInfo)
{
String str2 = paramActivityInfo.parentActivityName;
String str1 = str2;
if (str2 == null) {
str1 = super.a(paramContext, paramActivityInfo);
}
return str1;
}
public final boolean a(Activity paramActivity, Intent paramIntent)
{
return paramActivity.shouldUpRecreateTask(paramIntent);
}
public final void b(Activity paramActivity, Intent paramIntent)
{
paramActivity.navigateUpTo(paramIntent);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/app/NavUtils.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/