|
@ -0,0 +1,1826 @@
|
|
1
|
package com.electric.chargingpile.fragment;
|
|
2
|
|
|
3
|
import android.Manifest;
|
|
4
|
import android.annotation.TargetApi;
|
|
5
|
import android.app.Activity;
|
|
6
|
import android.app.AlertDialog;
|
|
7
|
import android.content.ActivityNotFoundException;
|
|
8
|
import android.content.ClipData;
|
|
9
|
import android.content.ClipboardManager;
|
|
10
|
import android.content.Context;
|
|
11
|
import android.content.DialogInterface;
|
|
12
|
import android.content.Intent;
|
|
13
|
import android.content.SharedPreferences;
|
|
14
|
import android.graphics.Bitmap;
|
|
15
|
import android.graphics.Color;
|
|
16
|
import android.graphics.drawable.Drawable;
|
|
17
|
import android.net.Uri;
|
|
18
|
import android.net.http.SslError;
|
|
19
|
import android.os.Build;
|
|
20
|
import android.os.Bundle;
|
|
21
|
import android.os.Handler;
|
|
22
|
import android.os.Looper;
|
|
23
|
import android.provider.MediaStore;
|
|
24
|
import android.text.TextUtils;
|
|
25
|
import android.util.Log;
|
|
26
|
import android.view.KeyEvent;
|
|
27
|
import android.view.LayoutInflater;
|
|
28
|
import android.view.View;
|
|
29
|
import android.view.ViewGroup;
|
|
30
|
import android.view.animation.AnimationUtils;
|
|
31
|
import android.webkit.GeolocationPermissions;
|
|
32
|
import android.webkit.JavascriptInterface;
|
|
33
|
import android.webkit.SslErrorHandler;
|
|
34
|
import android.webkit.ValueCallback;
|
|
35
|
import android.webkit.WebBackForwardList;
|
|
36
|
import android.webkit.WebChromeClient;
|
|
37
|
import android.webkit.WebSettings;
|
|
38
|
import android.webkit.WebView;
|
|
39
|
import android.webkit.WebViewClient;
|
|
40
|
import android.widget.ImageView;
|
|
41
|
import android.widget.ProgressBar;
|
|
42
|
import android.widget.RelativeLayout;
|
|
43
|
import android.widget.TextView;
|
|
44
|
import android.widget.Toast;
|
|
45
|
|
|
46
|
import androidx.annotation.NonNull;
|
|
47
|
import androidx.annotation.Nullable;
|
|
48
|
import androidx.fragment.app.Fragment;
|
|
49
|
|
|
50
|
import com.afollestad.materialdialogs.DialogAction;
|
|
51
|
import com.afollestad.materialdialogs.MaterialDialog;
|
|
52
|
import com.alibaba.fastjson.JSONException;
|
|
53
|
import com.blankj.utilcode.util.LogUtils;
|
|
54
|
import com.bumptech.glide.Glide;
|
|
55
|
import com.bumptech.glide.request.target.CustomTarget;
|
|
56
|
import com.bumptech.glide.request.transition.Transition;
|
|
57
|
import com.electric.chargingpile.BuildConfig;
|
|
58
|
import com.electric.chargingpile.R;
|
|
59
|
import com.electric.chargingpile.activity.AccountRechargeActivity;
|
|
60
|
import com.electric.chargingpile.activity.CarOwnerCertificateActivity;
|
|
61
|
import com.electric.chargingpile.activity.CarOwnerCertificateListActivity;
|
|
62
|
import com.electric.chargingpile.activity.ChargingCommentActivity;
|
|
63
|
import com.electric.chargingpile.activity.CreditActivity;
|
|
64
|
import com.electric.chargingpile.activity.EditQuestionOneActivity;
|
|
65
|
import com.electric.chargingpile.activity.FeedbackActivity;
|
|
66
|
import com.electric.chargingpile.activity.LoginActivity;
|
|
67
|
import com.electric.chargingpile.activity.MainMapActivity;
|
|
68
|
import com.electric.chargingpile.activity.MemberGetCoinActivity;
|
|
69
|
import com.electric.chargingpile.activity.MyBalanceActivity;
|
|
70
|
import com.electric.chargingpile.activity.MyFeedbackActivity;
|
|
71
|
import com.electric.chargingpile.activity.NewZhanDetailsActivity;
|
|
72
|
import com.electric.chargingpile.activity.NonSecretSeettingActivity;
|
|
73
|
import com.electric.chargingpile.activity.RankingListActivity;
|
|
74
|
import com.electric.chargingpile.activity.RegisterActivity;
|
|
75
|
import com.electric.chargingpile.activity.RoutePlanShowAddressActivity;
|
|
76
|
import com.electric.chargingpile.activity.ShareTwoActivity;
|
|
77
|
import com.electric.chargingpile.activity.UnansweredActivity;
|
|
78
|
import com.electric.chargingpile.activity.YaoQingListActivity;
|
|
79
|
import com.electric.chargingpile.activity.ZhanCommentActivity;
|
|
80
|
import com.electric.chargingpile.application.MainApplication;
|
|
81
|
import com.electric.chargingpile.data.CarOwnerCertificateBean;
|
|
82
|
import com.electric.chargingpile.data.ChargingShareBean;
|
|
83
|
import com.electric.chargingpile.data.User;
|
|
84
|
import com.electric.chargingpile.manager.ProfileManager;
|
|
85
|
import com.electric.chargingpile.util.DES3;
|
|
86
|
import com.electric.chargingpile.util.ImageUitl;
|
|
87
|
import com.electric.chargingpile.util.JsonUtils;
|
|
88
|
import com.electric.chargingpile.util.LoadingDialog;
|
|
89
|
import com.electric.chargingpile.util.PhotoUtils;
|
|
90
|
import com.electric.chargingpile.util.ToastUtil;
|
|
91
|
import com.electric.chargingpile.util.Util;
|
|
92
|
import com.electric.chargingpile.view.AlertDialogTwo;
|
|
93
|
import com.google.gson.Gson;
|
|
94
|
import com.khoiron.actionsheets.ActionSheet;
|
|
95
|
import com.khoiron.actionsheets.callback.ActionSheetCallBack;
|
|
96
|
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
|
|
97
|
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
|
|
98
|
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
|
99
|
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
|
100
|
import com.umeng.analytics.MobclickAgent;
|
|
101
|
import com.zhy.http.okhttp.OkHttpUtils;
|
|
102
|
import com.zhy.http.okhttp.callback.StringCallback;
|
|
103
|
|
|
104
|
import org.jetbrains.annotations.NotNull;
|
|
105
|
import org.json.JSONObject;
|
|
106
|
|
|
107
|
import java.io.File;
|
|
108
|
import java.net.URLEncoder;
|
|
109
|
import java.util.ArrayList;
|
|
110
|
import java.util.HashMap;
|
|
111
|
import java.util.List;
|
|
112
|
|
|
113
|
import cn.sharesdk.framework.Platform;
|
|
114
|
import cn.sharesdk.framework.PlatformActionListener;
|
|
115
|
import cn.sharesdk.framework.ShareSDK;
|
|
116
|
import cn.sharesdk.tencent.qq.QQ;
|
|
117
|
import cn.sharesdk.wechat.friends.Wechat;
|
|
118
|
import cn.sharesdk.wechat.moments.WechatMoments;
|
|
119
|
import okhttp3.Call;
|
|
120
|
import pub.devrel.easypermissions.AfterPermissionGranted;
|
|
121
|
import pub.devrel.easypermissions.EasyPermissions;
|
|
122
|
|
|
123
|
import static android.app.Activity.RESULT_OK;
|
|
124
|
|
|
125
|
public class WebFragment extends Fragment implements PlatformActionListener, View.OnClickListener, EasyPermissions.PermissionCallbacks {
|
|
126
|
private static final String TAG = "MyWebViewActivity";
|
|
127
|
private OpenFileWebChromeClient mOpenFileWebChromeClient = null;
|
|
128
|
private WebViewClient mWebViewClient;
|
|
129
|
private TextView tv_webTitle, tv_webShare;
|
|
130
|
private ImageView iv_webClose, iv_webBack, iv_message;
|
|
131
|
private ProgressBar pb_webBar;
|
|
132
|
private LoadingDialog loadDialog;
|
|
133
|
private WebView webView;
|
|
134
|
private String canRefresh = "false";
|
|
135
|
private String index = "0";
|
|
136
|
private String mUrl = "";
|
|
137
|
private String advertiser;
|
|
138
|
private ArrayList<String> list = new ArrayList<>();
|
|
139
|
private String refreshUrl = "";
|
|
140
|
private String currentUrl = "";
|
|
141
|
private String shareTitle, shareIcon, shareContext, shareUrl;
|
|
142
|
private String nickname, username, usersex, hascar, nocar, usericon, userid;
|
|
143
|
private TextView tv_point;
|
|
144
|
private RelativeLayout rl_point;
|
|
145
|
private android.view.animation.Animation animation;
|
|
146
|
private static final int RC_CALL_PERM = 123;
|
|
147
|
|
|
148
|
private static final int RC_ALBUM_PERM = 127;
|
|
149
|
private final static int FILE_CHOOSER_RESULT_CODE = 128; // 图片
|
|
150
|
private final static int FILE_CAMERA_RESULT_CODE = 129; // 拍照
|
|
151
|
private String cameraFilePath; // 拍照图片路径
|
|
152
|
private boolean loginToShare;
|
|
153
|
private boolean mIsDownload;
|
|
154
|
private Handler mHandler = new Handler(Looper.getMainLooper());
|
|
155
|
|
|
156
|
|
|
157
|
public static WebFragment getInstance(String url){
|
|
158
|
WebFragment fragment = new WebFragment();
|
|
159
|
Bundle bundle = new Bundle();
|
|
160
|
bundle.putString("url",url);
|
|
161
|
fragment.setArguments(bundle);
|
|
162
|
return fragment;
|
|
163
|
}
|
|
164
|
public static WebFragment getInstance(String url,String advertiser){
|
|
165
|
WebFragment fragment = new WebFragment();
|
|
166
|
Bundle bundle = new Bundle();
|
|
167
|
bundle.putString("url",url);
|
|
168
|
bundle.putString("advertiser",advertiser);
|
|
169
|
fragment.setArguments(bundle);
|
|
170
|
return fragment;
|
|
171
|
}
|
|
172
|
@Nullable
|
|
173
|
@org.jetbrains.annotations.Nullable
|
|
174
|
@Override
|
|
175
|
public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
|
176
|
View rootView = inflater.inflate(R.layout.fragment_web,container,false);
|
|
177
|
getIntentData();
|
|
178
|
initView(rootView);
|
|
179
|
initWebView();
|
|
180
|
return rootView;
|
|
181
|
}
|
|
182
|
|
|
183
|
private void getIntentData() {
|
|
184
|
mUrl = getArguments().getString("url");
|
|
185
|
advertiser = getArguments().getString("advertiser");
|
|
186
|
if (advertiser != null && advertiser.equals("1")) {
|
|
187
|
mUrl = Util.generateDmpUrl(mUrl);
|
|
188
|
}
|
|
189
|
}
|
|
190
|
|
|
191
|
|
|
192
|
private void initView(View rootView) {
|
|
193
|
loadDialog = new LoadingDialog(getActivity());
|
|
194
|
loadDialog.setCanceledOnTouchOutside(false);
|
|
195
|
rl_point = (RelativeLayout) rootView.findViewById(R.id.rl_point);
|
|
196
|
tv_point = (TextView) rootView.findViewById(R.id.tv_point);
|
|
197
|
animation = AnimationUtils.loadAnimation(getActivity(), R.anim.nn);
|
|
198
|
tv_webTitle = (TextView) rootView.findViewById(R.id.tv_webview_title);
|
|
199
|
tv_webShare = (TextView) rootView.findViewById(R.id.tv_webview_share);
|
|
200
|
tv_webShare.setOnClickListener(this);
|
|
201
|
iv_webBack = (ImageView) rootView.findViewById(R.id.iv_webview_back);
|
|
202
|
iv_webBack.setOnClickListener(this);
|
|
203
|
iv_webClose = (ImageView) rootView.findViewById(R.id.iv_webview_close);
|
|
204
|
iv_webClose.setOnClickListener(this);
|
|
205
|
pb_webBar = (ProgressBar) rootView.findViewById(R.id.pb_webview_bar);
|
|
206
|
iv_message = (ImageView) rootView.findViewById(R.id.iv_message);
|
|
207
|
webView = (WebView) rootView.findViewById(R.id.webView);
|
|
208
|
Log.e("!!", webView.getId() + "");
|
|
209
|
|
|
210
|
}
|
|
211
|
|
|
212
|
private void initWebView() {
|
|
213
|
mOpenFileWebChromeClient = new OpenFileWebChromeClient();
|
|
214
|
mWebViewClient = new MyWebViewClient();
|
|
215
|
webView.getSettings().setSupportZoom(true);
|
|
216
|
webView.getSettings().setBuiltInZoomControls(true);
|
|
217
|
webView.getSettings().setJavaScriptEnabled(true);
|
|
218
|
webView.getSettings().setDatabaseEnabled(true);
|
|
219
|
String dir = this.getContext().getDir("database", Context.MODE_PRIVATE).getPath();
|
|
220
|
webView.getSettings().setGeolocationEnabled(true);
|
|
221
|
webView.getSettings().setGeolocationDatabasePath(dir);
|
|
222
|
webView.setWebChromeClient(mOpenFileWebChromeClient);
|
|
223
|
webView.getSettings().setDomStorageEnabled(true);
|
|
224
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
225
|
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
|
226
|
}
|
|
227
|
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
|
|
228
|
webView.addJavascriptInterface(this, "cdz");
|
|
229
|
webView.setWebViewClient(mWebViewClient);
|
|
230
|
if (null != mUrl && !"".equals(mUrl)) {
|
|
231
|
if (mUrl.contains("?")) {
|
|
232
|
mUrl = mUrl + "&version_code=" + BuildConfig.VERSION_CODE + "&from=cdz&system=android";
|
|
233
|
} else {
|
|
234
|
mUrl = mUrl + "?version_code=" + BuildConfig.VERSION_CODE + "&from=cdz&system=android";
|
|
235
|
}
|
|
236
|
if (MainApplication.isLogin()) {
|
|
237
|
mUrl = mUrl + "&phone=" + MainApplication.userPhone;
|
|
238
|
}
|
|
239
|
|
|
240
|
webView.loadUrl(mUrl);
|
|
241
|
}
|
|
242
|
|
|
243
|
webView.setDownloadListener((url, userAgent, contentDisposition, mimetype, contentLength) -> {
|
|
244
|
if (mIsDownload) {
|
|
245
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
246
|
Uri uri = Uri.parse(url);
|
|
247
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
|
248
|
intent.setData(uri);
|
|
249
|
startActivity(intent);
|
|
250
|
}
|
|
251
|
mIsDownload = true;//重置为初始状态
|
|
252
|
});
|
|
253
|
|
|
254
|
webView.setLongClickable(true);
|
|
255
|
webView.setOnLongClickListener(new View.OnLongClickListener() {
|
|
256
|
@Override
|
|
257
|
public boolean onLongClick(View v) {
|
|
258
|
final WebView.HitTestResult result = webView.getHitTestResult(); // 获取元素内容
|
|
259
|
// 判断元素类型是 图片 || 图片URL
|
|
260
|
if (result.getType() == WebView.HitTestResult.IMAGE_TYPE || result.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
|
|
261
|
String url = result.getExtra(); // 获取元素
|
|
262
|
Glide.with(WebFragment.this).asBitmap().load(url).into(new CustomTarget<Bitmap>() {
|
|
263
|
@Override
|
|
264
|
public void onResourceReady(@NonNull @NotNull Bitmap resource, @Nullable @org.jetbrains.annotations.Nullable Transition<? super Bitmap> transition) {
|
|
265
|
ArrayList<String> data = new ArrayList<>();
|
|
266
|
data.add("保存图像");
|
|
267
|
if (getActivity()==null)return;
|
|
268
|
new ActionSheet(getActivity(), data)
|
|
269
|
.hideTitle()
|
|
270
|
.setCancelTitle("取消")
|
|
271
|
.setColorTitle(Color.parseColor("#999999"))
|
|
272
|
.setColorTitleCancel(Color.parseColor("#999999"))
|
|
273
|
.setColorData(getResources().getColor(R.color.ui_green, null))
|
|
274
|
.create(new ActionSheetCallBack() {
|
|
275
|
@Override
|
|
276
|
public void data(@NotNull String data, int position) {
|
|
277
|
System.out.println(position);
|
|
278
|
System.out.println(data);
|
|
279
|
switch (position) {
|
|
280
|
case 0:
|
|
281
|
saveImage(resource);
|
|
282
|
break;
|
|
283
|
}
|
|
284
|
}
|
|
285
|
});
|
|
286
|
}
|
|
287
|
|
|
288
|
@Override
|
|
289
|
public void onLoadCleared(@Nullable @org.jetbrains.annotations.Nullable Drawable placeholder) {
|
|
290
|
|
|
291
|
}
|
|
292
|
});
|
|
293
|
}
|
|
294
|
return true;
|
|
295
|
}
|
|
296
|
});
|
|
297
|
}
|
|
298
|
|
|
299
|
private void saveImage(Bitmap resource) {
|
|
300
|
if (getActivity() == null){
|
|
301
|
return;
|
|
302
|
}
|
|
303
|
PhotoUtils.saveBitmap(getActivity(),resource);
|
|
304
|
}
|
|
305
|
|
|
306
|
|
|
307
|
|
|
308
|
// 93 3.5.5 小程序埋点
|
|
309
|
@JavascriptInterface
|
|
310
|
public void showminiprogram(final String user_name, String path, int type) {
|
|
311
|
if (getActivity() == null)return;
|
|
312
|
if (Util.isWxAppInstalledAndSupported(getActivity())) {
|
|
313
|
IWXAPI api = WXAPIFactory.createWXAPI(getActivity(), getResources().getString(R.string.wx_app_key));
|
|
314
|
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
|
|
315
|
req.userName = user_name;
|
|
316
|
req.path = path;
|
|
317
|
req.miniprogramType = type;
|
|
318
|
api.sendReq(req);
|
|
319
|
} else {
|
|
320
|
ToastUtil.showToast(getContext(), "请先安装微信", Toast.LENGTH_SHORT);
|
|
321
|
}
|
|
322
|
}
|
|
323
|
|
|
324
|
@JavascriptInterface
|
|
325
|
public void welfareshare(final String shareUrl) {
|
|
326
|
if (TextUtils.isEmpty(shareUrl)) {
|
|
327
|
loginToShare = true;
|
|
328
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
329
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
330
|
} else {
|
|
331
|
loginToShare = false;
|
|
332
|
showSimpleBottomSheetGrid(shareUrl);
|
|
333
|
}
|
|
334
|
}
|
|
335
|
|
|
336
|
@JavascriptInterface
|
|
337
|
public void showsharebtn(final String show) {
|
|
338
|
mHandler.post(new Runnable() {
|
|
339
|
@Override
|
|
340
|
public void run() {
|
|
341
|
Log.e(TAG, "hyc run: "+show);
|
|
342
|
if (show.equals("yes")) {
|
|
343
|
tv_webShare.setVisibility(View.VISIBLE);
|
|
344
|
tv_webShare.setText("分享");
|
|
345
|
} else {
|
|
346
|
tv_webShare.setVisibility(View.GONE);
|
|
347
|
tv_webShare.setText("");
|
|
348
|
}
|
|
349
|
}
|
|
350
|
});
|
|
351
|
|
|
352
|
}
|
|
353
|
|
|
354
|
@JavascriptInterface
|
|
355
|
public void freshpage(final String url) {
|
|
356
|
list.add(url);
|
|
357
|
}
|
|
358
|
|
|
359
|
@JavascriptInterface
|
|
360
|
public void setrctext(final String s) {
|
|
361
|
Log.e(TAG, "setrctext: s=" + s);
|
|
362
|
String[] strarray = s.split("\\#\\#");
|
|
363
|
final String text = strarray[0];
|
|
364
|
final String show = strarray[1];
|
|
365
|
final String message = strarray[2];
|
|
366
|
mHandler.post(new Runnable() {
|
|
367
|
@Override
|
|
368
|
public void run() {
|
|
369
|
if (show.equals("yes")) {
|
|
370
|
tv_webShare.setVisibility(View.VISIBLE);
|
|
371
|
tv_webShare.setText(text);
|
|
372
|
if (message.equals("yes")) {
|
|
373
|
iv_message.setVisibility(View.VISIBLE);
|
|
374
|
} else {
|
|
375
|
iv_message.setVisibility(View.GONE);
|
|
376
|
}
|
|
377
|
} else {
|
|
378
|
tv_webShare.setVisibility(View.GONE);
|
|
379
|
}
|
|
380
|
}
|
|
381
|
});
|
|
382
|
}
|
|
383
|
|
|
384
|
@JavascriptInterface
|
|
385
|
public void emitshareinfo(String shareInfo) {
|
|
386
|
// "分享标题##分享描述##分享ico##分享url"
|
|
387
|
String[] strarray = shareInfo.split("\\#\\#");
|
|
388
|
if (strarray.length > 1) {
|
|
389
|
shareTitle = strarray[0];
|
|
390
|
shareContext = strarray[1];
|
|
391
|
shareIcon = strarray[2];
|
|
392
|
shareUrl = strarray[3];
|
|
393
|
}
|
|
394
|
}
|
|
395
|
|
|
396
|
@JavascriptInterface
|
|
397
|
public void sharetowxfd() {
|
|
398
|
if (null != shareTitle && null != shareContext && null != shareIcon && null != shareUrl) {
|
|
399
|
mHandler.post(new Runnable() {
|
|
400
|
|
|
401
|
@Override
|
|
402
|
public void run() {
|
|
403
|
Platform.ShareParams wechat = new Platform.ShareParams();
|
|
404
|
wechat.setTitle(shareTitle);
|
|
405
|
wechat.setText(shareContext);
|
|
406
|
wechat.setImageUrl(shareIcon);
|
|
407
|
wechat.setUrl(shareUrl);
|
|
408
|
wechat.setShareType(Platform.SHARE_WEBPAGE);
|
|
409
|
Platform weixin = ShareSDK.getPlatform(Wechat.NAME);
|
|
410
|
weixin.setPlatformActionListener(WebFragment.this);
|
|
411
|
weixin.share(wechat);
|
|
412
|
}
|
|
413
|
});
|
|
414
|
} else {
|
|
415
|
ToastUtil.showToast(getContext(), "分享信息不完整", Toast.LENGTH_SHORT);
|
|
416
|
}
|
|
417
|
}
|
|
418
|
|
|
419
|
@JavascriptInterface
|
|
420
|
public void sharetowxlf() {
|
|
421
|
if (null != shareTitle && null != shareContext && null != shareIcon && null != shareUrl) {
|
|
422
|
mHandler.post(new Runnable() {
|
|
423
|
|
|
424
|
@Override
|
|
425
|
public void run() {
|
|
426
|
Platform.ShareParams wechatMoments = new Platform.ShareParams();
|
|
427
|
wechatMoments.setTitle(shareTitle);
|
|
428
|
wechatMoments.setUrl(shareUrl);
|
|
429
|
wechatMoments.setImageUrl(shareIcon);
|
|
430
|
wechatMoments.setText(shareContext);
|
|
431
|
wechatMoments.setShareType(Platform.SHARE_WEBPAGE);
|
|
432
|
Platform weixin1 = ShareSDK.getPlatform(WechatMoments.NAME);
|
|
433
|
weixin1.setPlatformActionListener(WebFragment.this);
|
|
434
|
weixin1.share(wechatMoments);
|
|
435
|
}
|
|
436
|
});
|
|
437
|
} else {
|
|
438
|
ToastUtil.showToast(getContext(), "分享信息不完整", Toast.LENGTH_SHORT);
|
|
439
|
}
|
|
440
|
}
|
|
441
|
|
|
442
|
@JavascriptInterface
|
|
443
|
public void sharetoqq() {
|
|
444
|
if (null != shareTitle && null != shareContext && null != shareIcon && null != shareUrl) {
|
|
445
|
mHandler.post(new Runnable() {
|
|
446
|
|
|
447
|
@Override
|
|
448
|
public void run() {
|
|
449
|
Platform.ShareParams qq = new Platform.ShareParams();
|
|
450
|
qq.setTitle(shareTitle);
|
|
451
|
qq.setUrl(shareUrl);
|
|
452
|
qq.setImageUrl(shareIcon);
|
|
453
|
qq.setText(shareContext);
|
|
454
|
qq.setShareType(Platform.SHARE_WEBPAGE);
|
|
455
|
Platform weixin1 = ShareSDK.getPlatform(QQ.NAME);
|
|
456
|
weixin1.setPlatformActionListener(WebFragment.this);
|
|
457
|
weixin1.share(qq);
|
|
458
|
}
|
|
459
|
});
|
|
460
|
} else {
|
|
461
|
ToastUtil.showToast(getContext(), "分享信息不完整", Toast.LENGTH_SHORT);
|
|
462
|
}
|
|
463
|
}
|
|
464
|
|
|
465
|
private void btnToShare() {
|
|
466
|
showSimpleBottomSheetGrid(shareUrl);
|
|
467
|
}
|
|
468
|
|
|
469
|
private void showSimpleBottomSheetGrid(final String shareUrl) {
|
|
470
|
final int TAG_SHARE_WECHAT_FRIEND = 0;
|
|
471
|
final int TAG_SHARE_WECHAT_MOMENT = 1;
|
|
472
|
final int TAG_SHARE_QQ = 2;
|
|
473
|
if (getActivity()==null){
|
|
474
|
return;
|
|
475
|
}
|
|
476
|
|
|
477
|
QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(getActivity());
|
|
478
|
QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
|
|
479
|
.addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
|
|
480
|
.addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
|
|
481
|
.setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
|
|
482
|
@Override
|
|
483
|
public void onClick(QMUIBottomSheet dialog, View itemView) {
|
|
484
|
dialog.dismiss();
|
|
485
|
int tag = (int) itemView.getTag();
|
|
486
|
switch (tag) {
|
|
487
|
case TAG_SHARE_WECHAT_FRIEND:
|
|
488
|
share(Wechat.NAME, shareUrl);
|
|
489
|
break;
|
|
490
|
case TAG_SHARE_WECHAT_MOMENT:
|
|
491
|
share(WechatMoments.NAME, shareUrl);
|
|
492
|
break;
|
|
493
|
case TAG_SHARE_QQ:
|
|
494
|
share(QQ.NAME, shareUrl);
|
|
495
|
break;
|
|
496
|
}
|
|
497
|
}
|
|
498
|
}).build();
|
|
499
|
build.show();
|
|
500
|
}
|
|
501
|
|
|
502
|
private void showSimpleBottomSheetGrid(final ChargingShareBean chargingShareBean) {
|
|
503
|
final int TAG_SHARE_WECHAT_FRIEND = 0;
|
|
504
|
final int TAG_SHARE_WECHAT_MOMENT = 1;
|
|
505
|
final int TAG_SHARE_QQ = 2;
|
|
506
|
if (getActivity() == null){
|
|
507
|
return;
|
|
508
|
}
|
|
509
|
QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(getActivity());
|
|
510
|
QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
|
|
511
|
.addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
|
|
512
|
.addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
|
|
513
|
.setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
|
|
514
|
@Override
|
|
515
|
public void onClick(QMUIBottomSheet dialog, View itemView) {
|
|
516
|
dialog.dismiss();
|
|
517
|
int tag = (int) itemView.getTag();
|
|
518
|
switch (tag) {
|
|
519
|
case TAG_SHARE_WECHAT_FRIEND:
|
|
520
|
share(Wechat.NAME, chargingShareBean);
|
|
521
|
break;
|
|
522
|
case TAG_SHARE_WECHAT_MOMENT:
|
|
523
|
share(WechatMoments.NAME, chargingShareBean);
|
|
524
|
break;
|
|
525
|
case TAG_SHARE_QQ:
|
|
526
|
share(QQ.NAME, chargingShareBean);
|
|
527
|
break;
|
|
528
|
}
|
|
529
|
}
|
|
530
|
}).build();
|
|
531
|
build.show();
|
|
532
|
}
|
|
533
|
|
|
534
|
private void share(final String name, final String shareUrl) {
|
|
535
|
Platform.ShareParams paramsToShare = new Platform.ShareParams();
|
|
536
|
paramsToShare.setText(shareContext);
|
|
537
|
paramsToShare.setTitle(shareTitle);
|
|
538
|
paramsToShare.setTitleUrl(shareUrl);
|
|
539
|
paramsToShare.setUrl(shareUrl);
|
|
540
|
paramsToShare.setImageUrl(shareIcon);
|
|
541
|
paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
|
|
542
|
Platform platform = ShareSDK.getPlatform(name);
|
|
543
|
platform.setPlatformActionListener(new PlatformActionListener() {
|
|
544
|
@Override
|
|
545
|
public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
|
|
546
|
getShareIntegral();
|
|
547
|
}
|
|
548
|
|
|
549
|
@Override
|
|
550
|
public void onError(Platform platform, int i, Throwable throwable) {
|
|
551
|
LogUtils.e(throwable.getMessage());
|
|
552
|
}
|
|
553
|
|
|
554
|
@Override
|
|
555
|
public void onCancel(Platform platform, int i) {
|
|
556
|
}
|
|
557
|
});
|
|
558
|
platform.share(paramsToShare);
|
|
559
|
}
|
|
560
|
|
|
561
|
private void share(final String name, ChargingShareBean chargingShareBean) {
|
|
562
|
Platform.ShareParams paramsToShare = new Platform.ShareParams();
|
|
563
|
paramsToShare.setText(chargingShareBean.getText());
|
|
564
|
paramsToShare.setTitle(chargingShareBean.getTitle());
|
|
565
|
paramsToShare.setTitleUrl(chargingShareBean.getUrl());
|
|
566
|
paramsToShare.setUrl(chargingShareBean.getUrl());
|
|
567
|
paramsToShare.setImageUrl(chargingShareBean.getIcon());
|
|
568
|
paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
|
|
569
|
Platform platform = ShareSDK.getPlatform(name);
|
|
570
|
platform.setPlatformActionListener(new PlatformActionListener() {
|
|
571
|
@Override
|
|
572
|
public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
|
|
573
|
if (MainApplication.isLogin()) {
|
|
574
|
getShareIntegral();
|
|
575
|
}
|
|
576
|
}
|
|
577
|
|
|
578
|
@Override
|
|
579
|
public void onError(Platform platform, int i, Throwable throwable) {
|
|
580
|
LogUtils.e(throwable.getMessage());
|
|
581
|
}
|
|
582
|
|
|
583
|
@Override
|
|
584
|
public void onCancel(Platform platform, int i) {
|
|
585
|
}
|
|
586
|
});
|
|
587
|
platform.share(paramsToShare);
|
|
588
|
}
|
|
589
|
|
|
590
|
@JavascriptInterface
|
|
591
|
public void gotoshare() {
|
|
592
|
showSimpleBottomSheetGrid(shareUrl);
|
|
593
|
}
|
|
594
|
|
|
595
|
|
|
596
|
@AfterPermissionGranted(RC_CALL_PERM)
|
|
597
|
public void telTask(final String s) {
|
|
598
|
if (getActivity()==null){
|
|
599
|
return;
|
|
600
|
}
|
|
601
|
|
|
602
|
if (hasCallPhonePermission()) {
|
|
603
|
// Have permission, do the thing!
|
|
604
|
new com.electric.chargingpile.view.AlertDialog(getActivity()).builder()
|
|
605
|
.setMsg(s)
|
|
606
|
.setPositiveButton("呼叫", new View.OnClickListener() {
|
|
607
|
@Override
|
|
608
|
public void onClick(View v) {
|
|
609
|
Intent intent = new Intent();
|
|
610
|
intent.setAction("android.intent.action.CALL");
|
|
611
|
intent.addCategory("android.intent.category.DEFAULT");
|
|
612
|
intent.setData(Uri.parse("tel:" + s));
|
|
613
|
startActivity(intent);
|
|
614
|
}
|
|
615
|
}).setNegativeButton("取消", new View.OnClickListener() {
|
|
616
|
@Override
|
|
617
|
public void onClick(View v) {
|
|
618
|
|
|
619
|
}
|
|
620
|
}).show();
|
|
621
|
} else {
|
|
622
|
// Ask for one permission
|
|
623
|
EasyPermissions.requestPermissions(
|
|
624
|
this,
|
|
625
|
"该功能需要开启拨号权限,是否前往开启?",
|
|
626
|
RC_CALL_PERM,
|
|
627
|
Manifest.permission.CALL_PHONE);
|
|
628
|
}
|
|
629
|
}
|
|
630
|
|
|
631
|
@JavascriptInterface
|
|
632
|
public void makeacall(final String s) {
|
|
633
|
//telTask(s);
|
|
634
|
wechatAlert();
|
|
635
|
}
|
|
636
|
|
|
637
|
private void wechatAlert() {
|
|
638
|
if (getActivity()==null){
|
|
639
|
return;
|
|
640
|
}
|
|
641
|
|
|
642
|
AlertDialogTwo wechatAlert = new AlertDialogTwo(getActivity());
|
|
643
|
wechatAlert.builder().setTitle("温馨提示")
|
|
644
|
.setMsg("客服微信:chongdianzhuang2")
|
|
645
|
.setPositiveButton("复制", new View.OnClickListener() {
|
|
646
|
@Override
|
|
647
|
public void onClick(View view) {
|
|
648
|
ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
|
649
|
ClipData cdzData = ClipData.newPlainText("Label", "chongdianzhuang2");
|
|
650
|
cm.setPrimaryClip(cdzData);
|
|
651
|
ToastUtil.showToast(getContext(), "微信号复制成功", Toast.LENGTH_SHORT);
|
|
652
|
}
|
|
653
|
}).show();
|
|
654
|
}
|
|
655
|
|
|
656
|
@JavascriptInterface
|
|
657
|
public void closepage() {
|
|
658
|
if (getActivity()!=null){
|
|
659
|
getActivity().finish();
|
|
660
|
}
|
|
661
|
|
|
662
|
}
|
|
663
|
|
|
664
|
@JavascriptInterface
|
|
665
|
public String getuserinfo() throws Exception {
|
|
666
|
String s = null;
|
|
667
|
if (MainApplication.isLogin()) {
|
|
668
|
long appTime1 = System.currentTimeMillis() / 1000;
|
|
669
|
long updatetime = appTime1 - MainMapActivity.cha - 3;
|
|
670
|
String token = DES3.encode(String.valueOf(updatetime));
|
|
671
|
s = MainApplication.userId + "##" + MainApplication.userPhone + "##" + token;
|
|
672
|
} else {
|
|
673
|
s = "no";
|
|
674
|
}
|
|
675
|
final String finalS = s;
|
|
676
|
mHandler.post(new Runnable() {
|
|
677
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
678
|
@Override
|
|
679
|
public void run() {
|
|
680
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
681
|
webView.evaluateJavascript("window.myglobal.regetuserinfo('" + finalS + "')", new ValueCallback<String>() {
|
|
682
|
@Override
|
|
683
|
public void onReceiveValue(String arg0) {
|
|
684
|
|
|
685
|
}
|
|
686
|
});
|
|
687
|
} else {
|
|
688
|
webView.loadUrl("window.myglobal.regetuserinfo('" + finalS + "')");
|
|
689
|
}
|
|
690
|
|
|
691
|
}
|
|
692
|
});
|
|
693
|
return s;
|
|
694
|
}
|
|
695
|
|
|
696
|
@JavascriptInterface
|
|
697
|
public void openpaynopwd() {
|
|
698
|
Intent intent = new Intent(getContext(), NonSecretSeettingActivity.class);
|
|
699
|
Uri uri = Uri.parse("chongdianzhuang://");
|
|
700
|
intent.setData(uri);
|
|
701
|
startActivity(intent);
|
|
702
|
if (getActivity()!=null){
|
|
703
|
getActivity().finish();
|
|
704
|
}
|
|
705
|
|
|
706
|
}
|
|
707
|
|
|
708
|
@JavascriptInterface
|
|
709
|
public void runpaynopwd(String s) {
|
|
710
|
String[] strarray = s.split("\\#\\#");
|
|
711
|
String user_id = strarray[0];
|
|
712
|
String order_id = strarray[1];
|
|
713
|
Intent intent = new Intent(getContext(), NonSecretSeettingActivity.class);
|
|
714
|
intent.putExtra("user_id", user_id);
|
|
715
|
intent.putExtra("order_id", order_id);
|
|
716
|
intent.putExtra("money", "");
|
|
717
|
intent.putExtra("tag", "1");
|
|
718
|
Uri uri = Uri.parse("chongdianzhuang://");
|
|
719
|
intent.setData(uri);
|
|
720
|
startActivity(intent);
|
|
721
|
if (getActivity()!=null){
|
|
722
|
getActivity().finish();
|
|
723
|
}
|
|
724
|
}
|
|
725
|
|
|
726
|
@JavascriptInterface
|
|
727
|
public void commentredpack(String s) {
|
|
728
|
String[] strarray = s.split("\\#\\#");
|
|
729
|
String zhanid = strarray[0];
|
|
730
|
String orderid = strarray[1];
|
|
731
|
String url = strarray[2];
|
|
732
|
String money = strarray[3];
|
|
733
|
Intent intent = new Intent(getContext(), ChargingCommentActivity.class);
|
|
734
|
intent.putExtra("zhan_id", zhanid);
|
|
735
|
intent.putExtra("order_id", orderid);
|
|
736
|
intent.putExtra("money", money);
|
|
737
|
intent.putExtra("url", url);
|
|
738
|
intent.putExtra("zhuang_id", "");
|
|
739
|
startActivity(intent);
|
|
740
|
MobclickAgent.onEvent(getContext(), "0610");
|
|
741
|
}
|
|
742
|
|
|
743
|
|
|
744
|
@JavascriptInterface
|
|
745
|
public void gotopage(String s) {
|
|
746
|
Log.e(TAG, "gotopage: s=" + s);
|
|
747
|
String[] strarray = s.split("\\#\\#");
|
|
748
|
String id = strarray[0];
|
|
749
|
switch (id) {
|
|
750
|
case "01":
|
|
751
|
//注册
|
|
752
|
startActivity(new Intent(getContext(), RegisterActivity.class));
|
|
753
|
break;
|
|
754
|
case "02":
|
|
755
|
//登录页
|
|
756
|
if (MainApplication.isLogin()) {
|
|
757
|
ToastUtil.showToast(getContext(), "您已经登录", Toast.LENGTH_SHORT);
|
|
758
|
} else {
|
|
759
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
760
|
}
|
|
761
|
break;
|
|
762
|
case "03":
|
|
763
|
//余额页
|
|
764
|
if (MainApplication.isLogin()) {
|
|
765
|
startActivity(new Intent(getContext(), MyBalanceActivity.class));
|
|
766
|
} else {
|
|
767
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
768
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
769
|
index = "3";
|
|
770
|
}
|
|
771
|
break;
|
|
772
|
case "04":
|
|
773
|
//充值页
|
|
774
|
if (!MainApplication.isLogin()) {
|
|
775
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
776
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
777
|
index = "4";
|
|
778
|
} else {
|
|
779
|
startActivity(new Intent(getContext(), AccountRechargeActivity.class));
|
|
780
|
}
|
|
781
|
break;
|
|
782
|
case "05":
|
|
783
|
//兑吧商城首页
|
|
784
|
skipShopCenter();
|
|
785
|
break;
|
|
786
|
case "06":
|
|
787
|
//兑吧商品详情页
|
|
788
|
String url = strarray[1];
|
|
789
|
Log.e(TAG, "gotopage: !!!!!");
|
|
790
|
skipShopDetail(url);
|
|
791
|
break;
|
|
792
|
case "07":
|
|
793
|
//添加新站点
|
|
794
|
if (MainApplication.isLogin()) {
|
|
795
|
startActivity(new Intent(getContext(), ShareTwoActivity.class));
|
|
796
|
} else {
|
|
797
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
798
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
799
|
index = "7";
|
|
800
|
}
|
|
801
|
break;
|
|
802
|
case "08":
|
|
803
|
//充电排行榜
|
|
804
|
if (MainApplication.isLogin()) {
|
|
805
|
startActivity(new Intent(getContext(), RankingListActivity.class));
|
|
806
|
} else {
|
|
807
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
808
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
809
|
index = "8";
|
|
810
|
}
|
|
811
|
break;
|
|
812
|
case "09":
|
|
813
|
//路径规划
|
|
814
|
startActivity(new Intent(getContext(), RoutePlanShowAddressActivity.class));
|
|
815
|
break;
|
|
816
|
case "10":
|
|
817
|
//站点详情
|
|
818
|
String zhan_id = strarray[1];
|
|
819
|
String current = strarray[2];
|
|
820
|
if (current.equals("detail")) {
|
|
821
|
Intent intent = new Intent(getContext(), NewZhanDetailsActivity.class);
|
|
822
|
intent.putExtra("zhan_id", zhan_id);
|
|
823
|
MainApplication.details_flag = "2";
|
|
824
|
startActivity(intent);
|
|
825
|
} else if (current.equals("comment")) {
|
|
826
|
Intent intent = new Intent(getContext(), NewZhanDetailsActivity.class);
|
|
827
|
intent.putExtra("zhan_id", zhan_id);
|
|
828
|
MainApplication.details_flag = "4";
|
|
829
|
startActivity(intent);
|
|
830
|
} else if (current.equals("writecomment")) {
|
|
831
|
Intent intent = new Intent(getContext(), ZhanCommentActivity.class);
|
|
832
|
intent.putExtra("zhan_id", zhan_id);
|
|
833
|
intent.putExtra("show_txt", "有什么想吐槽的吗?来跟其他车友分享一下吧...");
|
|
834
|
startActivity(intent);
|
|
835
|
}
|
|
836
|
break;
|
|
837
|
case "11":
|
|
838
|
//意见反馈
|
|
839
|
if (MainApplication.isLogin()) {
|
|
840
|
startActivity(new Intent(getContext(), FeedbackActivity.class));
|
|
841
|
} else {
|
|
842
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
843
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
844
|
index = "11";
|
|
845
|
}
|
|
846
|
break;
|
|
847
|
case "12":
|
|
848
|
//邀请记录
|
|
849
|
startActivity(new Intent(getContext(), YaoQingListActivity.class));
|
|
850
|
break;
|
|
851
|
case "13":
|
|
852
|
//提问页
|
|
853
|
if (MainApplication.isLogin()) {
|
|
854
|
startActivity(new Intent(getContext(), EditQuestionOneActivity.class));
|
|
855
|
} else {
|
|
856
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
857
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
858
|
index = "13";
|
|
859
|
}
|
|
860
|
break;
|
|
861
|
case "14":
|
|
862
|
startActivity(new Intent(getContext(), UnansweredActivity.class));
|
|
863
|
break;
|
|
864
|
case "15":
|
|
865
|
if (MainApplication.isLogin()) {
|
|
866
|
mHandler.post(new Runnable() {
|
|
867
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
868
|
@Override
|
|
869
|
public void run() {
|
|
870
|
loadDialog.show();
|
|
871
|
}
|
|
872
|
});
|
|
873
|
|
|
874
|
getCarOwnerCertificateList();
|
|
875
|
} else {
|
|
876
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
877
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
878
|
index = "15";
|
|
879
|
}
|
|
880
|
break;
|
|
881
|
|
|
882
|
case "16":
|
|
883
|
if (MainApplication.isLogin()) {
|
|
884
|
startActivity(new Intent(getContext(), MemberGetCoinActivity.class));
|
|
885
|
} else {
|
|
886
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
887
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
888
|
|
|
889
|
}
|
|
890
|
|
|
891
|
break;
|
|
892
|
}
|
|
893
|
|
|
894
|
}
|
|
895
|
|
|
896
|
@JavascriptInterface
|
|
897
|
public void userlogin(String s) throws Exception {
|
|
898
|
String[] strarray = s.split("\\#\\#");
|
|
899
|
final String user_name = strarray[0];
|
|
900
|
final String password = strarray[1];
|
|
901
|
long appTime1 = System.currentTimeMillis() / 1000;
|
|
902
|
long updatetime = appTime1 - MainMapActivity.cha - 3;
|
|
903
|
String token = DES3.encode(String.valueOf(updatetime));
|
|
904
|
final String replace = URLEncoder.encode(token, "UTF-8");
|
|
905
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/tpmember/login?phone="
|
|
906
|
+ user_name + "&password=" + URLEncoder.encode(password, "UTF-8") + "&token=" + replace
|
|
907
|
+ "&imei=" + "android_" + MainApplication.imei + "®istration_id=" + MainApplication.getInstance().getPushID();
|
|
908
|
StringCallback stringCallback = new StringCallback() {
|
|
909
|
@Override
|
|
910
|
public void onError(Call call, Exception e) {
|
|
911
|
mHandler.post(new Runnable() {
|
|
912
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
913
|
@Override
|
|
914
|
public void run() {
|
|
915
|
webView.evaluateJavascript("window.myglobal.reuserlogin('" + "no" + "')", new ValueCallback<String>() {
|
|
916
|
@Override
|
|
917
|
public void onReceiveValue(String arg0) {
|
|
918
|
}
|
|
919
|
});
|
|
920
|
}
|
|
921
|
});
|
|
922
|
}
|
|
923
|
|
|
924
|
@Override
|
|
925
|
public void onResponse(String response) {
|
|
926
|
try {
|
|
927
|
JSONObject jsonObj = new JSONObject(response);
|
|
928
|
String rtnCode = jsonObj.getString("rtnCode");
|
|
929
|
if (rtnCode.equals("01")) {
|
|
930
|
String data = jsonObj.getString("data");
|
|
931
|
try {
|
|
932
|
Gson g = new Gson();
|
|
933
|
User u = g.fromJson(data, User.class);
|
|
934
|
userid = u.getUserid().toString();
|
|
935
|
if (!u.getUserpic().toString().equals("")) {
|
|
936
|
usericon = MainApplication.url + "/zhannew//uploadfile/" + u.getUserpic().toString();
|
|
937
|
} else {
|
|
938
|
usericon = "";
|
|
939
|
}
|
|
940
|
nickname = u.getNickname();
|
|
941
|
username = u.getUsername();
|
|
942
|
usersex = u.getSex();
|
|
943
|
hascar = u.getChexing();
|
|
944
|
nocar = u.getYichexing();
|
|
945
|
if (nickname == null) {
|
|
946
|
nickname = "";
|
|
947
|
}
|
|
948
|
Log.e("usericon", usericon);
|
|
949
|
} catch (Exception e) {
|
|
950
|
e.printStackTrace();
|
|
951
|
}
|
|
952
|
if (getActivity()!=null){
|
|
953
|
SharedPreferences mySharedPreferences = getActivity().getSharedPreferences("loginUserName",
|
|
954
|
Activity.MODE_PRIVATE);
|
|
955
|
SharedPreferences.Editor editor1 = mySharedPreferences.edit();
|
|
956
|
editor1.putString("username", user_name);
|
|
957
|
editor1.commit();
|
|
958
|
|
|
959
|
SharedPreferences mSharedPreferences = getActivity().getSharedPreferences("userInfo",
|
|
960
|
Activity.MODE_PRIVATE);
|
|
961
|
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
|
962
|
editor.putString("nickname", nickname);
|
|
963
|
editor.putString("username", username);
|
|
964
|
editor.putString("sex", usersex);
|
|
965
|
editor.putString("chexing", hascar);
|
|
966
|
editor.putString("yichexing", nocar);
|
|
967
|
editor.putString("password", password);
|
|
968
|
editor.putString("yonghuming", user_name);
|
|
969
|
editor.commit();
|
|
970
|
}
|
|
971
|
|
|
972
|
MainApplication.ok = "1";
|
|
973
|
MainApplication.userPhone = user_name;
|
|
974
|
MainApplication.userPassword = password;
|
|
975
|
ProfileManager.getInstance().setUsername(MainApplication.context,
|
|
976
|
user_name);
|
|
977
|
ProfileManager.getInstance().setId(MainApplication.context, user_name);
|
|
978
|
ProfileManager.getInstance().setKeyUserpassword(MainApplication.context, password);
|
|
979
|
MainApplication.userId = userid;
|
|
980
|
MainApplication.userIcon = usericon;
|
|
981
|
MainApplication.userNickname = nickname;
|
|
982
|
ProfileManager.getInstance().setUserid(MainApplication.context, userid);
|
|
983
|
ProfileManager.getInstance().setUsericon(MainApplication.context, usericon);
|
|
984
|
ProfileManager.getInstance().setNickname(MainApplication.context, nickname);
|
|
985
|
MobclickAgent.onProfileSignIn(MainApplication.userId);
|
|
986
|
ToastUtil.showToast(getContext(), "登录成功", Toast.LENGTH_SHORT);
|
|
987
|
mHandler.post(new Runnable() {
|
|
988
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
989
|
@Override
|
|
990
|
public void run() {
|
|
991
|
webView.evaluateJavascript("window.myglobal.reuserlogin('" + "yes" + "')", new ValueCallback<String>() {
|
|
992
|
@Override
|
|
993
|
public void onReceiveValue(String arg0) {
|
|
994
|
|
|
995
|
}
|
|
996
|
});
|
|
997
|
}
|
|
998
|
});
|
|
999
|
} else if (rtnCode.equals("03")) {
|
|
1000
|
mHandler.post(new Runnable() {
|
|
1001
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
1002
|
@Override
|
|
1003
|
public void run() {
|
|
1004
|
webView.evaluateJavascript("window.myglobal.reuserlogin('" + "no" + "')", new ValueCallback<String>() {
|
|
1005
|
@Override
|
|
1006
|
public void onReceiveValue(String arg0) {
|
|
1007
|
|
|
1008
|
}
|
|
1009
|
});
|
|
1010
|
}
|
|
1011
|
});
|
|
1012
|
ToastUtil.showToast(getContext(), "登录超时,请重新登录", Toast.LENGTH_SHORT);
|
|
1013
|
} else if (rtnCode.equals("02")) {
|
|
1014
|
mHandler.post(new Runnable() {
|
|
1015
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
1016
|
@Override
|
|
1017
|
public void run() {
|
|
1018
|
webView.evaluateJavascript("window.myglobal.reuserlogin('" + "no" + "')", new ValueCallback<String>() {
|
|
1019
|
@Override
|
|
1020
|
public void onReceiveValue(String arg0) {
|
|
1021
|
|
|
1022
|
}
|
|
1023
|
});
|
|
1024
|
}
|
|
1025
|
});
|
|
1026
|
ToastUtil.showToast(getContext(), "用户不存在,请核对后重新填写", Toast.LENGTH_SHORT);
|
|
1027
|
} else if (rtnCode.equals("04")) {
|
|
1028
|
mHandler.post(new Runnable() {
|
|
1029
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
1030
|
@Override
|
|
1031
|
public void run() {
|
|
1032
|
webView.evaluateJavascript("window.myglobal.reuserlogin('" + "no" + "')", new ValueCallback<String>() {
|
|
1033
|
@Override
|
|
1034
|
public void onReceiveValue(String arg0) {
|
|
1035
|
|
|
1036
|
}
|
|
1037
|
});
|
|
1038
|
}
|
|
1039
|
});
|
|
1040
|
ToastUtil.showToast(getContext(), "密码错误,请重新输入", Toast.LENGTH_SHORT);
|
|
1041
|
}
|
|
1042
|
} catch (Exception e) {
|
|
1043
|
e.printStackTrace();
|
|
1044
|
}
|
|
1045
|
}
|
|
1046
|
};
|
|
1047
|
OkHttpUtils.get().url(url).build().execute(stringCallback);
|
|
1048
|
}
|
|
1049
|
|
|
1050
|
private void onResumeSkip() {
|
|
1051
|
switch (index) {
|
|
1052
|
case "3":
|
|
1053
|
if (MainApplication.isLogin()) {
|
|
1054
|
startActivity(new Intent(getContext(), MyBalanceActivity.class));
|
|
1055
|
index = "0";
|
|
1056
|
}
|
|
1057
|
break;
|
|
1058
|
case "4":
|
|
1059
|
if (MainApplication.isLogin()) {
|
|
1060
|
startActivity(new Intent(getContext(), AccountRechargeActivity.class));
|
|
1061
|
index = "0";
|
|
1062
|
}
|
|
1063
|
break;
|
|
1064
|
case "7":
|
|
1065
|
if (MainApplication.isLogin()) {
|
|
1066
|
startActivity(new Intent(getContext(), ShareTwoActivity.class));
|
|
1067
|
index = "0";
|
|
1068
|
}
|
|
1069
|
break;
|
|
1070
|
case "8":
|
|
1071
|
if (MainApplication.isLogin()) {
|
|
1072
|
startActivity(new Intent(getContext(), RankingListActivity.class));
|
|
1073
|
index = "0";
|
|
1074
|
}
|
|
1075
|
break;
|
|
1076
|
case "11":
|
|
1077
|
if (MainApplication.isLogin()) {
|
|
1078
|
startActivity(new Intent(getContext(), FeedbackActivity.class));
|
|
1079
|
index = "0";
|
|
1080
|
}
|
|
1081
|
break;
|
|
1082
|
case "13":
|
|
1083
|
if (MainApplication.isLogin()) {
|
|
1084
|
startActivity(new Intent(getContext(), EditQuestionOneActivity.class));
|
|
1085
|
index = "0";
|
|
1086
|
}
|
|
1087
|
break;
|
|
1088
|
case "100":
|
|
1089
|
if (MainApplication.isLogin()) {
|
|
1090
|
startActivity(new Intent(getContext(), MyFeedbackActivity.class));
|
|
1091
|
index = "0";
|
|
1092
|
}
|
|
1093
|
break;
|
|
1094
|
}
|
|
1095
|
}
|
|
1096
|
|
|
1097
|
|
|
1098
|
@Override
|
|
1099
|
public void onResume() {
|
|
1100
|
super.onResume();
|
|
1101
|
onResumeSkip();
|
|
1102
|
Log.e(TAG, "onResume: =" + "---------");
|
|
1103
|
for (int i = 0; i < list.size(); i++) {
|
|
1104
|
if (currentUrl.contains(list.get(i))) {
|
|
1105
|
Log.e(TAG, "onResume: =" + "========");
|
|
1106
|
webView.reload();
|
|
1107
|
list.remove(list.get(i));
|
|
1108
|
break;
|
|
1109
|
}
|
|
1110
|
}
|
|
1111
|
|
|
1112
|
if (null != mUrl && !"".equals(mUrl) && loginToShare) {
|
|
1113
|
if (!mUrl.contains("&phone=")) {
|
|
1114
|
if (MainApplication.isLogin()) {
|
|
1115
|
mUrl = mUrl + "&phone=" + MainApplication.userPhone;
|
|
1116
|
webView.loadUrl(mUrl);
|
|
1117
|
}
|
|
1118
|
}
|
|
1119
|
}
|
|
1120
|
}
|
|
1121
|
|
|
1122
|
private void skipShopCenter() {
|
|
1123
|
long appTime11 = System.currentTimeMillis() / 1000;
|
|
1124
|
Log.i("appTime(long)---", appTime11 + "");
|
|
1125
|
long updatetime1 = appTime11 - MainMapActivity.cha - 5;
|
|
1126
|
Log.i("updatetime(long)---", updatetime1 + "");
|
|
1127
|
Log.i("cha---", MainMapActivity.cha + "");
|
|
1128
|
String token1 = String.valueOf(updatetime1);
|
|
1129
|
String encode_token = null;
|
|
1130
|
try {
|
|
1131
|
encode_token = DES3.encode(token1);
|
|
1132
|
} catch (Exception e) {
|
|
1133
|
e.printStackTrace();
|
|
1134
|
}
|
|
1135
|
String replace = URLEncoder.encode(encode_token);
|
|
1136
|
Intent intent11 = new Intent();
|
|
1137
|
intent11.setClass(getContext(), CreditActivity.class);
|
|
1138
|
intent11.putExtra("navColor", "#fcfcfc"); //配置导航条的背景颜色,请用#ffffff长格式。
|
|
1139
|
intent11.putExtra("titleColor", "#222222"); //配置导航条标题的颜色,请用#ffffff长格式。
|
|
1140
|
MainApplication.goods_type = "shop";
|
|
1141
|
if (!MainApplication.isLogin()) {
|
|
1142
|
intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace); //配置自动登陆地址,每次需服务端动态生成。
|
|
1143
|
} else {
|
|
1144
|
intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace); //配置自动登陆地址,每次需服务端动态生成。
|
|
1145
|
}
|
|
1146
|
startActivity(intent11);
|
|
1147
|
|
|
1148
|
CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
|
|
1149
|
/**
|
|
1150
|
* 当点击分享按钮被点击
|
|
1151
|
* @param shareUrl 分享的地址
|
|
1152
|
* @param shareThumbnail 分享的缩略图
|
|
1153
|
* @param shareTitle 分享的标题
|
|
1154
|
* @param shareSubtitle 分享的副标题
|
|
1155
|
*/
|
|
1156
|
public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
|
|
1157
|
//当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。
|
|
1158
|
ChargingShareBean chargingShareBean = new ChargingShareBean();
|
|
1159
|
chargingShareBean.setIcon(shareThumbnail);
|
|
1160
|
chargingShareBean.setTitle(shareTitle);
|
|
1161
|
chargingShareBean.setUrl(shareUrl);
|
|
1162
|
chargingShareBean.setText("");
|
|
1163
|
showSimpleBottomSheetGrid(chargingShareBean);
|
|
1164
|
}
|
|
1165
|
|
|
1166
|
/**
|
|
1167
|
* 当点击“请先登录”按钮唤起登录时,会调用此处代码。
|
|
1168
|
* 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
|
|
1169
|
* @param webView 用于登录成功后返回到当前的webview刷新登录状态。
|
|
1170
|
* @param currentUrl 当前页面的url
|
|
1171
|
*/
|
|
1172
|
public void onLoginClick(WebView webView, final String currentUrl) {
|
|
1173
|
//当未登录的用户点击去登录时,会调用此处代码。
|
|
1174
|
//用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
|
|
1175
|
//为了用户登录后能回到未登录前的页面(currentUrl)。
|
|
1176
|
//当用户登录成功后,需要重新请求一次服务端,带上currentUrl。
|
|
1177
|
//用该方法中的webview变量加载请求链接。
|
|
1178
|
//服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。
|
|
1179
|
new AlertDialog.Builder(webView.getContext()).setTitle("跳转登录").setMessage("跳转到登录页面?")
|
|
1180
|
.setPositiveButton("是", new DialogInterface.OnClickListener() {
|
|
1181
|
@Override
|
|
1182
|
public void onClick(DialogInterface dialog, int which) {
|
|
1183
|
MainApplication.current_url = currentUrl;
|
|
1184
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
1185
|
}
|
|
1186
|
})
|
|
1187
|
.setNegativeButton("否", null)
|
|
1188
|
.show();
|
|
1189
|
}
|
|
1190
|
|
|
1191
|
/**
|
|
1192
|
* 当点击“复制”按钮时,触发该方法,回调获取到券码code
|
|
1193
|
* @param webView webview对象。
|
|
1194
|
* @param code 复制的券码
|
|
1195
|
*/
|
|
1196
|
public void onCopyCode(WebView webView, String code) {
|
|
1197
|
//当未登录的用户点击去登录时,会调用此处代码。
|
|
1198
|
new AlertDialog.Builder(webView.getContext())
|
|
1199
|
.setTitle("复制券码")
|
|
1200
|
.setMessage("已复制,券码为:" + code)
|
|
1201
|
.setPositiveButton("是", null)
|
|
1202
|
.setNegativeButton("否", null)
|
|
1203
|
.show();
|
|
1204
|
}
|
|
1205
|
|
|
1206
|
/**
|
|
1207
|
* 积分商城返回首页刷新积分时,触发该方法。
|
|
1208
|
*/
|
|
1209
|
public void onLocalRefresh(WebView mWebView, String credits) {
|
|
1210
|
//String credits为积分商城返回的最新积分,不保证准确。
|
|
1211
|
//触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。
|
|
1212
|
}
|
|
1213
|
};
|
|
1214
|
}
|
|
1215
|
|
|
1216
|
private void skipShopDetail(String url) {
|
|
1217
|
long appTime11 = System.currentTimeMillis() / 1000;
|
|
1218
|
long updatetime1 = appTime11 - MainMapActivity.cha - 5;
|
|
1219
|
String token1 = String.valueOf(updatetime1);
|
|
1220
|
String encode_token = null;
|
|
1221
|
try {
|
|
1222
|
encode_token = DES3.encode(token1);
|
|
1223
|
} catch (Exception e) {
|
|
1224
|
e.printStackTrace();
|
|
1225
|
}
|
|
1226
|
String replace = URLEncoder.encode(encode_token);
|
|
1227
|
// startActivity(new Intent(getContext(), ShopActivity.class));
|
|
1228
|
Intent intent11 = new Intent();
|
|
1229
|
intent11.setClass(getContext(), CreditActivity.class);
|
|
1230
|
intent11.putExtra("navColor", "#fcfcfc"); //配置导航条的背景颜色,请用#ffffff长格式。
|
|
1231
|
intent11.putExtra("titleColor", "#222222"); //配置导航条标题的颜色,请用#ffffff长格式。
|
|
1232
|
MainApplication.goods_type = "details";
|
|
1233
|
// MainApplication.current_url = getIntent().getStringExtra("shareUrl");
|
|
1234
|
// MainApplication.current_url = "http://www.duiba.com.cn/mobile/appItemDetail?appItemId=453087";
|
|
1235
|
if (!MainApplication.isLogin()) {
|
|
1236
|
intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + url); //配置自动登陆地址,每次需服务端动态生成。
|
|
1237
|
} else {
|
|
1238
|
intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + url); //配置自动登陆地址,每次需服务端动态生成。
|
|
1239
|
}
|
|
1240
|
startActivity(intent11);
|
|
1241
|
if (getActivity()!=null){
|
|
1242
|
getActivity().overridePendingTransition(0, 0);
|
|
1243
|
}
|
|
1244
|
|
|
1245
|
CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
|
|
1246
|
/**
|
|
1247
|
* 当点击分享按钮被点击
|
|
1248
|
* @param shareUrl 分享的地址
|
|
1249
|
* @param shareThumbnail 分享的缩略图
|
|
1250
|
* @param shareTitle 分享的标题
|
|
1251
|
* @param shareSubtitle 分享的副标题
|
|
1252
|
*/
|
|
1253
|
public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
|
|
1254
|
//当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。
|
|
1255
|
ChargingShareBean chargingShareBean = new ChargingShareBean();
|
|
1256
|
chargingShareBean.setIcon(shareThumbnail);
|
|
1257
|
chargingShareBean.setTitle(shareTitle);
|
|
1258
|
chargingShareBean.setUrl(shareUrl);
|
|
1259
|
chargingShareBean.setText("");
|
|
1260
|
|
|
1261
|
|
|
1262
|
showSimpleBottomSheetGrid(chargingShareBean);
|
|
1263
|
}
|
|
1264
|
|
|
1265
|
/**
|
|
1266
|
* 当点击“请先登录”按钮唤起登录时,会调用此处代码。
|
|
1267
|
* 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
|
|
1268
|
* @param webView 用于登录成功后返回到当前的webview刷新登录状态。
|
|
1269
|
* @param currentUrl 当前页面的url
|
|
1270
|
*/
|
|
1271
|
public void onLoginClick(WebView webView, final String currentUrl) {
|
|
1272
|
//当未登录的用户点击去登录时,会调用此处代码。
|
|
1273
|
//用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
|
|
1274
|
//为了用户登录后能回到未登录前的页面(currentUrl)。
|
|
1275
|
//当用户登录成功后,需要重新请求一次服务端,带上currentUrl。
|
|
1276
|
//用该方法中的webview变量加载请求链接。
|
|
1277
|
//服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。
|
|
1278
|
new AlertDialog.Builder(webView.getContext())
|
|
1279
|
.setTitle("跳转登录")
|
|
1280
|
.setMessage("跳转到登录页面?")
|
|
1281
|
.setPositiveButton("是", new DialogInterface.OnClickListener() {
|
|
1282
|
@Override
|
|
1283
|
public void onClick(DialogInterface dialog, int which) {
|
|
1284
|
MainApplication.h5_url = currentUrl;
|
|
1285
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
1286
|
|
|
1287
|
}
|
|
1288
|
})
|
|
1289
|
.setNegativeButton("否", null)
|
|
1290
|
.show();
|
|
1291
|
}
|
|
1292
|
|
|
1293
|
/**
|
|
1294
|
* 当点击“复制”按钮时,触发该方法,回调获取到券码code
|
|
1295
|
* @param webView webview对象。
|
|
1296
|
* @param code 复制的券码
|
|
1297
|
*/
|
|
1298
|
public void onCopyCode(WebView webView, String code) {
|
|
1299
|
//当未登录的用户点击去登录时,会调用此处代码。
|
|
1300
|
new AlertDialog.Builder(webView.getContext())
|
|
1301
|
.setTitle("复制券码")
|
|
1302
|
.setMessage("已复制,券码为:" + code)
|
|
1303
|
.setPositiveButton("是", null)
|
|
1304
|
.setNegativeButton("否", null)
|
|
1305
|
.show();
|
|
1306
|
}
|
|
1307
|
|
|
1308
|
/**
|
|
1309
|
* 积分商城返回首页刷新积分时,触发该方法。
|
|
1310
|
*/
|
|
1311
|
public void onLocalRefresh(WebView mWebView, String credits) {
|
|
1312
|
//String credits为积分商城返回的最新积分,不保证准确。
|
|
1313
|
//触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。
|
|
1314
|
}
|
|
1315
|
};
|
|
1316
|
}
|
|
1317
|
|
|
1318
|
public boolean onKeyDown(int keyCode, KeyEvent event, OnKeyDownListener keyDownListener) {
|
|
1319
|
WebBackForwardList mWebBackForwardList = webView.copyBackForwardList();
|
|
1320
|
Log.e("tag", "mWebBackForwardList.getSize() " + mWebBackForwardList.getSize());
|
|
1321
|
if (webView.canGoBack()) {
|
|
1322
|
webView.goBack();
|
|
1323
|
iv_webBack.setVisibility(View.VISIBLE);
|
|
1324
|
return true;
|
|
1325
|
} else {
|
|
1326
|
if (keyDownListener!=null){
|
|
1327
|
return keyDownListener.onKeyDown(keyCode,event);
|
|
1328
|
}else{
|
|
1329
|
return false;
|
|
1330
|
}
|
|
1331
|
}
|
|
1332
|
}
|
|
1333
|
|
|
1334
|
@Override
|
|
1335
|
public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
|
|
1336
|
mHandler.post(new Runnable() {
|
|
1337
|
@Override
|
|
1338
|
public void run() {
|
|
1339
|
ToastUtil.showToast(getContext(), "分享成功", Toast.LENGTH_SHORT);
|
|
1340
|
}
|
|
1341
|
});
|
|
1342
|
ToastUtil.showToast(getContext(), "分享成功", Toast.LENGTH_SHORT);
|
|
1343
|
getShareIntegral();
|
|
1344
|
}
|
|
1345
|
|
|
1346
|
@Override
|
|
1347
|
public void onError(Platform platform, int i, Throwable throwable) {
|
|
1348
|
mHandler.post(new Runnable() {
|
|
1349
|
@Override
|
|
1350
|
public void run() {
|
|
1351
|
ToastUtil.showToast(getContext(), "分享失败", Toast.LENGTH_SHORT);
|
|
1352
|
}
|
|
1353
|
});
|
|
1354
|
|
|
1355
|
}
|
|
1356
|
|
|
1357
|
@Override
|
|
1358
|
public void onCancel(Platform platform, int i) {
|
|
1359
|
mHandler.post(new Runnable() {
|
|
1360
|
@Override
|
|
1361
|
public void run() {
|
|
1362
|
ToastUtil.showToast(getContext(), "分享已取消", Toast.LENGTH_SHORT);
|
|
1363
|
}
|
|
1364
|
|
|
1365
|
});
|
|
1366
|
}
|
|
1367
|
|
|
1368
|
|
|
1369
|
@Override
|
|
1370
|
public void onClick(View v) {
|
|
1371
|
switch (v.getId()) {
|
|
1372
|
case R.id.tv_webview_share:
|
|
1373
|
if (tv_webShare.getText().toString().equals("分享")) {
|
|
1374
|
if (null != shareIcon && null != shareUrl && null != shareTitle && null != shareContext) {
|
|
1375
|
btnToShare();
|
|
1376
|
}
|
|
1377
|
} else if (tv_webShare.getText().toString().equals("我的反馈")) {
|
|
1378
|
if (MainApplication.isLogin()) {
|
|
1379
|
Intent i = new Intent(getContext(), MyFeedbackActivity.class);
|
|
1380
|
startActivity(i);
|
|
1381
|
} else {
|
|
1382
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
|
1383
|
ToastUtil.showToast(getContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
1384
|
index = "100";
|
|
1385
|
}
|
|
1386
|
|
|
1387
|
} else {
|
|
1388
|
mHandler.post(new Runnable() {
|
|
1389
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
1390
|
@Override
|
|
1391
|
public void run() {
|
|
1392
|
webView.evaluateJavascript("window.myglobal.resetrctext()", new ValueCallback<String>() {
|
|
1393
|
@Override
|
|
1394
|
public void onReceiveValue(String arg0) {
|
|
1395
|
|
|
1396
|
}
|
|
1397
|
});
|
|
1398
|
}
|
|
1399
|
});
|
|
1400
|
}
|
|
1401
|
break;
|
|
1402
|
case R.id.iv_webview_back:
|
|
1403
|
WebBackForwardList mWebBackForwardList = webView.copyBackForwardList();
|
|
1404
|
Log.e("tag", "mWebBackForwardList.getSize() " + mWebBackForwardList.getSize());
|
|
1405
|
if (webView.canGoBack()) {
|
|
1406
|
showsharebtn("no");
|
|
1407
|
webView.goBack();
|
|
1408
|
iv_webClose.setVisibility(View.VISIBLE);
|
|
1409
|
} else {
|
|
1410
|
if (getActivity() == null){
|
|
1411
|
return;
|
|
1412
|
}
|
|
1413
|
getActivity().finish();
|
|
1414
|
}
|
|
1415
|
break;
|
|
1416
|
case R.id.iv_webview_close:
|
|
1417
|
if (getActivity() == null){
|
|
1418
|
return;
|
|
1419
|
}
|
|
1420
|
getActivity().finish();
|
|
1421
|
break;
|
|
1422
|
}
|
|
1423
|
}
|
|
1424
|
|
|
1425
|
@Override
|
|
1426
|
public void onRequestPermissionsResult(int requestCode,
|
|
1427
|
@NonNull String[] permissions,
|
|
1428
|
@NonNull int[] grantResults) {
|
|
1429
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
1430
|
|
|
1431
|
// EasyPermissions handles the request result.
|
|
1432
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
|
1433
|
}
|
|
1434
|
|
|
1435
|
@Override
|
|
1436
|
public void onPermissionsGranted(int requestCode, List<String> perms) {
|
|
1437
|
|
|
1438
|
}
|
|
1439
|
|
|
1440
|
@Override
|
|
1441
|
public void onPermissionsDenied(int requestCode, List<String> perms) {
|
|
1442
|
if (requestCode == RC_ALBUM_PERM) {
|
|
1443
|
mOpenFileWebChromeClient.mFilePathCallback = null;
|
|
1444
|
mOpenFileWebChromeClient.mFilePathCallbacks = null;
|
|
1445
|
}
|
|
1446
|
}
|
|
1447
|
|
|
1448
|
private boolean hasCallPhonePermission() {
|
|
1449
|
if (getContext()==null) return false;
|
|
1450
|
return EasyPermissions.hasPermissions(getContext(), Manifest.permission.CALL_PHONE);
|
|
1451
|
}
|
|
1452
|
|
|
1453
|
public class OpenFileWebChromeClient extends WebChromeClient {
|
|
1454
|
public static final int REQUEST_FILE_PICKER = 1;
|
|
1455
|
public ValueCallback<Uri> mFilePathCallback;
|
|
1456
|
public ValueCallback<Uri[]> mFilePathCallbacks;
|
|
1457
|
|
|
1458
|
|
|
1459
|
public OpenFileWebChromeClient() {
|
|
1460
|
super();
|
|
1461
|
}
|
|
1462
|
|
|
1463
|
@Override
|
|
1464
|
public void onReceivedTitle(WebView view, String title) {
|
|
1465
|
super.onReceivedTitle(view, title);
|
|
1466
|
Log.d("ANDROID_LAB", "TITLE=" + title);
|
|
1467
|
tv_webTitle.setText(title);
|
|
1468
|
}
|
|
1469
|
|
|
1470
|
@Override
|
|
1471
|
public void onProgressChanged(WebView view, int newProgress) {
|
|
1472
|
super.onProgressChanged(view, newProgress);
|
|
1473
|
pb_webBar.setProgress(newProgress);
|
|
1474
|
}
|
|
1475
|
|
|
1476
|
@Override
|
|
1477
|
public void onGeolocationPermissionsShowPrompt(String origin,
|
|
1478
|
GeolocationPermissions.Callback callback) {
|
|
1479
|
callback.invoke(origin, true, false);
|
|
1480
|
super.onGeolocationPermissionsShowPrompt(origin, callback);
|
|
1481
|
}
|
|
1482
|
|
|
1483
|
// Android < 3.0 调用这个方法
|
|
1484
|
public void openFileChooser(ValueCallback<Uri> filePathCallback) {
|
|
1485
|
mFilePathCallback = filePathCallback;
|
|
1486
|
permissionTask();
|
|
1487
|
}
|
|
1488
|
|
|
1489
|
// 3.0 + 调用这个方法
|
|
1490
|
public void openFileChooser(ValueCallback filePathCallback, String acceptType) {
|
|
1491
|
mFilePathCallback = filePathCallback;
|
|
1492
|
permissionTask();
|
|
1493
|
}
|
|
1494
|
|
|
1495
|
// / js上传文件的<input type="file" name="fileField" id="fileField" />事件捕获
|
|
1496
|
// Android > 4.1.1 调用这个方法
|
|
1497
|
public void openFileChooser(ValueCallback<Uri> filePathCallback, String acceptType, String capture) {
|
|
1498
|
mFilePathCallback = filePathCallback;
|
|
1499
|
permissionTask();
|
|
1500
|
}
|
|
1501
|
|
|
1502
|
@Override
|
|
1503
|
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
|
|
1504
|
mFilePathCallbacks = filePathCallback;
|
|
1505
|
permissionTask();
|
|
1506
|
return true;
|
|
1507
|
}
|
|
1508
|
}
|
|
1509
|
|
|
1510
|
@AfterPermissionGranted(RC_ALBUM_PERM)
|
|
1511
|
public void permissionTask() {
|
|
1512
|
if (isPermissionOK()) {
|
|
1513
|
openImageChooserActivity();
|
|
1514
|
} else {
|
|
1515
|
EasyPermissions.requestPermissions(
|
|
1516
|
this, "充电桩想要获取您的图片读取权限,是否允许?",
|
|
1517
|
RC_ALBUM_PERM,
|
|
1518
|
Manifest.permission.CAMERA,
|
|
1519
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
1520
|
Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
1521
|
}
|
|
1522
|
}
|
|
1523
|
|
|
1524
|
private boolean isPermissionOK() {
|
|
1525
|
if (getContext()==null){
|
|
1526
|
return false;
|
|
1527
|
}
|
|
1528
|
|
|
1529
|
return EasyPermissions.hasPermissions(getContext(),
|
|
1530
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
1531
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
1532
|
Manifest.permission.CAMERA
|
|
1533
|
);
|
|
1534
|
}
|
|
1535
|
|
|
1536
|
private void openImageChooserActivity() {
|
|
1537
|
if (getContext()==null){
|
|
1538
|
return;
|
|
1539
|
}
|
|
1540
|
new MaterialDialog.Builder(getContext()).items(R.array.photo).positiveText("取消")
|
|
1541
|
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
|
1542
|
@Override
|
|
1543
|
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
|
1544
|
if (mOpenFileWebChromeClient.mFilePathCallbacks != null) {
|
|
1545
|
mOpenFileWebChromeClient.mFilePathCallbacks.onReceiveValue(null);
|
|
1546
|
mOpenFileWebChromeClient.mFilePathCallbacks = null;
|
|
1547
|
}
|
|
1548
|
|
|
1549
|
if (mOpenFileWebChromeClient.mFilePathCallback != null) {
|
|
1550
|
mOpenFileWebChromeClient.mFilePathCallback.onReceiveValue(null);
|
|
1551
|
mOpenFileWebChromeClient.mFilePathCallback = null;
|
|
1552
|
}
|
|
1553
|
dialog.dismiss();
|
|
1554
|
}
|
|
1555
|
}).cancelable(false)
|
|
1556
|
.canceledOnTouchOutside(false).itemsCallback(new MaterialDialog.ListCallback() {
|
|
1557
|
@Override
|
|
1558
|
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
|
|
1559
|
if (position == 0) {
|
|
1560
|
takeCamera();
|
|
1561
|
} else if (position == 1) {
|
|
1562
|
takePhoto();
|
|
1563
|
}
|
|
1564
|
}
|
|
1565
|
}).show();
|
|
1566
|
}
|
|
1567
|
|
|
1568
|
// 选择图片
|
|
1569
|
private void takePhoto() {
|
|
1570
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
1571
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
1572
|
intent.setType("image/*");
|
|
1573
|
startActivityForResult(Intent.createChooser(intent, "Image Choose"), FILE_CHOOSER_RESULT_CODE);
|
|
1574
|
}
|
|
1575
|
|
|
1576
|
// 拍照
|
|
1577
|
private void takeCamera() {
|
|
1578
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
1579
|
if (ImageUitl.hasSdcard()) {
|
|
1580
|
String fileName = "android" + System.currentTimeMillis() / 1000 + ".jpg";
|
|
1581
|
cameraFilePath = ImageUitl.getPath(PhotoUtils.CACHE_DIR) + "/" + fileName;
|
|
1582
|
File imageFile = ImageUitl.getFile(cameraFilePath);
|
|
1583
|
Uri uri =PhotoUtils.parseUri(imageFile);
|
|
1584
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
|
|
1585
|
try {
|
|
1586
|
startActivityForResult(intent, FILE_CAMERA_RESULT_CODE);
|
|
1587
|
} catch (Exception e) {
|
|
1588
|
e.printStackTrace();
|
|
1589
|
}
|
|
1590
|
|
|
1591
|
}
|
|
1592
|
}
|
|
1593
|
|
|
1594
|
public class MyWebViewClient extends WebViewClient {
|
|
1595
|
@Override
|
|
1596
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
1597
|
super.onPageStarted(view, url, favicon);
|
|
1598
|
Log.e(TAG, "onPageStarted: " + url);
|
|
1599
|
pb_webBar.setVisibility(View.VISIBLE);
|
|
1600
|
}
|
|
1601
|
|
|
1602
|
@Override
|
|
1603
|
public void onPageFinished(WebView view, String url) {
|
|
1604
|
super.onPageFinished(view, url);
|
|
1605
|
Log.e(TAG, "onPageFinished: " + url);
|
|
1606
|
currentUrl = url;
|
|
1607
|
pb_webBar.setVisibility(View.GONE);
|
|
1608
|
|
|
1609
|
}
|
|
1610
|
|
|
1611
|
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
|
1612
|
//handler.cancel(); // Android默认的处理方式
|
|
1613
|
handler.proceed(); // 接受所有网站的证书
|
|
1614
|
//handleMessage(Message msg); // 进行其他处理
|
|
1615
|
}
|
|
1616
|
|
|
1617
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
1618
|
Log.e(TAG, "onPage1 :" + url);
|
|
1619
|
// 重写此方法表明点击网页里面的链接还是在当前的webview里跳转,不跳到浏览器那边
|
|
1620
|
// view.loadUrl(url);
|
|
1621
|
if (url.startsWith("http://cdz.evcharge.cc/zhannew/basic/web/index.php/drive/wxpay?")) {
|
|
1622
|
try {
|
|
1623
|
Intent intent = new Intent();
|
|
1624
|
intent.setAction(Intent.ACTION_VIEW);
|
|
1625
|
intent.setData(Uri.parse(url));
|
|
1626
|
startActivity(intent);
|
|
1627
|
} catch (ActivityNotFoundException e) {
|
|
1628
|
}
|
|
1629
|
} else if (url.startsWith("tel:")) {
|
|
1630
|
Intent intent = new Intent(Intent.ACTION_VIEW,
|
|
1631
|
Uri.parse(url));
|
|
1632
|
startActivity(intent);
|
|
1633
|
return true;
|
|
1634
|
}else if (url.contains("app://com.d1ev.app.ev01")){
|
|
1635
|
try {
|
|
1636
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
1637
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
|
1638
|
startActivity(intent);
|
|
1639
|
mIsDownload = false;
|
|
1640
|
} catch (Exception e) {
|
|
1641
|
//通过直接处理抛出的ActivityNotFound异常来确保程序不会崩溃
|
|
1642
|
e.printStackTrace();
|
|
1643
|
}
|
|
1644
|
return true;
|
|
1645
|
|
|
1646
|
}else {
|
|
1647
|
Log.e(TAG, "shouldOverrideUrlLoading: 1");
|
|
1648
|
view.loadUrl(url);
|
|
1649
|
}
|
|
1650
|
return false;
|
|
1651
|
}
|
|
1652
|
}
|
|
1653
|
|
|
1654
|
@Override
|
|
1655
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
1656
|
super.onActivityResult(requestCode, resultCode, data);
|
|
1657
|
if (null == mOpenFileWebChromeClient.mFilePathCallback && null == mOpenFileWebChromeClient.mFilePathCallbacks)
|
|
1658
|
return;
|
|
1659
|
if (resultCode != RESULT_OK) {
|
|
1660
|
if (mOpenFileWebChromeClient.mFilePathCallbacks != null) {
|
|
1661
|
mOpenFileWebChromeClient.mFilePathCallbacks.onReceiveValue(null);
|
|
1662
|
mOpenFileWebChromeClient.mFilePathCallbacks = null;
|
|
1663
|
}
|
|
1664
|
|
|
1665
|
if (mOpenFileWebChromeClient.mFilePathCallback != null) {
|
|
1666
|
mOpenFileWebChromeClient.mFilePathCallback.onReceiveValue(null);
|
|
1667
|
mOpenFileWebChromeClient.mFilePathCallback = null;
|
|
1668
|
}
|
|
1669
|
return;
|
|
1670
|
}
|
|
1671
|
|
|
1672
|
Uri result = null;
|
|
1673
|
if (requestCode == FILE_CAMERA_RESULT_CODE) {
|
|
1674
|
if (null != data && null != data.getData()) {
|
|
1675
|
result = data.getData();
|
|
1676
|
}
|
|
1677
|
if (result == null && ImageUitl.hasFile(cameraFilePath)) {
|
|
1678
|
result = PhotoUtils.parseUri(new File(cameraFilePath));
|
|
1679
|
}
|
|
1680
|
|
|
1681
|
if (mOpenFileWebChromeClient.mFilePathCallbacks != null) {
|
|
1682
|
mOpenFileWebChromeClient.mFilePathCallbacks.onReceiveValue(new Uri[]{result});
|
|
1683
|
mOpenFileWebChromeClient.mFilePathCallbacks = null;
|
|
1684
|
} else if (mOpenFileWebChromeClient.mFilePathCallback != null) {
|
|
1685
|
mOpenFileWebChromeClient.mFilePathCallback.onReceiveValue(result);
|
|
1686
|
mOpenFileWebChromeClient.mFilePathCallback = null;
|
|
1687
|
}
|
|
1688
|
} else if (requestCode == FILE_CHOOSER_RESULT_CODE) {
|
|
1689
|
if (data != null) {
|
|
1690
|
result = data.getData();
|
|
1691
|
}
|
|
1692
|
if (mOpenFileWebChromeClient.mFilePathCallbacks != null) {
|
|
1693
|
onActivityResultCallbacks(data);
|
|
1694
|
} else if (mOpenFileWebChromeClient.mFilePathCallback != null) {
|
|
1695
|
mOpenFileWebChromeClient.mFilePathCallback.onReceiveValue(result);
|
|
1696
|
mOpenFileWebChromeClient.mFilePathCallback = null;
|
|
1697
|
}
|
|
1698
|
}
|
|
1699
|
}
|
|
1700
|
|
|
1701
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
1702
|
private void onActivityResultCallbacks(Intent intent) {
|
|
1703
|
Uri[] results = null;
|
|
1704
|
if (intent != null) {
|
|
1705
|
String dataString = intent.getDataString();
|
|
1706
|
ClipData clipData = intent.getClipData();
|
|
1707
|
if (clipData != null) {
|
|
1708
|
results = new Uri[clipData.getItemCount()];
|
|
1709
|
for (int i = 0; i < clipData.getItemCount(); i++) {
|
|
1710
|
ClipData.Item item = clipData.getItemAt(i);
|
|
1711
|
results[i] = item.getUri();
|
|
1712
|
}
|
|
1713
|
}
|
|
1714
|
if (dataString != null) {
|
|
1715
|
results = new Uri[]{Uri.parse(dataString)};
|
|
1716
|
}
|
|
1717
|
mOpenFileWebChromeClient.mFilePathCallbacks.onReceiveValue(results);
|
|
1718
|
mOpenFileWebChromeClient.mFilePathCallbacks = null;
|
|
1719
|
}
|
|
1720
|
}
|
|
1721
|
|
|
1722
|
private void getShareIntegral() {
|
|
1723
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId;
|
|
1724
|
OkHttpUtils.get().url(url).build().execute(new StringCallback() {
|
|
1725
|
@Override
|
|
1726
|
public void onError(Call call, Exception e) {
|
|
1727
|
|
|
1728
|
}
|
|
1729
|
|
|
1730
|
@Override
|
|
1731
|
public void onResponse(String response) {
|
|
1732
|
Log.e(TAG, "onResponse: getShareIntegral=" + response);
|
|
1733
|
String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
|
|
1734
|
if ("01".equals(rtnCode)) {
|
|
1735
|
String plusScore = JsonUtils.getKeyResult(response, "plusScore");
|
|
1736
|
if (!plusScore.equals("")) {
|
|
1737
|
tv_point.setText(plusScore);
|
|
1738
|
rl_point.setVisibility(View.VISIBLE);
|
|
1739
|
rl_point.startAnimation(animation);
|
|
1740
|
new Handler().postDelayed(new Runnable() {
|
|
1741
|
public void run() {
|
|
1742
|
rl_point.setVisibility(View.GONE);
|
|
1743
|
}
|
|
1744
|
}, 1500);
|
|
1745
|
}
|
|
1746
|
|
|
1747
|
} else {
|
|
1748
|
ToastUtil.showToast(getContext(), "分享成功", Toast.LENGTH_SHORT);
|
|
1749
|
}
|
|
1750
|
}
|
|
1751
|
});
|
|
1752
|
}
|
|
1753
|
|
|
1754
|
|
|
1755
|
@Override
|
|
1756
|
public void onDestroy() {
|
|
1757
|
super.onDestroy();
|
|
1758
|
list.clear();
|
|
1759
|
mHandler.removeCallbacksAndMessages(null);
|
|
1760
|
}
|
|
1761
|
|
|
1762
|
/**
|
|
1763
|
* 获取车主认证信息
|
|
1764
|
*/
|
|
1765
|
private void getCarOwnerCertificateList() {
|
|
1766
|
long tokenTime = System.currentTimeMillis() / 1000 - MainMapActivity.cha - 1;
|
|
1767
|
String token = null;
|
|
1768
|
try {
|
|
1769
|
token = DES3.encode(String.valueOf(tokenTime));
|
|
1770
|
token = URLEncoder.encode(token, "UTF-8");
|
|
1771
|
} catch (Exception e) {
|
|
1772
|
e.printStackTrace();
|
|
1773
|
}
|
|
1774
|
|
|
1775
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
|
|
1776
|
OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
|
1777
|
@Override
|
|
1778
|
public void onError(Call call, Exception e) {
|
|
1779
|
e.printStackTrace();
|
|
1780
|
mHandler.post(new Runnable() {
|
|
1781
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
1782
|
@Override
|
|
1783
|
public void run() {
|
|
1784
|
loadDialog.dismiss();
|
|
1785
|
}
|
|
1786
|
});
|
|
1787
|
|
|
1788
|
Toast.makeText(getContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
|
|
1789
|
}
|
|
1790
|
|
|
1791
|
@Override
|
|
1792
|
public void onResponse(String response) {
|
|
1793
|
mHandler.post(new Runnable() {
|
|
1794
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
1795
|
@Override
|
|
1796
|
public void run() {
|
|
1797
|
loadDialog.dismiss();
|
|
1798
|
}
|
|
1799
|
});
|
|
1800
|
String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
|
|
1801
|
if ("01".equals(rtnCode)) {
|
|
1802
|
String data = JsonUtils.getKeyResult(response, "data");
|
|
1803
|
List<CarOwnerCertificateBean> list =new ArrayList<>();
|
|
1804
|
try{
|
|
1805
|
list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
|
|
1806
|
}catch (JSONException e){
|
|
1807
|
|
|
1808
|
}
|
|
1809
|
if (list.size() == 0) {
|
|
1810
|
startActivity(new Intent(getContext(), CarOwnerCertificateActivity.class));
|
|
1811
|
} else {
|
|
1812
|
Intent intent = new Intent(getContext(), CarOwnerCertificateListActivity.class);
|
|
1813
|
intent.putExtra("data", data);
|
|
1814
|
startActivity(intent);
|
|
1815
|
}
|
|
1816
|
} else {
|
|
1817
|
String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
|
|
1818
|
Toast.makeText(getContext(), rtnMsg, Toast.LENGTH_SHORT).show();
|
|
1819
|
}
|
|
1820
|
}
|
|
1821
|
});
|
|
1822
|
}
|
|
1823
|
public interface OnKeyDownListener {
|
|
1824
|
boolean onKeyDown(int keyCode, KeyEvent event);
|
|
1825
|
}
|
|
1826
|
}
|