Commit 40297dd4a4ce4e37907f104c31c58b9ba5ffaa68

Authored by shixianjie
1 parent e73fb8ff90
Exists in master

教师登录默认首页;

布局调整, 允许滚动;
app/src/main/java/com/hjx/parent/LoginActivity.java
1 package com.hjx.parent; 1 package com.hjx.parent;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.telephony.PhoneNumberUtils; 5 import android.telephony.PhoneNumberUtils;
6 import android.text.InputType; 6 import android.text.InputType;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 import android.text.method.HideReturnsTransformationMethod; 8 import android.text.method.HideReturnsTransformationMethod;
9 import android.text.method.PasswordTransformationMethod; 9 import android.text.method.PasswordTransformationMethod;
10 import android.widget.Button; 10 import android.widget.Button;
11 import android.widget.CheckBox; 11 import android.widget.CheckBox;
12 import android.widget.EditText; 12 import android.widget.EditText;
13 import android.widget.ImageView; 13 import android.widget.ImageView;
14 import android.widget.TextView; 14 import android.widget.TextView;
15 import android.widget.Toast; 15 import android.widget.Toast;
16 16
17 import androidx.appcompat.app.AppCompatActivity; 17 import androidx.appcompat.app.AppCompatActivity;
18 18
19 import com.prws.common.base.BaseActivity; 19 import com.prws.common.base.BaseActivity;
20 import com.prws.common.base.BasePresenter; 20 import com.prws.common.base.BasePresenter;
21 import com.prws.common.bean.BaseEntity; 21 import com.prws.common.bean.BaseEntity;
22 import com.prws.common.net.NetWorks; 22 import com.prws.common.net.NetWorks;
23 import com.prws.common.utils.LogUtil; 23 import com.prws.common.utils.LogUtil;
24 import com.prws.common.utils.SharedPreferencesUtil; 24 import com.prws.common.utils.SharedPreferencesUtil;
25 import com.prws.common.utils.acmanager.ActivityManager; 25 import com.prws.common.utils.acmanager.ActivityManager;
26 26
27 import org.json.JSONObject; 27 import org.json.JSONObject;
28 28
29 import java.io.IOException; 29 import java.io.IOException;
30 import java.util.HashMap; 30 import java.util.HashMap;
31 import java.util.Map; 31 import java.util.Map;
32 32
33 import io.reactivex.Observer; 33 import io.reactivex.Observer;
34 import io.reactivex.disposables.Disposable; 34 import io.reactivex.disposables.Disposable;
35 import okhttp3.ResponseBody; 35 import okhttp3.ResponseBody;
36 36
37 37
38 public class LoginActivity extends BaseActivity { 38 public class LoginActivity extends BaseActivity {
39 39
40 40
41 EditText et_phone; 41 EditText et_phone;
42 EditText et_pwd; 42 EditText et_pwd;
43 ImageView iv_show; 43 ImageView iv_show;
44 ImageView iv_delete; 44 ImageView iv_delete;
45 Button btn_login; 45 Button btn_login;
46 46
47 47
48 @Override 48 @Override
49 protected int layoutResId() { 49 protected int layoutResId() {
50 return R.layout.activity_login; 50 return R.layout.activity_login;
51 } 51 }
52 52
53 @Override 53 @Override
54 public Object getContract() { 54 public Object getContract() {
55 return null; 55 return null;
56 } 56 }
57 57
58 @Override 58 @Override
59 public BasePresenter getPresenter() { 59 public BasePresenter getPresenter() {
60 return null; 60 return null;
61 } 61 }
62 62
63 63
64 @Override 64 @Override
65 protected void initView() { 65 protected void initView() {
66 et_phone = findViewById(R.id.et_phone); 66 et_phone = findViewById(R.id.et_phone);
67 et_pwd = findViewById(R.id.et_pwd); 67 et_pwd = findViewById(R.id.et_pwd);
68 iv_show = findViewById(R.id.iv_4); 68 iv_show = findViewById(R.id.iv_4);
69 iv_delete = findViewById(R.id.iv_2); 69 iv_delete = findViewById(R.id.iv_2);
70 btn_login = findViewById(R.id.btn_1); 70 btn_login = findViewById(R.id.btn_1);
71 71
72 String student = (String) SharedPreferencesUtil.getData("student", ""); 72 String student = (String) SharedPreferencesUtil.getData("student", "");
73 73
74 if (!TextUtils.isEmpty(student)) { 74 if (!TextUtils.isEmpty(student)) {
75 LogUtil.e(TAG, "role 不是空----"); 75 LogUtil.e(TAG, "role 不是空----");
76 if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { 76 if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) {
77 Intent intent = new Intent(this, MainActivity.class); 77 Intent intent = new Intent(this, MainActivity.class);
78 startActivity(intent); 78 startActivity(intent);
79 finish(); 79 finish();
80 } else { 80 } else {
81 Intent intent = new Intent(this, TeacherMainActivity.class); 81 Intent intent = new Intent(this, TeacherMainActivity.class);
82 startActivity(intent); 82 startActivity(intent);
83 finish(); 83 finish();
84 } 84 }
85 return; 85 return;
86 } else { 86 } else {
87 LogUtil.e(TAG, "role 是空----"); 87 LogUtil.e(TAG, "role 是空----");
88 } 88 }
89 89
90 findViewById(R.id.tvBack).setOnClickListener(v -> { 90 findViewById(R.id.tvBack).setOnClickListener(v -> {
91 startActivity(new Intent(this, SmsLoginActivity.class)); 91 Intent intent = new Intent(this, SmsLoginActivity.class);
92 intent.putExtra("fromLogin", true);
93 startActivity(intent);
92 finish(); 94 finish();
93 }); 95 });
94 96
95 } 97 }
96 98
97 @Override 99 @Override
98 protected void initListener() { 100 protected void initListener() {
99 iv_delete.setOnClickListener(view -> { 101 iv_delete.setOnClickListener(view -> {
100 et_phone.setText(""); 102 et_phone.setText("");
101 }); 103 });
102 iv_show.setOnClickListener(view -> { 104 iv_show.setOnClickListener(view -> {
103 if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { 105 if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) {
104 iv_show.setBackgroundResource(R.mipmap.yc); 106 iv_show.setBackgroundResource(R.mipmap.yc);
105 et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); 107 et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
106 et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); 108 et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
107 } else { 109 } else {
108 iv_show.setBackgroundResource(R.mipmap.xs); 110 iv_show.setBackgroundResource(R.mipmap.xs);
109 et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); 111 et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
110 et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); 112 et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
111 } 113 }
112 }); 114 });
113 115
114 116
115 btn_login.setOnClickListener(view -> { 117 btn_login.setOnClickListener(view -> {
116 118
117 String phone = et_phone.getText().toString().trim(); 119 String phone = et_phone.getText().toString().trim();
118 String pwd = et_pwd.getText().toString().trim(); 120 String pwd = et_pwd.getText().toString().trim();
119 if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { 121 if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) {
120 Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); 122 Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show();
121 return; 123 return;
122 } 124 }
123 125
124 if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { 126 if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) {
125 Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); 127 Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show();
126 return; 128 return;
127 } 129 }
128 130
129 // if (!cb_1.isChecked()) { 131 // if (!cb_1.isChecked()) {
130 // Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); 132 // Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show();
131 // return; 133 // return;
132 // } 134 // }
133 135
134 login(phone, pwd); 136 login(phone, pwd);
135 137
136 }); 138 });
137 139
138 // tv_ys.setOnClickListener(view -> { 140 // tv_ys.setOnClickListener(view -> {
139 // startActivity(YinsiActivity.class); 141 // startActivity(YinsiActivity.class);
140 // }); 142 // });
141 // tv_user.setOnClickListener(view -> { 143 // tv_user.setOnClickListener(view -> {
142 // startActivity(UserAgreementActivity.class); 144 // startActivity(UserAgreementActivity.class);
143 // }); 145 // });
144 } 146 }
145 147
146 public void login(final String phone, String pwd) { 148 public void login(final String phone, String pwd) {
147 149
148 Map map = new HashMap(); 150 Map map = new HashMap();
149 map.put("username", phone); 151 map.put("username", phone);
150 map.put("password", pwd); 152 map.put("password", pwd);
151 153
152 154
153 NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { 155 NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() {
154 @Override 156 @Override
155 public void onSubscribe(Disposable d) { 157 public void onSubscribe(Disposable d) {
156 158
157 } 159 }
158 160
159 @Override 161 @Override
160 public void onNext(ResponseBody responseBody) { 162 public void onNext(ResponseBody responseBody) {
161 try { 163 try {
162 String str = responseBody.string().toString(); 164 String str = responseBody.string().toString();
163 LogUtil.e(TAG, "----" + str); 165 LogUtil.e(TAG, "----" + str);
164 JSONObject jo = new JSONObject(str); 166 JSONObject jo = new JSONObject(str);
165 boolean isSucceed = jo.getBoolean("success"); 167 boolean isSucceed = jo.getBoolean("success");
166 if (isSucceed) { 168 if (isSucceed) {
167 JSONObject jo2 = jo.getJSONObject("data"); 169 JSONObject jo2 = jo.getJSONObject("data");
168 String role = jo2.getString("role"); 170 String role = jo2.getString("role");
169 if ("member_advisor".equals(role) || "teaching_supervision".equals(role)) { 171 if ("member_advisor".equals(role) || "teaching_supervision".equals(role)) {
170 SharedPreferencesUtil.putData("phone", phone); 172 SharedPreferencesUtil.putData("phone", phone);
171 SharedPreferencesUtil.putData("role", role); 173 SharedPreferencesUtil.putData("role", role);
172 SharedPreferencesUtil.putData("userId", jo2.getString("id")); 174 SharedPreferencesUtil.putData("userId", jo2.getString("id"));
173 SharedPreferencesUtil.putData("token", jo2.getString("token")); 175 SharedPreferencesUtil.putData("token", jo2.getString("token"));
174 SharedPreferencesUtil.putData("name", jo2.getString("username")); 176 SharedPreferencesUtil.putData("name", jo2.getString("username"));
175 SharedPreferencesUtil.putData("photo", jo2.getString("photo")); 177 SharedPreferencesUtil.putData("photo", jo2.getString("photo"));
176 startActivity(TeacherChooseActivity.class); 178 startActivity(TeacherChooseActivity.class);
177 finish(); 179 finish();
178 } else { 180 } else {
179 showToast("您没有权限"); 181 showToast("您没有权限");
180 } 182 }
181 183
182 } else { 184 } else {
183 Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); 185 Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show();
184 } 186 }
185 } catch (Exception e) { 187 } catch (Exception e) {
186 e.printStackTrace(); 188 e.printStackTrace();
187 Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); 189 Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show();
188 } 190 }
189 } 191 }
190 192
191 @Override 193 @Override
192 public void onError(Throwable e) { 194 public void onError(Throwable e) {
193 195
194 } 196 }
195 197
196 @Override 198 @Override
197 public void onComplete() { 199 public void onComplete() {
198 200
199 } 201 }
200 }); 202 });
201 } 203 }
202 204
203 205
204 @Override 206 @Override
205 protected void initData() { 207 protected void initData() {
206 208
207 } 209 }
208 210
209 @Override 211 @Override
210 public void onNetChanged(int netWorkState) { 212 public void onNetChanged(int netWorkState) {
211 213
212 } 214 }
213 } 215 }
app/src/main/java/com/hjx/parent/SmsLoginActivity.java
1 package com.hjx.parent; 1 package com.hjx.parent;
2 2
3 import android.annotation.SuppressLint; 3 import android.annotation.SuppressLint;
4 import android.content.Intent; 4 import android.content.Intent;
5 import android.os.Bundle; 5 import android.os.Bundle;
6 import android.telephony.PhoneNumberUtils; 6 import android.telephony.PhoneNumberUtils;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.Toast; 9 import android.widget.Toast;
10 10
11 import com.hjx.parent.databinding.ActivitySmsLoginBinding; 11 import com.hjx.parent.databinding.ActivitySmsLoginBinding;
12 import com.hjx.parent.rx.BaseRxActivity; 12 import com.hjx.parent.rx.BaseRxActivity;
13 import com.prws.common.bean.Student; 13 import com.prws.common.bean.Student;
14 import com.prws.common.net.NetWorks; 14 import com.prws.common.net.NetWorks;
15 import com.prws.common.utils.LogUtil; 15 import com.prws.common.utils.LogUtil;
16 import com.prws.common.utils.SharedPreferencesUtil; 16 import com.prws.common.utils.SharedPreferencesUtil;
17 17
18 import java.util.HashMap; 18 import java.util.HashMap;
19 import java.util.List; 19 import java.util.List;
20 import java.util.Map; 20 import java.util.Map;
21 import java.util.concurrent.TimeUnit; 21 import java.util.concurrent.TimeUnit;
22 22
23 import io.reactivex.Observable; 23 import io.reactivex.Observable;
24 import io.reactivex.android.schedulers.AndroidSchedulers; 24 import io.reactivex.android.schedulers.AndroidSchedulers;
25 import io.reactivex.disposables.Disposable; 25 import io.reactivex.disposables.Disposable;
26 26
27 public class SmsLoginActivity extends BaseRxActivity<ActivitySmsLoginBinding> { 27 public class SmsLoginActivity extends BaseRxActivity<ActivitySmsLoginBinding> {
28 private final NetWorks.NetService api = NetWorks.service_url; 28 private final NetWorks.NetService api = NetWorks.service_url;
29 @Override 29 @Override
30 public void initView(Bundle savedInstanceState) { 30 public void initView(Bundle savedInstanceState) {
31 getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE); 31 getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
32 32
33 String student = (String) SharedPreferencesUtil.getData("student", ""); 33 String student = (String) SharedPreferencesUtil.getData("student", "");
34 34
35 if (!TextUtils.isEmpty(student)) { 35 if (!TextUtils.isEmpty(student)) {
36 if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { 36 if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) {
37 Intent intent = new Intent(this, MainActivity.class); 37 Intent intent = new Intent(this, MainActivity.class);
38 startActivity(intent); 38 startActivity(intent);
39 finish(); 39 finish();
40 } else { 40 } else {
41 Intent intent = new Intent(this, TeacherMainActivity.class); 41 Intent intent = new Intent(this, TeacherMainActivity.class);
42 startActivity(intent); 42 startActivity(intent);
43 finish(); 43 finish();
44 } 44 }
45 return; 45 return;
46 } 46 }
47 47
48 binding.tvEntrance.setOnClickListener(v -> { 48 binding.tvEntrance.setOnClickListener(v -> {
49 startActivity(new Intent(this, LoginActivity.class)); 49 startActivity(new Intent(this, LoginActivity.class));
50 finish(); 50 finish();
51 }); 51 });
52 binding.btnGetCode.setOnClickListener(v -> { 52 binding.btnGetCode.setOnClickListener(v -> {
53 String phone = binding.etPhone.getText().toString().trim(); 53 String phone = binding.etPhone.getText().toString().trim();
54 if (phone.isEmpty()) { 54 if (phone.isEmpty()) {
55 showToast("请输入手机号"); 55 showToast("请输入手机号");
56 return; 56 return;
57 } 57 }
58 sendCode(phone); 58 sendCode(phone);
59 }); 59 });
60 binding.btnLogin.setOnClickListener(v -> { 60 binding.btnLogin.setOnClickListener(v -> {
61 61
62 String phone = binding.etPhone.getText().toString().trim(); 62 String phone = binding.etPhone.getText().toString().trim();
63 String code = binding.etCode.getText().toString().trim(); 63 String code = binding.etCode.getText().toString().trim();
64 if (phone.isEmpty() || code.isEmpty()) { 64 if (phone.isEmpty() || code.isEmpty()) {
65 Toast.makeText(this, "手机号以及验证码不能为空", Toast.LENGTH_SHORT).show(); 65 Toast.makeText(this, "手机号以及验证码不能为空", Toast.LENGTH_SHORT).show();
66 return; 66 return;
67 } 67 }
68 68
69 if (!binding.chkPermission.isChecked()) { 69 if (!binding.chkPermission.isChecked()) {
70 Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); 70 Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show();
71 return; 71 return;
72 } 72 }
73 login(phone, code); 73 login(phone, code);
74 }); 74 });
75 75
76 binding.tv6.setOnClickListener(view -> { 76 binding.tv6.setOnClickListener(view -> {
77 startActivity(new Intent(this, YinsiActivity.class)); 77 startActivity(new Intent(this, YinsiActivity.class));
78 }); 78 });
79 binding.tv4.setOnClickListener(view -> { 79 binding.tv4.setOnClickListener(view -> {
80 startActivity(new Intent(this, UserAgreementActivity.class)); 80 startActivity(new Intent(this, UserAgreementActivity.class));
81 }); 81 });
82
83 if (!getIntent().getBooleanExtra("fromLogin", false)) {
84 startActivity(new Intent(this, LoginActivity.class));
85 finish();
86 }
82 } 87 }
83 88
84 @SuppressLint("CheckResult") 89 @SuppressLint("CheckResult")
85 private void login(String phone, String code) { 90 private void login(String phone, String code) {
86 binding.btnLogin.setEnabled(false); 91 binding.btnLogin.setEnabled(false);
87 Map<String, String> body = new HashMap<>(); 92 Map<String, String> body = new HashMap<>();
88 body.put("phone", phone); 93 body.put("phone", phone);
89 body.put("code", code); 94 body.put("code", code);
90 api.smsLogin(body) 95 api.smsLogin(body)
91 .compose(transformSingle()) 96 .compose(transformSingle())
92 .subscribe((response, th) -> { 97 .subscribe((response, th) -> {
93 binding.btnLogin.setEnabled(true); 98 binding.btnLogin.setEnabled(true);
94 if (handleResponseData(response, th)) { 99 if (handleResponseData(response, th)) {
95 List<Student> list = response.getData().parentInfoList; 100 List<Student> list = response.getData().parentInfoList;
96 if (list == null || list.isEmpty()) { 101 if (list == null || list.isEmpty()) {
97 showToast("未注册学生, 无法登录"); 102 showToast("未注册学生, 无法登录");
98 return; 103 return;
99 } 104 }
100 SharedPreferencesUtil.putData("phone", phone); 105 SharedPreferencesUtil.putData("phone", phone);
101 SharedPreferencesUtil.putData("role", "parent"); 106 SharedPreferencesUtil.putData("role", "parent");
102 SharedPreferencesUtil.putData("userId", response.getData().id); 107 SharedPreferencesUtil.putData("userId", response.getData().id);
103 SharedPreferencesUtil.putData("token", response.getData().token); 108 SharedPreferencesUtil.putData("token", response.getData().token);
104 SharedPreferencesUtil.putData("name", response.getData().username); 109 SharedPreferencesUtil.putData("name", response.getData().username);
105 startActivity(new Intent(this, ChooseActivity.class)); 110 startActivity(new Intent(this, ChooseActivity.class));
106 finish(); 111 finish();
107 } 112 }
108 }); 113 });
109 } 114 }
110 115
111 @SuppressLint({"SetTextI18n", "CheckResult"}) 116 @SuppressLint({"SetTextI18n", "CheckResult"})
112 private void sendCode(String phone) { 117 private void sendCode(String phone) {
113 binding.btnGetCode.setEnabled(false); 118 binding.btnGetCode.setEnabled(false);
114 api.smsCode(phone) 119 api.smsCode(phone)
115 .compose(transformSingle()) 120 .compose(transformSingle())
116 .subscribe((response, th) -> { 121 .subscribe((response, th) -> {
117 if (handleResponse(response, th)) { 122 if (handleResponse(response, th)) {
118 showToast("验证码已发送"); 123 showToast("验证码已发送");
119 timeDown(); 124 timeDown();
120 } else { 125 } else {
121 if (disposable != null) disposable.dispose(); 126 if (disposable != null) disposable.dispose();
122 binding.btnGetCode.setText("获取验证码"); 127 binding.btnGetCode.setText("获取验证码");
123 binding.btnGetCode.setEnabled(true); 128 binding.btnGetCode.setEnabled(true);
124 } 129 }
125 }); 130 });
126 } 131 }
127 132
128 private int timeDown = 0; 133 private int timeDown = 0;
129 private Disposable disposable; 134 private Disposable disposable;
130 @SuppressLint("SetTextI18n") 135 @SuppressLint("SetTextI18n")
131 private void timeDown() { 136 private void timeDown() {
132 timeDown = 60; 137 timeDown = 60;
133 disposable = Observable 138 disposable = Observable
134 .interval(0, 1, TimeUnit.SECONDS) 139 .interval(0, 1, TimeUnit.SECONDS)
135 .observeOn(AndroidSchedulers.mainThread()) 140 .observeOn(AndroidSchedulers.mainThread())
136 .subscribe(l -> { 141 .subscribe(l -> {
137 if (--timeDown <= 0) { 142 if (--timeDown <= 0) {
138 if (disposable != null) disposable.dispose(); 143 if (disposable != null) disposable.dispose();
139 binding.btnGetCode.setText("获取验证码"); 144 binding.btnGetCode.setText("获取验证码");
140 binding.btnGetCode.setEnabled(true); 145 binding.btnGetCode.setEnabled(true);
141 } else { 146 } else {
142 binding.btnGetCode.setText("获取验证码(" + timeDown + "s)"); 147 binding.btnGetCode.setText("获取验证码(" + timeDown + "s)");
143 binding.btnGetCode.setEnabled(false); 148 binding.btnGetCode.setEnabled(false);
144 } 149 }
145 }, Throwable::printStackTrace); 150 }, Throwable::printStackTrace);
146 } 151 }
147 152
148 @Override 153 @Override
149 protected void onDestroy() { 154 protected void onDestroy() {
150 super.onDestroy(); 155 super.onDestroy();
151 if (disposable != null) disposable.dispose(); 156 if (disposable != null) disposable.dispose();
152 } 157 }
153 158
154 @Override 159 @Override
155 protected ActivitySmsLoginBinding getViewBinding() { 160 protected ActivitySmsLoginBinding getViewBinding() {
156 return ActivitySmsLoginBinding.inflate(getLayoutInflater()); 161 return ActivitySmsLoginBinding.inflate(getLayoutInflater());
157 } 162 }
158 } 163 }
159 164
app/src/main/res/layout/dialog_add_error.xml
1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 1 <androidx.core.widget.NestedScrollView
2 xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="match_parent" 3 android:layout_width="match_parent"
3 android:layout_height="wrap_content" 4 android:layout_height="match_parent">
4 android:background="@drawable/bg_solid_white_10_top" 5 <LinearLayout
5 android:orientation="vertical">
6
7 <RelativeLayout
8 android:layout_width="match_parent"
9 android:layout_height="50dp">
10
11 <TextView
12 android:layout_width="wrap_content"
13 android:layout_height="wrap_content"
14 android:layout_centerInParent="true"
15 android:text="加入错题本"
16 android:textColor="@color/text_title"
17 android:textSize="17sp"
18 android:textStyle="bold" />
19
20 <ImageView
21 android:id="@+id/iv_back"
22 android:layout_width="35dp"
23 android:layout_height="35dp"
24 android:layout_alignParentRight="true"
25 android:layout_centerVertical="true"
26 android:layout_marginRight="10dp"
27 android:padding="10dp"
28 android:src="@mipmap/ic_close" />
29 </RelativeLayout>
30
31 <androidx.recyclerview.widget.RecyclerView
32 android:id="@+id/list_item"
33 android:layout_width="match_parent"
34 android:layout_height="30dp"
35 android:layout_marginLeft="20dp"
36 android:layout_marginTop="10dp"
37 android:layout_marginRight="20dp" />
38
39 <RelativeLayout
40 android:layout_width="match_parent" 6 android:layout_width="match_parent"
41 android:layout_height="90dp" 7 android:layout_height="wrap_content"
42 android:layout_marginLeft="20dp" 8 android:background="@drawable/bg_solid_white_10_top"
43 android:layout_marginTop="20dp" 9 android:orientation="vertical">
44 android:layout_marginRight="20dp">
45 10
46 <RelativeLayout 11 <RelativeLayout
47 android:layout_width="match_parent" 12 android:layout_width="match_parent"
48 android:layout_height="match_parent" 13 android:layout_height="50dp">
49 android:background="#F5F5F5">
50 14
51 <ImageView 15 <TextView
52 android:id="@+id/iv_topic"
53 android:layout_width="wrap_content" 16 android:layout_width="wrap_content"
54 android:layout_height="wrap_content" 17 android:layout_height="wrap_content"
55 android:layout_centerVertical="true" /> 18 android:layout_centerInParent="true"
56 </RelativeLayout> 19 android:text="加入错题本"
57 </RelativeLayout> 20 android:textColor="@color/text_title"
58 21 android:textSize="17sp"
59 <TextView 22 android:textStyle="bold" />
60 android:layout_width="wrap_content"
61 android:layout_height="wrap_content"
62 android:layout_centerVertical="true"
63 android:layout_marginLeft="20dp"
64 android:layout_marginTop="20dp"
65 android:text="年级"
66 android:textColor="@color/text_title"
67 android:textSize="15sp"
68 android:textStyle="bold" />
69 23
70 <androidx.appcompat.widget.AppCompatSpinner 24 <ImageView
71 android:id="@+id/spinner_grade" 25 android:id="@+id/iv_back"
72 style="@style/customSpinnerStyle" 26 android:layout_width="35dp"
73 android:layout_width="match_parent" 27 android:layout_height="35dp"
74 android:layout_height="40dp" 28 android:layout_alignParentRight="true"
75 android:layout_centerHorizontal="true" 29 android:layout_centerVertical="true"
76 android:layout_marginLeft="20dp" 30 android:layout_marginRight="10dp"
77 android:layout_marginTop="10dp" 31 android:padding="10dp"
78 android:layout_marginRight="20dp" 32 android:src="@mipmap/ic_close" />
79 android:background="@drawable/selector_for_custom_spinner" 33 </RelativeLayout>
80 android:popupBackground="@drawable/shape_for_custom_spinner"
81 android:scrollbars="none" />
82
83 <TextView
84 android:layout_width="wrap_content"
85 android:layout_height="wrap_content"
86 android:layout_centerVertical="true"
87 android:layout_marginLeft="20dp"
88 android:layout_marginTop="20dp"
89 android:text="学期"
90 android:textColor="@color/text_title"
91 android:textSize="15sp"
92 android:textStyle="bold" />
93 34
94 <androidx.appcompat.widget.AppCompatSpinner 35 <androidx.recyclerview.widget.RecyclerView
95 android:id="@+id/spinner_grade1" 36 android:id="@+id/list_item"
96 style="@style/customSpinnerStyle" 37 android:layout_width="match_parent"
97 android:layout_width="match_parent" 38 android:layout_height="30dp"
98 android:layout_height="40dp" 39 android:layout_marginLeft="20dp"
99 android:layout_centerHorizontal="true" 40 android:layout_marginTop="10dp"
100 android:layout_marginLeft="20dp" 41 android:layout_marginRight="20dp" />
101 android:layout_marginTop="10dp"
102 android:layout_marginRight="20dp"
103 android:background="@drawable/selector_for_custom_spinner"
104 android:entries="@array/grade_array"
105 android:popupBackground="@drawable/shape_for_custom_spinner"
106 android:scrollbars="none" />
107 42
108 <TextView 43 <RelativeLayout
109 android:layout_width="wrap_content" 44 android:layout_width="match_parent"
110 android:layout_height="wrap_content" 45 android:layout_height="90dp"
111 android:layout_centerVertical="true" 46 android:layout_marginLeft="20dp"
112 android:layout_marginLeft="20dp" 47 android:layout_marginTop="20dp"
113 android:layout_marginTop="20dp" 48 android:layout_marginRight="20dp">
114 android:text="科目"
115 android:textColor="@color/text_title"
116 android:textSize="15sp"
117 android:textStyle="bold" />
118 49
119 <androidx.appcompat.widget.AppCompatSpinner 50 <RelativeLayout
120 android:id="@+id/spinner_subject" 51 android:layout_width="match_parent"
121 style="@style/customSpinnerStyle" 52 android:layout_height="match_parent"
122 android:layout_width="match_parent" 53 android:background="#F5F5F5">
123 android:layout_height="40dp"
124 android:layout_centerHorizontal="true"
125 android:layout_marginLeft="20dp"
126 android:layout_marginTop="10dp"
127 android:layout_marginRight="20dp"
128 android:background="@drawable/selector_for_custom_spinner"
129 android:entries="@array/filter_subject"
130 android:popupBackground="@drawable/shape_for_custom_spinner"
131 android:scrollbars="none" />
132 54
133 <TextView 55 <ImageView
134 android:layout_width="wrap_content" 56 android:id="@+id/iv_topic"
135 android:layout_height="wrap_content" 57 android:layout_width="wrap_content"
136 android:layout_centerVertical="true" 58 android:layout_height="wrap_content"
137 android:layout_marginLeft="20dp" 59 android:layout_centerVertical="true" />
138 android:layout_marginTop="20dp" 60 </RelativeLayout>
139 android:text="错误原因" 61 </RelativeLayout>
140 android:textColor="@color/text_title"
141 android:textSize="15sp"
142 android:textStyle="bold" />
143 62
144 <androidx.appcompat.widget.AppCompatSpinner 63 <TextView
145 android:id="@+id/spinner_reason" 64 android:layout_width="wrap_content"
146 style="@style/customSpinnerStyle" 65 android:layout_height="wrap_content"
147 android:layout_width="match_parent" 66 android:layout_centerVertical="true"
148 android:layout_height="40dp" 67 android:layout_marginLeft="20dp"
149 android:layout_centerHorizontal="true" 68 android:layout_marginTop="20dp"
150 android:layout_marginLeft="20dp" 69 android:text="年级"
151 android:layout_marginTop="10dp" 70 android:textColor="@color/text_title"
152 android:layout_marginRight="20dp" 71 android:textSize="15sp"
153 android:background="@drawable/selector_for_custom_spinner" 72 android:textStyle="bold" />
154 android:entries="@array/filter_subject"
155 android:popupBackground="@drawable/shape_for_custom_spinner"
156 android:scrollbars="none" />
157 73
158 <TextView 74 <androidx.appcompat.widget.AppCompatSpinner
159 android:id="@+id/tv_student" 75 android:id="@+id/spinner_grade"
160 android:layout_width="wrap_content" 76 style="@style/customSpinnerStyle"
161 android:layout_height="wrap_content" 77 android:layout_width="match_parent"
162 android:layout_centerVertical="true" 78 android:layout_height="40dp"
163 android:layout_marginLeft="20dp" 79 android:layout_centerHorizontal="true"
164 android:layout_marginTop="20dp" 80 android:layout_marginLeft="20dp"
165 android:text="学生" 81 android:layout_marginTop="10dp"
166 android:textColor="@color/text_title" 82 android:layout_marginRight="20dp"
167 android:visibility="gone" 83 android:background="@drawable/selector_for_custom_spinner"
168 android:textSize="15sp" 84 android:popupBackground="@drawable/shape_for_custom_spinner"
169 android:textStyle="bold" /> 85 android:scrollbars="none" />
170 86
171 <androidx.appcompat.widget.AppCompatSpinner 87 <TextView
172 android:id="@+id/spinner_student" 88 android:layout_width="wrap_content"
173 style="@style/customSpinnerStyle" 89 android:layout_height="wrap_content"
174 android:layout_width="match_parent" 90 android:layout_centerVertical="true"
175 android:layout_height="40dp" 91 android:layout_marginLeft="20dp"
176 android:layout_centerHorizontal="true" 92 android:layout_marginTop="20dp"
177 android:layout_marginLeft="20dp" 93 android:text="学期"
178 android:layout_marginTop="10dp" 94 android:textColor="@color/text_title"
179 android:layout_marginRight="20dp" 95 android:textSize="15sp"
180 android:visibility="gone" 96 android:textStyle="bold" />
181 android:background="@drawable/selector_for_custom_spinner"
182 android:entries="@array/filter_subject"
183 android:popupBackground="@drawable/shape_for_custom_spinner"
184 android:scrollbars="none" />
185 97
186 <TextView 98 <androidx.appcompat.widget.AppCompatSpinner
187 android:layout_width="wrap_content" 99 android:id="@+id/spinner_grade1"
188 android:layout_height="wrap_content" 100 style="@style/customSpinnerStyle"
189 android:layout_centerVertical="true" 101 android:layout_width="match_parent"
190 android:layout_marginLeft="20dp" 102 android:layout_height="40dp"
191 android:layout_marginTop="20dp" 103 android:layout_centerHorizontal="true"
192 android:text="来源" 104 android:layout_marginLeft="20dp"
193 android:textColor="@color/text_title" 105 android:layout_marginTop="10dp"
194 android:textSize="15sp" 106 android:layout_marginRight="20dp"
195 android:textStyle="bold" /> 107 android:background="@drawable/selector_for_custom_spinner"
108 android:entries="@array/grade_array"
109 android:popupBackground="@drawable/shape_for_custom_spinner"
110 android:scrollbars="none" />
196 111
197 <RadioGroup 112 <TextView
198 android:id="@+id/type_radio" 113 android:layout_width="wrap_content"
199 android:layout_width="match_parent" 114 android:layout_height="wrap_content"
200 android:layout_height="40dp" 115 android:layout_centerVertical="true"
201 android:layout_marginLeft="20dp" 116 android:layout_marginLeft="20dp"
202 android:layout_marginTop="10dp" 117 android:layout_marginTop="20dp"
203 android:orientation="horizontal"> 118 android:text="科目"
119 android:textColor="@color/text_title"
120 android:textSize="15sp"
121 android:textStyle="bold" />
204 122
205 <RadioButton 123 <androidx.appcompat.widget.AppCompatSpinner
206 android:layout_width="65dp" 124 android:id="@+id/spinner_subject"
207 android:layout_height="match_parent" 125 style="@style/customSpinnerStyle"
126 android:layout_width="match_parent"
127 android:layout_height="40dp"
128 android:layout_centerHorizontal="true"
129 android:layout_marginLeft="20dp"
130 android:layout_marginTop="10dp"
208 android:layout_marginRight="20dp" 131 android:layout_marginRight="20dp"
209 android:background="@drawable/radio_button_selector" 132 android:background="@drawable/selector_for_custom_spinner"
210 android:button="@null" 133 android:entries="@array/filter_subject"
211 android:gravity="center" 134 android:popupBackground="@drawable/shape_for_custom_spinner"
212 android:text="课内" 135 android:scrollbars="none" />
213 android:textColor="@drawable/radio_text_selector" 136
214 android:textSize="14sp" /> 137 <TextView
138 android:layout_width="wrap_content"
139 android:layout_height="wrap_content"
140 android:layout_centerVertical="true"
141 android:layout_marginLeft="20dp"
142 android:layout_marginTop="20dp"
143 android:text="错误原因"
144 android:textColor="@color/text_title"
145 android:textSize="15sp"
146 android:textStyle="bold" />
215 147
216 <RadioButton 148 <androidx.appcompat.widget.AppCompatSpinner
217 android:layout_width="65dp" 149 android:id="@+id/spinner_reason"
218 android:layout_height="match_parent" 150 style="@style/customSpinnerStyle"
151 android:layout_width="match_parent"
152 android:layout_height="40dp"
153 android:layout_centerHorizontal="true"
154 android:layout_marginLeft="20dp"
155 android:layout_marginTop="10dp"
219 android:layout_marginRight="20dp" 156 android:layout_marginRight="20dp"
220 android:background="@drawable/radio_button_selector" 157 android:background="@drawable/selector_for_custom_spinner"
221 android:button="@null" 158 android:entries="@array/filter_subject"
222 android:gravity="center" 159 android:popupBackground="@drawable/shape_for_custom_spinner"
223 android:text="课外" 160 android:scrollbars="none" />
224 android:textColor="@drawable/radio_text_selector"
225 android:textSize="14sp" />
226 </RadioGroup>
227 161
162 <TextView
163 android:id="@+id/tv_student"
164 android:layout_width="wrap_content"
165 android:layout_height="wrap_content"
166 android:layout_centerVertical="true"
167 android:layout_marginLeft="20dp"
168 android:layout_marginTop="20dp"
169 android:text="学生"
170 android:textColor="@color/text_title"
171 android:visibility="gone"
172 android:textSize="15sp"
173 android:textStyle="bold" />
228 174