Commit f7a6aa863dfb90c5cf595e617bf34efa72ae2aa7
Exists in
yxb_dev
and in
2 other branches
no message
Showing
16 changed files
with
357 additions
and
217 deletions
 
Show diff stats
app/src/main/AndroidManifest.xml
| ... | ... | @@ -108,9 +108,12 @@ | 
| 108 | 108 | <activity | 
| 109 | 109 | android:name=".ui.activity.binding.InviteCodeActivity" | 
| 110 | 110 | android:screenOrientation="portrait" /> | 
| 111 | + <activity | |
| 112 | + android:name=".ui.activity.web.WebViewActivity" | |
| 113 | + android:screenOrientation="portrait" /> | |
| 111 | 114 | <activity android:name=".ui.activity.consult.ConsultTwoLevelActivity" /> | 
| 112 | 115 | <activity android:name=".ui.activity.orderdetail.OrderDetailActivity" /> | 
| 113 | - <activity android:name=".ui.activity.WebViewActivity"></activity> | |
| 116 | + <activity android:name=".ui.activity.web.WebViewActivity"></activity> | |
| 114 | 117 | </application> | 
| 115 | 118 | |
| 116 | 119 | </manifest> | 
| 117 | 120 | \ No newline at end of file | ... | ... | 
app/src/main/java/com/shunzhi/parent/AppConfig.java
| ... | ... | @@ -22,6 +22,11 @@ public class AppConfig { | 
| 22 | 22 | public static String USER_SEX = "user_sex"; | 
| 23 | 23 | public static String USER_IMAGE = "user_image"; | 
| 24 | 24 | public static String PARENT_ID = "parent_id"; | 
| 25 | + | |
| 26 | + public static int BINDING_SUCCESS_HEZUO = 1; | |
| 27 | + public static int BINDING_SUCCESS_NOT= 2; | |
| 28 | + public static int ORDER_CENTER = 3; | |
| 29 | + | |
| 25 | 30 | public static String USER_ID="user_id"; | 
| 26 | 31 | public static String APP_IS_START="app_is_start"; | 
| 27 | 32 | |
| ... | ... | @@ -30,6 +35,7 @@ public class AppConfig { | 
| 30 | 35 | public static String BASE_URL_IMG="http://60.190.202.57:1000"; | 
| 31 | 36 | |
| 32 | 37 | |
| 38 | + | |
| 33 | 39 | //默认日志保存的路径 | 
| 34 | 40 | public final static String DEFAULT_SAVE_LOG_PATH = Environment | 
| 35 | 41 | .getExternalStorageDirectory() | ... | ... | 
app/src/main/java/com/shunzhi/parent/bean/ChildBean.java
| ... | ... | @@ -27,6 +27,13 @@ public class ChildBean implements Serializable { | 
| 27 | 27 | private String cityName; | 
| 28 | 28 | private int sex; | 
| 29 | 29 | |
| 30 | + public String getCityName() { | |
| 31 | + return cityName; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setCityName(String cityName) { | |
| 35 | + this.cityName = cityName; | |
| 36 | + } | |
| 30 | 37 | |
| 31 | 38 | public String getAreaName() { | 
| 32 | 39 | return areaName; | 
| ... | ... | @@ -192,6 +199,7 @@ public class ChildBean implements Serializable { | 
| 192 | 199 | ",photo='" + photo + '\'' + | 
| 193 | 200 | ",studentCode='" + studentCode + '\'' + | 
| 194 | 201 | ",areaName='" + areaName + '\'' + | 
| 202 | + ",cityName='" + cityName + '\'' + | |
| 195 | 203 | ", sex=" + sex + | 
| 196 | 204 | "}"; | 
| 197 | 205 | } | ... | ... | 
app/src/main/java/com/shunzhi/parent/presenter/ceping/CePingPresenter.java
| 1 | 1 | package com.shunzhi.parent.presenter.ceping; | 
| 2 | 2 | |
| 3 | -import android.util.Log; | |
| 4 | 3 | import android.view.View; | 
| 5 | 4 | import android.widget.LinearLayout; | 
| 6 | 5 | |
| ... | ... | @@ -11,13 +10,10 @@ import com.shunzhi.parent.R; | 
| 11 | 10 | import com.shunzhi.parent.bean.ToolBean; | 
| 12 | 11 | import com.shunzhi.parent.contract.ceping.CepingContract; | 
| 13 | 12 | import com.shunzhi.parent.model.CePingModel; | 
| 14 | -import com.shunzhi.parent.ui.activity.WebViewActivity; | |
| 13 | +import com.shunzhi.parent.ui.activity.web.WebViewActivity; | |
| 15 | 14 | import com.shunzhi.parent.util.AttrsUtils; | 
| 16 | 15 | import com.shunzhi.parent.views.TextAndImgShowView; | 
| 17 | 16 | |
| 18 | -import java.util.ArrayList; | |
| 19 | -import java.util.List; | |
| 20 | - | |
| 21 | 17 | import io.reactivex.functions.Consumer; | 
| 22 | 18 | |
| 23 | 19 | /** | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/activity/ChildDetialActivity.java
| ... | ... | @@ -44,7 +44,7 @@ public class ChildDetialActivity extends BaseCompatActivity { | 
| 44 | 44 | child_name.setText(childBean.getStudentName()); | 
| 45 | 45 | child_school.setText(childBean.getSchoolName()); | 
| 46 | 46 | child_class.setText(childBean.getClassName()); | 
| 47 | - school_area.setText(childBean.getAreaName()); | |
| 47 | + school_area.setText(childBean.getCityName()+childBean.getAreaName()); | |
| 48 | 48 | student_code.setText(childBean.getStudentCode()); | 
| 49 | 49 | |
| 50 | 50 | } | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/activity/MyChildActivity.java
| ... | ... | @@ -94,8 +94,9 @@ public class MyChildActivity extends BaseMVPCompatActivity<MyChildContract.MyChi | 
| 94 | 94 | @Override | 
| 95 | 95 | public void onClick(View v) { | 
| 96 | 96 | popupWindow.dismiss(); | 
| 97 | + backgroundAlpha(1f); | |
| 97 | 98 | mPresenter.unBinndingResult(Integer.parseInt(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.PARENT_ID)) | 
| 98 | - , currlist.get(menuBridge.getPosition()).getStudentId()); | |
| 99 | + , currlist.get(menuBridge.getAdapterPosition()).getStudentId()); | |
| 99 | 100 | } | 
| 100 | 101 | }); | 
| 101 | 102 | popupWindow.setContentView(view); | 
| ... | ... | @@ -123,6 +124,7 @@ public class MyChildActivity extends BaseMVPCompatActivity<MyChildContract.MyChi | 
| 123 | 124 | |
| 124 | 125 | @Override | 
| 125 | 126 | public void updateChildList(CurrentBean currentBean) { | 
| 127 | + currlist.clear(); | |
| 126 | 128 | List<ChildBean> list = currentBean.getStudentClass(); | 
| 127 | 129 | currlist.addAll(list); | 
| 128 | 130 | if (childAdapter == null) { | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/activity/WebViewActivity.java
| ... | ... | @@ -1,200 +0,0 @@ | 
| 1 | -package com.shunzhi.parent.ui.activity; | |
| 2 | - | |
| 3 | -import android.content.Context; | |
| 4 | -import android.content.Intent; | |
| 5 | -import android.graphics.Bitmap; | |
| 6 | -import android.os.Bundle; | |
| 7 | -import android.view.View; | |
| 8 | -import android.webkit.JavascriptInterface; | |
| 9 | -import android.webkit.WebChromeClient; | |
| 10 | -import android.webkit.WebSettings; | |
| 11 | -import android.webkit.WebView; | |
| 12 | -import android.webkit.WebViewClient; | |
| 13 | -import android.widget.ProgressBar; | |
| 14 | - | |
| 15 | -import com.share.mvpsdk.base.activity.BaseCompatActivity; | |
| 16 | -import com.share.mvpsdk.utils.AppUtils; | |
| 17 | -import com.share.mvpsdk.utils.NetworkConnectionUtils; | |
| 18 | -import com.share.mvpsdk.widgets.NestedScrollWebView; | |
| 19 | -import com.shunzhi.parent.R; | |
| 20 | - | |
| 21 | -public class WebViewActivity extends BaseCompatActivity { | |
| 22 | - | |
| 23 | - NestedScrollWebView nesteScrollWebView; | |
| 24 | - | |
| 25 | - private ProgressBar pvWeb; | |
| 26 | - | |
| 27 | - public static void getInstance(Context context,String url){ | |
| 28 | - Intent intent=new Intent(context,WebViewActivity.class); | |
| 29 | - intent.putExtra("url",url); | |
| 30 | - context.startActivity(intent); | |
| 31 | - } | |
| 32 | - | |
| 33 | - @Override | |
| 34 | - protected void initView(Bundle savedInstanceState) { | |
| 35 | - nesteScrollWebView=findViewById(R.id.nesteScrollWebView); | |
| 36 | - pvWeb=findViewById(R.id.pb_web); | |
| 37 | - initWebView(); | |
| 38 | - initWebSetting(nesteScrollWebView.getSettings()); | |
| 39 | - nesteScrollWebView.loadUrl(getIntent().getStringExtra("url")); | |
| 40 | - } | |
| 41 | - | |
| 42 | - @Override | |
| 43 | - protected int getLayoutId() { | |
| 44 | - return R.layout.activity_web_view; | |
| 45 | - } | |
| 46 | - | |
| 47 | - @Override | |
| 48 | - public void onBackPressedSupport() { | |
| 49 | - if (nesteScrollWebView.canGoBack()){ | |
| 50 | - nesteScrollWebView.goBack(); | |
| 51 | - }else { | |
| 52 | - super.onBackPressedSupport(); | |
| 53 | - } | |
| 54 | - } | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * js接口 | |
| 58 | - */ | |
| 59 | - public class SupportJavascriptInterface { | |
| 60 | - private Context context; | |
| 61 | - | |
| 62 | - public SupportJavascriptInterface(Context context) { | |
| 63 | - this.context = context; | |
| 64 | - } | |
| 65 | - | |
| 66 | - @JavascriptInterface | |
| 67 | - public void openImage(final String img) { | |
| 68 | - AppUtils.runOnUIThread(new Runnable() { | |
| 69 | - @Override | |
| 70 | - public void run() { | |
| 71 | -// gotoImageBrowse(img); | |
| 72 | - } | |
| 73 | - }); | |
| 74 | - } | |
| 75 | - } | |
| 76 | - | |
| 77 | - protected void initWebView() { | |
| 78 | - // 添加js交互接口类,并起别名 imagelistner | |
| 79 | - nesteScrollWebView.addJavascriptInterface(new SupportJavascriptInterface(this), | |
| 80 | - "imagelistner"); | |
| 81 | - nesteScrollWebView.setWebViewClient(new WebViewClient() { | |
| 82 | - @Override | |
| 83 | - public boolean shouldOverrideUrlLoading(WebView view, String url) { | |
| 84 | - view.loadUrl(url); | |
| 85 | - return true; | |
| 86 | - } | |
| 87 | - | |
| 88 | - @Override | |
| 89 | - public void onPageFinished(WebView view, String url) { | |
| 90 | - view.getSettings().setJavaScriptEnabled(true); | |
| 91 | - super.onPageFinished(view, url); | |
| 92 | - // html加载完成之后,添加监听图片的点击js函数 | |
| 93 | - addWebImageClickListner(view); | |
| 94 | -// toolbar.setTitle(getToolbarTitle()); | |
| 95 | - } | |
| 96 | - | |
| 97 | - @Override | |
| 98 | - public void onPageStarted(WebView view, String url, Bitmap favicon) { | |
| 99 | - view.getSettings().setJavaScriptEnabled(true); | |
| 100 | - super.onPageStarted(view, url, favicon); | |
| 101 | - } | |
| 102 | - | |
| 103 | - // 注入js函数监听 | |
| 104 | - protected void addWebImageClickListner(WebView webView) { | |
| 105 | - // 这段js函数的功能就是,遍历所有的img节点,并添加onclick函数, | |
| 106 | - // 函数的功能是在图片点击的时候调用本地java接口并传递url过去 | |
| 107 | - webView.loadUrl("javascript:(function(){" + | |
| 108 | - "var objs = document.getElementsByTagName(\"img\"); " + | |
| 109 | - "for(var i=0;i<objs.length;i++) " + | |
| 110 | - "{" | |
| 111 | - + " objs[i].onclick=function() " + | |
| 112 | - " { " | |
| 113 | - + " window.imagelistner.openImage(this.src); " + | |
| 114 | - " } " + | |
| 115 | - "}" + | |
| 116 | - "})()"); | |
| 117 | - } | |
| 118 | - }); | |
| 119 | - | |
| 120 | - nesteScrollWebView.setWebChromeClient(new WebChromeClient() { | |
| 121 | - @Override | |
| 122 | - public void onProgressChanged(WebView view, int newProgress) { | |
| 123 | - if (newProgress == 100) { | |
| 124 | - pvWeb.setVisibility(View.GONE);//加载完网页进度条消失 | |
| 125 | - } else { | |
| 126 | - pvWeb.setVisibility(View.VISIBLE);//开始加载网页时显示进度条 | |
| 127 | - pvWeb.setProgress(newProgress);//设置进度值 | |
| 128 | - } | |
| 129 | - } | |
| 130 | - }); | |
| 131 | - | |
| 132 | - nesteScrollWebView.setOnLongClickListener(new View.OnLongClickListener() { | |
| 133 | - @Override | |
| 134 | - public boolean onLongClick(View v) { | |
| 135 | - WebView.HitTestResult result = ((WebView) v).getHitTestResult(); | |
| 136 | - if (null == result) | |
| 137 | - return false; | |
| 138 | - | |
| 139 | -// mPresenter.imageLongClicked(result); | |
| 140 | -// mImgurl = result.getExtra(); | |
| 141 | - | |
| 142 | - return true; | |
| 143 | - } | |
| 144 | - }); | |
| 145 | - | |
| 146 | -// nswvDetailContent.setOnTouchListener(WebViewOnTouchListener); | |
| 147 | - } | |
| 148 | - | |
| 149 | - | |
| 150 | - /** | |
| 151 | - * 初始化WebSetting | |
| 152 | - * | |
| 153 | - * @param settings WebSetting | |
| 154 | - */ | |
| 155 | - protected void initWebSetting(WebSettings settings) { | |
| 156 | - // 缩放至屏幕的大小 | |
| 157 | - settings.setLoadWithOverviewMode(true); | |
| 158 | - // 保存表单数据 | |
| 159 | - settings.setSaveFormData(true); | |
| 160 | - // 是否应该支持使用其屏幕缩放控件和手势缩放 | |
| 161 | - settings.setSupportZoom(true); | |
| 162 | - // //是否支持手势缩放控制 | |
| 163 | - // settings.setBuiltInZoomControls(true); | |
| 164 | - // 是否隐藏原生的缩放控件 | |
| 165 | - // settings.setDisplayZoomControls(false); | |
| 166 | - // 启动应用缓存 | |
| 167 | - settings.setAppCacheEnabled(true); | |
| 168 | - // 排版适应屏幕,只显示一列 | |
| 169 | - settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); | |
| 170 | - // settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); | |
| 171 | - // 页面加载好以后,再放开图片 | |
| 172 | - settings.setBlockNetworkImage(false); | |
| 173 | - // 使用localStorage则必须打开 | |
| 174 | - settings.setDomStorageEnabled(true); | |
| 175 | - settings.setDatabaseEnabled(true); | |
| 176 | - // WebView启用JavaScript执行。默认的是false。 | |
| 177 | - settings.setJavaScriptEnabled(true); // 设置支持javascript脚本 | |
| 178 | - settings.setJavaScriptCanOpenWindowsAutomatically(true);//设置支持js脚本 | |
| 179 | - if (NetworkConnectionUtils.isConnected(mContext)) { | |
| 180 | - settings.setCacheMode(WebSettings.LOAD_DEFAULT); | |
| 181 | - } else { | |
| 182 | - settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY); | |
| 183 | - } | |
| 184 | - | |
| 185 | - // settings.setBlockNetworkImage(false); | |
| 186 | - // settings.setAppCacheEnabled(true); | |
| 187 | - // settings.setDomStorageEnabled(true); | |
| 188 | - // settings.setDatabaseEnabled(true); | |
| 189 | - // if (NetworkConnectionUtils.isConnected(mContext)) { | |
| 190 | - // settings.setCacheMode(WebSettings.LOAD_DEFAULT); | |
| 191 | - // } else { | |
| 192 | - // settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY); | |
| 193 | - // } | |
| 194 | - // settings.setJavaScriptEnabled(true); | |
| 195 | - // settings.setLoadWithOverviewMode(true); | |
| 196 | - // settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); | |
| 197 | - // settings.setSupportZoom(true); | |
| 198 | - } | |
| 199 | - | |
| 200 | -} | 
app/src/main/java/com/shunzhi/parent/ui/activity/binding/CheckInfoActivity.java
| ... | ... | @@ -25,6 +25,7 @@ import com.shunzhi.parent.bean.CurrentBean; | 
| 25 | 25 | import com.shunzhi.parent.contract.mine.MyChildContract; | 
| 26 | 26 | import com.shunzhi.parent.presenter.mine.MyChildPresenter; | 
| 27 | 27 | import com.shunzhi.parent.ui.activity.MyChildActivity; | 
| 28 | +import com.shunzhi.parent.ui.activity.web.WebViewActivity; | |
| 28 | 29 | |
| 29 | 30 | import java.util.List; | 
| 30 | 31 | |
| ... | ... | @@ -81,7 +82,7 @@ public class CheckInfoActivity extends BaseMVPCompatActivity<MyChildContract.MyC | 
| 81 | 82 | if (!TextUtils.isEmpty(child_name.getText()) && !TextUtils.isEmpty(child_sex.getText()) | 
| 82 | 83 | && !TextUtils.isEmpty(child_grade.getText()) && !TextUtils.isEmpty(child_class.getText())) { | 
| 83 | 84 | if (isNew == 0) { | 
| 84 | - mPresenter.addChild(0, true, true, 0, 0, 0, childBean.getStudentUserId()); | |
| 85 | + mPresenter.addChild(Integer.parseInt(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.PARENT_ID)), true, true, 0, 0, studentId,""); | |
| 85 | 86 | } else { | 
| 86 | 87 | mPresenter.addChild(Integer.parseInt(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.PARENT_ID)), false, true, 0, classId, studentId, ""); | 
| 87 | 88 | } | 
| ... | ... | @@ -98,7 +99,7 @@ public class CheckInfoActivity extends BaseMVPCompatActivity<MyChildContract.MyC | 
| 98 | 99 | right_btn.setOnClickListener(new View.OnClickListener() { | 
| 99 | 100 | @Override | 
| 100 | 101 | public void onClick(View v) { | 
| 101 | - startActivity(new Intent().setClass(CheckInfoActivity.this, MyChildActivity.class)); | |
| 102 | + startActivity(new Intent().setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).setClass(CheckInfoActivity.this, MyChildActivity.class)); | |
| 102 | 103 | finish(); | 
| 103 | 104 | } | 
| 104 | 105 | }); | 
| ... | ... | @@ -149,7 +150,7 @@ public class CheckInfoActivity extends BaseMVPCompatActivity<MyChildContract.MyC | 
| 149 | 150 | |
| 150 | 151 | @Override | 
| 151 | 152 | public void addChildSuccess() { | 
| 152 | - startActivity(new Intent().setClass(CheckInfoActivity.this, MyChildActivity.class)); | |
| 153 | + WebViewActivity.start_show(CheckInfoActivity.this,AppConfig.BINDING_SUCCESS_HEZUO); | |
| 153 | 154 | finish(); | 
| 154 | 155 | } | 
| 155 | 156 | |
| ... | ... | @@ -173,7 +174,7 @@ public class CheckInfoActivity extends BaseMVPCompatActivity<MyChildContract.MyC | 
| 173 | 174 | right_btn.setOnClickListener(new View.OnClickListener() { | 
| 174 | 175 | @Override | 
| 175 | 176 | public void onClick(View v) { | 
| 176 | - startActivity(new Intent().setClass(CheckInfoActivity.this, MyChildActivity.class)); | |
| 177 | + startActivity(new Intent().setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).setClass(CheckInfoActivity.this, MyChildActivity.class)); | |
| 177 | 178 | finish(); | 
| 178 | 179 | } | 
| 179 | 180 | }); | 
| ... | ... | @@ -183,7 +184,7 @@ public class CheckInfoActivity extends BaseMVPCompatActivity<MyChildContract.MyC | 
| 183 | 184 | @Override | 
| 184 | 185 | public void onClick(View v) { | 
| 185 | 186 | popupWindow.dismiss(); | 
| 186 | - startActivity(new Intent().putExtra("school_id", school_id).setClass(CheckInfoActivity.this, InviteCodeActivity.class)); | |
| 187 | + startActivity(new Intent().putExtra("school_id", school_id).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).setClass(CheckInfoActivity.this, InviteCodeActivity.class)); | |
| 187 | 188 | finish(); | 
| 188 | 189 | } | 
| 189 | 190 | }); | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/activity/binding/InviteCodeActivity.java
| ... | ... | @@ -3,12 +3,14 @@ package com.shunzhi.parent.ui.activity.binding; | 
| 3 | 3 | import android.content.Intent; | 
| 4 | 4 | import android.os.Bundle; | 
| 5 | 5 | import android.support.annotation.NonNull; | 
| 6 | +import android.text.TextUtils; | |
| 6 | 7 | import android.view.View; | 
| 7 | 8 | import android.widget.EditText; | 
| 8 | 9 | import android.widget.TextView; | 
| 9 | 10 | |
| 10 | 11 | import com.share.mvpsdk.base.BasePresenter; | 
| 11 | 12 | import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; | 
| 13 | +import com.share.mvpsdk.utils.ToastUtils; | |
| 12 | 14 | import com.shunzhi.parent.R; | 
| 13 | 15 | import com.shunzhi.parent.presenter.mine.MyChildPresenter; | 
| 14 | 16 | |
| ... | ... | @@ -44,8 +46,11 @@ public class InviteCodeActivity extends BaseMVPCompatActivity { | 
| 44 | 46 | add_child.setOnClickListener(new View.OnClickListener() { | 
| 45 | 47 | @Override | 
| 46 | 48 | public void onClick(View v) { | 
| 47 | - startActivity(new Intent().putExtra("school_id",school_id).putExtra("captcha", et_invite_code.getText().toString().trim()).setClass(InviteCodeActivity.this, CheckInfoActivity.class)); | |
| 48 | - } | |
| 49 | + if(!TextUtils.isEmpty(et_invite_code.getText())) | |
| 50 | + startActivity(new Intent().putExtra("school_id", school_id).putExtra("captcha", et_invite_code.getText().toString().trim()).setClass(InviteCodeActivity.this, CheckInfoActivity.class)); | |
| 51 | + else | |
| 52 | + ToastUtils.showToast("请填写邀请码"); | |
| 53 | + } | |
| 49 | 54 | }); | 
| 50 | 55 | |
| 51 | 56 | } | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/activity/binding/SelectSchoolActivity.java
| ... | ... | @@ -94,7 +94,7 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity<SchoolListContra | 
| 94 | 94 | } | 
| 95 | 95 | |
| 96 | 96 | private void setSchoolList() { | 
| 97 | - mPresenter.schoolListResult("杭州", ""); | |
| 97 | + mPresenter.schoolListResult(AppContext.getInstance().cityName, ""); | |
| 98 | 98 | } | 
| 99 | 99 | |
| 100 | 100 | @Override | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/activity/web/WebViewActivity.java
0 → 100644
| ... | ... | @@ -0,0 +1,200 @@ | 
| 1 | +package com.shunzhi.parent.ui.activity.web; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.graphics.Bitmap; | |
| 6 | +import android.os.Bundle; | |
| 7 | +import android.view.View; | |
| 8 | +import android.webkit.JavascriptInterface; | |
| 9 | +import android.webkit.WebChromeClient; | |
| 10 | +import android.webkit.WebSettings; | |
| 11 | +import android.webkit.WebView; | |
| 12 | +import android.webkit.WebViewClient; | |
| 13 | +import android.widget.ProgressBar; | |
| 14 | + | |
| 15 | +import com.share.mvpsdk.base.activity.BaseCompatActivity; | |
| 16 | +import com.share.mvpsdk.utils.AppUtils; | |
| 17 | +import com.share.mvpsdk.utils.NetworkConnectionUtils; | |
| 18 | +import com.share.mvpsdk.widgets.NestedScrollWebView; | |
| 19 | +import com.shunzhi.parent.R; | |
| 20 | + | |
| 21 | +public class WebViewActivity extends BaseCompatActivity { | |
| 22 | + | |
| 23 | + NestedScrollWebView nesteScrollWebView; | |
| 24 | + | |
| 25 | + private ProgressBar pvWeb; | |
| 26 | + | |
| 27 | + public static void getInstance(Context context,String url) { | |
| 28 | + Intent intent = new Intent(context, WebViewActivity.class); | |
| 29 | + intent.putExtra("url", url); | |
| 30 | + context.startActivity(intent); | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + protected void initView(Bundle savedInstanceState) { | |
| 35 | + nesteScrollWebView=findViewById(R.id.nesteScrollWebView); | |
| 36 | + pvWeb=findViewById(R.id.pb_web); | |
| 37 | + initWebView(); | |
| 38 | + initWebSetting(nesteScrollWebView.getSettings()); | |
| 39 | + nesteScrollWebView.loadUrl(getIntent().getStringExtra("url")); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + protected int getLayoutId() { | |
| 44 | + return R.layout.activity_web_view; | |
| 45 | + } | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + public void onBackPressedSupport() { | |
| 49 | + if (nesteScrollWebView.canGoBack()){ | |
| 50 | + nesteScrollWebView.goBack(); | |
| 51 | + }else { | |
| 52 | + super.onBackPressedSupport(); | |
| 53 | + } | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * js接口 | |
| 58 | + */ | |
| 59 | + public class SupportJavascriptInterface { | |
| 60 | + private Context context; | |
| 61 | + | |
| 62 | + public SupportJavascriptInterface(Context context) { | |
| 63 | + this.context = context; | |
| 64 | + } | |
| 65 | + | |
| 66 | + @JavascriptInterface | |
| 67 | + public void openImage(final String img) { | |
| 68 | + AppUtils.runOnUIThread(new Runnable() { | |
| 69 | + @Override | |
| 70 | + public void run() { | |
| 71 | +// gotoImageBrowse(img); | |
| 72 | + } | |
| 73 | + }); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 77 | + protected void initWebView() { | |
| 78 | + // 添加js交互接口类,并起别名 imagelistner | |
| 79 | + nesteScrollWebView.addJavascriptInterface(new SupportJavascriptInterface(this), | |
| 80 | + "imagelistner"); | |
| 81 | + nesteScrollWebView.setWebViewClient(new WebViewClient() { | |
| 82 | + @Override | |
| 83 | + public boolean shouldOverrideUrlLoading(WebView view, String url) { | |
| 84 | + view.loadUrl(url); | |
| 85 | + return true; | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public void onPageFinished(WebView view, String url) { | |
| 90 | + view.getSettings().setJavaScriptEnabled(true); | |
| 91 | + super.onPageFinished(view, url); | |
| 92 | + // html加载完成之后,添加监听图片的点击js函数 | |
| 93 | + addWebImageClickListner(view); | |
| 94 | +// toolbar.setTitle(getToolbarTitle()); | |
| 95 | + } | |
| 96 | + | |
| 97 | + @Override | |
| 98 | + public void onPageStarted(WebView view, String url, Bitmap favicon) { | |
| 99 | + view.getSettings().setJavaScriptEnabled(true); | |
| 100 | + super.onPageStarted(view, url, favicon); | |
| 101 | + } | |
| 102 | + | |
| 103 | + // 注入js函数监听 | |
| 104 | + protected void addWebImageClickListner(WebView webView) { | |
| 105 | + // 这段js函数的功能就是,遍历所有的img节点,并添加onclick函数, | |
| 106 | + // 函数的功能是在图片点击的时候调用本地java接口并传递url过去 | |
| 107 | + webView.loadUrl("javascript:(function(){" + | |
| 108 | + "var objs = document.getElementsByTagName(\"img\"); " + | |
| 109 | + "for(var i=0;i<objs.length;i++) " + | |
| 110 | + "{" | |
| 111 | + + " objs[i].onclick=function() " + | |
| 112 | + " { " | |
| 113 | + + " window.imagelistner.openImage(this.src); " + | |
| 114 | + " } " + | |
| 115 | + "}" + | |
| 116 | + "})()"); | |
| 117 | + } | |
| 118 | + }); | |
| 119 | + | |
| 120 | + nesteScrollWebView.setWebChromeClient(new WebChromeClient() { | |
| 121 | + @Override | |
| 122 | + public void onProgressChanged(WebView view, int newProgress) { | |
| 123 | + if (newProgress == 100) { | |
| 124 | + pvWeb.setVisibility(View.GONE);//加载完网页进度条消失 | |
| 125 | + } else { | |
| 126 | + pvWeb.setVisibility(View.VISIBLE);//开始加载网页时显示进度条 | |
| 127 | + pvWeb.setProgress(newProgress);//设置进度值 | |
| 128 | + } | |
| 129 | + } | |
| 130 | + }); | |
| 131 | + | |
| 132 | + nesteScrollWebView.setOnLongClickListener(new View.OnLongClickListener() { | |
| 133 | + @Override | |
| 134 | + public boolean onLongClick(View v) { | |
| 135 | + WebView.HitTestResult result = ((WebView) v).getHitTestResult(); | |
| 136 | + if (null == result) | |
| 137 | + return false; | |
| 138 | + | |
| 139 | +// mPresenter.imageLongClicked(result); | |
| 140 | +// mImgurl = result.getExtra(); | |
| 141 | + | |
| 142 | + return true; | |
| 143 | + } | |
| 144 | + }); | |
| 145 | + | |
| 146 | +// nswvDetailContent.setOnTouchListener(WebViewOnTouchListener); | |
| 147 | + } | |
| 148 | + | |
| 149 | + | |
| 150 | + /** | |
| 151 | + * 初始化WebSetting | |
| 152 | + * | |
| 153 | + * @param settings WebSetting | |
| 154 | + */ | |
| 155 | + protected void initWebSetting(WebSettings settings) { | |
| 156 | + // 缩放至屏幕的大小 | |
| 157 | + settings.setLoadWithOverviewMode(true); | |
| 158 | + // 保存表单数据 | |
| 159 | + settings.setSaveFormData(true); | |
| 160 | + // 是否应该支持使用其屏幕缩放控件和手势缩放 | |
| 161 | + settings.setSupportZoom(true); | |
| 162 | + // //是否支持手势缩放控制 | |
| 163 | + // settings.setBuiltInZoomControls(true); | |
| 164 | + // 是否隐藏原生的缩放控件 | |
| 165 | + // settings.setDisplayZoomControls(false); | |
| 166 | + // 启动应用缓存 | |
| 167 | + settings.setAppCacheEnabled(true); | |
| 168 | + // 排版适应屏幕,只显示一列 | |
| 169 | + settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); | |
| 170 | + // settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); | |
| 171 | + // 页面加载好以后,再放开图片 | |
| 172 | + settings.setBlockNetworkImage(false); | |
| 173 | + // 使用localStorage则必须打开 | |
| 174 | + settings.setDomStorageEnabled(true); | |
| 175 | + settings.setDatabaseEnabled(true); | |
| 176 | + // WebView启用JavaScript执行。默认的是false。 | |
| 177 | + settings.setJavaScriptEnabled(true); // 设置支持javascript脚本 | |
| 178 | + settings.setJavaScriptCanOpenWindowsAutomatically(true);//设置支持js脚本 | |
| 179 | + if (NetworkConnectionUtils.isConnected(mContext)) { | |
| 180 | + settings.setCacheMode(WebSettings.LOAD_DEFAULT); | |
| 181 | + } else { | |
| 182 | + settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY); | |
| 183 | + } | |
| 184 | + | |
| 185 | + // settings.setBlockNetworkImage(false); | |
| 186 | + // settings.setAppCacheEnabled(true); | |
| 187 | + // settings.setDomStorageEnabled(true); | |
| 188 | + // settings.setDatabaseEnabled(true); | |
| 189 | + // if (NetworkConnectionUtils.isConnected(mContext)) { | |
| 190 | + // settings.setCacheMode(WebSettings.LOAD_DEFAULT); | |
| 191 | + // } else { | |
| 192 | + // settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY); | |
| 193 | + // } | |
| 194 | + // settings.setJavaScriptEnabled(true); | |
| 195 | + // settings.setLoadWithOverviewMode(true); | |
| 196 | + // settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); | |
| 197 | + // settings.setSupportZoom(true); | |
| 198 | + } | |
| 199 | + | |
| 200 | +} | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
| ... | ... | @@ -106,6 +106,7 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | 
| 106 | 106 | et_password_new = view.findViewById(R.id.et_password_new); | 
| 107 | 107 | et_password_new.addTextChangedListener(textWatcher); | 
| 108 | 108 | |
| 109 | + | |
| 109 | 110 | if ("登录".equals(typepage)) { | 
| 110 | 111 | idCodeLayout.setVisibility(View.GONE); | 
| 111 | 112 | passwordLayout_new.setVisibility(View.GONE); | ... | ... | 
655 Bytes
5.98 KB
app/src/main/res/layout/activity_web_view.xml
| ... | ... | @@ -6,7 +6,7 @@ | 
| 6 | 6 | android:layout_height="match_parent" | 
| 7 | 7 | android:orientation="vertical" | 
| 8 | 8 | android:background="@color/bgColor" | 
| 9 | - tools:context="com.shunzhi.parent.ui.activity.WebViewActivity"> | |
| 9 | + tools:context="com.shunzhi.parent.ui.activity.web.WebViewActivity"> | |
| 10 | 10 | <ProgressBar | 
| 11 | 11 | android:id="@+id/pb_web" | 
| 12 | 12 | style="?android:attr/progressBarStyleHorizontal" | ... | ... | 
| ... | ... | @@ -0,0 +1,118 @@ | 
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:layout_width="match_parent" | |
| 4 | + android:layout_height="match_parent" | |
| 5 | + android:orientation="vertical" | |
| 6 | + android:background="@color/bgColor"> | |
| 7 | + <RelativeLayout | |
| 8 | + android:layout_width="match_parent" | |
| 9 | + android:background="@color/back_top" | |
| 10 | + android:layout_height="?android:actionBarSize" | |
| 11 | + android:orientation="horizontal" | |
| 12 | + > | |
| 13 | + <TextView | |
| 14 | + android:id="@+id/close_btn" | |
| 15 | + android:layout_width="30dp" | |
| 16 | + android:layout_height="30dp" | |
| 17 | + android:layout_marginLeft="10dp" | |
| 18 | + android:layout_centerVertical="true" | |
| 19 | + android:background="@drawable/close" | |
| 20 | + /> | |
| 21 | + <TextView | |
| 22 | + android:id="@+id/title_web" | |
| 23 | + android:layout_width="wrap_content" | |
| 24 | + android:layout_height="wrap_content" | |
| 25 | + android:text="订购中心" | |
| 26 | + android:textSize="@dimen/txtsize_title" | |
| 27 | + android:layout_centerInParent="true" | |
| 28 | + android:visibility="gone" | |
| 29 | + android:textColor="@color/textColor" | |
| 30 | + | |
| 31 | + /> | |
| 32 | + | |
| 33 | + </RelativeLayout> | |
| 34 | + | |
| 35 | + <LinearLayout | |
| 36 | + android:id="@+id/binding_success" | |
| 37 | + android:layout_width="match_parent" | |
| 38 | + android:layout_height="wrap_content" | |
| 39 | + android:gravity="center" | |
| 40 | + android:background="@color/white" | |
| 41 | + android:layout_marginLeft="20dp" | |
| 42 | + android:padding="30dp" | |
| 43 | + android:layout_marginRight="20dp" | |
| 44 | + | |
| 45 | + > | |
| 46 | + | |
| 47 | + <ImageView | |
| 48 | + android:layout_width="40dp" | |
| 49 | + android:layout_height="40dp" | |
| 50 | + android:background="@drawable/success_big" /> | |
| 51 | + | |
| 52 | + <TextView | |
| 53 | + android:layout_width="wrap_content" | |
| 54 | + android:layout_height="match_parent" | |
| 55 | + android:layout_marginLeft="20dp" | |
| 56 | + android:text="绑定成功" | |
| 57 | + android:gravity="center" | |
| 58 | + android:textColor="@color/textColor" | |
| 59 | + android:textSize="@dimen/txtsize_headline" /> | |
| 60 | + | |
| 61 | + </LinearLayout> | |
| 62 | + <LinearLayout | |
| 63 | + android:id="@+id/binding_success2" | |
| 64 | + android:visibility="gone" | |
| 65 | + android:layout_width="match_parent" | |
| 66 | + android:layout_height="wrap_content" | |
| 67 | + android:gravity="center" | |
| 68 | + android:background="@color/white" | |
| 69 | + android:layout_marginLeft="20dp" | |
| 70 | + android:padding="30dp" | |
| 71 | + android:orientation="vertical" | |
| 72 | + android:layout_marginRight="20dp" | |
| 73 | + | |
| 74 | + > | |
| 75 | + <TextView | |
| 76 | + android:id="@+id/tv_info" | |
| 77 | + android:layout_width="wrap_content" | |
| 78 | + android:layout_height="match_parent" | |
| 79 | + android:layout_marginLeft="20dp" | |
| 80 | + android:text="生成孩子“汇作业”账号为:sz1803081515,初始密码为:sz1803081515(与账号相同)。孩子可以下载“汇作业”app进行使用" | |
| 81 | + android:gravity="center" | |
| 82 | + android:textColor="@color/textColor" | |
| 83 | + android:textSize="@dimen/txtsize_headline" /> | |
| 84 | + <LinearLayout | |
| 85 | + android:layout_width="match_parent" | |
| 86 | + android:layout_height="wrap_content" | |
| 87 | + android:layout_marginTop="10dp" | |
| 88 | + android:gravity="center" | |
| 89 | + > | |
| 90 | + <TextView | |
| 91 | + android:layout_width="wrap_content" | |
| 92 | + android:layout_height="match_parent" | |
| 93 | + android:layout_marginLeft="20dp" | |
| 94 | + android:text="下载地址:" | |
| 95 | + android:textColor="@color/textColor" | |
| 96 | + android:textSize="@dimen/txtsize_headline" /> | |
| 97 | + <TextView | |
| 98 | + android:id="@+id/zuoye" | |
| 99 | + android:layout_width="wrap_content" | |
| 100 | + android:layout_height="match_parent" | |
| 101 | + android:layout_marginLeft="20dp" | |
| 102 | + android:text="汇作业" | |
| 103 | + android:gravity="center" | |
| 104 | + android:textColor="@color/textBlue" | |
| 105 | + android:textSize="@dimen/txtsize_headline" /> | |
| 106 | + </LinearLayout> | |
| 107 | + | |
| 108 | + </LinearLayout> | |
| 109 | + <com.share.mvpsdk.widgets.NestedScrollWebView | |
| 110 | + android:id="@+id/webView" | |
| 111 | + android:layout_height="match_parent" | |
| 112 | + android:layout_width="match_parent" | |
| 113 | + android:layout_marginTop="20dp" | |
| 114 | + android:layout_marginRight="20dp" | |
| 115 | + android:layout_marginLeft="20dp" | |
| 116 | + /> | |
| 117 | + | |
| 118 | +</LinearLayout> | ... | ... |