Commit 69c0bf10c748e27ff93f9ef5f48fe6abd1cd4756
1 parent
2b1c9aa3
Exists in
yxb_dev
and in
2 other branches
no message
Showing
4 changed files
with
84 additions
and
11 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/presenter/ceping/CePingPresenter.java
| @@ -55,7 +55,7 @@ public class CePingPresenter extends CepingContract.CePingPresenter { | @@ -55,7 +55,7 @@ public class CePingPresenter extends CepingContract.CePingPresenter { | ||
| 55 | @Override | 55 | @Override |
| 56 | public void onClick(View view) { | 56 | public void onClick(View view) { |
| 57 | ToolBean toolBean1= (ToolBean) view.getTag(); | 57 | ToolBean toolBean1= (ToolBean) view.getTag(); |
| 58 | - WebViewActivity.getInstance(mIView.getBindActivity(),toolBean1.toolUrl); | 58 | + WebViewActivity.getInstance(mIView.getBindActivity(),toolBean1.toolUrl,-1); |
| 59 | } | 59 | } |
| 60 | }); | 60 | }); |
| 61 | layout_control.addView(textAndImgShowView); | 61 | layout_control.addView(textAndImgShowView); |
app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java
| @@ -3,39 +3,75 @@ package com.shunzhi.parent.ui.activity.mywebview; | @@ -3,39 +3,75 @@ package com.shunzhi.parent.ui.activity.mywebview; | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.graphics.Bitmap; | 5 | import android.graphics.Bitmap; |
| 6 | +import android.os.Build; | ||
| 6 | import android.os.Bundle; | 7 | import android.os.Bundle; |
| 7 | import android.support.v7.app.AppCompatActivity; | 8 | import android.support.v7.app.AppCompatActivity; |
| 9 | +import android.util.Log; | ||
| 8 | import android.view.View; | 10 | import android.view.View; |
| 9 | import android.webkit.JavascriptInterface; | 11 | import android.webkit.JavascriptInterface; |
| 10 | import android.webkit.WebChromeClient; | 12 | import android.webkit.WebChromeClient; |
| 11 | import android.webkit.WebSettings; | 13 | import android.webkit.WebSettings; |
| 12 | import android.webkit.WebView; | 14 | import android.webkit.WebView; |
| 13 | import android.webkit.WebViewClient; | 15 | import android.webkit.WebViewClient; |
| 16 | +import android.widget.LinearLayout; | ||
| 14 | import android.widget.ProgressBar; | 17 | import android.widget.ProgressBar; |
| 18 | +import android.widget.TextView; | ||
| 15 | 19 | ||
| 16 | import com.share.mvpsdk.base.activity.BaseCompatActivity; | 20 | import com.share.mvpsdk.base.activity.BaseCompatActivity; |
| 17 | import com.share.mvpsdk.utils.AppUtils; | 21 | import com.share.mvpsdk.utils.AppUtils; |
| 18 | import com.share.mvpsdk.utils.NetworkConnectionUtils; | 22 | import com.share.mvpsdk.utils.NetworkConnectionUtils; |
| 19 | import com.share.mvpsdk.widgets.NestedScrollWebView; | 23 | import com.share.mvpsdk.widgets.NestedScrollWebView; |
| 24 | +import com.shunzhi.parent.AppConfig; | ||
| 20 | import com.shunzhi.parent.R; | 25 | import com.shunzhi.parent.R; |
| 21 | 26 | ||
| 22 | public class WebViewActivity extends BaseCompatActivity { | 27 | public class WebViewActivity extends BaseCompatActivity { |
| 23 | 28 | ||
| 24 | NestedScrollWebView nesteScrollWebView; | 29 | NestedScrollWebView nesteScrollWebView; |
| 30 | + LinearLayout binding_success, binding_success2; | ||
| 31 | + TextView close,tv_info,zuoye,title_web; | ||
| 32 | + int type; | ||
| 25 | 33 | ||
| 26 | private ProgressBar pvWeb; | 34 | private ProgressBar pvWeb; |
| 27 | 35 | ||
| 28 | - public static void getInstance(Context context,String url,int type) { | 36 | + public static void getInstance(Context context, String url, int type) { |
| 29 | Intent intent = new Intent(context, WebViewActivity.class); | 37 | Intent intent = new Intent(context, WebViewActivity.class); |
| 30 | intent.putExtra("url", url); | 38 | intent.putExtra("url", url); |
| 31 | - intent.putExtra("type",type); | 39 | + intent.putExtra("type", type); |
| 32 | context.startActivity(intent); | 40 | context.startActivity(intent); |
| 33 | } | 41 | } |
| 34 | 42 | ||
| 35 | @Override | 43 | @Override |
| 36 | protected void initView(Bundle savedInstanceState) { | 44 | protected void initView(Bundle savedInstanceState) { |
| 37 | - nesteScrollWebView=findViewById(R.id.nesteScrollWebView); | ||
| 38 | - pvWeb=findViewById(R.id.pb_web); | 45 | + binding_success=findViewById(R.id.binding_success1); |
| 46 | + binding_success2=findViewById(R.id.binding_success2); | ||
| 47 | + close = findViewById(R.id.close_btn); | ||
| 48 | + tv_info = findViewById(R.id.tv_info); | ||
| 49 | + zuoye = findViewById(R.id.zuoye); | ||
| 50 | + title_web = findViewById(R.id.title_web); | ||
| 51 | + | ||
| 52 | + nesteScrollWebView = findViewById(R.id.webView); | ||
| 53 | + pvWeb = findViewById(R.id.pb_web); | ||
| 54 | + type = getIntent().getIntExtra("type", 0); | ||
| 55 | + if (type == AppConfig.BINDING_SUCCESS_HEZUO) { | ||
| 56 | + binding_success.setVisibility(View.VISIBLE); | ||
| 57 | + binding_success2.setVisibility(View.GONE); | ||
| 58 | + title_web.setVisibility(View.GONE); | ||
| 59 | + | ||
| 60 | + } else if (type == AppConfig.BINDING_SUCCESS_NOT) { | ||
| 61 | + binding_success.setVisibility(View.GONE); | ||
| 62 | + binding_success2.setVisibility(View.VISIBLE); | ||
| 63 | + title_web.setVisibility(View.GONE); | ||
| 64 | + | ||
| 65 | + } else if (type == AppConfig.ORDER_CENTER) { | ||
| 66 | + binding_success.setVisibility(View.GONE); | ||
| 67 | + binding_success2.setVisibility(View.GONE); | ||
| 68 | + title_web.setVisibility(View.VISIBLE); | ||
| 69 | + }else { | ||
| 70 | + binding_success.setVisibility(View.GONE); | ||
| 71 | + binding_success2.setVisibility(View.GONE); | ||
| 72 | + title_web.setVisibility(View.GONE); | ||
| 73 | + } | ||
| 74 | + | ||
| 39 | initWebView(); | 75 | initWebView(); |
| 40 | initWebSetting(nesteScrollWebView.getSettings()); | 76 | initWebSetting(nesteScrollWebView.getSettings()); |
| 41 | nesteScrollWebView.loadUrl(getIntent().getStringExtra("url")); | 77 | nesteScrollWebView.loadUrl(getIntent().getStringExtra("url")); |
| @@ -43,14 +79,14 @@ public class WebViewActivity extends BaseCompatActivity { | @@ -43,14 +79,14 @@ public class WebViewActivity extends BaseCompatActivity { | ||
| 43 | 79 | ||
| 44 | @Override | 80 | @Override |
| 45 | protected int getLayoutId() { | 81 | protected int getLayoutId() { |
| 46 | - return R.layout.activity_web_view; | 82 | + return R.layout.activity_webview; |
| 47 | } | 83 | } |
| 48 | 84 | ||
| 49 | @Override | 85 | @Override |
| 50 | public void onBackPressedSupport() { | 86 | public void onBackPressedSupport() { |
| 51 | - if (nesteScrollWebView.canGoBack()){ | 87 | + if (nesteScrollWebView.canGoBack()) { |
| 52 | nesteScrollWebView.goBack(); | 88 | nesteScrollWebView.goBack(); |
| 53 | - }else { | 89 | + } else { |
| 54 | super.onBackPressedSupport(); | 90 | super.onBackPressedSupport(); |
| 55 | } | 91 | } |
| 56 | } | 92 | } |
| @@ -75,6 +111,20 @@ public class WebViewActivity extends BaseCompatActivity { | @@ -75,6 +111,20 @@ public class WebViewActivity extends BaseCompatActivity { | ||
| 75 | }); | 111 | }); |
| 76 | } | 112 | } |
| 77 | } | 113 | } |
| 114 | + // 调起支付宝并跳转到指定页面 | ||
| 115 | + private void startAlipayActivity(String url) { | ||
| 116 | + Intent intent; | ||
| 117 | + try { | ||
| 118 | + intent = Intent.parseUri(url, | ||
| 119 | + Intent.URI_INTENT_SCHEME); | ||
| 120 | + intent.addCategory(Intent.CATEGORY_BROWSABLE); | ||
| 121 | + intent.setComponent(null); | ||
| 122 | + startActivity(intent); | ||
| 123 | + finish(); | ||
| 124 | + } catch (Exception e) { | ||
| 125 | + e.printStackTrace(); | ||
| 126 | + } | ||
| 127 | + } | ||
| 78 | 128 | ||
| 79 | protected void initWebView() { | 129 | protected void initWebView() { |
| 80 | // 添加js交互接口类,并起别名 imagelistner | 130 | // 添加js交互接口类,并起别名 imagelistner |
| @@ -83,8 +133,18 @@ public class WebViewActivity extends BaseCompatActivity { | @@ -83,8 +133,18 @@ public class WebViewActivity extends BaseCompatActivity { | ||
| 83 | nesteScrollWebView.setWebViewClient(new WebViewClient() { | 133 | nesteScrollWebView.setWebViewClient(new WebViewClient() { |
| 84 | @Override | 134 | @Override |
| 85 | public boolean shouldOverrideUrlLoading(WebView view, String url) { | 135 | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
| 86 | - view.loadUrl(url); | 136 | + if (url.startsWith("http"))view.loadUrl(url); |
| 137 | +// if (url.contains("platformapi/startapp")) { | ||
| 138 | +// startAlipayActivity(url); | ||
| 139 | +// android 6.0 两种方式获取intent都可以跳转支付宝成功,7.1测试不成功 | ||
| 140 | +// } else if ((Build.VERSION.SDK_INT > Build.VERSION_CODES.M) | ||
| 141 | +// && (url.contains("platformapi") && url.contains("startapp"))) { | ||
| 142 | +// startAlipayActivity(url); | ||
| 143 | +// } else { | ||
| 144 | +// view.loadUrl(url); | ||
| 145 | +// } | ||
| 87 | return true; | 146 | return true; |
| 147 | + | ||
| 88 | } | 148 | } |
| 89 | 149 | ||
| 90 | @Override | 150 | @Override |
| @@ -178,6 +238,11 @@ public class WebViewActivity extends BaseCompatActivity { | @@ -178,6 +238,11 @@ public class WebViewActivity extends BaseCompatActivity { | ||
| 178 | // WebView启用JavaScript执行。默认的是false。 | 238 | // WebView启用JavaScript执行。默认的是false。 |
| 179 | settings.setJavaScriptEnabled(true); // 设置支持javascript脚本 | 239 | settings.setJavaScriptEnabled(true); // 设置支持javascript脚本 |
| 180 | settings.setJavaScriptCanOpenWindowsAutomatically(true);//设置支持js脚本 | 240 | settings.setJavaScriptCanOpenWindowsAutomatically(true);//设置支持js脚本 |
| 241 | + settings.setAllowFileAccess(true);//设置可以访问文件 | ||
| 242 | +// settings.setBuiltInZoomControls(true); | ||
| 243 | + settings.setCacheMode(WebSettings.LOAD_NO_CACHE); | ||
| 244 | + settings.setDomStorageEnabled(true); | ||
| 245 | + settings.setGeolocationEnabled(true); | ||
| 181 | if (NetworkConnectionUtils.isConnected(mContext)) { | 246 | if (NetworkConnectionUtils.isConnected(mContext)) { |
| 182 | settings.setCacheMode(WebSettings.LOAD_DEFAULT); | 247 | settings.setCacheMode(WebSettings.LOAD_DEFAULT); |
| 183 | } else { | 248 | } 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 | } |