Commit bb44855981db60328cc7605a55ce5ea12842e6f6
Exists in
yxb_dev
and in
2 other branches
Merge branch 'developer' into yxb_dev
# Conflicts: # app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java
Showing
3 changed files
with
56 additions
and
5 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java
... | ... | @@ -26,8 +26,9 @@ public class WebViewActivity extends BaseCompatActivity { |
26 | 26 | |
27 | 27 | NestedScrollWebView nesteScrollWebView; |
28 | 28 | LinearLayout binding_success, binding_success2; |
29 | - TextView tv_info,zuoye,title_web; | |
30 | 29 | ImageView close; |
30 | + TextView tv_info,zuoye,title_web; | |
31 | + | |
31 | 32 | int type; |
32 | 33 | |
33 | 34 | private ProgressBar pvWeb; |
... | ... | @@ -41,13 +42,18 @@ public class WebViewActivity extends BaseCompatActivity { |
41 | 42 | |
42 | 43 | @Override |
43 | 44 | protected void initView(Bundle savedInstanceState) { |
45 | + | |
44 | 46 | binding_success=findViewById(R.id.binding_success); |
47 | + | |
48 | + binding_success=findViewById(R.id.binding_success1); | |
49 | + | |
45 | 50 | binding_success2=findViewById(R.id.binding_success2); |
46 | 51 | close = findViewById(R.id.close_btn); |
47 | 52 | tv_info = findViewById(R.id.tv_info); |
48 | 53 | zuoye = findViewById(R.id.zuoye); |
49 | 54 | title_web = findViewById(R.id.title_web); |
50 | 55 | |
56 | + | |
51 | 57 | close.setOnClickListener(new View.OnClickListener() { |
52 | 58 | @Override |
53 | 59 | public void onClick(View v) { |
... | ... | @@ -57,6 +63,9 @@ public class WebViewActivity extends BaseCompatActivity { |
57 | 63 | |
58 | 64 | |
59 | 65 | nesteScrollWebView = findViewById(R.id.nesteScrollWebView); |
66 | + | |
67 | + nesteScrollWebView = findViewById(R.id.webView); | |
68 | + | |
60 | 69 | pvWeb = findViewById(R.id.pb_web); |
61 | 70 | type = getIntent().getIntExtra("type", 0); |
62 | 71 | if (type == AppConfig.BINDING_SUCCESS_HEZUO) { |
... | ... | @@ -74,6 +83,11 @@ public class WebViewActivity extends BaseCompatActivity { |
74 | 83 | binding_success2.setVisibility(View.GONE); |
75 | 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 | 93 | initWebView(); |
... | ... | @@ -83,7 +97,7 @@ public class WebViewActivity extends BaseCompatActivity { |
83 | 97 | |
84 | 98 | @Override |
85 | 99 | protected int getLayoutId() { |
86 | - return R.layout.activity_web_view; | |
100 | + return R.layout.activity_webview; | |
87 | 101 | } |
88 | 102 | |
89 | 103 | @Override |
... | ... | @@ -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 | 147 | protected void initWebView() { |
120 | 148 | // 添加js交互接口类,并起别名 imagelistner |
... | ... | @@ -123,8 +151,18 @@ public class WebViewActivity extends BaseCompatActivity { |
123 | 151 | nesteScrollWebView.setWebViewClient(new WebViewClient() { |
124 | 152 | @Override |
125 | 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 | 164 | return true; |
165 | + | |
128 | 166 | } |
129 | 167 | |
130 | 168 | @Override |
... | ... | @@ -218,6 +256,11 @@ public class WebViewActivity extends BaseCompatActivity { |
218 | 256 | // WebView启用JavaScript执行。默认的是false。 |
219 | 257 | settings.setJavaScriptEnabled(true); // 设置支持javascript脚本 |
220 | 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 | 264 | if (NetworkConnectionUtils.isConnected(mContext)) { |
222 | 265 | settings.setCacheMode(WebSettings.LOAD_DEFAULT); |
223 | 266 | } else { | ... | ... |
app/src/main/res/layout/activity_webview.xml
... | ... | @@ -32,8 +32,16 @@ |
32 | 32 | |
33 | 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 | 43 | <LinearLayout |
36 | - android:id="@+id/binding_success" | |
44 | + android:id="@+id/binding_success1" | |
37 | 45 | android:layout_width="match_parent" |
38 | 46 | android:layout_height="wrap_content" |
39 | 47 | android:gravity="center" | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/utils/OkHttpExceptionUtil.java
... | ... | @@ -20,7 +20,7 @@ public class OkHttpExceptionUtil { |
20 | 20 | if (responseBody==null)return; |
21 | 21 | try { |
22 | 22 | JSONObject json = new JSONObject(responseBody.string()); |
23 | - ToastUtils.showToast(json.optString("message")); | |
23 | + ToastUtils.showToast(json.optString("message")+"json="+json); | |
24 | 24 | } catch (Exception e1) { |
25 | 25 | e1.printStackTrace(); |
26 | 26 | } | ... | ... |