HelperUtil.java
7.73 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
package com.cnlive.strike.util;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import com.cnlive.strike.moudle.user.model.LoginSuccessInfo;
import com.cnlive.strike.moudle.user.model.UserConst;
import com.cnlive.strike.moudle.user.ui.activity.LoginActivity;
public class HelperUtil {
private static final String activityClassName = "com.cnlive.strike.moduleuser.TestActivity";
// public static boolean goTo(Activity context, int eventType) {
// boolean result = true;
// if (null == context) {
// return result;
// }
//// PackageManager packageManager = context.getPackageManager();
//// PackageInfo packageInfo = null;
//// try {
//// packageInfo = packageManager.getPackageInfo(
//// context.getPackageName(), PackageManager.GET_ACTIVITIES);
//// for (ActivityInfo activity : packageInfo.activities) {
//// CharSequence labelSeq = activity.loadLabel(packageManager);
//// if (null == activity || null != labelSeq || null == activity.name || TextUtils.isEmpty(activity.name)) {
//// if ("UserAPI".equals(labelSeq)) {
//// Class<?> aClass = Class.forName(activity.name);
//// Intent intent = new Intent(context, aClass);
//// intent.putExtra("eventType", eventType);
//// context.startActivity(intent);
//// Log.e("回调结果", activity.name);
//// result = true;
//// break;
//// } else {
//// continue;
//// }
////
//// } else {
//// continue;
//// }
//// }
//// } catch (PackageManager.NameNotFoundException e) {
//// e.printStackTrace();
//// } catch (ClassNotFoundException e) {
//// e.printStackTrace();
//// }
//
// try {
// Class clz = Class.forName(activityClassName);
// Intent intent = new Intent(context, clz);
// intent.putExtra("eventType", eventType);
// context.startActivity(intent);
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// Log.d("error", e.toString());
// }
// return result;
// }
public static void isNewUser(Activity context, LoginSuccessInfo successInfo, boolean isHasOtherUserInfo) {
if (null == context) {
return;
}
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
try {
Class clz = Class.forName(activityClassName);
Intent intent = new Intent(context, clz);
intent.putExtra("eventType", UserConst.IS_NEW_USER);
//有第三方平台数据
if (isHasOtherUserInfo) {
intent.putExtra("type", successInfo.getType());
intent.putExtra("uri", successInfo.getUri());
intent.putExtra(LoginActivity.TAG_CLICK_AD, successInfo.clickAd);
intent.putExtra("sharetype", successInfo.getTagShare());
if (!TextUtils.isEmpty(successInfo.getTagMsg())) {
intent.putExtra("classifyTagMsg", successInfo.getTagMsg());
}
context.startActivity(intent);
} else {
//没有第三方平台数据
intent.putExtra(LoginActivity.TAG_MSG, TextUtils.isEmpty(successInfo.getTagMsg()) ? "" : successInfo.getTagMsg());
intent.putExtra(LoginActivity.TAG_CLICK_AD, successInfo.clickAd);
context.startActivity(intent);
context.finish();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
Log.d("error", e.toString());
}
}
/**
* 不是新用户
*
* @param context
* @param successInfo
*/
public static void isNotNewUser(Activity context, LoginSuccessInfo successInfo) {
if (null == context) {
return;
}
try {
Class clz = Class.forName(activityClassName);
Intent intent = new Intent(context, clz);
intent.putExtra("eventType", UserConst.IS_NOT_NEW_USER);
intent.putExtra("type", successInfo.getType());
intent.putExtra("uri", successInfo.getUri());
intent.putExtra(LoginActivity.TAG_CLICK_AD, successInfo.clickAd);
intent.putExtra("sharetype", successInfo.getTagShare());
if (!TextUtils.isEmpty(successInfo.getTagMsg())) {
intent.putExtra("classifyTagMsg", successInfo.getTagMsg());
}
context.startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
Log.d("error", e.toString());
}
}
/**
* 修改用户头像
*
* @param context
* @param faceUrl
*/
public static void modifyUserImage(Context context, String faceUrl) {
if (null == context) {
return;
}
try {
Class clz = Class.forName(activityClassName);
Intent intent = new Intent(context, clz);
intent.putExtra("eventType", UserConst.MODIFY_USER_IMAGE);
context.startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
Log.d("error", e.toString());
}
}
/**
* 用户失效
*
* @param context
*/
public static void userInvalid(Context context) {
if (null == context) {
return;
}
try {
Class clz = Class.forName(activityClassName);
Intent intent = new Intent(context, clz);
intent.putExtra("eventType", UserConst.USER_INVALID);
context.startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
Log.d("error", e.toString());
}
}
/**
* 修改用户名称
*
* @param context
*/
public static void modifyUserName(Context context, String nickName) {
if (null == context) {
return;
}
try {
Class clz = Class.forName(activityClassName);
Intent intent = new Intent(context, clz);
intent.putExtra("eventType", UserConst.MODIFY_USER_NAME);
intent.putExtra("nickName", nickName);
context.startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
Log.d("error", e.toString());
}
}
/**
* 下金币
*
* @param context
* @param taskId
* @param contentId
* @param addtype
* @param isDouyin
*/
public static void goToCoinRainAction(Context context, String taskId, String contentId, String addtype, Boolean isDouyin) {
if (null == context) {
return;
}
try {
Class clz = Class.forName(activityClassName);
Intent intent = new Intent(context, clz);
intent.putExtra("eventType", UserConst.COIN_RAIN_ACTION);
intent.putExtra("taskId", taskId);
intent.putExtra("contentId", contentId);
intent.putExtra("addtype", addtype);
intent.putExtra("isDouyin", isDouyin);
context.startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
Log.d("error", e.toString());
}
}
}