Commit 6a9221532534d354b7900b7fe1a9063fb703adb8
Exists in
yxb_dev
and in
2 other branches
Merge branch 'yxb_dev' of http://git.shunzhi.net/taohd/parentwork into developer
Showing
13 changed files
with
121 additions
and
37 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/adapter/ChildAdapter.java
... | ... | @@ -33,7 +33,7 @@ public class ChildAdapter extends BaseRecyclerViewAdapter<ChildBean> { |
33 | 33 | |
34 | 34 | @Override |
35 | 35 | public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
36 | - View view = LayoutInflater.from(context).inflate(R.layout.activity_web_view, null); | |
36 | + View view = LayoutInflater.from(context).inflate(R.layout.item_childlist, null); | |
37 | 37 | return new MyViewHolder(view); |
38 | 38 | } |
39 | 39 | ... | ... |
app/src/main/java/com/shunzhi/parent/contract/loginandregister/LoginAndRegisterContract.java
app/src/main/java/com/shunzhi/parent/contract/mine/MyChildContract.java
... | ... | @@ -41,7 +41,7 @@ public interface MyChildContract { |
41 | 41 | |
42 | 42 | interface IMyChildView extends IBaseActivity { |
43 | 43 | void updateChildList(CurrentBean currentBean); |
44 | - void addChildSuccess(); | |
44 | + void addChildSuccess(String account,String password); | |
45 | 45 | void showClass(List<ChildClass>list); |
46 | 46 | void showError(String error); |
47 | 47 | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java
... | ... | @@ -17,11 +17,15 @@ import com.shunzhi.parent.model.loginandregister.LoginAndRegisterModel; |
17 | 17 | import com.shunzhi.parent.ui.fragment.loginandregistfragment.LoginAndRegistFragment; |
18 | 18 | import com.shunzhi.parent.util.Utils; |
19 | 19 | |
20 | +import org.json.JSONObject; | |
21 | + | |
20 | 22 | import java.util.regex.Matcher; |
21 | 23 | import java.util.regex.Pattern; |
22 | 24 | |
23 | 25 | import io.reactivex.functions.Consumer; |
26 | +import okhttp3.ResponseBody; | |
24 | 27 | import retrofit2.HttpException; |
28 | +import retrofit2.Response; | |
25 | 29 | import timber.log.Timber; |
26 | 30 | |
27 | 31 | /** |
... | ... | @@ -35,7 +39,8 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
35 | 39 | @Override |
36 | 40 | public void loginResult(final String loginName, final String loginPwd) { |
37 | 41 | if (!isMate(loginName, REGEX_MOBILE)) { |
38 | - ToastUtils.showToast("请输入正确的手机号!!"); | |
42 | + | |
43 | + mIView.showerror("请输入正确的手机号!!"); | |
39 | 44 | return; |
40 | 45 | } |
41 | 46 | |
... | ... | @@ -64,9 +69,21 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
64 | 69 | }, new Consumer<Throwable>() { |
65 | 70 | @Override |
66 | 71 | public void accept(Throwable throwable) throws Exception { |
67 | - if (null != throwable) | |
68 | - OkHttpExceptionUtil.handOkHttpException((HttpException) throwable); | |
69 | -// ToastUtils.showToast(throwable.getMessage()); | |
72 | + Response response = ((HttpException)throwable).response(); | |
73 | + if (response==null)return; | |
74 | + ResponseBody responseBody = response.errorBody(); | |
75 | + if (responseBody==null)return; | |
76 | + try { | |
77 | + JSONObject json = new JSONObject(responseBody.string()); | |
78 | +// ToastUtils.showToast(json.optString("message")+"json="+json); | |
79 | + if(TextUtils.isEmpty(json.optString("error"))){ | |
80 | + mIView.showerror(json.optString("message")); | |
81 | + return; | |
82 | + } | |
83 | + mIView.showerror(json.optString("error")); | |
84 | + } catch (Exception e1) { | |
85 | + e1.printStackTrace(); | |
86 | + } | |
70 | 87 | } |
71 | 88 | })); |
72 | 89 | |
... | ... | @@ -95,8 +112,17 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
95 | 112 | }, new Consumer<Throwable>() { |
96 | 113 | @Override |
97 | 114 | public void accept(Throwable throwable) throws Exception { |
98 | - LoginAndRegistFragment.progressDialog.dismiss(); | |
99 | - OkHttpExceptionUtil.handOkHttpException((HttpException) throwable); | |
115 | + Response response = ((HttpException)throwable).response(); | |
116 | + if (response==null)return; | |
117 | + ResponseBody responseBody = response.errorBody(); | |
118 | + if (responseBody==null)return; | |
119 | + try { | |
120 | + JSONObject json = new JSONObject(responseBody.string()); | |
121 | +// ToastUtils.showToast(json.optString("message")+"json="+json); | |
122 | + mIView.showerror(json.optString("message")); | |
123 | + } catch (Exception e1) { | |
124 | + e1.printStackTrace(); | |
125 | + } | |
100 | 126 | } |
101 | 127 | })); |
102 | 128 | |
... | ... | @@ -160,8 +186,19 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
160 | 186 | }, new Consumer<Throwable>() { |
161 | 187 | @Override |
162 | 188 | public void accept(Throwable throwable) throws Exception { |
163 | - LoginAndRegistFragment.progressDialog.dismiss(); | |
164 | - OkHttpExceptionUtil.handOkHttpException((HttpException) throwable); | |
189 | + Response response = ((HttpException)throwable).response(); | |
190 | + if (response==null)return; | |
191 | + ResponseBody responseBody = response.errorBody(); | |
192 | + if (responseBody==null)return; | |
193 | + try { | |
194 | + JSONObject json = new JSONObject(responseBody.string()); | |
195 | +// ToastUtils.showToast(json.optString("message")+"json="+json); | |
196 | + mIView.showerror(json.optString("message")); | |
197 | + } catch (Exception e1) { | |
198 | + e1.printStackTrace(); | |
199 | + } | |
200 | + | |
201 | +// OkHttpExceptionUtil.handOkHttpException((HttpException) throwable); | |
165 | 202 | } |
166 | 203 | })); |
167 | 204 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/mine/MyChildPresenter.java
1 | 1 | package com.shunzhi.parent.presenter.mine; |
2 | 2 | |
3 | +import android.util.Log; | |
4 | + | |
3 | 5 | import com.google.gson.JsonObject; |
4 | 6 | import com.share.mvpsdk.utils.OkHttpExceptionUtil; |
5 | 7 | import com.share.mvpsdk.utils.ToastUtils; |
... | ... | @@ -47,14 +49,14 @@ public class MyChildPresenter extends MyChildContract.MyChildPresenter { |
47 | 49 | }, new Consumer<Throwable>() { |
48 | 50 | @Override |
49 | 51 | public void accept(Throwable throwable) throws Exception { |
50 | - Response response = ((HttpException)throwable).response(); | |
51 | - if (response==null)return; | |
52 | + Response response = ((HttpException) throwable).response(); | |
53 | + if (response == null) return; | |
52 | 54 | ResponseBody responseBody = response.errorBody(); |
53 | - if (responseBody==null)return; | |
55 | + if (responseBody == null) return; | |
54 | 56 | try { |
55 | 57 | JSONObject json = new JSONObject(responseBody.string()); |
56 | 58 | mIView.showError(json.optString("message")); |
57 | - } catch (Exception e1) { | |
59 | + } catch (Exception e1) { | |
58 | 60 | e1.printStackTrace(); |
59 | 61 | } |
60 | 62 | |
... | ... | @@ -64,12 +66,19 @@ public class MyChildPresenter extends MyChildContract.MyChildPresenter { |
64 | 66 | } |
65 | 67 | |
66 | 68 | @Override |
67 | - public void addChild( int sex , String studentName,int parentId, boolean mobileFlag, boolean cooperateFlag, int schoolId, int classId, int studentId, String studentUserId) { | |
68 | - mRxManager.register(mIModel.addChildResult(sex,studentName,parentId, mobileFlag, cooperateFlag, schoolId, classId, studentId, studentUserId).subscribe(new Consumer<JsonObject>() { | |
69 | + public void addChild(int sex, String studentName, int parentId, boolean mobileFlag, boolean cooperateFlag, int schoolId, int classId, int studentId, String studentUserId) { | |
70 | + mRxManager.register(mIModel.addChildResult(sex, studentName, parentId, mobileFlag, cooperateFlag, schoolId, classId, studentId, studentUserId).subscribe(new Consumer<JsonObject>() { | |
69 | 71 | @Override |
70 | 72 | public void accept(JsonObject jsonObject) throws Exception { |
71 | 73 | ToastUtils.showToast("绑定孩子成功"); |
72 | - mIView.addChildSuccess(); | |
74 | + Log.e("asdasda", jsonObject.get("data").toString()); | |
75 | + if (jsonObject.get("data").toString().equals("null")) { | |
76 | + mIView.addChildSuccess("", ""); | |
77 | + } else { | |
78 | + JsonObject data = jsonObject.getAsJsonObject("data"); | |
79 | + mIView.addChildSuccess(data.get("account").getAsString(), data.get("password").getAsString()); | |
80 | + } | |
81 | + | |
73 | 82 | } |
74 | 83 | }, new Consumer<Throwable>() { |
75 | 84 | @Override | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/MyChildActivity.java
app/src/main/java/com/shunzhi/parent/ui/activity/binding/CheckInfoActivity.java
... | ... | @@ -151,10 +151,10 @@ public class CheckInfoActivity extends BaseMVPCompatActivity<MyChildContract.MyC |
151 | 151 | } |
152 | 152 | |
153 | 153 | @Override |
154 | - public void addChildSuccess() { | |
154 | + public void addChildSuccess(String account,String password) { | |
155 | 155 | // WebViewActivity.start_show(CheckInfoActivity.this,AppConfig.BINDING_SUCCESS_HEZUO); |
156 | 156 | WebViewActivity.getInstance(CheckInfoActivity.this, |
157 | - AppConfig.BASE_URL_ORDER+"/ParentOrderCenter.aspx?userid="+ | |
157 | + AppConfig.BASE_URL_ORDER+"/RecommendOrder.aspx?userid="+ | |
158 | 158 | AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID),AppConfig.BINDING_SUCCESS_HEZUO); |
159 | 159 | finish(); |
160 | 160 | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/binding/CreateChildInfoActivity.java
... | ... | @@ -132,8 +132,9 @@ public class CreateChildInfoActivity extends BaseMVPCompatActivity<MyChildContra |
132 | 132 | } |
133 | 133 | |
134 | 134 | @Override |
135 | - public void addChildSuccess() { | |
136 | - WebViewActivity.getInstance(CreateChildInfoActivity.this,AppConfig.BASE_URL_ORDER+"/ParentOrderCenter.aspx?userid="+AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID),AppConfig.BINDING_SUCCESS_NOT); | |
135 | + public void addChildSuccess(String account,String password) { | |
136 | + WebViewActivity.startShow(CreateChildInfoActivity.this,AppConfig.BASE_URL_ORDER+"/RecommendOrder.aspx?userid="+ | |
137 | + AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID),AppConfig.BINDING_SUCCESS_NOT,account,password,child_name.getText().toString()); | |
137 | 138 | finish(); |
138 | 139 | } |
139 | 140 | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java
... | ... | @@ -22,13 +22,14 @@ import com.share.mvpsdk.utils.NetworkConnectionUtils; |
22 | 22 | import com.share.mvpsdk.widgets.NestedScrollWebView; |
23 | 23 | import com.shunzhi.parent.AppConfig; |
24 | 24 | import com.shunzhi.parent.R; |
25 | +import com.shunzhi.parent.ui.MainActivity; | |
25 | 26 | |
26 | 27 | public class WebViewActivity extends BaseCompatActivity { |
27 | 28 | |
28 | 29 | NestedScrollWebView nesteScrollWebView; |
29 | 30 | LinearLayout binding_success, binding_success2; |
30 | 31 | ImageView close_btn; |
31 | - TextView tv_info,zuoye,title_web; | |
32 | + TextView tv_info, zuoye, title_web; | |
32 | 33 | |
33 | 34 | int type; |
34 | 35 | |
... | ... | @@ -41,14 +42,25 @@ public class WebViewActivity extends BaseCompatActivity { |
41 | 42 | context.startActivity(intent); |
42 | 43 | } |
43 | 44 | |
45 | + public static void startShow(Context context, String url, int type, String account, String password, String name) { | |
46 | + Intent intent = new Intent(context, WebViewActivity.class); | |
47 | + intent.putExtra("url", url); | |
48 | + intent.putExtra("type", type); | |
49 | + intent.putExtra("account", account); | |
50 | + intent.putExtra("password", password); | |
51 | + intent.putExtra("name", name); | |
52 | + context.startActivity(intent); | |
53 | + } | |
54 | + | |
55 | + | |
44 | 56 | @Override |
45 | 57 | protected void initView(Bundle savedInstanceState) { |
46 | 58 | |
47 | - binding_success=findViewById(R.id.binding_success); | |
59 | + binding_success = findViewById(R.id.binding_success); | |
48 | 60 | |
49 | - binding_success=findViewById(R.id.binding_success1); | |
61 | + binding_success = findViewById(R.id.binding_success1); | |
50 | 62 | |
51 | - binding_success2=findViewById(R.id.binding_success2); | |
63 | + binding_success2 = findViewById(R.id.binding_success2); | |
52 | 64 | close_btn = findViewById(R.id.close_btn); |
53 | 65 | tv_info = findViewById(R.id.tv_info); |
54 | 66 | zuoye = findViewById(R.id.zuoye); |
... | ... | @@ -78,13 +90,18 @@ public class WebViewActivity extends BaseCompatActivity { |
78 | 90 | binding_success.setVisibility(View.GONE); |
79 | 91 | binding_success2.setVisibility(View.VISIBLE); |
80 | 92 | title_web.setVisibility(View.GONE); |
93 | + String account = getIntent().getStringExtra("account"); | |
94 | + String name = getIntent().getStringExtra("name"); | |
95 | + String password = getIntent().getStringExtra("password"); | |
96 | + | |
97 | + tv_info.setText("生成孩子“" + name + "”账号为:" + account + ",初始密码为:" + password + "(与账号相同)。孩子可以下载“汇作业”app进行使用"); | |
81 | 98 | |
82 | 99 | } else if (type == AppConfig.ORDER_CENTER) { |
83 | 100 | binding_success.setVisibility(View.GONE); |
84 | 101 | binding_success2.setVisibility(View.GONE); |
85 | 102 | title_web.setVisibility(View.VISIBLE); |
86 | 103 | |
87 | - }else { | |
104 | + } else { | |
88 | 105 | binding_success.setVisibility(View.GONE); |
89 | 106 | binding_success2.setVisibility(View.GONE); |
90 | 107 | title_web.setVisibility(View.GONE); |
... | ... | @@ -107,6 +124,7 @@ public class WebViewActivity extends BaseCompatActivity { |
107 | 124 | nesteScrollWebView.goBack(); |
108 | 125 | } else { |
109 | 126 | super.onBackPressedSupport(); |
127 | + startActivity(new Intent().setClass(this, MainActivity.class)); | |
110 | 128 | } |
111 | 129 | } |
112 | 130 | |
... | ... | @@ -130,6 +148,7 @@ public class WebViewActivity extends BaseCompatActivity { |
130 | 148 | }); |
131 | 149 | } |
132 | 150 | } |
151 | + | |
133 | 152 | // 调起支付宝并跳转到指定页面 |
134 | 153 | private void startAlipayActivity(String url) { |
135 | 154 | Intent intent; |
... | ... | @@ -152,8 +171,8 @@ public class WebViewActivity extends BaseCompatActivity { |
152 | 171 | nesteScrollWebView.setWebViewClient(new WebViewClient() { |
153 | 172 | @Override |
154 | 173 | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
155 | - Log.d("666666","url="+url); | |
156 | - if (url.startsWith("http"))view.loadUrl(url); | |
174 | + Log.d("666666", "url=" + url); | |
175 | + if (url.startsWith("http")) view.loadUrl(url); | |
157 | 176 | // if (url.contains("platformapi/startapp")) { |
158 | 177 | // startAlipayActivity(url); |
159 | 178 | // android 6.0 两种方式获取intent都可以跳转支付宝成功,7.1测试不成功 |
... | ... | @@ -174,6 +193,13 @@ public class WebViewActivity extends BaseCompatActivity { |
174 | 193 | // html加载完成之后,添加监听图片的点击js函数 |
175 | 194 | addWebImageClickListner(view); |
176 | 195 | // toolbar.setTitle(getToolbarTitle()); |
196 | + if (nesteScrollWebView.canGoBack()) { | |
197 | + binding_success.setVisibility(View.GONE); | |
198 | + binding_success2.setVisibility(View.GONE); | |
199 | + title_web.setVisibility(View.GONE); | |
200 | + } else { | |
201 | + | |
202 | + } | |
177 | 203 | } |
178 | 204 | |
179 | 205 | @Override |
... | ... | @@ -212,7 +238,6 @@ public class WebViewActivity extends BaseCompatActivity { |
212 | 238 | } |
213 | 239 | } |
214 | 240 | }); |
215 | - | |
216 | 241 | nesteScrollWebView.setOnLongClickListener(new View.OnLongClickListener() { |
217 | 242 | @Override |
218 | 243 | public boolean onLongClick(View v) { |
... | ... | @@ -231,6 +256,8 @@ public class WebViewActivity extends BaseCompatActivity { |
231 | 256 | } |
232 | 257 | |
233 | 258 | |
259 | + | |
260 | + | |
234 | 261 | /** |
235 | 262 | * 初始化WebSetting |
236 | 263 | * | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
... | ... | @@ -179,6 +179,12 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist |
179 | 179 | } |
180 | 180 | |
181 | 181 | @Override |
182 | + public void showerror(String error) { | |
183 | + progressDialog.dismiss(); | |
184 | + ToastUtils.showToast(error); | |
185 | + } | |
186 | + | |
187 | + @Override | |
182 | 188 | public void onClick(View v) { |
183 | 189 | if (v == loginAndRegister) { |
184 | 190 | progressDialog.show(); | ... | ... |
app/src/main/res/drawable/rudiobtn_unclick.xml
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> |
3 | 3 | <stroke android:color="#00000000" android:width="1dp"/> |
4 | - <solid android:color="@color/xueqing_blue" /> | |
4 | + <solid android:color="@color/bottomline" /> | |
5 | 5 | <corners android:radius="5dp"/> |
6 | 6 | </shape> |
7 | 7 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/activity_webview.xml
... | ... | @@ -12,12 +12,14 @@ |
12 | 12 | > |
13 | 13 | <ImageView |
14 | 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 | - /> | |
15 | + android:layout_width="wrap_content" | |
16 | + android:layout_height="match_parent" | |
17 | + android:gravity="center" | |
18 | + android:paddingLeft="@dimen/size_dp_15" | |
19 | + android:src="@drawable/back" | |
20 | + android:paddingRight="@dimen/size_dp_15" | |
21 | + android:textColor="@color/textColor" | |
22 | + android:textSize="@dimen/textSize16" /> | |
21 | 23 | <TextView |
22 | 24 | android:id="@+id/title_web" |
23 | 25 | android:layout_width="wrap_content" | ... | ... |
app/src/main/res/layout/fragment_login_and_regist.xml
... | ... | @@ -200,6 +200,7 @@ |
200 | 200 | android:layout_height="wrap_content" |
201 | 201 | android:layout_marginTop="40dp" |
202 | 202 | android:background="@drawable/rudiobtn_unclick" |
203 | + android:enabled="false" | |
203 | 204 | android:gravity="center" |
204 | 205 | android:paddingBottom="10dp" |
205 | 206 | android:paddingTop="10dp" | ... | ... |