Commit bb44855981db60328cc7605a55ce5ea12842e6f6

Authored by 姚旭斌
2 parents e71dbb40 d8f68cd8

Merge branch 'developer' into yxb_dev

# Conflicts:
#	app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java
app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java
@@ -26,8 +26,9 @@ public class WebViewActivity extends BaseCompatActivity { @@ -26,8 +26,9 @@ public class WebViewActivity extends BaseCompatActivity {
26 26
27 NestedScrollWebView nesteScrollWebView; 27 NestedScrollWebView nesteScrollWebView;
28 LinearLayout binding_success, binding_success2; 28 LinearLayout binding_success, binding_success2;
29 - TextView tv_info,zuoye,title_web;  
30 ImageView close; 29 ImageView close;
  30 + TextView tv_info,zuoye,title_web;
  31 +
31 int type; 32 int type;
32 33
33 private ProgressBar pvWeb; 34 private ProgressBar pvWeb;
@@ -41,13 +42,18 @@ public class WebViewActivity extends BaseCompatActivity { @@ -41,13 +42,18 @@ public class WebViewActivity extends BaseCompatActivity {
41 42
42 @Override 43 @Override
43 protected void initView(Bundle savedInstanceState) { 44 protected void initView(Bundle savedInstanceState) {
  45 +
44 binding_success=findViewById(R.id.binding_success); 46 binding_success=findViewById(R.id.binding_success);
  47 +
  48 + binding_success=findViewById(R.id.binding_success1);
  49 +
45 binding_success2=findViewById(R.id.binding_success2); 50 binding_success2=findViewById(R.id.binding_success2);
46 close = findViewById(R.id.close_btn); 51 close = findViewById(R.id.close_btn);
47 tv_info = findViewById(R.id.tv_info); 52 tv_info = findViewById(R.id.tv_info);
48 zuoye = findViewById(R.id.zuoye); 53 zuoye = findViewById(R.id.zuoye);
49 title_web = findViewById(R.id.title_web); 54 title_web = findViewById(R.id.title_web);
50 55
  56 +
51 close.setOnClickListener(new View.OnClickListener() { 57 close.setOnClickListener(new View.OnClickListener() {
52 @Override 58 @Override
53 public void onClick(View v) { 59 public void onClick(View v) {
@@ -57,6 +63,9 @@ public class WebViewActivity extends BaseCompatActivity { @@ -57,6 +63,9 @@ public class WebViewActivity extends BaseCompatActivity {
57 63
58 64
59 nesteScrollWebView = findViewById(R.id.nesteScrollWebView); 65 nesteScrollWebView = findViewById(R.id.nesteScrollWebView);
  66 +
  67 + nesteScrollWebView = findViewById(R.id.webView);
  68 +
60 pvWeb = findViewById(R.id.pb_web); 69 pvWeb = findViewById(R.id.pb_web);
61 type = getIntent().getIntExtra("type", 0); 70 type = getIntent().getIntExtra("type", 0);
62 if (type == AppConfig.BINDING_SUCCESS_HEZUO) { 71 if (type == AppConfig.BINDING_SUCCESS_HEZUO) {
@@ -74,6 +83,11 @@ public class WebViewActivity extends BaseCompatActivity { @@ -74,6 +83,11 @@ public class WebViewActivity extends BaseCompatActivity {
74 binding_success2.setVisibility(View.GONE); 83 binding_success2.setVisibility(View.GONE);
75 title_web.setVisibility(View.VISIBLE); 84 title_web.setVisibility(View.VISIBLE);
76 85
  86 + }else {
  87 + binding_success.setVisibility(View.GONE);
  88 + binding_success2.setVisibility(View.GONE);
  89 + title_web.setVisibility(View.GONE);
  90 +
77 } 91 }
78 92
79 initWebView(); 93 initWebView();
@@ -83,7 +97,7 @@ public class WebViewActivity extends BaseCompatActivity { @@ -83,7 +97,7 @@ public class WebViewActivity extends BaseCompatActivity {
83 97
84 @Override 98 @Override
85 protected int getLayoutId() { 99 protected int getLayoutId() {
86 - return R.layout.activity_web_view; 100 + return R.layout.activity_webview;
87 } 101 }
88 102
89 @Override 103 @Override
@@ -115,6 +129,20 @@ public class WebViewActivity extends BaseCompatActivity { @@ -115,6 +129,20 @@ public class WebViewActivity extends BaseCompatActivity {
115 }); 129 });
116 } 130 }
117 } 131 }
  132 + // 调起支付宝并跳转到指定页面
  133 + private void startAlipayActivity(String url) {
  134 + Intent intent;
  135 + try {
  136 + intent = Intent.parseUri(url,
  137 + Intent.URI_INTENT_SCHEME);
  138 + intent.addCategory(Intent.CATEGORY_BROWSABLE);
  139 + intent.setComponent(null);
  140 + startActivity(intent);
  141 + finish();
  142 + } catch (Exception e) {
  143 + e.printStackTrace();
  144 + }
  145 + }
118 146
119 protected void initWebView() { 147 protected void initWebView() {
120 // 添加js交互接口类,并起别名 imagelistner 148 // 添加js交互接口类,并起别名 imagelistner
@@ -123,8 +151,18 @@ public class WebViewActivity extends BaseCompatActivity { @@ -123,8 +151,18 @@ public class WebViewActivity extends BaseCompatActivity {
123 nesteScrollWebView.setWebViewClient(new WebViewClient() { 151 nesteScrollWebView.setWebViewClient(new WebViewClient() {
124 @Override 152 @Override
125 public boolean shouldOverrideUrlLoading(WebView view, String url) { 153 public boolean shouldOverrideUrlLoading(WebView view, String url) {
126 - view.loadUrl(url); 154 + if (url.startsWith("http"))view.loadUrl(url);
  155 +// if (url.contains("platformapi/startapp")) {
  156 +// startAlipayActivity(url);
  157 +// android 6.0 两种方式获取intent都可以跳转支付宝成功,7.1测试不成功
  158 +// } else if ((Build.VERSION.SDK_INT > Build.VERSION_CODES.M)
  159 +// && (url.contains("platformapi") && url.contains("startapp"))) {
  160 +// startAlipayActivity(url);
  161 +// } else {
  162 +// view.loadUrl(url);
  163 +// }
127 return true; 164 return true;
  165 +
128 } 166 }
129 167
130 @Override 168 @Override
@@ -218,6 +256,11 @@ public class WebViewActivity extends BaseCompatActivity { @@ -218,6 +256,11 @@ public class WebViewActivity extends BaseCompatActivity {
218 // WebView启用JavaScript执行。默认的是false。 256 // WebView启用JavaScript执行。默认的是false。
219 settings.setJavaScriptEnabled(true); // 设置支持javascript脚本 257 settings.setJavaScriptEnabled(true); // 设置支持javascript脚本
220 settings.setJavaScriptCanOpenWindowsAutomatically(true);//设置支持js脚本 258 settings.setJavaScriptCanOpenWindowsAutomatically(true);//设置支持js脚本
  259 + settings.setAllowFileAccess(true);//设置可以访问文件
  260 +// settings.setBuiltInZoomControls(true);
  261 + settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
  262 + settings.setDomStorageEnabled(true);
  263 + settings.setGeolocationEnabled(true);
221 if (NetworkConnectionUtils.isConnected(mContext)) { 264 if (NetworkConnectionUtils.isConnected(mContext)) {
222 settings.setCacheMode(WebSettings.LOAD_DEFAULT); 265 settings.setCacheMode(WebSettings.LOAD_DEFAULT);
223 } else { 266 } else {
app/src/main/res/layout/activity_webview.xml
@@ -32,8 +32,16 @@ @@ -32,8 +32,16 @@
32 32
33 </RelativeLayout> 33 </RelativeLayout>
34 34
  35 + <ProgressBar
  36 + android:id="@+id/pb_web"
  37 + style="?android:attr/progressBarStyleHorizontal"
  38 + android:layout_width="match_parent"
  39 + android:layout_height="3dp"
  40 + android:progressDrawable="@drawable/web_progress_bar_bg"
  41 + android:visibility="gone"/>
  42 +
35 <LinearLayout 43 <LinearLayout
36 - android:id="@+id/binding_success" 44 + android:id="@+id/binding_success1"
37 android:layout_width="match_parent" 45 android:layout_width="match_parent"
38 android:layout_height="wrap_content" 46 android:layout_height="wrap_content"
39 android:gravity="center" 47 android:gravity="center"
mvpsdk/src/main/java/com/share/mvpsdk/utils/OkHttpExceptionUtil.java
@@ -20,7 +20,7 @@ public class OkHttpExceptionUtil { @@ -20,7 +20,7 @@ public class OkHttpExceptionUtil {
20 if (responseBody==null)return; 20 if (responseBody==null)return;
21 try { 21 try {
22 JSONObject json = new JSONObject(responseBody.string()); 22 JSONObject json = new JSONObject(responseBody.string());
23 - ToastUtils.showToast(json.optString("message")); 23 + ToastUtils.showToast(json.optString("message")+"json="+json);
24 } catch (Exception e1) { 24 } catch (Exception e1) {
25 e1.printStackTrace(); 25 e1.printStackTrace();
26 } 26 }