Commit 0648fe46aa4e4fe63eb3d3ee24a76227f9f655dc

Authored by zhanghaochen
1 parent d37e980ebb
Exists in master

绑定老师

app/src/main/AndroidManifest.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:tools="http://schemas.android.com/tools" 3 xmlns:tools="http://schemas.android.com/tools"
4 package="com.hjx.parent"> 4 package="com.hjx.parent">
5 5
6 6
7 <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> 7 <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
8 <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> 8 <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 -->
9 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> 9 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 -->
10 <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> 10 <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 -->
11 <!-- 6.0系统需要添加权限才能获得wifi列表 --> 11 <!-- 6.0系统需要添加权限才能获得wifi列表 -->
12 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 12 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
13 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 13 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
14 <uses-permission android:name="android.permission.INTERNET" /> 14 <uses-permission android:name="android.permission.INTERNET" />
15 <uses-permission android:name="android.permission.RECORD_AUDIO" /> 15 <uses-permission android:name="android.permission.RECORD_AUDIO" />
16 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 16 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17 17
18 <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> 18 <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
19 <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 19 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
20 <uses-permission android:name="android.permission.WAKE_LOCK" /> 20 <uses-permission android:name="android.permission.WAKE_LOCK" />
21 <uses-permission android:name="android.permission.CAMERA" /> 21 <uses-permission android:name="android.permission.CAMERA" />
22 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 22 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
23 <uses-permission android:name="android.permission.VIBRATE" /> 23 <uses-permission android:name="android.permission.VIBRATE" />
24 24
25 <application 25 <application
26 android:name=".MyApplication" 26 android:name=".MyApplication"
27 android:allowBackup="true" 27 android:allowBackup="true"
28 android:icon="@mipmap/icon" 28 android:icon="@mipmap/icon"
29 android:label="@string/app_name" 29 android:label="@string/app_name"
30 android:networkSecurityConfig="@xml/network_security_config" 30 android:networkSecurityConfig="@xml/network_security_config"
31 android:supportsRtl="true" 31 android:supportsRtl="true"
32 android:theme="@style/Theme.Parent"> 32 android:theme="@style/Theme.Parent">
33 <activity 33 <activity
34 android:name=".LoginActivity" 34 android:name=".LoginActivity"
35 android:exported="true" 35 android:exported="true"
36 android:theme="@style/ThemeSplash"> 36 android:theme="@style/ThemeSplash">
37 <intent-filter> 37 <intent-filter>
38 <action android:name="android.intent.action.MAIN" /> 38 <action android:name="android.intent.action.MAIN" />
39 <category android:name="android.intent.category.LAUNCHER" /> 39 <category android:name="android.intent.category.LAUNCHER" />
40 </intent-filter> 40 </intent-filter>
41 </activity> 41 </activity>
42 <activity 42 <activity
43 android:name=".MainActivity" 43 android:name=".MainActivity"
44 android:launchMode="singleTask" 44 android:launchMode="singleTask"
45 android:theme="@style/Theme.AppCompat.NoActionBar" /> 45 android:theme="@style/Theme.AppCompat.NoActionBar" />
46 <activity 46 <activity
47 android:name=".RegisterActivity" 47 android:name=".RegisterActivity"
48 android:theme="@style/ThemeSplash" /> 48 android:theme="@style/ThemeSplash" />
49 <activity 49 <activity
50 android:name=".UserActivity" 50 android:name=".UserActivity"
51 android:theme="@style/Theme.AppCompat.NoActionBar" /> 51 android:theme="@style/Theme.AppCompat.NoActionBar" />
52 <activity 52 <activity
53 android:name=".YinsiActivity" 53 android:name=".YinsiActivity"
54 android:theme="@style/Theme.AppCompat.NoActionBar" /> 54 android:theme="@style/Theme.AppCompat.NoActionBar" />
55 <activity 55 <activity
56 android:name=".QRActivity" 56 android:name=".QRActivity"
57 android:theme="@style/Theme.AppCompat.NoActionBar" /> 57 android:theme="@style/Theme.AppCompat.NoActionBar" />
58 <activity 58 <activity
59 android:name=".AddStudentActivity" 59 android:name=".AddStudentActivity"
60 android:theme="@style/Theme.AppCompat.NoActionBar" /> 60 android:theme="@style/Theme.AppCompat.NoActionBar" />
61 <activity 61 <activity
62 android:name=".NickActivity" 62 android:name=".NickActivity"
63 android:theme="@style/Theme.AppCompat.NoActionBar" /> 63 android:theme="@style/Theme.AppCompat.NoActionBar" />
64 <activity 64 <activity
65 android:name=".SexActivity" 65 android:name=".SexActivity"
66 android:theme="@style/Theme.AppCompat.NoActionBar" /> 66 android:theme="@style/Theme.AppCompat.NoActionBar" />
67 <activity 67 <activity
68 android:name=".NianActivity" 68 android:name=".NianActivity"
69 android:theme="@style/Theme.AppCompat.NoActionBar" /> 69 android:theme="@style/Theme.AppCompat.NoActionBar" />
70 <activity 70 <activity
71 android:name=".ShenActivity" 71 android:name=".ShenActivity"
72 android:theme="@style/Theme.AppCompat.NoActionBar" /> 72 android:theme="@style/Theme.AppCompat.NoActionBar" />
73 <activity 73 <activity
74 android:name=".AccountActivity" 74 android:name=".AccountActivity"
75 android:theme="@style/Theme.AppCompat.NoActionBar" /> 75 android:theme="@style/Theme.AppCompat.NoActionBar" />
76 76
77 <activity 77 <activity
78 android:name=".ChangePwdActivity" 78 android:name=".ChangePwdActivity"
79 android:theme="@style/Theme.AppCompat.NoActionBar" /> 79 android:theme="@style/Theme.AppCompat.NoActionBar" />
80 <activity 80 <activity
81 android:name=".EditStudentActivity" 81 android:name=".EditStudentActivity"
82 android:theme="@style/Theme.AppCompat.NoActionBar" /> 82 android:theme="@style/Theme.AppCompat.NoActionBar" />
83 <activity 83 <activity
84 android:name=".ChooseActivity" 84 android:name=".ChooseActivity"
85 android:theme="@style/Theme.AppCompat.NoActionBar" /> 85 android:theme="@style/Theme.AppCompat.NoActionBar" />
86 <activity
87 android:name=".AddTeacherActivity"
88 android:theme="@style/Theme.AppCompat.NoActionBar" />
86 89
87 <provider 90 <provider
88 android:name="androidx.core.content.FileProvider" 91 android:name="androidx.core.content.FileProvider"
89 android:authorities="com.hjx.parent.fileprovider" 92 android:authorities="com.hjx.parent.fileprovider"
90 android:exported="false" 93 android:exported="false"
91 android:grantUriPermissions="true"> 94 android:grantUriPermissions="true">
92 <meta-data 95 <meta-data
93 android:name="android.support.FILE_PROVIDER_PATHS" 96 android:name="android.support.FILE_PROVIDER_PATHS"
94 android:resource="@xml/file_provider_paths" 97 android:resource="@xml/file_provider_paths"
95 tools:replace="android:resource" /> 98 tools:replace="android:resource" />
96 </provider> 99 </provider>
97 </application> 100 </application>
98 101
99 </manifest> 102 </manifest>
app/src/main/java/com/hjx/parent/AddStudentActivity.java
1 package com.hjx.parent; 1 package com.hjx.parent;
2 2
3 import android.content.DialogInterface;
3 import android.content.Intent; 4 import android.content.Intent;
4 import android.graphics.Bitmap; 5 import android.graphics.Bitmap;
5 import android.graphics.Color; 6 import android.graphics.Color;
6 import android.net.Uri; 7 import android.net.Uri;
7 import android.os.Build; 8 import android.os.Build;
8 import android.os.Bundle; 9 import android.os.Bundle;
9 import android.os.Environment; 10 import android.os.Environment;
10 import android.provider.MediaStore; 11 import android.provider.MediaStore;
12 import android.text.TextUtils;
11 import android.util.Log; 13 import android.util.Log;
12 import android.view.LayoutInflater; 14 import android.view.LayoutInflater;
13 import android.view.View; 15 import android.view.View;
14 import android.widget.Button; 16 import android.widget.Button;
15 import android.widget.ImageView; 17 import android.widget.ImageView;
18 import android.widget.LinearLayout;
19 import android.widget.RelativeLayout;
16 import android.widget.TextView; 20 import android.widget.TextView;
17 import android.widget.Toast; 21 import android.widget.Toast;
18 22
19 import androidx.core.content.FileProvider; 23 import androidx.core.content.FileProvider;
20 24
21 import com.bumptech.glide.Glide; 25 import com.bumptech.glide.Glide;
22 import com.bumptech.glide.load.resource.bitmap.RoundedCorners; 26 import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
23 import com.bumptech.glide.request.RequestOptions; 27 import com.bumptech.glide.request.RequestOptions;
24 import com.google.android.material.bottomsheet.BottomSheetDialog; 28 import com.google.android.material.bottomsheet.BottomSheetDialog;
29 import com.google.gson.Gson;
25 import com.hjq.permissions.OnPermissionCallback; 30 import com.hjq.permissions.OnPermissionCallback;
26 import com.hjq.permissions.Permission; 31 import com.hjq.permissions.Permission;
27 import com.hjq.permissions.XXPermissions; 32 import com.hjq.permissions.XXPermissions;
28 import com.prws.common.base.BaseActivity; 33 import com.prws.common.base.BaseActivity;
29 import com.prws.common.base.BasePresenter; 34 import com.prws.common.base.BasePresenter;
30 import com.prws.common.bean.ResponseResult; 35 import com.prws.common.bean.ResponseResult;
36 import com.prws.common.bean.Teacher;
31 import com.prws.common.net.NetWorks; 37 import com.prws.common.net.NetWorks;
32 import com.prws.common.utils.LogUtil; 38 import com.prws.common.utils.LogUtil;
33 import com.prws.common.utils.ScreenUtils; 39 import com.prws.common.utils.ScreenUtils;
34 import com.prws.common.utils.SharedPreferencesUtil; 40 import com.prws.common.utils.SharedPreferencesUtil;
35 41
36 import org.json.JSONObject; 42 import org.json.JSONObject;
37 43
38 import java.io.File; 44 import java.io.File;
39 import java.io.FileOutputStream; 45 import java.io.FileOutputStream;
40 import java.io.IOException; 46 import java.io.IOException;
41 import java.util.HashMap; 47 import java.util.HashMap;
42 import java.util.List; 48 import java.util.List;
43 import java.util.Map; 49 import java.util.Map;
44 50
45 import butterknife.BindView; 51 import butterknife.BindView;
46 import butterknife.OnClick; 52 import butterknife.OnClick;
47 import io.reactivex.Observer; 53 import io.reactivex.Observer;
48 import io.reactivex.disposables.Disposable; 54 import io.reactivex.disposables.Disposable;
49 import okhttp3.ResponseBody; 55 import okhttp3.ResponseBody;
50 56
51 public class AddStudentActivity extends BaseActivity { 57 public class AddStudentActivity extends BaseActivity {
52 @Override 58 @Override
53 protected int layoutResId() { 59 protected int layoutResId() {
54 return R.layout.activity_add_stu; 60 return R.layout.activity_add_stu;
55 } 61 }
56 62
57 @Override 63 @Override
58 public Object getContract() { 64 public Object getContract() {
59 return null; 65 return null;
60 } 66 }
61 67
62 @Override 68 @Override
63 public BasePresenter getPresenter() { 69 public BasePresenter getPresenter() {
64 return null; 70 return null;
65 } 71 }
66 72
67 View view_2; 73 View view_2;
68 View view_3; 74 View view_3;
69 View view_4; 75 View view_4;
70 View view_5; 76 View view_5;
77 @BindView(R.id.tv_teacher)
78 TextView tv_teacher;
79 @BindView(R.id.rl_teacher)
80 RelativeLayout rl_teacher;
81 @BindView(R.id.iv_teacher)
82 ImageView iv_teacher;
83 @BindView(R.id.tv_bind)
84 TextView tv_bind;
71 Button btn_next; 85 Button btn_next;
72 TextView tv_name, tv_sex, tv_nian, tv_shen; 86 TextView tv_name, tv_sex, tv_nian, tv_shen;
73 @BindView(R.id.iv_avatar) 87 @BindView(R.id.iv_avatar)
74 ImageView iv_avatar; 88 ImageView iv_avatar;
75 89
76 @Override 90 @Override
77 protected void initView() { 91 protected void initView() {
78 view_2 = findViewById(R.id.view_2); 92 view_2 = findViewById(R.id.view_2);
79 view_3 = findViewById(R.id.view_3); 93 view_3 = findViewById(R.id.view_3);
80 view_4 = findViewById(R.id.view_4); 94 view_4 = findViewById(R.id.view_4);
81 view_5 = findViewById(R.id.view_5); 95 view_5 = findViewById(R.id.view_5);
82 tv_name = findViewById(R.id.tv_name); 96 tv_name = findViewById(R.id.tv_name);
83 tv_sex = findViewById(R.id.tv_sex); 97 tv_sex = findViewById(R.id.tv_sex);
84 tv_nian = findViewById(R.id.tv_nian); 98 tv_nian = findViewById(R.id.tv_nian);
85 tv_shen = findViewById(R.id.tv_shen); 99 tv_shen = findViewById(R.id.tv_shen);
86 btn_next = findViewById(R.id.btn_next); 100 btn_next = findViewById(R.id.btn_next);
87 } 101 }
88 102
89 boolean isName = false; 103 boolean isName = false;
90 boolean isSex = false; 104 boolean isSex = false;
91 boolean isNian = false; 105 boolean isNian = false;
92 boolean isShen = false; 106 boolean isShen = false;
93 private static int CAMERA_REQUEST_CODE = 343; 107 private static int CAMERA_REQUEST_CODE = 343;
94 private static int ALBUM_REQUEST_CODE = 456; 108 private static int ALBUM_REQUEST_CODE = 456;
95 private static int CROP_REQUEST_CODE = 234; 109 private static int CROP_REQUEST_CODE = 234;
110 private static int BIND_TEACHER_CODE = 345;
96 private File tempFile; 111 private File tempFile;
97 private String path; 112 private String path;
113 private Teacher teacher;
98 114
99 @Override 115 @Override
100 protected void onStart() { 116 protected void onStart() {
101 super.onStart(); 117 super.onStart();
102 String name = (String) SharedPreferencesUtil.getData("setName", ""); 118 String name = (String) SharedPreferencesUtil.getData("setName", "");
103 String sex = (String) SharedPreferencesUtil.getData("setSex", ""); 119 String sex = (String) SharedPreferencesUtil.getData("setSex", "");
104 String nian = (String) SharedPreferencesUtil.getData("setNian", "") + SharedPreferencesUtil.getData("setXueq", ""); 120 String nian = (String) SharedPreferencesUtil.getData("setNian", "") + SharedPreferencesUtil.getData("setXueq", "");
105 String shen = (String) SharedPreferencesUtil.getData("setShen", ""); 121 String shen = (String) SharedPreferencesUtil.getData("setShen", "");
106 122
107 if (name != null && name.length() > 0) { 123 if (name != null && name.length() > 0) {
108 tv_name.setText(name); 124 tv_name.setText(name);
109 isName = true; 125 isName = true;
110 } else { 126 } else {
111 isName = false; 127 isName = false;
112 } 128 }
113 if (sex != null && sex.length() > 0) { 129 if (sex != null && sex.length() > 0) {
114 tv_sex.setText(sex); 130 tv_sex.setText(sex);
115 isSex = true; 131 isSex = true;
116 } else { 132 } else {
117 isSex = false; 133 isSex = false;
118 } 134 }
119 if (nian != null && nian.length() > 0) { 135 if (nian != null && nian.length() > 0) {
120 tv_nian.setText(nian); 136 tv_nian.setText(nian);
121 isNian = true; 137 isNian = true;
122 } else { 138 } else {
123 isNian = false; 139 isNian = false;
124 } 140 }
125 if (shen != null && shen.length() > 0) { 141 if (shen != null && shen.length() > 0) {
126 tv_shen.setText(shen); 142 tv_shen.setText(shen);
127 isShen = true; 143 isShen = true;
128 } else { 144 } else {
129 isShen = false; 145 isShen = false;
130 } 146 }
131 147
132 if (isName && isSex && isNian && isShen) { 148 if (isName && isSex && isNian && isShen) {
133 btn_next.setTextColor(Color.WHITE); 149 btn_next.setTextColor(Color.WHITE);
134 btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn)); 150 btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn));
135 } 151 }
136 152
137 } 153 }
138 154
139 @Override 155 @Override
140 protected void initListener() { 156 protected void initListener() {
141 view_2.setOnClickListener(view -> startActivity(NickActivity.class)); 157 view_2.setOnClickListener(view -> startActivity(NickActivity.class));
142 view_3.setOnClickListener(view -> startActivity(SexActivity.class)); 158 view_3.setOnClickListener(view -> startActivity(SexActivity.class));
143 view_4.setOnClickListener(view -> startActivity(NianActivity.class)); 159 view_4.setOnClickListener(view -> startActivity(NianActivity.class));
144 view_5.setOnClickListener(view -> startActivity(ShenActivity.class)); 160 view_5.setOnClickListener(view -> startActivity(ShenActivity.class));
145 findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); 161 findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed());
146 btn_next.setOnClickListener(view -> { 162 btn_next.setOnClickListener(view -> {
147 if (isName && isSex && isNian && isShen) { 163 if (isName && isSex && isNian && isShen) {
148 addStudent(); 164 if (teacher != null) {
165 addStudent();
166 } else {
167 showDialog("温馨提示", "您还未绑定老师,是否绑定?", "去绑定", "暂不绑定", new DialogInterface.OnClickListener() {
168 @Override
169 public void onClick(DialogInterface dialogInterface, int i) {
170 dialogInterface.dismiss();
171 showDialog("温馨提示", "您暂未绑定老师,如需绑定老师\n" + "请联系400-800-3813", "确定", "", null, new DialogInterface.OnClickListener() {
172 @Override
173 public void onClick(DialogInterface dialogInterface, int i) {
174 addStudent();
175 }
176 });
177 }
178 }, new DialogInterface.OnClickListener() {
179 @Override
180 public void onClick(DialogInterface dialogInterface, int i) {
181 Intent intent = new Intent(AddStudentActivity.this, AddTeacherActivity.class);
182 startActivityForResult(intent, BIND_TEACHER_CODE);
183 }
184 });
185 }
149 } else { 186 } else {
150 Toast.makeText(this, "请完成设置后点击", Toast.LENGTH_SHORT).show(); 187 Toast.makeText(this, "请完成设置后点击", Toast.LENGTH_SHORT).show();
151 } 188 }
152 }); 189 });
153 } 190 }
154 191
155 @Override 192 @Override
156 protected void onDestroy() { 193 protected void onDestroy() {
157 super.onDestroy(); 194 super.onDestroy();
158 SharedPreferencesUtil.putData("setName", ""); 195 SharedPreferencesUtil.putData("setName", "");
159 SharedPreferencesUtil.putData("setSex", ""); 196 SharedPreferencesUtil.putData("setSex", "");
160 SharedPreferencesUtil.putData("setNian", ""); 197 SharedPreferencesUtil.putData("setNian", "");
161 SharedPreferencesUtil.putData("setShen", ""); 198 SharedPreferencesUtil.putData("setShen", "");
162 SharedPreferencesUtil.putData("setXueq", ""); 199 SharedPreferencesUtil.putData("setXueq", "");
163 SharedPreferencesUtil.putData("grade", 0); 200 SharedPreferencesUtil.putData("grade", 0);
164 } 201 }
165 202
166 203
167 public void addStudent() { 204 public void addStudent() {
168 String name = (String) SharedPreferencesUtil.getData("setName", ""); 205 String name = (String) SharedPreferencesUtil.getData("setName", "");
169 String sex = (String) SharedPreferencesUtil.getData("setSex", ""); 206 String sex = (String) SharedPreferencesUtil.getData("setSex", "");
170 String nian = (String) SharedPreferencesUtil.getData("setNian", ""); 207 String nian = (String) SharedPreferencesUtil.getData("setNian", "");
171 String shen = (String) SharedPreferencesUtil.getData("setShen", ""); 208 String shen = (String) SharedPreferencesUtil.getData("setShen", "");
172 String xueq = (String) SharedPreferencesUtil.getData("setXueq", ""); 209 String xueq = (String) SharedPreferencesUtil.getData("setXueq", "");
173
174
175 Map map = new HashMap(); 210 Map map = new HashMap();
176 map.put("nickName", name); 211 map.put("nickName", name);
177 map.put("gender", "男".equals(sex) ? 0 : 1); 212 map.put("gender", "男".equals(sex) ? 0 : 1);
178 map.put("gradeId", SharedPreferencesUtil.getData("grade", 1)); 213 map.put("gradeId", SharedPreferencesUtil.getData("grade", 1));
179 map.put("parentIdentity", shen); 214 map.put("parentIdentity", shen);
180 map.put("term", xueq); 215 map.put("term", xueq);
216 if (teacher != null)
217 map.put("userId", teacher.getId());
181 if (path != null) { 218 if (path != null) {
182 map.put("photo", path); 219 map.put("photo", path);
183 } 220 }
184
185 NetWorks.registerStudent(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { 221 NetWorks.registerStudent(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() {
186 @Override 222 @Override
187 public void onSubscribe(Disposable d) { 223 public void onSubscribe(Disposable d) {
188 224
189 } 225 }
190 226
191 @Override 227 @Override
192 public void onNext(ResponseBody responseBody) { 228 public void onNext(ResponseBody responseBody) {
193 try { 229 try {
194
195 String str = responseBody.string().toString(); 230 String str = responseBody.string().toString();
196 LogUtil.e(TAG, "----" + str); 231 LogUtil.e(TAG, "----" + str);
197 JSONObject jo = new JSONObject(str); 232 JSONObject jo = new JSONObject(str);
198 boolean isSucceed = jo.getBoolean("success"); 233 boolean isSucceed = jo.getBoolean("success");
199 if (isSucceed) { 234 if (isSucceed) {
200 finish(); 235 finish();
201 } else { 236 } else {
202 Toast.makeText(AddStudentActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); 237 Toast.makeText(AddStudentActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show();
203 } 238 }
204 } catch (Exception e) { 239 } catch (Exception e) {
205 e.printStackTrace(); 240 e.printStackTrace();
206 Toast.makeText(AddStudentActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); 241 Toast.makeText(AddStudentActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show();
207 } 242 }
208
209 } 243 }
210 244
211 @Override 245 @Override
212 public void onError(Throwable e) { 246 public void onError(Throwable e) {
213 247
214 } 248 }
215 249
216 @Override 250 @Override
217 public void onComplete() { 251 public void onComplete() {
218 252
219 } 253 }
220 254
221 }); 255 });
222 } 256 }
223 257
258
224 @Override 259 @Override
225 protected void initData() { 260 protected void initData() {
226 261
227 } 262 }
228 263
229 @Override 264 @Override
230 public void onNetChanged(int netWorkState) { 265 public void onNetChanged(int netWorkState) {
231 266
232 } 267 }
233 268
234 @OnClick(R.id.iv_avatar) 269 @OnClick(R.id.iv_avatar)
235 public void showButtonDialog(View view) { 270 public void showButtonDialog(View view) {
236 BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog); 271 BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
237 View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null); 272 View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null);
238 dialog.setContentView(bottomView); 273 dialog.setContentView(bottomView);
239 bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { 274 bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() {
240 @Override 275 @Override
241 public void onClick(View view) { 276 public void onClick(View view) {
242 dialog.dismiss(); 277 dialog.dismiss();
243 if (!XXPermissions.isGranted(AddStudentActivity.this, Permission.CAMERA)) { 278 if (!XXPermissions.isGranted(AddStudentActivity.this, Permission.CAMERA)) {
244 XXPermissions.with(AddStudentActivity.this) 279 XXPermissions.with(AddStudentActivity.this)
245 // 申请多个权限 280 // 申请多个权限
246 .permission(Permission.CAMERA) 281 .permission(Permission.CAMERA)
247 .request(new OnPermissionCallback() { 282 .request(new OnPermissionCallback() {
248 @Override 283 @Override
249 public void onGranted(List<String> permissions, boolean all) { 284 public void onGranted(List<String> permissions, boolean all) {
250 if (all) { 285 if (all) {
251 //开启扫码界面 286 //开启扫码界面
252 getPicFromCamera(); 287 getPicFromCamera();
253 } else { 288 } else {
254 Toast.makeText(AddStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); 289 Toast.makeText(AddStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show();
255 } 290 }
256 } 291 }
257 292
258 @Override 293 @Override
259 public void onDenied(List<String> permissions, boolean never) { 294 public void onDenied(List<String> permissions, boolean never) {
260 XXPermissions.startPermissionActivity(AddStudentActivity.this, permissions); 295 XXPermissions.startPermissionActivity(AddStudentActivity.this, permissions);
261 } 296 }
262 }); 297 });
263 } else { 298 } else {
264 getPicFromCamera(); 299 getPicFromCamera();
265 } 300 }
266 } 301 }
267 }); 302 });
268 bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { 303 bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() {
269 @Override 304 @Override
270 public void onClick(View view) { 305 public void onClick(View view) {
271 dialog.dismiss(); 306 dialog.dismiss();
272 getPicFromAlbm(); 307 getPicFromAlbm();
273 } 308 }
274 }); 309 });
275 bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { 310 bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
276 @Override 311 @Override
277 public void onClick(View view) { 312 public void onClick(View view) {
278 dialog.dismiss(); 313 dialog.dismiss();
279 } 314 }
280 }); 315 });
281 dialog.show(); 316 dialog.show();
282 } 317 }
283 318
284 private void cropPhoto(Uri uri) { 319 private void cropPhoto(Uri uri) {
285 Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg")); 320 Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"));
286 Intent intent = new Intent("com.android.camera.action.CROP"); 321 Intent intent = new Intent("com.android.camera.action.CROP");
287 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 322 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
288 //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片 323 //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片
289 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 324 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
290 } 325 }
291 intent.setDataAndType(uri, "image/*"); 326 intent.setDataAndType(uri, "image/*");
292 intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪 327 intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪
293 intent.putExtra("scale", true);// 设置缩放 328 intent.putExtra("scale", true);// 设置缩放
294 intent.putExtra("scaleUpIfNeeded", true);// 去黑边 329 intent.putExtra("scaleUpIfNeeded", true);// 去黑边
295 intent.putExtra("aspectX", 1); 330 intent.putExtra("aspectX", 1);
296 intent.putExtra("aspectY", 1); 331 intent.putExtra("aspectY", 1);
297 //上述两个属性控制裁剪框的缩放比例。 332 //上述两个属性控制裁剪框的缩放比例。
298 //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。 333 //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。
299 intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。 334 intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。
300 intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存, 335 intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存,
301 intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式 336 intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式
302 intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap 337 intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap
303 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径 338 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径
304 startActivityForResult(intent, CROP_REQUEST_CODE); 339 startActivityForResult(intent, CROP_REQUEST_CODE);
305 } 340 }
306 341
307 @Override 342 @Override
308 protected void onActivityResult(int requestCode, int resultCode, Intent intent) { 343 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
309 super.onActivityResult(requestCode, resultCode, intent); 344 super.onActivityResult(requestCode, resultCode, intent);
310 if (requestCode == CAMERA_REQUEST_CODE) { 345 if (requestCode == CAMERA_REQUEST_CODE) {
311 if (resultCode == RESULT_OK) { 346 if (resultCode == RESULT_OK) {
312 //用相机返回的照片去调用剪裁也需要对Uri进行处理 347 //用相机返回的照片去调用剪裁也需要对Uri进行处理
313 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 348 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
314 Uri contentUri = FileProvider.getUriForFile(AddStudentActivity.this, 349 Uri contentUri = FileProvider.getUriForFile(AddStudentActivity.this,
315 this.getPackageName() + ".fileprovider", tempFile); 350 this.getPackageName() + ".fileprovider", tempFile);
316 cropPhoto(contentUri); 351 cropPhoto(contentUri);
317 } else { 352 } else {
318 cropPhoto(Uri.fromFile(tempFile)); 353 cropPhoto(Uri.fromFile(tempFile));
319 } 354 }
320 } 355 }
321 } else if (requestCode == ALBUM_REQUEST_CODE) { 356 } else if (requestCode == ALBUM_REQUEST_CODE) {
322 if (resultCode == RESULT_OK) { 357 if (resultCode == RESULT_OK) {
323 Uri uri = intent.getData(); 358 Uri uri = intent.getData();
324 cropPhoto(uri); 359 cropPhoto(uri);
325 } 360 }
326 } else if (requestCode == CROP_REQUEST_CODE) { 361 } else if (requestCode == CROP_REQUEST_CODE) {
327 if (intent == null) { 362 if (intent == null) {
328 return; 363 return;
329 } 364 }
330 Bundle bundle = intent.getExtras(); 365 Bundle bundle = intent.getExtras();
331 if (bundle != null) { 366 if (bundle != null) {
332 //在这里获得了剪裁后的Bitmap对象,可以用于上传 367 //在这里获得了剪裁后的Bitmap对象,可以用于上传
333 Bitmap image = bundle.getParcelable("data"); 368 Bitmap image = bundle.getParcelable("data");
334 //设置到ImageView上 369 //设置到ImageView上
335 //也可以进行一些保存、压缩等操作后上传 370 //也可以进行一些保存、压缩等操作后上传
336 File file = saveImage("head_output", image); 371 File file = saveImage("head_output", image);
337 uploadAvatar(file); 372 uploadAvatar(file);
338 // Log.d("dsadsadsa",path); 373 }
374 } else if (requestCode == BIND_TEACHER_CODE && resultCode == 1000) {
375 String t = intent.getStringExtra("teacher");
376 teacher = new Gson().fromJson(t, Teacher.class);
377 rl_teacher.setVisibility(View.VISIBLE);
378 tv_bind.setText("重新绑定");
379 tv_teacher.setText(teacher.getUserName());
380 if (!TextUtils.isEmpty(teacher.getPhoto())) {
381 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AddStudentActivity.this, 20));
382 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
383 Glide.with(AddStudentActivity.this).load(teacher.getPhoto()).apply(options).into(iv_teacher);
339 } 384 }
340 } 385 }
341 } 386 }
342 387
343 private void uploadAvatar(File file) { 388 private void uploadAvatar(File file) {
344 NetWorks.uploadAvatar(file, new Observer<ResponseResult<Map<String, String>>>() { 389 NetWorks.uploadAvatar(file, new Observer<ResponseResult<Map<String, String>>>() {
345 @Override 390 @Override
346 public void onSubscribe(Disposable d) { 391 public void onSubscribe(Disposable d) {
347 392
348 } 393 }
349 394
350 @Override 395 @Override
351 public void onNext(ResponseResult<Map<String, String>> responseBody) { 396 public void onNext(ResponseResult<Map<String, String>> responseBody) {
352 if (responseBody.getData() != null && responseBody.getCode() == 200) { 397 if (responseBody.getData() != null && responseBody.getCode() == 200) {
353 path = responseBody.getData().get("imageUrl"); 398 path = responseBody.getData().get("imageUrl");
354 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AddStudentActivity.this, 45)); 399 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AddStudentActivity.this, 45));
355 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); 400 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
356 Glide.with(AddStudentActivity.this).load(path).apply(options).into(iv_avatar); 401 Glide.with(AddStudentActivity.this).load(path).apply(options).into(iv_avatar);
357 } 402 }
358 } 403 }
359 404
360 @Override 405 @Override
361 public void onError(Throwable e) { 406 public void onError(Throwable e) {
362 e.toString(); 407 e.toString();
363 } 408 }
364 409
365 @Override 410 @Override
366 public void onComplete() { 411 public void onComplete() {
367 412
368 } 413 }
369 }); 414 });
370 } 415 }
371 416
372 public File saveImage(String name, Bitmap bmp) { 417 public File saveImage(String name, Bitmap bmp) {
373 File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath()); 418 File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath());
374 if (!appDir.exists()) { 419 if (!appDir.exists()) {
375 appDir.mkdir(); 420 appDir.mkdir();
376 } 421 }
377 String fileName = name + ".jpg"; 422 String fileName = name + ".jpg";
378 File file = new File(appDir, fileName); 423 File file = new File(appDir, fileName);
379 try { 424 try {
380 FileOutputStream fos = new FileOutputStream(file); 425 FileOutputStream fos = new FileOutputStream(file);
381 bmp.compress(Bitmap.CompressFormat.PNG, 100, fos); 426 bmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
382 fos.flush(); 427 fos.flush();
383 fos.close(); 428 fos.close();
384 return file; 429 return file;
385 } catch (IOException e) { 430 } catch (IOException e) {
386 Log.d("dsadsadsa", e.getLocalizedMessage());
387 e.printStackTrace(); 431 e.printStackTrace();
388 } 432 }
389 return null; 433 return null;
390 } 434 }
391 435
392 private void getPicFromCamera() { 436 private void getPicFromCamera() {
393 //用于保存调用相机拍照后所生成的文件 437 //用于保存调用相机拍照后所生成的文件
394 tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"); 438 tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg");
395 //跳转到调用系统相机 439 //跳转到调用系统相机
396 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 440 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
397 //判断版本 441 //判断版本
398 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri 442 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri
399 intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 443 intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
400 Uri contentUri = FileProvider.getUriForFile(AddStudentActivity.this, 444 Uri contentUri = FileProvider.getUriForFile(AddStudentActivity.this,
401 this.getPackageName() + ".fileprovider", tempFile); 445 this.getPackageName() + ".fileprovider", tempFile);
402 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); 446 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);
403 } else { //否则使用Uri.fromFile(file)方法获取Uri 447 } else { //否则使用Uri.fromFile(file)方法获取Uri
404 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); 448 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
405 } 449 }
406 startActivityForResult(intent, CAMERA_REQUEST_CODE); 450 startActivityForResult(intent, CAMERA_REQUEST_CODE);
407 } 451 }
408 452
409 /** 453 /**
410 * 从相册获取图片 454 * 从相册获取图片
411 */ 455 */
412 private void getPicFromAlbm() { 456 private void getPicFromAlbm() {
413 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); 457 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
414 photoPickerIntent.setType("image/*"); 458 photoPickerIntent.setType("image/*");
415 startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE); 459 startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE);
416 } 460 }
417 461
462
463 @OnClick(R.id.view_6)
app/src/main/java/com/hjx/parent/AddTeacherActivity.java
File was created 1 package com.hjx.parent;
2
3 import android.content.Intent;
4 import android.graphics.Color;
5 import android.text.Editable;
6 import android.text.TextUtils;
7 import android.text.TextWatcher;
8 import android.view.View;
9 import android.widget.Button;
10 import android.widget.EditText;
11 import android.widget.ImageView;
12 import android.widget.RelativeLayout;
13 import android.widget.TextView;
14
15 import com.bumptech.glide.Glide;
16 import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
17 import com.bumptech.glide.request.RequestOptions;
18 import com.google.gson.Gson;
19 import com.prws.common.base.BaseActivity;
20 import com.prws.common.base.BasePresenter;
21 import com.prws.common.bean.ResponseResult;
22 import com.prws.common.bean.Teacher;
23 import com.prws.common.net.NetWorks;
24 import com.prws.common.utils.Common;
25 import com.prws.common.utils.ScreenUtils;
26
27 import butterknife.BindView;
28 import butterknife.OnClick;
29 import io.reactivex.Observer;
30 import io.reactivex.disposables.Disposable;
31
32 public class AddTeacherActivity extends BaseActivity {
33 @BindView(R.id.et_1)
34 EditText et_1;
35 @BindView(R.id.btn_next)
36 Button btn_next;
37 @BindView(R.id.rl_teacher)
38 RelativeLayout rl_teacher;
39 @BindView(R.id.iv_teacher)
40 ImageView iv_teacher;
41 @BindView(R.id.tv_teacher)
42 TextView tv_teacher;
43 Teacher teacher;
44
45 @Override
46 protected int layoutResId() {
47 return R.layout.activity_add_teacher;
48 }
49
50 @Override
51 public Object getContract() {
52 return null;
53 }
54
55 @Override
56 public BasePresenter getPresenter() {
57 return null;
58 }
59
60 @Override
61 protected void initView() {
62 et_1.addTextChangedListener(new TextWatcher() {
63 @Override
64 public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
65
66 }
67
68 @Override
69 public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
70
71 }
72
73 @Override
74 public void afterTextChanged(Editable editable) {
75 if (editable.length() == 11) {
76 if (Common.isValidPhoneNumber(editable.toString())) {
77 searchTeacher(editable.toString());
78 } else {
79 rl_teacher.setVisibility(View.GONE);
80 showToast("请输入正确的手机号码");
81 btn_next.setTextColor(Color.parseColor("#999999"));
82 btn_next.setBackgroundResource(R.drawable.bg_solid_btn_grad);
83 btn_next.setEnabled(false);
84 }
85 } else {
86 rl_teacher.setVisibility(View.GONE);
87 btn_next.setBackgroundResource(R.drawable.bg_solid_btn_grad);
88 btn_next.setTextColor(Color.parseColor("#999999"));
89 btn_next.setEnabled(false);
90 }
91 }
92 });
93 }
94
95
96 public void searchTeacher(String phone) {
97 NetWorks.searchTeacher(phone, new Observer<ResponseResult<Teacher>>() {
98 @Override
99 public void onSubscribe(Disposable d) {
100
101 }
102
103 @Override
104 public void onNext(ResponseResult<Teacher> result) {
105 if (result != null && result.getCode() == 200) {
106 teacher = result.getData();
107 rl_teacher.setVisibility(View.VISIBLE);
108 if (!TextUtils.isEmpty(teacher.getPhoto())) {
109 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(AddTeacherActivity.this, 20));
110 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
111 Glide.with(AddTeacherActivity.this).load(teacher.getPhoto()).apply(options).into(iv_teacher);
112 } else {
113 iv_teacher.setImageResource(R.mipmap.ic_teacher_male);
114 }
115 tv_teacher.setText(teacher.getUserName());
116 btn_next.setBackgroundResource(R.drawable.bg_solid_btn);
117 btn_next.setTextColor(Color.WHITE);
118 btn_next.setEnabled(true);
119 }
120 }
121
122 @Override
123 public void onError(Throwable e) {
124
125 }
126
127 @Override
128 public void onComplete() {
129
130 }
131 });
132 }
133
134 @OnClick(R.id.btn_next)
135 public void confirm(View view) {
136 Intent intent = new Intent();
137 intent.putExtra("teacher", new Gson().toJson(teacher));
138 setResult(1000,intent);
139 finish();
140 }
141
142 @Override
143 protected void initListener() {
144
145 }
146
147 @Override
148 protected void initData() {
149
150 }
151
152 @Override
153 public void onNetChanged(int netWorkState) {
154
155 }
156
157 }
158
app/src/main/java/com/hjx/parent/ChangePwdActivity.java
1 package com.hjx.parent; 1 package com.hjx.parent;
2 2
3 import android.widget.EditText; 3 import android.widget.EditText;
4 import android.widget.TextView; 4 import android.widget.TextView;
5 import android.widget.Toast; 5 import android.widget.Toast;
6 6
7 import com.prws.common.base.BaseActivity; 7 import com.prws.common.base.BaseActivity;
8 import com.prws.common.base.BasePresenter; 8 import com.prws.common.base.BasePresenter;
9 import com.prws.common.net.NetWorks; 9 import com.prws.common.net.NetWorks;
10 import com.prws.common.utils.LogUtil; 10 import com.prws.common.utils.LogUtil;
11 import com.prws.common.utils.SharedPreferencesUtil; 11 import com.prws.common.utils.SharedPreferencesUtil;
12 12
13 import org.json.JSONObject; 13 import org.json.JSONObject;
14 14
15 import java.util.HashMap; 15 import java.util.HashMap;
16 import java.util.Map; 16 import java.util.Map;
17 17
18 import butterknife.BindView; 18 import butterknife.BindView;
19 import io.reactivex.Observer; 19 import io.reactivex.Observer;
20 import io.reactivex.disposables.Disposable; 20 import io.reactivex.disposables.Disposable;
21 import okhttp3.ResponseBody; 21 import okhttp3.ResponseBody;
22 22
23 public class ChangePwdActivity extends BaseActivity { 23 public class ChangePwdActivity extends BaseActivity {
24 @BindView(R.id.et_old_password) 24 @BindView(R.id.et_old_password)
25 EditText et_old_password; 25 EditText et_old_password;
26 @BindView(R.id.et_pwd_2) 26 @BindView(R.id.et_pwd_2)
27 EditText et_pwd_2; 27 EditText et_pwd_2;
28 28
29 @Override 29 @Override
30 protected int layoutResId() { 30 protected int layoutResId() {
31 return R.layout.activity_changem; 31 return R.layout.activity_changem;
32 } 32 }
33 33
34 @Override 34 @Override
35 public Object getContract() { 35 public Object getContract() {
36 return null; 36 return null;
37 } 37 }
38 38
39 @Override 39 @Override
40 public BasePresenter getPresenter() { 40 public BasePresenter getPresenter() {
41 return null; 41 return null;
42 } 42 }
43 43
44 44
45 EditText et_pwd; 45 EditText et_pwd;
46 46
47 @Override 47 @Override
48 protected void initView() { 48 protected void initView() {
49 et_pwd = findViewById(R.id.et_pwd); 49 et_pwd = findViewById(R.id.et_pwd);
50 } 50 }
51 51
52 @Override 52 @Override
53 protected void initListener() { 53 protected void initListener() {
54 findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); 54 findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed());
55 findViewById(R.id.btn_next).setOnClickListener(view -> { 55 findViewById(R.id.btn_next).setOnClickListener(view -> {
56 String pwd = et_pwd.getText().toString().trim(); 56 String pwd = et_pwd.getText().toString().trim();
57 if (pwd == null || pwd.length() == 0) { 57 if (pwd == null || pwd.length() == 0) {
58 Toast.makeText(this, "密码不能为空", Toast.LENGTH_SHORT).show(); 58 Toast.makeText(this, "密码不能为空", Toast.LENGTH_SHORT).show();
59 return; 59 return;
60 } 60 }
61 if (pwd.length() < 6 || pwd.length() > 16) { 61 if (pwd.length() < 6 || pwd.length() > 16) {
62 Toast.makeText(this, "密码必须为6-16位,数字或字母", Toast.LENGTH_SHORT).show(); 62 Toast.makeText(this, "密码必须为6-16位,数字或字母", Toast.LENGTH_SHORT).show();
63 return; 63 return;
64 } 64 }
65 if (!pwd.equals(et_pwd_2.getText().toString())) { 65 if (!pwd.equals(et_pwd_2.getText().toString())) {
66 Toast.makeText(this, "两次密码输入不一致", Toast.LENGTH_SHORT).show(); 66 Toast.makeText(this, "两次密码输入不一致", Toast.LENGTH_SHORT).show();
67 return; 67 return;
68 } 68 }
69 changePwd(pwd); 69 changePwd(pwd);
70 }); 70 });
71 } 71 }
72 72
73 public void changePwd(String pwd) { 73 public void changePwd(String pwd) {
74 String userId = (String) SharedPreferencesUtil.getData("userId", ""); 74 String userId = (String) SharedPreferencesUtil.getData("userId", "");
75 Map map = new HashMap(); 75 Map map = new HashMap();
76 map.put("userId", userId); 76 map.put("userId", userId);
77 map.put("password", pwd); 77 map.put("password", pwd);
78 map.put("oldPassword", et_old_password.getText().toString()); 78 map.put("oldPassword", et_old_password.getText().toString());
79 NetWorks.changePassword(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { 79 NetWorks.changePassword(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() {
80 @Override 80 @Override
81 public void onSubscribe(Disposable d) { 81 public void onSubscribe(Disposable d) {
82 82
83 } 83 }
84 84
85 @Override 85 @Override
86 public void onNext(ResponseBody responseBody) { 86 public void onNext(ResponseBody responseBody) {
87 try { 87 try {
88 88
89 String str = responseBody.string().toString(); 89 String str = responseBody.string().toString();
90
91
92 LogUtil.e(TAG, "----" + str); 90 LogUtil.e(TAG, "----" + str);
93 JSONObject jo = new JSONObject(str); 91 JSONObject jo = new JSONObject(str);
94 boolean isSucceed = jo.getBoolean("success"); 92 boolean isSucceed = jo.getBoolean("success");
95 if (isSucceed) { 93 if (isSucceed) {
96 Toast.makeText(ChangePwdActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); 94 Toast.makeText(ChangePwdActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
97 finish(); 95 finish();
98 96
99 } else { 97 } else {
100 Toast.makeText(ChangePwdActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); 98 Toast.makeText(ChangePwdActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show();
101 } 99 }
102 } catch (Exception e) { 100 } catch (Exception e) {
103 e.printStackTrace(); 101 e.printStackTrace();
104 Toast.makeText(ChangePwdActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); 102 Toast.makeText(ChangePwdActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show();
105 } 103 }
106 104
107 } 105 }
108 106
109 @Override 107 @Override
110 public void onError(Throwable e) { 108 public void onError(Throwable e) {
111 109
112 } 110 }
113 111
114 @Override 112 @Override
115 public void onComplete() { 113 public void onComplete() {
116 114
117 } 115 }
118 }); 116 });
119 117
120 } 118 }
121 119
122 @Override 120 @Override
123 protected void initData() { 121 protected void initData() {
124 122
125 } 123 }
126 124
127 @Override 125 @Override
128 public void onNetChanged(int netWorkState) { 126 public void onNetChanged(int netWorkState) {
129 127
130 } 128 }
131 } 129 }
app/src/main/java/com/hjx/parent/ChooseActivity.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.text.TextUtils; 4 import android.text.TextUtils;
5 import android.view.View; 5 import android.view.View;
6 import android.widget.ImageView; 6 import android.widget.ImageView;
7 7
8 import androidx.annotation.NonNull; 8 import androidx.annotation.NonNull;
9 import androidx.recyclerview.widget.LinearLayoutManager; 9 import androidx.recyclerview.widget.LinearLayoutManager;
10 import androidx.recyclerview.widget.RecyclerView; 10 import androidx.recyclerview.widget.RecyclerView;
11 11
12 import com.bumptech.glide.Glide; 12 import com.bumptech.glide.Glide;
13 import com.bumptech.glide.load.resource.bitmap.RoundedCorners; 13 import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
14 import com.bumptech.glide.request.RequestOptions; 14 import com.bumptech.glide.request.RequestOptions;
15 import com.chad.library.adapter.base.BaseQuickAdapter; 15 import com.chad.library.adapter.base.BaseQuickAdapter;
16 import com.chad.library.adapter.base.BaseViewHolder; 16 import com.chad.library.adapter.base.BaseViewHolder;
17 import com.google.gson.Gson; 17 import com.google.gson.Gson;
18 import com.hjx.parent.bean.StudentBean; 18 import com.hjx.parent.bean.StudentBean;
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.net.NetWorks; 21 import com.prws.common.net.NetWorks;
22 import com.prws.common.utils.LogUtil; 22 import com.prws.common.utils.LogUtil;
23 import com.prws.common.utils.ScreenUtils; 23 import com.prws.common.utils.ScreenUtils;
24 import com.prws.common.utils.SharedPreferencesUtil; 24 import com.prws.common.utils.SharedPreferencesUtil;
25 25
26 import org.json.JSONArray; 26 import org.json.JSONArray;
27 import org.json.JSONObject; 27 import org.json.JSONObject;
28 28
29 import java.util.ArrayList; 29 import java.util.ArrayList;
30 30
31 import butterknife.BindView; 31 import butterknife.BindView;
32 import butterknife.OnClick; 32 import butterknife.OnClick;
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 public class ChooseActivity extends BaseActivity { 37 public class ChooseActivity extends BaseActivity {
38 @BindView(R.id.recycle) 38 @BindView(R.id.recycle)
39 RecyclerView recycle; 39 RecyclerView recycle;
40 private int select = 0; 40 private int select = 0;
41 41
42 @Override 42 @Override
43 protected int layoutResId() { 43 protected int layoutResId() {
44 return R.layout.choose_activity; 44 return R.layout.choose_activity;
45 } 45 }
46 46
47 @Override 47 @Override
48 public Object getContract() { 48 public Object getContract() {
49 return null; 49 return null;
50 } 50 }
51 51
52 @Override 52 @Override
53 public BasePresenter getPresenter() { 53 public BasePresenter getPresenter() {
54 return null; 54 return null;
55 } 55 }
56 56
57 @Override 57 @Override
58 protected void initView() { 58 protected void initView() {
59 59
60 } 60 }
61 61
62 @Override 62 @Override
63 protected void initListener() { 63 protected void initListener() {
64 64
65 } 65 }
66 66
67 @Override 67 @Override
68 protected void initData() { 68 protected void initData() {
69 69
70 } 70 }
71 71
72 @Override 72 @Override
73 public void onNetChanged(int netWorkState) { 73 public void onNetChanged(int netWorkState) {
74 74
75 } 75 }
76 76
77 @Override 77 @Override
78 protected void onResume() { 78 protected void onResume() {
79 super.onResume(); 79 super.onResume();
80 loadChildList(); 80 loadChildList();
81 } 81 }
82 82
83 ArrayList<StudentBean> alist = new ArrayList<>(); 83 ArrayList<StudentBean> alist = new ArrayList<>();
84 84
85 public void loadChildList() { 85 public void loadChildList() {
86 NetWorks.listChildren(new Observer<ResponseBody>() { 86 NetWorks.listChildren(new Observer<ResponseBody>() {
87 @Override 87 @Override
88 public void onSubscribe(Disposable d) { 88 public void onSubscribe(Disposable d) {
89 89
90 } 90 }
91 91
92 @Override 92 @Override
93 public void onNext(ResponseBody responseBody) { 93 public void onNext(ResponseBody responseBody) {
94 try { 94 try {
95
96 String str = responseBody.string().toString(); 95 String str = responseBody.string().toString();
97
98
99 LogUtil.e("TAG", "----" + str); 96 LogUtil.e("TAG", "----" + str);
100 JSONObject jo = new JSONObject(str); 97 JSONObject jo = new JSONObject(str);
101 boolean isSucceed = jo.getBoolean("success"); 98 boolean isSucceed = jo.getBoolean("success");
102 if (isSucceed) { 99 if (isSucceed) {
103 JSONArray jarr = jo.getJSONArray("data"); 100 JSONArray jarr = jo.getJSONArray("data");
104 alist.clear(); 101 alist.clear();
105 for (int i = 0; i < jarr.length(); i++) { 102 for (int i = 0; i < jarr.length(); i++) {
106 JSONObject jo2 = jarr.getJSONObject(i); 103 JSONObject jo2 = jarr.getJSONObject(i);
107 Gson gson = new Gson(); 104 Gson gson = new Gson();
108 StudentBean sb = gson.fromJson(jo2.toString(), StudentBean.class); 105 StudentBean sb = gson.fromJson(jo2.toString(), StudentBean.class);
109 alist.add(sb); 106 alist.add(sb);
110 } 107 }
111 loadList(); 108 loadList();
112 } else { 109 } else {
113 110
114 } 111 }
115 } catch (Exception e) { 112 } catch (Exception e) {
116 e.printStackTrace(); 113 e.printStackTrace();
117 } 114 }
118 } 115 }
119 116
120 @Override 117 @Override
121 public void onError(Throwable e) { 118 public void onError(Throwable e) {
122 119
123 } 120 }
124 121
125 @Override 122 @Override
126 public void onComplete() { 123 public void onComplete() {
127 124
128 } 125 }
129 }); 126 });
130 } 127 }
131 128
132 public void loadList() { 129 public void loadList() {
133 StudentBean sb = new StudentBean(); 130 StudentBean sb = new StudentBean();
134 sb.setNickName("添加学生"); 131 sb.setNickName("添加学生");
135 alist.add(sb); 132 alist.add(sb);
136 String student = (String) SharedPreferencesUtil.getData("student", ""); 133 String student = (String) SharedPreferencesUtil.getData("student", "");
137 try { 134 try {
138 StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); 135 StudentBean studentBean = new Gson().fromJson(student, StudentBean.class);
139 for (int i = 0; i < alist.size(); i++) { 136 for (int i = 0; i < alist.size(); i++) {
140 if (studentBean.getStuId().equals(alist.get(i).getStuId())) { 137 if (studentBean.getStuId().equals(alist.get(i).getStuId())) {
141 select = i; 138 select = i;
142 break; 139 break;
143 } 140 }
144 } 141 }
145 } catch (Exception e) { 142 } catch (Exception e) {
146 143
147 } 144 }
148 BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_child_choose, alist) { 145 BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_child_choose, alist) {
149 @Override 146 @Override
150 protected void convert(@NonNull BaseViewHolder item, Object o) { 147 protected void convert(@NonNull BaseViewHolder item, Object o) {
151 StudentBean studentBean = alist.get(item.getAdapterPosition()); 148 StudentBean studentBean = alist.get(item.getAdapterPosition());
152 item.setText(R.id.tv_name, studentBean.getNickName()); 149 item.setText(R.id.tv_name, studentBean.getNickName());
153 if (TextUtils.isEmpty(studentBean.getStuId())) { 150 if (TextUtils.isEmpty(studentBean.getStuId())) {
154 item.setVisible(R.id.rl_add, true); 151 item.setVisible(R.id.rl_add, true);
155 item.getConvertView().setOnClickListener(new View.OnClickListener() { 152 item.getConvertView().setOnClickListener(new View.OnClickListener() {
156 @Override 153 @Override
157 public void onClick(View view) { 154 public void onClick(View view) {
158 startActivity(new Intent(ChooseActivity.this, AddStudentActivity.class)); 155 startActivity(new Intent(ChooseActivity.this, AddStudentActivity.class));
159 } 156 }
160 }); 157 });
161 } else { 158 } else {
162 item.setBackgroundRes(R.id.rl_child, select == item.getAdapterPosition() ? R.drawable.bg_solid_white_10_or : R.drawable.bg_solid_white_10); 159 item.setBackgroundRes(R.id.rl_child, select == item.getAdapterPosition() ? R.drawable.bg_solid_white_10_or : R.drawable.bg_solid_white_10);
163 item.setImageResource(R.id.iv_select, select == item.getAdapterPosition() ? R.mipmap.gx : R.mipmap.wsyq); 160 item.setImageResource(R.id.iv_select, select == item.getAdapterPosition() ? R.mipmap.gx : R.mipmap.wsyq);
164 item.setVisible(R.id.rl_add, false); 161 item.setVisible(R.id.rl_add, false);
165 if (TextUtils.isEmpty(studentBean.getPhoto())) { 162 if (TextUtils.isEmpty(studentBean.getPhoto())) {
166 item.setImageResource(R.id.iv_avatar, studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); 163 item.setImageResource(R.id.iv_avatar, studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female);
167 } else { 164 } else {
168 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(ChooseActivity.this, 45)); 165 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(ChooseActivity.this, 45));
169 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); 166 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
170 Glide.with(ChooseActivity.this).load(studentBean.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_avatar)); 167 Glide.with(ChooseActivity.this).load(studentBean.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_avatar));
171 } 168 }
172 item.setVisible(R.id.iv_vip, !"虚拟".equals(studentBean.getTeacherIdentity())); 169 item.setVisible(R.id.iv_vip, !"虚拟".equals(studentBean.getTeacherIdentity()));
173 item.getConvertView().setOnClickListener(new View.OnClickListener() { 170 item.getConvertView().setOnClickListener(new View.OnClickListener() {
174 @Override 171 @Override
175 public void onClick(View view) { 172 public void onClick(View view) {
176 select = item.getAdapterPosition(); 173 select = item.getAdapterPosition();
177 notifyDataSetChanged(); 174 notifyDataSetChanged();
178 } 175 }
179 }); 176 });
180 } 177 }
181 } 178 }
182 }; 179 };
183 recycle.setLayoutManager(new LinearLayoutManager(ChooseActivity.this, LinearLayoutManager.VERTICAL, false)); 180 recycle.setLayoutManager(new LinearLayoutManager(ChooseActivity.this, LinearLayoutManager.VERTICAL, false));
184 recycle.setAdapter(adapter); 181 recycle.setAdapter(adapter);
185 } 182 }
186 183
187 @OnClick(R.id.tv_confirm) 184 @OnClick(R.id.tv_confirm)
188 public void confirm(View view) { 185 public void confirm(View view) {
189 if (alist.size() > 0 && alist.size() - 1 >= select && alist.get(select) != null) { 186 if (alist.size() > 0 && alist.size() - 1 >= select && alist.get(select) != null) {
190 StudentBean studentBean = alist.get(select); 187 StudentBean studentBean = alist.get(select);
191 if (studentBean.getStuId() != null) { 188 if (studentBean.getStuId() != null) {
192 Intent intent = new Intent(ChooseActivity.this, MainActivity.class); 189 Intent intent = new Intent(ChooseActivity.this, MainActivity.class);
193 SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); 190 SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean));
194 startActivity(intent); 191 startActivity(intent);
195 finish(); 192 finish();
196 } 193 }
197 } 194 }
198 } 195 }
199 } 196 }
200 197
app/src/main/java/com/hjx/parent/EditStudentActivity.java
1 package com.hjx.parent; 1 package com.hjx.parent;
2 2
3 import android.content.DialogInterface;
3 import android.content.Intent; 4 import android.content.Intent;
4 import android.graphics.Bitmap; 5 import android.graphics.Bitmap;
5 import android.graphics.Color; 6 import android.graphics.Color;
6 import android.net.Uri; 7 import android.net.Uri;
7 import android.os.Build; 8 import android.os.Build;
8 import android.os.Bundle; 9 import android.os.Bundle;
9 import android.os.Environment; 10 import android.os.Environment;
10 import android.provider.MediaStore; 11 import android.provider.MediaStore;
11 import android.text.TextUtils; 12 import android.text.TextUtils;
12 import android.util.Log; 13 import android.util.Log;
13 import android.view.LayoutInflater; 14 import android.view.LayoutInflater;
14 import android.view.View; 15 import android.view.View;
15 import android.widget.Button; 16 import android.widget.Button;
16 import android.widget.ImageView; 17 import android.widget.ImageView;
18 import android.widget.LinearLayout;
19 import android.widget.RelativeLayout;
17 import android.widget.TextView; 20 import android.widget.TextView;
18 import android.widget.Toast; 21 import android.widget.Toast;
19 22
20 import androidx.core.content.FileProvider; 23 import androidx.core.content.FileProvider;
21 24
22 import com.bumptech.glide.Glide; 25 import com.bumptech.glide.Glide;
23 import com.bumptech.glide.load.resource.bitmap.RoundedCorners; 26 import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
24 import com.bumptech.glide.request.RequestOptions; 27 import com.bumptech.glide.request.RequestOptions;
25 import com.google.android.material.bottomsheet.BottomSheetDialog; 28 import com.google.android.material.bottomsheet.BottomSheetDialog;
26 import com.google.gson.Gson; 29 import com.google.gson.Gson;
27 import com.hjq.permissions.OnPermissionCallback; 30 import com.hjq.permissions.OnPermissionCallback;
28 import com.hjq.permissions.Permission; 31 import com.hjq.permissions.Permission;
29 import com.hjq.permissions.XXPermissions; 32 import com.hjq.permissions.XXPermissions;
30 import com.hjx.parent.bean.StudentBean; 33 import com.hjx.parent.bean.StudentBean;
31 import com.prws.common.base.BaseActivity; 34 import com.prws.common.base.BaseActivity;
32 import com.prws.common.base.BasePresenter; 35 import com.prws.common.base.BasePresenter;
33 import com.prws.common.bean.ResponseResult; 36 import com.prws.common.bean.ResponseResult;
37 import com.prws.common.bean.Teacher;
34 import com.prws.common.net.NetWorks; 38 import com.prws.common.net.NetWorks;
35 import com.prws.common.utils.LogUtil; 39 import com.prws.common.utils.LogUtil;
36 import com.prws.common.utils.ScreenUtils; 40 import com.prws.common.utils.ScreenUtils;
37 import com.prws.common.utils.SharedPreferencesUtil; 41 import com.prws.common.utils.SharedPreferencesUtil;
38 42
39 import org.json.JSONObject; 43 import org.json.JSONObject;
40 44
41 import java.io.File; 45 import java.io.File;
42 import java.io.FileOutputStream; 46 import java.io.FileOutputStream;
43 import java.io.IOException; 47 import java.io.IOException;
44 import java.util.HashMap; 48 import java.util.HashMap;
45 import java.util.List; 49 import java.util.List;
46 import java.util.Map; 50 import java.util.Map;
47 51
48 import butterknife.BindView; 52 import butterknife.BindView;
49 import butterknife.OnClick; 53 import butterknife.OnClick;
50 import io.reactivex.Observer; 54 import io.reactivex.Observer;
51 import io.reactivex.disposables.Disposable; 55 import io.reactivex.disposables.Disposable;
52 56
53 public class EditStudentActivity extends BaseActivity { 57 public class EditStudentActivity extends BaseActivity {
54 View view_2; 58 View view_2;
55 View view_3; 59 View view_3;
56 View view_4; 60 View view_4;
57 View view_5; 61 View view_5;
58 Button btn_next; 62 Button btn_next;
59 TextView tv_name, tv_sex, tv_nian, tv_shen; 63 TextView tv_name, tv_sex, tv_nian, tv_shen;
60 @BindView(R.id.iv_avatar) 64 @BindView(R.id.iv_avatar)
61 ImageView iv_avatar; 65 ImageView iv_avatar;
62 @BindView(R.id.tv_teacher) 66 @BindView(R.id.tv_teacher)
63 TextView tv_teacher; 67 TextView tv_teacher;
64 @BindView(R.id.iv_teacher) 68 @BindView(R.id.iv_teacher)
65 ImageView iv_teacher; 69 ImageView iv_teacher;
70 @BindView(R.id.rl_teacher)
71 RelativeLayout rl_teacher;
72 @BindView(R.id.tv_bind)
73 TextView tv_bind;
74 @BindView(R.id.view_6)
75 LinearLayout view_6;
66 private static int CAMERA_REQUEST_CODE = 343; 76 private static int CAMERA_REQUEST_CODE = 343;
67 private static int ALBUM_REQUEST_CODE = 456; 77 private static int ALBUM_REQUEST_CODE = 456;
68 private static int CROP_REQUEST_CODE = 234; 78 private static int CROP_REQUEST_CODE = 234;
79
80 private static int BIND_TEACHER_CODE = 345;
69 private File tempFile; 81 private File tempFile;
70 private String path; 82 private String path;
71 StudentBean studentBean; 83 StudentBean studentBean;
84 private Teacher teacher;
72 85
73 @Override 86 @Override
74 protected int layoutResId() { 87 protected int layoutResId() {
75 return R.layout.activity_edit_stu; 88 return R.layout.activity_edit_stu;
76 } 89 }
77 90
78 @Override 91 @Override
79 public Object getContract() { 92 public Object getContract() {
80 return null; 93 return null;
81 } 94 }
82 95
83 @Override 96 @Override
84 public BasePresenter getPresenter() { 97 public BasePresenter getPresenter() {
85 return null; 98 return null;
86 } 99 }
87 100
88 @Override 101 @Override
89 protected void initView() { 102 protected void initView() {
90 view_2 = findViewById(R.id.view_2); 103 view_2 = findViewById(R.id.view_2);
91 view_3 = findViewById(R.id.view_3); 104 view_3 = findViewById(R.id.view_3);
92 view_4 = findViewById(R.id.view_4); 105 view_4 = findViewById(R.id.view_4);
93 view_5 = findViewById(R.id.view_5); 106 view_5 = findViewById(R.id.view_5);
94 tv_name = findViewById(R.id.tv_name); 107 tv_name = findViewById(R.id.tv_name);
95 tv_sex = findViewById(R.id.tv_sex); 108 tv_sex = findViewById(R.id.tv_sex);
96 tv_nian = findViewById(R.id.tv_nian); 109 tv_nian = findViewById(R.id.tv_nian);
97 tv_shen = findViewById(R.id.tv_shen); 110 tv_shen = findViewById(R.id.tv_shen);
98 btn_next = findViewById(R.id.btn_next); 111 btn_next = findViewById(R.id.btn_next);
99 } 112 }
100 113
101 @Override 114 @Override
102 protected void onStart() { 115 protected void onStart() {
103 super.onStart(); 116 super.onStart();
104 String name = (String) SharedPreferencesUtil.getData("setName", ""); 117 String name = (String) SharedPreferencesUtil.getData("setName", "");
105 String sex = (String) SharedPreferencesUtil.getData("setSex", ""); 118 String sex = (String) SharedPreferencesUtil.getData("setSex", "");
106 String nian = (String) SharedPreferencesUtil.getData("setNian", ""); 119 String nian = (String) SharedPreferencesUtil.getData("setNian", "");
107 String shen = (String) SharedPreferencesUtil.getData("setShen", ""); 120 String shen = (String) SharedPreferencesUtil.getData("setShen", "");
108 String xueq = (String) SharedPreferencesUtil.getData("setXueq", ""); 121 String xueq = (String) SharedPreferencesUtil.getData("setXueq", "");
109 btn_next.setTextColor(Color.WHITE); 122 btn_next.setTextColor(Color.WHITE);
110 btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn)); 123 btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn));
111 studentBean = new Gson().fromJson(getIntent().getStringExtra("student"), StudentBean.class); 124 studentBean = new Gson().fromJson(getIntent().getStringExtra("student"), StudentBean.class);
112 if (name != null && name.length() > 0) { 125 if (name != null && name.length() > 0) {
113 studentBean.setNickName(name); 126 studentBean.setNickName(name);
114 } 127 }
115 if (sex != null && sex.length() > 0) { 128 if (sex != null && sex.length() > 0) {
116 studentBean.setGender("男".equals(sex) ? 0 : 1); 129 studentBean.setGender("男".equals(sex) ? 0 : 1);
117 } 130 }
118 if (nian != null && nian.length() > 0) { 131 if (nian != null && nian.length() > 0) {
119 studentBean.setGrade(nian); 132 studentBean.setGrade(nian);
120 studentBean.setGradeId((Integer) SharedPreferencesUtil.getData("grade", 1)); 133 studentBean.setGradeId((Integer) SharedPreferencesUtil.getData("grade", 1));
121 } 134 }
122 if (xueq != null && xueq.length() > 0) { 135 if (xueq != null && xueq.length() > 0) {
123 studentBean.setTerm(xueq); 136 studentBean.setTerm(xueq);
124 } 137 }
125 if (shen != null && shen.length() > 0) { 138 if (shen != null && shen.length() > 0) {
126 studentBean.setParentIdentity(shen); 139 studentBean.setParentIdentity(shen);
127 } 140 }
128 tv_name.setText(studentBean.getNickName()); 141 tv_name.setText(studentBean.getNickName());
129 tv_nian.setText(studentBean.getGrade() + studentBean.getTerm()); 142 tv_nian.setText(studentBean.getGrade() + studentBean.getTerm());
130 tv_sex.setText(studentBean.getGender() == 0 ? "男" : "女"); 143 tv_sex.setText(studentBean.getGender() == 0 ? "男" : "女");
131 tv_shen.setText(studentBean.getParentIdentity()); 144 tv_shen.setText(studentBean.getParentIdentity());
132 if (!TextUtils.isEmpty(studentBean.getPhoto())) { 145 if (!TextUtils.isEmpty(studentBean.getPhoto())) {
133 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 45)); 146 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 45));
134 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); 147 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
135 Glide.with(this).load(studentBean.getPhoto()).apply(options).into(iv_avatar); 148 Glide.with(this).load(studentBean.getPhoto()).apply(options).into(iv_avatar);
136 } else { 149 } else {
137 iv_avatar.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); 150 iv_avatar.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female);
138 } 151 }
139 if (!"虚拟".equals(studentBean.getTeacherIdentity())) { 152 if (!"虚拟".equals(studentBean.getTeacherIdentity())) {
153 rl_teacher.setVisibility(View.VISIBLE);
154 tv_bind.setText("重新绑定");
140 tv_teacher.setText(studentBean.getTeacherName()); 155 tv_teacher.setText(studentBean.getTeacherName());
141 if (!TextUtils.isEmpty(studentBean.getTeacherAvatar())) { 156 if (!TextUtils.isEmpty(studentBean.getTeacherAvatar())) {
142 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 25)); 157 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 25));
143 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); 158 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
144 Glide.with(this).load(studentBean.getTeacherAvatar()).apply(options).into(iv_teacher); 159 Glide.with(this).load(studentBean.getTeacherAvatar()).apply(options).into(iv_teacher);
145 } else { 160 } else {
146 iv_teacher.setImageResource(studentBean.getSex() == 0 ? R.mipmap.ic_teacher_male : R.mipmap.ic_teacher_female); 161 iv_teacher.setImageResource(studentBean.getSex() == 0 ? R.mipmap.ic_teacher_male : R.mipmap.ic_teacher_female);
147 } 162 }
148 } else { 163 } else {
149 iv_teacher.setVisibility(View.GONE); 164 rl_teacher.setVisibility(View.GONE);
165 if ((studentBean.getState() != null && studentBean.getState() == 0)) {
166 tv_bind.setText("待通过");
167 tv_bind.setTextColor(Color.parseColor("#FF3737"));
168 view_6.setEnabled(false);
169 }
150 } 170 }
151 171
152 } 172 }
153 173
154 @Override 174 @Override
155 protected void initListener() { 175 protected void initListener() {
156 view_2.setOnClickListener(view -> startActivity(NickActivity.class)); 176 view_2.setOnClickListener(view -> startActivity(NickActivity.class));
157 view_3.setOnClickListener(view -> startActivity(SexActivity.class)); 177 view_3.setOnClickListener(view -> startActivity(SexActivity.class));
158 view_4.setOnClickListener(view -> startActivity(NianActivity.class)); 178 view_4.setOnClickListener(view -> startActivity(NianActivity.class));
159 view_5.setOnClickListener(view -> startActivity(ShenActivity.class)); 179 view_5.setOnClickListener(view -> startActivity(ShenActivity.class));
160 findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); 180 findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed());
161 btn_next.setOnClickListener(view -> { 181 btn_next.setOnClickListener(view -> {
162 editStudent(); 182 if (teacher != null || !"虚拟".equals(studentBean.getTeacherIdentity()) || (studentBean.getState() != null && studentBean.getState() == 0)) {
183 editStudent();
184 } else {
185 showDialog("温馨提示", "您还未绑定老师,是否绑定?", "去绑定", "暂不绑定", new DialogInterface.OnClickListener() {
186 @Override
187 public void onClick(DialogInterface dialogInterface, int i) {
188 dialogInterface.dismiss();
189 showDialog("温馨提示", "您暂未绑定老师,如需绑定老师\n" + "请联系400-800-3813", "确定", "", null, new DialogInterface.OnClickListener() {
190 @Override
191 public void onClick(DialogInterface dialogInterface, int i) {
192 editStudent();
193 }
194 });
195 }
196 }, new DialogInterface.OnClickListener() {
197 @Override
198 public void onClick(DialogInterface dialogInterface, int i) {
199 Intent intent = new Intent(EditStudentActivity.this, AddTeacherActivity.class);
200 startActivityForResult(intent, BIND_TEACHER_CODE);
201 }
202 });
203 }
163 }); 204 });
164 } 205 }
165 206
207 @OnClick(R.id.view_6)
208 public void toAddTeacher(View view) {
209 Intent intent = new Intent(EditStudentActivity.this, AddTeacherActivity.class);
210 startActivityForResult(intent, BIND_TEACHER_CODE);
211 }
212
166 public void editStudent() { 213 public void editStudent() {
167 Map map = new HashMap(); 214 Map map = new HashMap();
168 map.put("nickName", studentBean.getNickName()); 215 map.put("nickName", studentBean.getNickName());
169 map.put("gender", studentBean.getGender()); 216 map.put("gender", studentBean.getGender());
170 map.put("gradeId", studentBean.getGradeId()); 217 map.put("gradeId", studentBean.getGradeId());
171 map.put("parentIdentity", studentBean.getParentIdentity()); 218 map.put("parentIdentity", studentBean.getParentIdentity());
172 map.put("term", studentBean.getTerm()); 219 map.put("term", studentBean.getTerm());
220 if (teacher != null) {
221 map.put("teacherId", teacher.getId());
222 }
173 map.put("stuId", studentBean.getStuId()); 223 map.put("stuId", studentBean.getStuId());
174 NetWorks.editStudent(NetWorks.getMapRequestBody(map), new Observer<ResponseResult>() { 224 NetWorks.editStudent(NetWorks.getMapRequestBody(map), new Observer<ResponseResult>() {
175 @Override 225 @Override
176 public void onSubscribe(Disposable d) { 226 public void onSubscribe(Disposable d) {
177 227
178 } 228 }
179 229
180 @Override 230 @Override
181 public void onNext(ResponseResult responseResult) { 231 public void onNext(ResponseResult responseResult) {
182 try { 232 try {
183 boolean isSucceed = responseResult.getSuccess(); 233 boolean isSucceed = responseResult.getSuccess();
184 if (isSucceed) { 234 if (isSucceed) {
185 finish(); 235 finish();
186 } else { 236 } else {
187 Toast.makeText(EditStudentActivity.this, responseResult.getMsg(), Toast.LENGTH_SHORT).show(); 237 Toast.makeText(EditStudentActivity.this, responseResult.getMsg(), Toast.LENGTH_SHORT).show();
188 } 238 }
189 } catch (Exception e) { 239 } catch (Exception e) {
190 240
191 } 241 }
192 } 242 }
193 243
194 @Override 244 @Override
195 public void onError(Throwable e) { 245 public void onError(Throwable e) {
196 246
197 } 247 }
198 248
199 @Override 249 @Override
200 public void onComplete() { 250 public void onComplete() {
201 251
202 } 252 }
203 }); 253 });
204 } 254 }
205 255
206 @Override 256 @Override
207 protected void initData() { 257 protected void initData() {
208 258
209 } 259 }
210 260
211 @Override 261 @Override
212 public void onNetChanged(int netWorkState) { 262 public void onNetChanged(int netWorkState) {
213 263
214 } 264 }
215 265
216 private void cropPhoto(Uri uri) { 266 private void cropPhoto(Uri uri) {
217 Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg")); 267 Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"));
218 Intent intent = new Intent("com.android.camera.action.CROP"); 268 Intent intent = new Intent("com.android.camera.action.CROP");
219 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 269 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
220 //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片 270 //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片
221 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 271 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
222 } 272 }
223 intent.setDataAndType(uri, "image/*"); 273 intent.setDataAndType(uri, "image/*");
224 intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪 274 intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪
225 intent.putExtra("scale", true);// 设置缩放 275 intent.putExtra("scale", true);// 设置缩放
226 intent.putExtra("scaleUpIfNeeded", true);// 去黑边 276 intent.putExtra("scaleUpIfNeeded", true);// 去黑边
227 intent.putExtra("aspectX", 1); 277 intent.putExtra("aspectX", 1);
228 intent.putExtra("aspectY", 1); 278 intent.putExtra("aspectY", 1);
229 //上述两个属性控制裁剪框的缩放比例。 279 //上述两个属性控制裁剪框的缩放比例。
230 //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。 280 //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。
231 intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。 281 intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。
232 intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存, 282 intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存,
233 intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式 283 intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式
234 intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap 284 intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap
235 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径 285 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径
236 startActivityForResult(intent, CROP_REQUEST_CODE); 286 startActivityForResult(intent, CROP_REQUEST_CODE);
237 } 287 }
238 288
239 @Override 289 @Override
240 protected void onActivityResult(int requestCode, int resultCode, Intent intent) { 290 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
241 super.onActivityResult(requestCode, resultCode, intent); 291 super.onActivityResult(requestCode, resultCode, intent);
242 if (requestCode == CAMERA_REQUEST_CODE) { 292 if (requestCode == CAMERA_REQUEST_CODE) {
243 if (resultCode == RESULT_OK) { 293 if (resultCode == RESULT_OK) {
244 //用相机返回的照片去调用剪裁也需要对Uri进行处理 294 //用相机返回的照片去调用剪裁也需要对Uri进行处理
245 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 295 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
246 Uri contentUri = FileProvider.getUriForFile(this, 296 Uri contentUri = FileProvider.getUriForFile(this,
247 this.getPackageName() + ".fileprovider", tempFile); 297 this.getPackageName() + ".fileprovider", tempFile);
248 cropPhoto(contentUri); 298 cropPhoto(contentUri);
249 } else { 299 } else {
250 cropPhoto(Uri.fromFile(tempFile)); 300 cropPhoto(Uri.fromFile(tempFile));
251 } 301 }
252 } 302 }
253 } else if (requestCode == ALBUM_REQUEST_CODE) { 303 } else if (requestCode == ALBUM_REQUEST_CODE) {
254 if (resultCode == RESULT_OK) { 304 if (resultCode == RESULT_OK) {
255 Uri uri = intent.getData(); 305 Uri uri = intent.getData();
256 cropPhoto(uri); 306 cropPhoto(uri);
257 } 307 }
258 } else if (requestCode == CROP_REQUEST_CODE) { 308 } else if (requestCode == CROP_REQUEST_CODE) {
259 if (intent == null) { 309 if (intent == null) {
260 return; 310 return;
261 } 311 }
262 Bundle bundle = intent.getExtras(); 312 Bundle bundle = intent.getExtras();
263 if (bundle != null) { 313 if (bundle != null) {
264 //在这里获得了剪裁后的Bitmap对象,可以用于上传 314 //在这里获得了剪裁后的Bitmap对象,可以用于上传
265 Bitmap image = bundle.getParcelable("data"); 315 Bitmap image = bundle.getParcelable("data");
266 //设置到ImageView上 316 //设置到ImageView上
267 //也可以进行一些保存、压缩等操作后上传 317 //也可以进行一些保存、压缩等操作后上传
268 File file = saveImage("head_output", image); 318 File file = saveImage("head_output", image);
269 uploadAvatar(file); 319 uploadAvatar(file);
270 // Log.d("dsadsadsa",path); 320 // Log.d("dsadsadsa",path);
271 } 321 }
322 } else if (requestCode == BIND_TEACHER_CODE && resultCode == 1000) {
323 String t = intent.getStringExtra("teacher");
324 teacher = new Gson().fromJson(t, Teacher.class);
325 rl_teacher.setVisibility(View.VISIBLE);
326 tv_bind.setText("重新绑定");
327 tv_teacher.setText(teacher.getUserName());
328 if (!TextUtils.isEmpty(teacher.getPhoto())) {
329 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(EditStudentActivity.this, 20));
330 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
331 Glide.with(EditStudentActivity.this).load(teacher.getPhoto()).apply(options).into(iv_teacher);
332 }
272 } 333 }
273 } 334 }
274 335
275 private void uploadAvatar(File file) { 336 private void uploadAvatar(File file) {
276 NetWorks.uploadStudentAvatar(file, studentBean.getStuId(), new Observer<ResponseResult<Map<String, String>>>() { 337 NetWorks.uploadStudentAvatar(file, studentBean.getStuId(), new Observer<ResponseResult<Map<String, String>>>() {
277 @Override 338 @Override
278 public void onSubscribe(Disposable d) { 339 public void onSubscribe(Disposable d) {
279 340
280 } 341 }
281 342
282 @Override 343 @Override
283 public void onNext(ResponseResult<Map<String, String>> responseBody) { 344 public void onNext(ResponseResult<Map<String, String>> responseBody) {
284 if (responseBody.getData() != null && responseBody.getCode() == 200) { 345 if (responseBody.getData() != null && responseBody.getCode() == 200) {
285 String filePath = responseBody.getData().get("imageUrl"); 346 String filePath = responseBody.getData().get("imageUrl");
286 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(EditStudentActivity.this, 45)); 347 RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(EditStudentActivity.this, 45));
287 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); 348 RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
288 Glide.with(EditStudentActivity.this).load(filePath).apply(options).into(iv_avatar); 349 Glide.with(EditStudentActivity.this).load(filePath).apply(options).into(iv_avatar);
289 } 350 }
290 } 351 }
291 352
292 @Override 353 @Override
293 public void onError(Throwable e) { 354 public void onError(Throwable e) {
294 e.toString(); 355 e.toString();
295 } 356 }
296 357
297 @Override 358 @Override
298 public void onComplete() { 359 public void onComplete() {
299 360
300 } 361 }
301 }); 362 });
302 } 363 }
303 364
304 public File saveImage(String name, Bitmap bmp) { 365 public File saveImage(String name, Bitmap bmp) {
305 File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath()); 366 File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath());
306 if (!appDir.exists()) { 367 if (!appDir.exists()) {
307 appDir.mkdir(); 368 appDir.mkdir();
308 } 369 }
309 String fileName = name + ".jpg"; 370 String fileName = name + ".jpg";
310 File file = new File(appDir, fileName); 371 File file = new File(appDir, fileName);
311 try { 372 try {
312 FileOutputStream fos = new FileOutputStream(file); 373 FileOutputStream fos = new FileOutputStream(file);
313 bmp.compress(Bitmap.CompressFormat.PNG, 100, fos); 374 bmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
314 fos.flush(); 375 fos.flush();
315 fos.close(); 376 fos.close();
316 return file; 377 return file;
317 } catch (IOException e) { 378 } catch (IOException e) {
318 Log.d("dsadsadsa", e.getLocalizedMessage()); 379 Log.d("dsadsadsa", e.getLocalizedMessage());
319 e.printStackTrace(); 380 e.printStackTrace();
320 } 381 }
321 return null; 382 return null;
322 } 383 }
323 384
324 private void getPicFromCamera() { 385 private void getPicFromCamera() {
325 //用于保存调用相机拍照后所生成的文件 386 //用于保存调用相机拍照后所生成的文件
326 tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"); 387 tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg");
327 //跳转到调用系统相机 388 //跳转到调用系统相机
328 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 389 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
329 //判断版本 390 //判断版本
330 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri 391 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri
331 intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 392 intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
332 Uri contentUri = FileProvider.getUriForFile(this, 393 Uri contentUri = FileProvider.getUriForFile(this,
333 this.getPackageName() + ".fileprovider", tempFile); 394 this.getPackageName() + ".fileprovider", tempFile);
334 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); 395 intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);
335 } else { //否则使用Uri.fromFile(file)方法获取Uri 396 } else { //否则使用Uri.fromFile(file)方法获取Uri
336 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); 397 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
337 } 398 }
338 startActivityForResult(intent, CAMERA_REQUEST_CODE); 399 startActivityForResult(intent, CAMERA_REQUEST_CODE);
339 } 400 }
340 401
341 /** 402 /**
342 * 从相册获取图片 403 * 从相册获取图片
343 */ 404 */
344 private void getPicFromAlbm() { 405 private void getPicFromAlbm() {
345 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); 406 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
346 photoPickerIntent.setType("image/*"); 407 photoPickerIntent.setType("image/*");
347 startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE); 408 startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE);
348 } 409 }
349 410
350 @Override 411 @Override
351 protected void onDestroy() { 412 protected void onDestroy() {
352 super.onDestroy(); 413 super.onDestroy();
353 SharedPreferencesUtil.putData("setName", ""); 414 SharedPreferencesUtil.putData("setName", "");
354 SharedPreferencesUtil.putData("setSex", ""); 415 SharedPreferencesUtil.putData("setSex", "");
355 SharedPreferencesUtil.putData("setNian", ""); 416 SharedPreferencesUtil.putData("setNian", "");
356 SharedPreferencesUtil.putData("setShen", ""); 417 SharedPreferencesUtil.putData("setShen", "");
357 SharedPreferencesUtil.putData("setXueq", ""); 418 SharedPreferencesUtil.putData("setXueq", "");
358 SharedPreferencesUtil.putData("grade", 0); 419 SharedPreferencesUtil.putData("grade", 0);
359 } 420 }
360 421
361 @OnClick(R.id.iv_avatar) 422 @OnClick(R.id.iv_avatar)
362 public void showButtonDialog(View view) { 423 public void showButtonDialog(View view) {
363 BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog); 424 BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
364 View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null); 425 View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null);
365 dialog.setContentView(bottomView); 426 dialog.setContentView(bottomView);
366 bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { 427 bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() {
367 @Override 428 @Override
368 public void onClick(View view) { 429 public void onClick(View view) {
369 dialog.dismiss(); 430 dialog.dismiss();
370 if (!XXPermissions.isGranted(EditStudentActivity.this, Permission.CAMERA)) { 431 if (!XXPermissions.isGranted(EditStudentActivity.this, Permission.CAMERA)) {
371 XXPermissions.with(EditStudentActivity.this) 432 XXPermissions.with(EditStudentActivity.this)
372 // 申请多个权限 433 // 申请多个权限
373 .permission(Permission.CAMERA) 434 .permission(Permission.CAMERA)
374 .request(new OnPermissionCallback() { 435 .request(new OnPermissionCallback() {
375 @Override 436 @Override
376 public void onGranted(List<String> permissions, boolean all) { 437 public void onGranted(List<String> permissions, boolean all) {
377 if (all) { 438 if (all) {
378 //开启扫码界面 439 //开启扫码界面
379 getPicFromCamera(); 440 getPicFromCamera();
380 } else { 441 } else {
381 Toast.makeText(EditStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); 442 Toast.makeText(EditStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show();
382 } 443 }
383 } 444 }
384 445
385 @Override 446 @Override
386 public void onDenied(List<String> permissions, boolean never) { 447 public void onDenied(List<String> permissions, boolean never) {
387 XXPermissions.startPermissionActivity(EditStudentActivity.this, permissions); 448 XXPermissions.startPermissionActivity(EditStudentActivity.this, permissions);
388 } 449 }
389 }); 450 });
390 } else { 451 } else {
391 getPicFromCamera(); 452 getPicFromCamera();
392 } 453 }
393 454
394 } 455 }
395 }); 456 });
396 bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { 457 bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() {
397 @Override 458 @Override
398 public void onClick(View view) { 459 public void onClick(View view) {
399 dialog.dismiss(); 460 dialog.dismiss();
400 getPicFromAlbm(); 461 getPicFromAlbm();
401 } 462 }
402 }); 463 });
403 bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { 464 bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
404 @Override 465 @Override
405 public void onClick(View view) { 466 public void onClick(View view) {
406 dialog.dismiss(); 467 dialog.dismiss();
407 } 468 }
408 }); 469 });
409 dialog.show(); 470 dialog.show();
410 } 471 }
411 } 472 }
412 473
app/src/main/java/com/hjx/parent/bean/StudentBean.java
1 package com.hjx.parent.bean; 1 package com.hjx.parent.bean;
2 2
3 public class StudentBean { 3 public class StudentBean {
4 4
5 String stuId; 5 String stuId;
6 String stuName; 6 String stuName;
7 int gender; 7 int gender;
8 String term; 8 String term;
9 String account; 9 String account;
10 String nickName; 10 String nickName;
11 String address; 11 String address;
12 String phone; 12 String phone;
13 String photo; 13 String photo;
14 int fromType; 14 int fromType;
15 int gradeId; 15 int gradeId;
16 String oriSchool; 16 String oriSchool;
17 String parentPhone; 17 String parentPhone;
18 String parentIdentity; 18 String parentIdentity;
19 String teacherName; 19 String teacherName;
20 int teacherId; 20 int teacherId;
21 String teacherAvatar; 21 String teacherAvatar;
22 String grade; 22 String grade;
23 String teacherIdentity; 23 String teacherIdentity;
24 int sex; 24 int sex;
25 Integer state;
25 26
27 public void setState(Integer state) {
28 this.state = state;
29 }
30
31 public Integer getState() {
32 return state;
33 }
26 34
27 @Override 35 @Override
28 public String toString() { 36 public String toString() {
29 return "StudentBean{" + 37 return "StudentBean{" +
30 "stuId='" + stuId + '\'' + 38 "stuId='" + stuId + '\'' +
31 ", stuName='" + stuName + '\'' + 39 ", stuName='" + stuName + '\'' +
32 ", gender=" + gender + 40 ", gender=" + gender +
33 ", term='" + term + '\'' + 41 ", term='" + term + '\'' +
34 ", account='" + account + '\'' + 42 ", account='" + account + '\'' +
35 ", nickName='" + nickName + '\'' + 43 ", nickName='" + nickName + '\'' +
36 ", address='" + address + '\'' + 44 ", address='" + address + '\'' +
37 ", phone='" + phone + '\'' + 45 ", phone='" + phone + '\'' +
38 ", photo='" + photo + '\'' + 46 ", photo='" + photo + '\'' +
39 ", fromType=" + fromType + 47 ", fromType=" + fromType +
40 ", gradeId=" + gradeId + 48 ", gradeId=" + gradeId +
41 ", oriSchool='" + oriSchool + '\'' + 49 ", oriSchool='" + oriSchool + '\'' +
42 ", parentPhone='" + parentPhone + '\'' + 50 ", parentPhone='" + parentPhone + '\'' +
43 ", parentIdentity='" + parentIdentity + '\'' + 51 ", parentIdentity='" + parentIdentity + '\'' +
44 ", teacherName='" + teacherName + '\'' + 52 ", teacherName='" + teacherName + '\'' +
45 ", teacherId=" + teacherId + 53 ", teacherId=" + teacherId +
46 ", teacherAvatar=" + teacherAvatar + 54 ", teacherAvatar=" + teacherAvatar +
47 ", grade=" + grade + 55 ", grade=" + grade +
48 ", teacherIdentity=" + teacherIdentity + 56 ", teacherIdentity=" + teacherIdentity +
49 ", sex=" + sex + 57 ", sex=" + sex +
58 ", state=" + state +
50 '}'; 59 '}';
51 } 60 }
52 61
53 public void setSex(int sex) { 62 public void setSex(int sex) {
54 this.sex = sex; 63 this.sex = sex;
55 } 64 }
56 65
57 public int getSex() { 66 public int getSex() {
58 return sex; 67 return sex;
59 } 68 }
60 69
61 public void setTeacherIdentity(String teacherIdentity) { 70 public void setTeacherIdentity(String teacherIdentity) {
62 this.teacherIdentity = teacherIdentity; 71 this.teacherIdentity = teacherIdentity;
63 } 72 }
64 73
65 public String getTeacherIdentity() { 74 public String getTeacherIdentity() {
66 return teacherIdentity; 75 return teacherIdentity;
67 } 76 }
68 77
69 public void setTeacherAvatar(String teacherAvatar) { 78 public void setTeacherAvatar(String teacherAvatar) {
70 this.teacherAvatar = teacherAvatar; 79 this.teacherAvatar = teacherAvatar;
71 } 80 }
72 81
73 public void setGrade(String grade) { 82 public void setGrade(String grade) {
74 this.grade = grade; 83 this.grade = grade;
75 } 84 }
76 85
77 public String getTeacherAvatar() { 86 public String getTeacherAvatar() {
78 return teacherAvatar; 87 return teacherAvatar;
79 } 88 }
80 89
81 public String getGrade() { 90 public String getGrade() {
82 return grade; 91 return grade;
83 } 92 }
84 93
85 public String getStuId() { 94 public String getStuId() {
86 return stuId; 95 return stuId;
87 } 96 }
88 97
89 public void setStuId(String stuId) { 98 public void setStuId(String stuId) {
90 this.stuId = stuId; 99 this.stuId = stuId;
91 } 100 }
92 101
93 public String getStuName() { 102 public String getStuName() {
94 return stuName; 103 return stuName;
95 } 104 }
96 105
97 public void setStuName(String stuName) { 106 public void setStuName(String stuName) {
98 this.stuName = stuName; 107 this.stuName = stuName;
99 } 108 }
100 109
101 public int getGender() { 110 public int getGender() {
102 return gender; 111 return gender;
103 } 112 }
104 113
105 public void setGender(int gender) { 114 public void setGender(int gender) {
106 this.gender = gender; 115 this.gender = gender;
107 } 116 }
108 117
109 public String getTerm() { 118 public String getTerm() {
110 return term; 119 return term;
111 } 120 }
112 121
113 public void setTerm(String term) { 122 public void setTerm(String term) {
114 this.term = term; 123 this.term = term;
115 } 124 }
116 125
117 public String getAccount() { 126 public String getAccount() {
118 return account; 127 return account;
119 } 128 }
120 129
121 public void setAccount(String account) { 130 public void setAccount(String account) {
122 this.account = account; 131 this.account = account;
123 } 132 }
124 133
125 public String getNickName() { 134 public String getNickName() {
126 return nickName; 135 return nickName;
127 } 136 }
128 137
129 public void setNickName(String nickName) { 138 public void setNickName(String nickName) {
130 this.nickName = nickName; 139 this.nickName = nickName;
131 } 140 }
132 141
133 public String getAddress() { 142 public String getAddress() {
134 return address; 143 return address;
135 } 144 }
136 145
137 public void setAddress(String address) { 146 public void setAddress(String address) {
138 this.address = address; 147 this.address = address;
139 } 148 }
140 149
141 public String getPhone() { 150 public String getPhone() {
142 return phone; 151 return phone;
143 } 152 }
144 153
145 public void setPhone(String phone) { 154 public void setPhone(String phone) {
146 this.phone = phone; 155 this.phone = phone;
147 } 156 }
148 157
149 public String getPhoto() { 158 public String getPhoto() {
150 return photo; 159 return photo;
151 } 160 }
152 161
153 public void setPhoto(String photo) { 162 public void setPhoto(String photo) {
154 this.photo = photo; 163 this.photo = photo;
155 } 164 }
156 165
157 public int getFromType() { 166 public int getFromType() {
158 return fromType; 167 return fromType;
159 } 168 }
160 169
161 public void setFromType(int fromType) { 170 public void setFromType(int fromType) {
162 this.fromType = fromType; 171 this.fromType = fromType;
163 } 172 }
164 173
165 public int getGradeId() { 174 public int getGradeId() {
166 return gradeId; 175 return gradeId;
167 } 176 }
168 177
169 public void setGradeId(int gradeId) { 178 public void setGradeId(int gradeId) {
170 this.gradeId = gradeId; 179 this.gradeId = gradeId;
171 } 180 }
172 181
173 public String getOriSchool() { 182 public String getOriSchool() {
174 return oriSchool; 183 return oriSchool;
175 } 184 }
176 185
177 public void setOriSchool(String oriSchool) { 186 public void setOriSchool(String oriSchool) {
178 this.oriSchool = oriSchool; 187 this.oriSchool = oriSchool;
179 } 188 }
180 189
181 public String getParentPhone() { 190 public String getParentPhone() {
182 return parentPhone; 191 return parentPhone;
183 } 192 }
184 193
185 public void setParentPhone(String parentPhone) { 194 public void setParentPhone(String parentPhone) {
186 this.parentPhone = parentPhone; 195 this.parentPhone = parentPhone;
187 } 196 }
188 197
189 public String getParentIdentity() { 198 public String getParentIdentity() {
190 return parentIdentity; 199 return parentIdentity;
191 } 200 }
192 201
193 public void setParentIdentity(String parentIdentity) { 202 public void setParentIdentity(String parentIdentity) {
194 this.parentIdentity = parentIdentity; 203 this.parentIdentity = parentIdentity;
195 } 204 }
196 205
197 public String getTeacherName() { 206 public String getTeacherName() {
198 return teacherName; 207 return teacherName;
199 } 208 }
200 209
201 public void setTeacherName(String teacherName) { 210 public void setTeacherName(String teacherName) {
202 this.teacherName = teacherName; 211 this.teacherName = teacherName;
203 } 212 }
204 213
205 public int getTeacherId() { 214 public int getTeacherId() {
206 return teacherId; 215 return teacherId;
207 } 216 }
208 217
209 public void setTeacherId(int teacherId) { 218 public void setTeacherId(int teacherId) {
210 this.teacherId = teacherId; 219 this.teacherId = teacherId;
211 } 220 }
212 } 221 }
213 222
app/src/main/res/layout/activity_add_stu.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 android:layout_width="match_parent" 4 android:layout_width="match_parent"
5 android:layout_height="match_parent" 5 android:layout_height="match_parent"
6 android:background="#F4F6F8"> 6 android:background="#F4F6F8">
7 7
8 <View 8 <View
9 android:id="@+id/view_1" 9 android:id="@+id/view_1"
10 android:layout_width="match_parent" 10 android:layout_width="match_parent"
11 android:layout_height="44dp" 11 android:layout_height="44dp"
12 android:background="@android:color/white" 12 android:background="@android:color/white"
13 app:layout_constraintTop_toTopOf="parent" /> 13 app:layout_constraintTop_toTopOf="parent" />
14 14
15 <TextView 15 <TextView
16 android:layout_width="wrap_content" 16 android:layout_width="wrap_content"
17 android:layout_height="wrap_content" 17 android:layout_height="wrap_content"
18 android:text="添加学生" 18 android:text="添加学生"
19 android:textColor="#333333" 19 android:textColor="#333333"
20 android:textSize="18dp" 20 android:textSize="18dp"
21 app:layout_constraintBottom_toBottomOf="@id/view_1" 21 app:layout_constraintBottom_toBottomOf="@id/view_1"
22 app:layout_constraintLeft_toLeftOf="@id/view_1" 22 app:layout_constraintLeft_toLeftOf="@id/view_1"
23 app:layout_constraintRight_toRightOf="@id/view_1" 23 app:layout_constraintRight_toRightOf="@id/view_1"
24 app:layout_constraintTop_toTopOf="@id/view_1" /> 24 app:layout_constraintTop_toTopOf="@id/view_1" />
25 25
26 <TextView 26 <TextView
27 android:id="@+id/tv_cancel" 27 android:id="@+id/tv_cancel"
28 android:layout_width="wrap_content" 28 android:layout_width="wrap_content"
29 android:layout_height="wrap_content" 29 android:layout_height="wrap_content"
30 android:layout_marginLeft="15dp" 30 android:layout_marginLeft="15dp"
31 android:text="取消" 31 android:text="取消"
32 android:textColor="#666666" 32 android:textColor="#666666"
33 android:textSize="16dp" 33 android:textSize="16dp"
34 app:layout_constraintBottom_toBottomOf="@id/view_1" 34 app:layout_constraintBottom_toBottomOf="@id/view_1"
35 app:layout_constraintLeft_toLeftOf="@id/view_1" 35 app:layout_constraintLeft_toLeftOf="@id/view_1"
36 app:layout_constraintTop_toTopOf="@id/view_1" /> 36 app:layout_constraintTop_toTopOf="@id/view_1" />
37 37
38 <RelativeLayout 38 <RelativeLayout
39 android:id="@+id/rl_avatar" 39 android:id="@+id/rl_avatar"
40 android:layout_width="75dp" 40 android:layout_width="75dp"
41 android:layout_height="75dp" 41 android:layout_height="75dp"
42 android:layout_marginTop="32dp" 42 android:layout_marginTop="32dp"
43 app:layout_constraintLeft_toLeftOf="parent" 43 app:layout_constraintLeft_toLeftOf="parent"
44 app:layout_constraintRight_toRightOf="parent" 44 app:layout_constraintRight_toRightOf="parent"
45 app:layout_constraintTop_toBottomOf="@id/view_1"> 45 app:layout_constraintTop_toBottomOf="@id/view_1">
46 46
47 <ImageView 47 <ImageView
48 android:id="@+id/iv_avatar" 48 android:id="@+id/iv_avatar"
49 android:layout_width="match_parent" 49 android:layout_width="match_parent"
50 android:layout_height="match_parent" 50 android:layout_height="match_parent"
51 android:background="@mipmap/txz" /> 51 android:background="@mipmap/txz" />
52 52
53 <ImageView 53 <ImageView
54 android:layout_width="20dp" 54 android:layout_width="20dp"
55 android:layout_height="20dp" 55 android:layout_height="20dp"
56 android:layout_alignParentRight="true" 56 android:layout_alignParentRight="true"
57 android:layout_alignParentBottom="true" 57 android:layout_alignParentBottom="true"
58 android:layout_marginBottom="5dp" 58 android:layout_marginBottom="5dp"
59 android:src="@mipmap/ic_edit" /> 59 android:src="@mipmap/ic_edit" />
60 </RelativeLayout> 60 </RelativeLayout>
61 61
62 62
63 <View 63 <View
64 android:id="@+id/view_2" 64 android:id="@+id/view_2"
65 android:layout_width="match_parent" 65 android:layout_width="match_parent"
66 android:layout_height="50dp" 66 android:layout_height="50dp"
67 android:layout_marginLeft="15dp" 67 android:layout_marginLeft="15dp"
68 android:layout_marginTop="195dp" 68 android:layout_marginTop="195dp"
69 android:layout_marginRight="15dp" 69 android:layout_marginRight="15dp"
70 android:background="@drawable/bg_solid_white_10" 70 android:background="@drawable/bg_solid_white_10"
71 app:layout_constraintLeft_toLeftOf="parent" 71 app:layout_constraintLeft_toLeftOf="parent"
72 app:layout_constraintRight_toRightOf="parent" 72 app:layout_constraintRight_toRightOf="parent"
73 app:layout_constraintTop_toTopOf="parent" /> 73 app:layout_constraintTop_toTopOf="parent" />
74 74
75 <TextView 75 <TextView
76 android:layout_width="wrap_content" 76 android:layout_width="wrap_content"
77 android:layout_height="wrap_content" 77 android:layout_height="wrap_content"
78 android:layout_marginLeft="15dp" 78 android:layout_marginLeft="15dp"
79 android:text="昵称" 79 android:text="昵称"
80 android:textColor="#666666" 80 android:textColor="#666666"
81 android:textSize="16dp" 81 android:textSize="16dp"
82 app:layout_constraintBottom_toBottomOf="@id/view_2" 82 app:layout_constraintBottom_toBottomOf="@id/view_2"
83 app:layout_constraintLeft_toLeftOf="@id/view_2" 83 app:layout_constraintLeft_toLeftOf="@id/view_2"
84 app:layout_constraintTop_toTopOf="@id/view_2" /> 84 app:layout_constraintTop_toTopOf="@id/view_2" />
85 85
86 <ImageView 86 <ImageView
87 android:layout_width="5.5dp" 87 android:layout_width="5.5dp"
88 android:layout_height="9.5dp" 88 android:layout_height="9.5dp"
89 android:layout_marginRight="15dp" 89 android:layout_marginRight="15dp"
90 android:background="@mipmap/ycaj" 90 android:background="@mipmap/ycaj"
91 app:layout_constraintBottom_toBottomOf="@id/view_2" 91 app:layout_constraintBottom_toBottomOf="@id/view_2"
92 app:layout_constraintRight_toRightOf="@id/view_2" 92 app:layout_constraintRight_toRightOf="@id/view_2"
93 app:layout_constraintTop_toTopOf="@id/view_2" /> 93 app:layout_constraintTop_toTopOf="@id/view_2" />
94 94
95 <TextView 95 <TextView
96 android:id="@+id/tv_name" 96 android:id="@+id/tv_name"
97 android:layout_width="wrap_content" 97 android:layout_width="wrap_content"
98 android:layout_height="wrap_content" 98 android:layout_height="wrap_content"
99 android:layout_marginRight="26dp" 99 android:layout_marginRight="26dp"
100 android:text="请输入" 100 android:text="请输入"
101 android:textColor="#999999" 101 android:textColor="#999999"
102 android:textSize="16dp" 102 android:textSize="16dp"
103 app:layout_constraintBottom_toBottomOf="@id/view_2" 103 app:layout_constraintBottom_toBottomOf="@id/view_2"
104 app:layout_constraintRight_toRightOf="@id/view_2" 104 app:layout_constraintRight_toRightOf="@id/view_2"
105 app:layout_constraintTop_toTopOf="@id/view_2" /> 105 app:layout_constraintTop_toTopOf="@id/view_2" />
106 106
107 <View 107 <View
108 android:id="@+id/view_3" 108 android:id="@+id/view_3"
109 android:layout_width="match_parent" 109 android:layout_width="match_parent"
110 android:layout_height="50dp" 110 android:layout_height="50dp"
111 android:layout_marginLeft="15dp" 111 android:layout_marginLeft="15dp"
112 android:layout_marginTop="260dp" 112 android:layout_marginTop="260dp"
113 android:layout_marginRight="15dp" 113 android:layout_marginRight="15dp"
114 android:background="@drawable/bg_solid_white_10" 114 android:background="@drawable/bg_solid_white_10"
115 app:layout_constraintLeft_toLeftOf="parent" 115 app:layout_constraintLeft_toLeftOf="parent"
116 app:layout_constraintRight_toRightOf="parent" 116 app:layout_constraintRight_toRightOf="parent"
117 app:layout_constraintTop_toTopOf="parent" /> 117 app:layout_constraintTop_toTopOf="parent" />
118 118
119 <TextView 119 <TextView
120 android:layout_width="wrap_content" 120 android:layout_width="wrap_content"
121 android:layout_height="wrap_content" 121 android:layout_height="wrap_content"
122 android:layout_marginLeft="15dp" 122 android:layout_marginLeft="15dp"
123 android:text="性别" 123 android:text="性别"
124 android:textColor="#666666" 124 android:textColor="#666666"
125 android:textSize="16dp" 125 android:textSize="16dp"
126 app:layout_constraintBottom_toBottomOf="@id/view_3" 126 app:layout_constraintBottom_toBottomOf="@id/view_3"
127 app:layout_constraintLeft_toLeftOf="@id/view_3" 127 app:layout_constraintLeft_toLeftOf="@id/view_3"
128 app:layout_constraintTop_toTopOf="@id/view_3" /> 128 app:layout_constraintTop_toTopOf="@id/view_3" />
129 129
130 <ImageView 130 <ImageView
131 android:layout_width="5.5dp" 131 android:layout_width="5.5dp"
132 android:layout_height="9.5dp" 132 android:layout_height="9.5dp"
133 android:layout_marginRight="15dp" 133 android:layout_marginRight="15dp"
134 android:background="@mipmap/ycaj" 134 android:background="@mipmap/ycaj"
135 app:layout_constraintBottom_toBottomOf="@id/view_3" 135 app:layout_constraintBottom_toBottomOf="@id/view_3"
136 app:layout_constraintRight_toRightOf="@id/view_3" 136 app:layout_constraintRight_toRightOf="@id/view_3"
137 app:layout_constraintTop_toTopOf="@id/view_3" /> 137 app:layout_constraintTop_toTopOf="@id/view_3" />
138 138
139 <TextView 139 <TextView
140 android:id="@+id/tv_sex" 140 android:id="@+id/tv_sex"
141 android:layout_width="wrap_content" 141 android:layout_width="wrap_content"
142 android:layout_height="wrap_content" 142 android:layout_height="wrap_content"
143 android:layout_marginRight="26dp" 143 android:layout_marginRight="26dp"
144 android:text="请选择" 144 android:text="请选择"
145 android:textColor="#999999" 145 android:textColor="#999999"
146 android:textSize="16dp" 146 android:textSize="16dp"
147 app:layout_constraintBottom_toBottomOf="@id/view_3" 147 app:layout_constraintBottom_toBottomOf="@id/view_3"
148 app:layout_constraintRight_toRightOf="@id/view_3" 148 app:layout_constraintRight_toRightOf="@id/view_3"
149 app:layout_constraintTop_toTopOf="@id/view_3" /> 149 app:layout_constraintTop_toTopOf="@id/view_3" />
150 150
151 <View 151 <View
152 android:id="@+id/view_4" 152 android:id="@+id/view_4"
153 android:layout_width="match_parent" 153 android:layout_width="match_parent"
154 android:layout_height="50dp" 154 android:layout_height="50dp"
155 android:layout_marginLeft="15dp" 155 android:layout_marginLeft="15dp"
156 android:layout_marginTop="325dp" 156 android:layout_marginTop="325dp"
157 android:layout_marginRight="15dp" 157 android:layout_marginRight="15dp"
158 android:background="@drawable/bg_solid_white_10" 158 android:background="@drawable/bg_solid_white_10"
159 app:layout_constraintLeft_toLeftOf="parent" 159 app:layout_constraintLeft_toLeftOf="parent"
160 app:layout_constraintRight_toRightOf="parent" 160 app:layout_constraintRight_toRightOf="parent"
161 app:layout_constraintTop_toTopOf="parent" 161 app:layout_constraintTop_toTopOf="parent" />
162
163 />
164 162
165 <TextView 163 <TextView
166 android:layout_width="wrap_content" 164 android:layout_width="wrap_content"
167 android:layout_height="wrap_content" 165 android:layout_height="wrap_content"
168 android:layout_marginLeft="15dp" 166 android:layout_marginLeft="15dp"
169 android:text="年级" 167 android:text="年级"
170 android:textColor="#666666" 168 android:textColor="#666666"
171 android:textSize="16dp" 169 android:textSize="16dp"
172 app:layout_constraintBottom_toBottomOf="@id/view_4" 170 app:layout_constraintBottom_toBottomOf="@id/view_4"
173 app:layout_constraintLeft_toLeftOf="@id/view_4" 171 app:layout_constraintLeft_toLeftOf="@id/view_4"
174 app:layout_constraintTop_toTopOf="@id/view_4" /> 172 app:layout_constraintTop_toTopOf="@id/view_4" />
175 173
176 <ImageView 174 <ImageView
177 android:layout_width="5.5dp" 175 android:layout_width="5.5dp"
178 android:layout_height="9.5dp" 176 android:layout_height="9.5dp"
179 android:layout_marginRight="15dp" 177 android:layout_marginRight="15dp"
180 android:background="@mipmap/ycaj" 178 android:background="@mipmap/ycaj"
181 app:layout_constraintBottom_toBottomOf="@id/view_4" 179 app:layout_constraintBottom_toBottomOf="@id/view_4"
182 app:layout_constraintRight_toRightOf="@id/view_4" 180 app:layout_constraintRight_toRightOf="@id/view_4"
183 app:layout_constraintTop_toTopOf="@id/view_4" /> 181 app:layout_constraintTop_toTopOf="@id/view_4" />
184 182
185 <TextView 183 <TextView
186 android:id="@+id/tv_nian" 184 android:id="@+id/tv_nian"
187 android:layout_width="wrap_content" 185 android:layout_width="wrap_content"
188 android:layout_height="wrap_content" 186 android:layout_height="wrap_content"
189 android:layout_marginRight="26dp" 187 android:layout_marginRight="26dp"
190 android:text="请选择" 188 android:text="请选择"
191 android:textColor="#999999" 189 android:textColor="#999999"
192 android:textSize="16dp" 190 android:textSize="16dp"
193 app:layout_constraintBottom_toBottomOf="@id/view_4" 191 app:layout_constraintBottom_toBottomOf="@id/view_4"
194 app:layout_constraintRight_toRightOf="@id/view_4" 192 app:layout_constraintRight_toRightOf="@id/view_4"
195 app:layout_constraintTop_toTopOf="@id/view_4" /> 193 app:layout_constraintTop_toTopOf="@id/view_4" />
196 194
197 <View 195 <View
198 android:id="@+id/view_5" 196 android:id="@+id/view_5"
199 android:layout_width="match_parent" 197 android:layout_width="match_parent"
200 android:layout_height="50dp" 198 android:layout_height="50dp"
201 android:layout_marginLeft="15dp" 199 android:layout_marginLeft="15dp"
202 android:layout_marginTop="390dp" 200 android:layout_marginTop="390dp"
203 android:layout_marginRight="15dp" 201 android:layout_marginRight="15dp"
204 android:background="@drawable/bg_solid_white_10" 202 android:background="@drawable/bg_solid_white_10"
205 app:layout_constraintLeft_toLeftOf="parent" 203 app:layout_constraintLeft_toLeftOf="parent"
206 app:layout_constraintRight_toRightOf="parent" 204 app:layout_constraintRight_toRightOf="parent"
207 app:layout_constraintTop_toTopOf="parent" 205 app:layout_constraintTop_toTopOf="parent" />
208 206
209 /> 207 <LinearLayout
208 android:id="@+id/view_6"
209 android:layout_width="match_parent"
210 android:layout_height="wrap_content"
211 android:layout_marginLeft="15dp"
212 android:layout_marginTop="460dp"
213 android:layout_marginRight="15dp"
214 android:background="@drawable/bg_solid_white_10"
215 android:orientation="vertical"
216 app:layout_constraintLeft_toLeftOf="parent"
217 app:layout_constraintRight_toRightOf="parent"
218 app:layout_constraintTop_toTopOf="parent">
210 219
211 <TextView 220 <RelativeLayout
221 android:layout_width="match_parent"
222 android:layout_height="50dp">
223
224 <ImageView
225 android:layout_width="15dp"
226 android:layout_height="15dp"
227 android:layout_centerVertical="true"
228 android:layout_marginRight="5dp"
229 android:layout_toLeftOf="@+id/tv_bind"
230 android:src="@mipmap/ic_bind_teacher" />
231
232 <TextView
233 android:id="@+id/tv_bind"
234 android:layout_width="wrap_content"
235 android:layout_height="wrap_content"
236 android:layout_alignParentRight="true"
237 android:layout_centerVertical="true"
238 android:layout_marginRight="15dp"
239 android:text="去绑定"
240 android:textColor="#999999"
241 android:textSize="16dp" />
242
243 <TextView
244 android:layout_width="wrap_content"
245 android:layout_height="wrap_content"
246 android:layout_centerVertical="true"
247 android:layout_marginLeft="15dp"
248 android:text="我的老师"
249 android:textColor="#666666"
250 android:textSize="16dp" />
251 </RelativeLayout>
252
253 <RelativeLayout
254 android:id="@+id/rl_teacher"
255 android:layout_width="match_parent"
256 android:layout_height="35dp"
257 android:layout_marginBottom="15dp"
258 android:visibility="gone">
212 259
260 <ImageView
261 android:id="@+id/iv_teacher"
262 android:layout_width="35dp"
263 android:layout_height="35dp"
264 android:layout_marginLeft="15dp"
265 android:src="@mipmap/ic_teacher_male" />
266
267 <TextView
268 android:id="@+id/tv_teacher"
269 android:layout_width="wrap_content"
270 android:layout_height="wrap_content"
271 android:layout_alignParentRight="true"
272 android:layout_centerVertical="true"
273 android:layout_marginRight="15dp"
274 android:textColor="#999999"
275 android:textSize="16dp" />
276 </RelativeLayout>
277 </LinearLayout>
278
279 <TextView
213 android:layout_width="wrap_content" 280 android:layout_width="wrap_content"
214 android:layout_height="wrap_content" 281 android:layout_height="wrap_content"
215 android:layout_marginLeft="15dp" 282 android:layout_marginLeft="15dp"
216 android:text="家长身份" 283 android:text="家长身份"
217 android:textColor="#666666" 284 android:textColor="#666666"
218 android:textSize="16dp" 285 android:textSize="16dp"
219 app:layout_constraintBottom_toBottomOf="@id/view_5" 286 app:layout_constraintBottom_toBottomOf="@id/view_5"
220 app:layout_constraintLeft_toLeftOf="@id/view_5" 287 app:layout_constraintLeft_toLeftOf="@id/view_5"
221 app:layout_constraintTop_toTopOf="@id/view_5" /> 288 app:layout_constraintTop_toTopOf="@id/view_5" />
222 289
290
223 <TextView 291 <TextView
224 android:id="@+id/tv_shen" 292 android:id="@+id/tv_shen"
225 android:layout_width="wrap_content" 293 android:layout_width="wrap_content"
226 android:layout_height="wrap_content" 294 android:layout_height="wrap_content"
227 android:layout_marginRight="26dp" 295 android:layout_marginRight="26dp"
228 android:text="请选择" 296 android:text="请选择"
229 android:textColor="#999999" 297 android:textColor="#999999"
230 android:textSize="16dp" 298 android:textSize="16dp"
231 app:layout_constraintBottom_toBottomOf="@id/view_5" 299 app:layout_constraintBottom_toBottomOf="@id/view_5"
232 app:layout_constraintRight_toRightOf="@id/view_5" 300 app:layout_constraintRight_toRightOf="@id/view_5"
233 app:layout_constraintTop_toTopOf="@id/view_5" /> 301 app:layout_constraintTop_toTopOf="@id/view_5" />
234 302
235 <ImageView 303 <ImageView
236 android:layout_width="5.5dp" 304 android:layout_width="5.5dp"
237 android:layout_height="9.5dp" 305 android:layout_height="9.5dp"
238 android:layout_marginRight="15dp" 306 android:layout_marginRight="15dp"
239 android:background="@mipmap/ycaj" 307 android:background="@mipmap/ycaj"
240 app:layout_constraintBottom_toBottomOf="@id/view_5" 308 app:layout_constraintBottom_toBottomOf="@id/view_5"
241 app:layout_constraintRight_toRightOf="@id/view_5" 309 app:layout_constraintRight_toRightOf="@id/view_5"
242 app:layout_constraintTop_toTopOf="@id/view_5" /> 310 app:layout_constraintTop_toTopOf="@id/view_5" />
243 311
244
245 <Button 312 <Button
246 android:id="@+id/btn_next" 313 android:id="@+id/btn_next"
247 android:layout_width="180dp" 314 android:layout_width="180dp"
248 android:layout_height="40dp" 315 android:layout_height="40dp"
249 android:layout_marginTop="500dp" 316 android:layout_marginTop="700dp"
250 android:background="@drawable/bg_solid_btn_grad" 317 android:background="@drawable/bg_solid_btn_grad"
251 android:text="确认" 318 android:text="确认"
252 android:textColor="#999999" 319 android:textColor="#999999"
253 android:textSize="16dp" 320 android:textSize="16dp"
254 app:layout_constraintLeft_toLeftOf="parent" 321 app:layout_constraintLeft_toLeftOf="parent"
255 app:layout_constraintRight_toRightOf="parent" 322 app:layout_constraintRight_toRightOf="parent"
256 app:layout_constraintTop_toTopOf="parent" /> 323 app:layout_constraintTop_toTopOf="parent" />
app/src/main/res/layout/activity_add_teacher.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 android:background="#F4F6F8">
7
8 <View
9 android:id="@+id/view_1"
10 android:layout_width="match_parent"
11 android:layout_height="44dp"
12 android:background="@android:color/white"
13 app:layout_constraintTop_toTopOf="parent" />
14
15 <TextView
16 android:layout_width="wrap_content"
17 android:layout_height="wrap_content"
18 android:text="绑定老师"
19 android:textColor="#333333"
20 android:textSize="18dp"
21 app:layout_constraintBottom_toBottomOf="@id/view_1"
22 app:layout_constraintLeft_toLeftOf="@id/view_1"
23 app:layout_constraintRight_toRightOf="@id/view_1"
24 app:layout_constraintTop_toTopOf="@id/view_1" />
25
26 <TextView
27 android:id="@+id/tv_cancel"
28 android:layout_width="wrap_content"
29 android:layout_height="wrap_content"
30 android:layout_marginLeft="15dp"
31 android:text="取消"
32 android:textColor="#666666"
33 android:textSize="16dp"
34 app:layout_constraintBottom_toBottomOf="@id/view_1"
35 app:layout_constraintLeft_toLeftOf="@id/view_1"
36 app:layout_constraintTop_toTopOf="@id/view_1" />
37
38 <View
39 android:id="@+id/view_3"
40 android:layout_width="match_parent"
41 android:layout_height="50dp"
42 android:layout_marginLeft="15dp"
43 android:layout_marginTop="109dp"
44 android:layout_marginRight="15dp"
45 android:background="@drawable/bg_solid_white_10"
46 app:layout_constraintLeft_toLeftOf="parent"
47 app:layout_constraintRight_toRightOf="parent"
48 app:layout_constraintTop_toTopOf="parent" />
49
50 <EditText
51 android:id="@+id/et_1"
52 android:layout_width="0dp"
53 android:layout_height="0dp"
54 android:layout_marginLeft="5dp"
55 android:layout_marginRight="5dp"
56 android:inputType="phone"
57 android:maxLength="11"
58 android:textColor="#333333"
59 android:textColorHint="#999999"
60 android:textSize="16dp"
61 app:layout_constraintBottom_toBottomOf="@+id/view_3"
62 app:layout_constraintLeft_toLeftOf="@+id/view_3"
63 app:layout_constraintRight_toRightOf="@+id/view_3"
64 app:layout_constraintTop_toTopOf="@+id/view_3" />
65
66 <TextView
67 android:layout_width="wrap_content"
68 android:layout_height="wrap_content"
69 android:layout_marginLeft="15dp"
70 android:layout_marginBottom="15dp"
71 android:text="请输入手机号"
72 android:textColor="#666666"
73 app:layout_constraintBottom_toTopOf="@id/et_1"
74 app:layout_constraintLeft_toLeftOf="parent" />
75
76 <RelativeLayout
77 android:id="@+id/rl_teacher"
78 android:layout_width="match_parent"
79 android:layout_height="60dp"
80 android:layout_marginLeft="15dp"
81 android:layout_marginTop="25dp"
82 android:layout_marginRight="15dp"
83 android:background="@drawable/bg_solid_white_10"
84 android:visibility="gone"
85 app:layout_constraintTop_toBottomOf="@+id/et_1">
86
87 <ImageView
88 android:id="@+id/iv_teacher"
89 android:layout_width="35dp"
90 android:layout_height="35dp"
91 android:layout_marginLeft="15dp"
92 android:layout_centerVertical="true"
93 android:src="@mipmap/ic_teacher_male" />
94
95 <TextView
96 android:id="@+id/tv_teacher"
97 android:layout_width="wrap_content"
98 android:layout_height="wrap_content"
99 android:layout_alignParentRight="true"
100 android:layout_centerVertical="true"
101 android:layout_marginRight="15dp"
102 android:textColor="#333333"
103 android:textSize="16dp" />
104 </RelativeLayout>
105
106 <Button
107 android:id="@+id/btn_next"
108 android:layout_width="180dp"
109 android:layout_height="40dp"
110 android:layout_marginTop="560dp"
111 android:background="@drawable/bg_solid_btn_grad"
112 android:text="申请绑定"
113 android:textColor="#999999"
114 android:textSize="16dp"
115 app:layout_constraintLeft_toLeftOf="parent"
116 app:layout_constraintRight_toRightOf="parent"
117 app:layout_constraintTop_toTopOf="parent" />
118 </androidx.constraintlayout.widget.ConstraintLayout>
app/src/main/res/layout/activity_edit_stu.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 android:layout_width="match_parent" 4 android:layout_width="match_parent"
5 android:layout_height="match_parent" 5 android:layout_height="match_parent"
6 android:background="#F4F6F8"> 6 android:background="#F4F6F8">
7 7
8 <View 8 <View
9 android:id="@+id/view_1" 9 android:id="@+id/view_1"
10 android:layout_width="match_parent" 10 android:layout_width="match_parent"
11 android:layout_height="44dp" 11 android:layout_height="44dp"
12 android:background="@android:color/white" 12 android:background="@android:color/white"
13 app:layout_constraintTop_toTopOf="parent" /> 13 app:layout_constraintTop_toTopOf="parent" />
14 14
15 <TextView 15 <TextView
16 android:layout_width="wrap_content" 16 android:layout_width="wrap_content"
17 android:layout_height="wrap_content" 17 android:layout_height="wrap_content"
18 android:text="编辑学生" 18 android:text="编辑学生"
19 android:textColor="#333333" 19 android:textColor="#333333"
20 android:textSize="18dp" 20 android:textSize="18dp"
21 app:layout_constraintBottom_toBottomOf="@id/view_1" 21 app:layout_constraintBottom_toBottomOf="@id/view_1"
22 app:layout_constraintLeft_toLeftOf="@id/view_1" 22 app:layout_constraintLeft_toLeftOf="@id/view_1"
23 app:layout_constraintRight_toRightOf="@id/view_1" 23 app:layout_constraintRight_toRightOf="@id/view_1"
24 app:layout_constraintTop_toTopOf="@id/view_1" /> 24 app:layout_constraintTop_toTopOf="@id/view_1" />
25 25
26 <TextView 26 <TextView
27 android:id="@+id/tv_cancel" 27 android:id="@+id/tv_cancel"
28 android:layout_width="wrap_content" 28 android:layout_width="wrap_content"
29 android:layout_height="wrap_content" 29 android:layout_height="wrap_content"
30 android:layout_marginLeft="15dp" 30 android:layout_marginLeft="15dp"
31 android:text="取消" 31 android:text="取消"
32 android:textColor="#666666" 32 android:textColor="#666666"
33 android:textSize="16dp" 33 android:textSize="16dp"
34 app:layout_constraintBottom_toBottomOf="@id/view_1" 34 app:layout_constraintBottom_toBottomOf="@id/view_1"
35 app:layout_constraintLeft_toLeftOf="@id/view_1" 35 app:layout_constraintLeft_toLeftOf="@id/view_1"
36 app:layout_constraintTop_toTopOf="@id/view_1" /> 36 app:layout_constraintTop_toTopOf="@id/view_1" />
37 37
38 <RelativeLayout 38 <RelativeLayout
39 android:id="@+id/rl_avatar" 39 android:id="@+id/rl_avatar"
40 android:layout_width="75dp" 40 android:layout_width="75dp"
41 android:layout_height="75dp" 41 android:layout_height="75dp"
42 android:layout_marginTop="32dp" 42 android:layout_marginTop="32dp"
43 app:layout_constraintLeft_toLeftOf="parent" 43 app:layout_constraintLeft_toLeftOf="parent"
44 app:layout_constraintRight_toRightOf="parent" 44 app:layout_constraintRight_toRightOf="parent"
45 app:layout_constraintTop_toBottomOf="@id/view_1"> 45 app:layout_constraintTop_toBottomOf="@id/view_1">
46 46
47 <ImageView 47 <ImageView
48 android:id="@+id/iv_avatar" 48 android:id="@+id/iv_avatar"
49 android:layout_width="match_parent" 49 android:layout_width="match_parent"
50 android:layout_height="match_parent" 50 android:layout_height="match_parent"
51 android:background="@mipmap/txz" /> 51 android:background="@mipmap/txz" />
52 52
53 <ImageView 53 <ImageView
54 android:layout_width="20dp" 54 android:layout_width="20dp"
55 android:layout_height="20dp" 55 android:layout_height="20dp"
56 android:layout_alignParentRight="true" 56 android:layout_alignParentRight="true"
57 android:layout_alignParentBottom="true" 57 android:layout_alignParentBottom="true"
58 android:layout_marginBottom="5dp" 58 android:layout_marginBottom="5dp"
59 android:src="@mipmap/ic_edit" /> 59 android:src="@mipmap/ic_edit" />
60 </RelativeLayout> 60 </RelativeLayout>
61 61
62 62
63 <View 63 <View
64 android:id="@+id/view_2" 64 android:id="@+id/view_2"
65 android:layout_width="match_parent" 65 android:layout_width="match_parent"
66 android:layout_marginLeft="15dp" 66 android:layout_marginLeft="15dp"
67 android:layout_marginRight="15dp" 67 android:layout_marginRight="15dp"
68 android:layout_height="50dp" 68 android:layout_height="50dp"
69 android:layout_marginTop="195dp" 69 android:layout_marginTop="195dp"
70 android:background="@drawable/bg_solid_white_10" 70 android:background="@drawable/bg_solid_white_10"
71 app:layout_constraintLeft_toLeftOf="parent" 71 app:layout_constraintLeft_toLeftOf="parent"
72 app:layout_constraintRight_toRightOf="parent" 72 app:layout_constraintRight_toRightOf="parent"
73 app:layout_constraintTop_toTopOf="parent" /> 73 app:layout_constraintTop_toTopOf="parent" />
74 74
75 <TextView 75 <TextView
76 android:layout_width="wrap_content" 76 android:layout_width="wrap_content"
77 android:layout_height="wrap_content" 77 android:layout_height="wrap_content"
78 android:layout_marginLeft="15dp" 78 android:layout_marginLeft="15dp"
79 android:text="昵称" 79 android:text="昵称"
80 android:textColor="#666666" 80 android:textColor="#666666"
81 android:textSize="16dp" 81 android:textSize="16dp"
82 app:layout_constraintBottom_toBottomOf="@id/view_2" 82 app:layout_constraintBottom_toBottomOf="@id/view_2"
83 app:layout_constraintLeft_toLeftOf="@id/view_2" 83 app:layout_constraintLeft_toLeftOf="@id/view_2"
84 app:layout_constraintTop_toTopOf="@id/view_2" /> 84 app:layout_constraintTop_toTopOf="@id/view_2" />
85 85
86 <ImageView 86 <ImageView
87 android:layout_width="5.5dp" 87 android:layout_width="5.5dp"
88 android:layout_height="9.5dp" 88 android:layout_height="9.5dp"
89 android:layout_marginRight="15dp" 89 android:layout_marginRight="15dp"
90 android:background="@mipmap/ycaj" 90 android:background="@mipmap/ycaj"
91 app:layout_constraintBottom_toBottomOf="@id/view_2" 91 app:layout_constraintBottom_toBottomOf="@id/view_2"
92 app:layout_constraintRight_toRightOf="@id/view_2" 92 app:layout_constraintRight_toRightOf="@id/view_2"
93 app:layout_constraintTop_toTopOf="@id/view_2" /> 93 app:layout_constraintTop_toTopOf="@id/view_2" />
94 94
95 <TextView 95 <TextView
96 android:id="@+id/tv_name" 96 android:id="@+id/tv_name"
97 android:layout_width="wrap_content" 97 android:layout_width="wrap_content"
98 android:layout_height="wrap_content" 98 android:layout_height="wrap_content"
99 android:layout_marginRight="26dp" 99 android:layout_marginRight="26dp"
100 android:text="请输入" 100 android:text="请输入"
101 android:textColor="#333333" 101 android:textColor="#333333"
102 android:textSize="16dp" 102 android:textSize="16dp"
103 app:layout_constraintBottom_toBottomOf="@id/view_2" 103 app:layout_constraintBottom_toBottomOf="@id/view_2"
104 app:layout_constraintRight_toRightOf="@id/view_2" 104 app:layout_constraintRight_toRightOf="@id/view_2"
105 app:layout_constraintTop_toTopOf="@id/view_2" /> 105 app:layout_constraintTop_toTopOf="@id/view_2" />
106 106
107 <View 107 <View
108 android:id="@+id/view_3" 108 android:id="@+id/view_3"
109 android:layout_width="match_parent" 109 android:layout_width="match_parent"
110 android:layout_marginLeft="15dp" 110 android:layout_marginLeft="15dp"
111 android:layout_marginRight="15dp" 111 android:layout_marginRight="15dp"
112 android:layout_height="50dp" 112 android:layout_height="50dp"
113 android:layout_marginTop="260dp" 113 android:layout_marginTop="260dp"
114 android:background="@drawable/bg_solid_white_10" 114 android:background="@drawable/bg_solid_white_10"
115 app:layout_constraintLeft_toLeftOf="parent" 115 app:layout_constraintLeft_toLeftOf="parent"
116 app:layout_constraintRight_toRightOf="parent" 116 app:layout_constraintRight_toRightOf="parent"
117 app:layout_constraintTop_toTopOf="parent" /> 117 app:layout_constraintTop_toTopOf="parent" />
118 118
119 <TextView 119 <TextView
120 android:layout_width="wrap_content" 120 android:layout_width="wrap_content"
121 android:layout_height="wrap_content" 121 android:layout_height="wrap_content"
122 android:layout_marginLeft="15dp" 122 android:layout_marginLeft="15dp"
123 android:text="性别" 123 android:text="性别"
124 android:textColor="#666666" 124 android:textColor="#666666"
125 android:textSize="16dp" 125 android:textSize="16dp"
126 app:layout_constraintBottom_toBottomOf="@id/view_3" 126 app:layout_constraintBottom_toBottomOf="@id/view_3"
127 app:layout_constraintLeft_toLeftOf="@id/view_3" 127 app:layout_constraintLeft_toLeftOf="@id/view_3"
128 app:layout_constraintTop_toTopOf="@id/view_3" /> 128 app:layout_constraintTop_toTopOf="@id/view_3" />
129 129
130 <ImageView 130 <ImageView
131 android:layout_width="5.5dp" 131 android:layout_width="5.5dp"
132 android:layout_height="9.5dp" 132 android:layout_height="9.5dp"
133 android:layout_marginRight="15dp" 133 android:layout_marginRight="15dp"
134 android:background="@mipmap/ycaj" 134 android:background="@mipmap/ycaj"
135 app:layout_constraintBottom_toBottomOf="@id/view_3" 135 app:layout_constraintBottom_toBottomOf="@id/view_3"
136 app:layout_constraintRight_toRightOf="@id/view_3" 136 app:layout_constraintRight_toRightOf="@id/view_3"
137 app:layout_constraintTop_toTopOf="@id/view_3" /> 137 app:layout_constraintTop_toTopOf="@id/view_3" />
138 138
139 <TextView 139 <TextView
140 android:id="@+id/tv_sex" 140 android:id="@+id/tv_sex"
141 android:layout_width="wrap_content" 141 android:layout_width="wrap_content"
142 android:layout_height="wrap_content" 142 android:layout_height="wrap_content"
143 android:layout_marginRight="26dp" 143 android:layout_marginRight="26dp"
144 android:text="请选择" 144 android:text="请选择"
145 android:textColor="#333333" 145 android:textColor="#333333"
146 android:textSize="16dp" 146 android:textSize="16dp"
147 app:layout_constraintBottom_toBottomOf="@id/view_3" 147 app:layout_constraintBottom_toBottomOf="@id/view_3"
148 app:layout_constraintRight_toRightOf="@id/view_3" 148 app:layout_constraintRight_toRightOf="@id/view_3"
149 app:layout_constraintTop_toTopOf="@id/view_3" /> 149 app:layout_constraintTop_toTopOf="@id/view_3" />
150 150
151 <View 151 <View
152 android:id="@+id/view_4" 152 android:id="@+id/view_4"
153 android:layout_width="match_parent" 153 android:layout_width="match_parent"
154 android:layout_marginLeft="15dp" 154 android:layout_marginLeft="15dp"
155 android:layout_marginRight="15dp" 155 android:layout_marginRight="15dp"
156 android:layout_height="50dp" 156 android:layout_height="50dp"
157 android:layout_marginTop="325dp" 157 android:layout_marginTop="325dp"
158 android:background="@drawable/bg_solid_white_10" 158 android:background="@drawable/bg_solid_white_10"
159 app:layout_constraintLeft_toLeftOf="parent" 159 app:layout_constraintLeft_toLeftOf="parent"
160 app:layout_constraintRight_toRightOf="parent" 160 app:layout_constraintRight_toRightOf="parent"
161 app:layout_constraintTop_toTopOf="parent" 161 app:layout_constraintTop_toTopOf="parent"
162 162
163 /> 163 />
164 164
165 <TextView 165 <TextView
166 android:layout_width="wrap_content" 166 android:layout_width="wrap_content"
167 android:layout_height="wrap_content" 167 android:layout_height="wrap_content"
168 android:layout_marginLeft="15dp" 168 android:layout_marginLeft="15dp"
169 android:text="年级" 169 android:text="年级"
170 android:textColor="#666666" 170 android:textColor="#666666"
171 android:textSize="16dp" 171 android:textSize="16dp"
172 app:layout_constraintBottom_toBottomOf="@id/view_4" 172 app:layout_constraintBottom_toBottomOf="@id/view_4"
173 app:layout_constraintLeft_toLeftOf="@id/view_4" 173 app:layout_constraintLeft_toLeftOf="@id/view_4"
174 app:layout_constraintTop_toTopOf="@id/view_4" /> 174 app:layout_constraintTop_toTopOf="@id/view_4" />
175 175
176 <ImageView 176 <ImageView
177 android:layout_width="5.5dp" 177 android:layout_width="5.5dp"
178 android:layout_height="9.5dp" 178 android:layout_height="9.5dp"
179 android:layout_marginRight="15dp" 179 android:layout_marginRight="15dp"
180 android:background="@mipmap/ycaj" 180 android:background="@mipmap/ycaj"
181 app:layout_constraintBottom_toBottomOf="@id/view_4" 181 app:layout_constraintBottom_toBottomOf="@id/view_4"
182 app:layout_constraintRight_toRightOf="@id/view_4" 182 app:layout_constraintRight_toRightOf="@id/view_4"
183 app:layout_constraintTop_toTopOf="@id/view_4" /> 183 app:layout_constraintTop_toTopOf="@id/view_4" />
184 184
185 <TextView 185 <TextView
186 android:id="@+id/tv_nian" 186 android:id="@+id/tv_nian"
187 android:layout_width="wrap_content" 187 android:layout_width="wrap_content"
188 android:layout_height="wrap_content" 188 android:layout_height="wrap_content"
189 android:layout_marginRight="26dp" 189 android:layout_marginRight="26dp"
190 android:text="请选择" 190 android:text="请选择"
191 android:textColor="#333333" 191 android:textColor="#333333"
192 android:textSize="16dp" 192 android:textSize="16dp"
193 app:layout_constraintBottom_toBottomOf="@id/view_4" 193 app:layout_constraintBottom_toBottomOf="@id/view_4"
194 app:layout_constraintRight_toRightOf="@id/view_4" 194 app:layout_constraintRight_toRightOf="@id/view_4"
195 app:layout_constraintTop_toTopOf="@id/view_4" /> 195 app:layout_constraintTop_toTopOf="@id/view_4" />
196 196
197 <View 197 <View
198 android:id="@+id/view_5" 198 android:id="@+id/view_5"
199 android:layout_width="match_parent" 199 android:layout_width="match_parent"
200 android:layout_marginLeft="15dp" 200 android:layout_marginLeft="15dp"
201 android:layout_marginRight="15dp" 201 android:layout_marginRight="15dp"
202 android:layout_height="50dp" 202 android:layout_height="50dp"
203 android:layout_marginTop="390dp" 203 android:layout_marginTop="390dp"
204 android:background="@drawable/bg_solid_white_10" 204 android:background="@drawable/bg_solid_white_10"
205 app:layout_constraintLeft_toLeftOf="parent" 205 app:layout_constraintLeft_toLeftOf="parent"
206 app:layout_constraintRight_toRightOf="parent" 206 app:layout_constraintRight_toRightOf="parent"
207 app:layout_constraintTop_toTopOf="parent" 207 app:layout_constraintTop_toTopOf="parent"
208 208
209 /> 209 />
210 210
211 <TextView 211 <TextView
212 212
213 android:layout_width="wrap_content" 213 android:layout_width="wrap_content"
214 android:layout_height="wrap_content" 214 android:layout_height="wrap_content"
215 android:layout_marginLeft="15dp" 215 android:layout_marginLeft="15dp"
216 android:text="家长身份" 216 android:text="家长身份"
217 android:textColor="#666666" 217 android:textColor="#666666"
218 android:textSize="16dp" 218 android:textSize="16dp"
219 app:layout_constraintBottom_toBottomOf="@id/view_5" 219 app:layout_constraintBottom_toBottomOf="@id/view_5"
220 app:layout_constraintLeft_toLeftOf="@id/view_5" 220 app:layout_constraintLeft_toLeftOf="@id/view_5"
221 app:layout_constraintTop_toTopOf="@id/view_5" /> 221 app:layout_constraintTop_toTopOf="@id/view_5" />
222 222
223 <TextView 223 <TextView
224 android:id="@+id/tv_shen" 224 android:id="@+id/tv_shen"
225 android:layout_width="wrap_content" 225 android:layout_width="wrap_content"
226 android:layout_height="wrap_content" 226 android:layout_height="wrap_content"
227 android:layout_marginRight="26dp" 227 android:layout_marginRight="26dp"
228 android:text="请选择" 228 android:text="请选择"
229 android:textColor="#333333" 229 android:textColor="#333333"
230 android:textSize="16dp" 230 android:textSize="16dp"
231 app:layout_constraintBottom_toBottomOf="@id/view_5" 231 app:layout_constraintBottom_toBottomOf="@id/view_5"
232 app:layout_constraintRight_toRightOf="@id/view_5" 232 app:layout_constraintRight_toRightOf="@id/view_5"
233 app:layout_constraintTop_toTopOf="@id/view_5" /> 233 app:layout_constraintTop_toTopOf="@id/view_5" />
234 234
235 <ImageView 235 <ImageView
236 android:layout_width="5.5dp" 236 android:layout_width="5.5dp"
237 android:layout_height="9.5dp" 237 android:layout_height="9.5dp"
238 android:layout_marginRight="15dp" 238 android:layout_marginRight="15dp"
239 android:background="@mipmap/ycaj" 239 android:background="@mipmap/ycaj"
240 app:layout_constraintBottom_toBottomOf="@id/view_5" 240 app:layout_constraintBottom_toBottomOf="@id/view_5"
241 app:layout_constraintRight_toRightOf="@id/view_5" 241 app:layout_constraintRight_toRightOf="@id/view_5"
242 app:layout_constraintTop_toTopOf="@id/view_5" /> 242 app:layout_constraintTop_toTopOf="@id/view_5" />
243 243
244 <View 244 <LinearLayout
245 android:id="@+id/view_6" 245 android:id="@+id/view_6"
246 android:layout_width="match_parent" 246 android:layout_width="match_parent"
247 android:layout_height="wrap_content"
247 android:layout_marginLeft="15dp" 248 android:layout_marginLeft="15dp"
249 android:layout_marginTop="460dp"
248 android:layout_marginRight="15dp" 250 android:layout_marginRight="15dp"
249 android:layout_height="50dp"
250 android:layout_marginTop="455dp"
251 android:background="@drawable/bg_solid_white_10" 251 android:background="@drawable/bg_solid_white_10"
252 android:orientation="vertical"
252 app:layout_constraintLeft_toLeftOf="parent" 253 app:layout_constraintLeft_toLeftOf="parent"
253 app:layout_constraintRight_toRightOf="parent" 254 app:layout_constraintRight_toRightOf="parent"
254 app:layout_constraintTop_toTopOf="parent" 255 app:layout_constraintTop_toTopOf="parent">
255
256 />
257 256
258 <TextView 257 <RelativeLayout
259 android:layout_width="wrap_content" 258 android:layout_width="match_parent"
260 android:layout_height="wrap_content" 259 android:layout_height="50dp">
261 android:layout_marginLeft="15dp" 260
262 android:text="绑定老师" 261 <ImageView
263 android:textColor="#666666" 262 android:layout_width="15dp"
264 android:textSize="16dp" 263 android:layout_height="15dp"
265 app:layout_constraintBottom_toBottomOf="@id/view_6" 264 android:layout_centerVertical="true"
266 app:layout_constraintLeft_toLeftOf="@id/view_6" 265 android:layout_marginRight="5dp"
267 app:layout_constraintTop_toTopOf="@id/view_6" /> 266 android:layout_toLeftOf="@+id/tv_bind"
268 267 android:src="@mipmap/ic_bind_teacher" />
269 <ImageView 268
270 android:id="@+id/iv_teacher" 269 <TextView
271 android:layout_width="28dp" 270 android:id="@+id/tv_bind"
272 android:layout_height="28dp" 271 android:layout_width="wrap_content"
273 android:layout_marginRight="10dp" 272 android:layout_height="wrap_content"
274 app:layout_constraintBottom_toBottomOf="@id/view_6" 273 android:layout_alignParentRight="true"
275 app:layout_constraintRight_toLeftOf="@+id/tv_teacher" 274 android:layout_centerVertical="true"
276 app:layout_constraintTop_toTopOf="@id/view_6" /> 275 android:layout_marginRight="15dp"
277 276 android:text="去绑定"
278 <TextView 277 android:textColor="#333333"
279 android:id="@+id/tv_teacher" 278 android:textSize="16dp" />
280 android:layout_width="wrap_content" 279
281 android:layout_height="wrap_content" 280 <TextView
282 android:layout_marginRight="15dp" 281 android:layout_width="wrap_content"
283 android:text="未绑定" 282 android:layout_height="wrap_content"
284 android:textColor="#333333" 283 android:layout_centerVertical="true"
285 android:textSize="16dp" 284 android:layout_marginLeft="15dp"
286 app:layout_constraintBottom_toBottomOf="@id/view_6" 285 android:text="我的老师"
287 app:layout_constraintRight_toRightOf="@id/view_6" 286 android:textColor="#666666"
288 app:layout_constraintTop_toTopOf="@id/view_6" /> 287 android:textSize="16dp" />
288 </RelativeLayout>
289
290 <RelativeLayout
291 android:id="@+id/rl_teacher"
292 android:layout_width="match_parent"
293 android:layout_height="35dp"
294 android:layout_marginBottom="15dp"
295 android:visibility="gone">
296
297 <ImageView
298 android:id="@+id/iv_teacher"
299 android:layout_width="35dp"
300 android:layout_height="35dp"
301 android:layout_marginLeft="15dp"
302 android:src="@mipmap/ic_teacher_male" />
303
304 <TextView
305 android:id="@+id/tv_teacher"
306 android:layout_width="wrap_content"
307 android:layout_height="wrap_content"
308 android:layout_alignParentRight="true"
309 android:layout_centerVertical="true"
310 android:layout_marginRight="15dp"
311 android:textColor="#999999"
312 android:textSize="16dp" />
313 </RelativeLayout>
314 </LinearLayout>
289 315
290 316
291 <Button 317 <Button
292 android:id="@+id/btn_next" 318 android:id="@+id/btn_next"
293 android:layout_width="180dp" 319 android:layout_width="180dp"
294 android:layout_height="40dp" 320 android:layout_height="40dp"
295 android:layout_marginTop="570dp" 321 android:layout_marginTop="570dp"
296 android:background="@drawable/bg_solid_btn_grad" 322 android:background="@drawable/bg_solid_btn_grad"
297 android:text="确认" 323 android:text="确认"
298 android:textColor="#999999" 324 android:textColor="#999999"
299 android:textSize="16dp" 325 android:textSize="16dp"
300 app:layout_constraintLeft_toLeftOf="parent" 326 app:layout_constraintLeft_toLeftOf="parent"
301 app:layout_constraintRight_toRightOf="parent" 327 app:layout_constraintRight_toRightOf="parent"
app/src/main/res/mipmap-hdpi/ic_bind_teacher.png

3.07 KB

libs/common/src/main/java/com/prws/common/base/BaseActivity.java
1 package com.prws.common.base; 1 package com.prws.common.base;
2 2
3 3
4 import android.app.Activity; 4 import android.app.Activity;
5 import android.app.AlertDialog;
5 import android.content.Context; 6 import android.content.Context;
7 import android.content.DialogInterface;
6 import android.content.Intent; 8 import android.content.Intent;
7 import android.os.Bundle; 9 import android.os.Bundle;
8 import android.os.IBinder; 10 import android.os.IBinder;
11 import android.text.TextUtils;
9 import android.util.Log; 12 import android.util.Log;
10 import android.view.MotionEvent; 13 import android.view.MotionEvent;
11 import android.view.View; 14 import android.view.View;
12 import android.view.Window; 15 import android.view.Window;
13 import android.view.WindowManager; 16 import android.view.WindowManager;
14 import android.view.inputmethod.InputMethodManager; 17 import android.view.inputmethod.InputMethodManager;
15 import android.widget.EditText; 18 import android.widget.EditText;
19 import android.widget.Toast;
16 20
17 import androidx.annotation.IdRes; 21 import androidx.annotation.IdRes;
18 import androidx.annotation.Nullable; 22 import androidx.annotation.Nullable;
19 import androidx.appcompat.app.AppCompatActivity; 23 import androidx.appcompat.app.AppCompatActivity;
20 import androidx.fragment.app.Fragment; 24 import androidx.fragment.app.Fragment;
21 import androidx.fragment.app.FragmentTransaction; 25 import androidx.fragment.app.FragmentTransaction;
22 import androidx.lifecycle.Lifecycle; 26 import androidx.lifecycle.Lifecycle;
23 27
24 import com.developer.wang.utils.PermissionUtils; 28 import com.developer.wang.utils.PermissionUtils;
25 import com.prws.common.R; 29 import com.prws.common.R;
26 import com.prws.common.net.INetEvent; 30 import com.prws.common.net.INetEvent;
27 import com.prws.common.utils.LogUtil; 31 import com.prws.common.utils.LogUtil;
28 import com.prws.common.utils.ScreenUtils; 32 import com.prws.common.utils.ScreenUtils;
33 import com.prws.common.utils.SharedPreferencesUtil;
29 import com.prws.common.view.LoadingView; 34 import com.prws.common.view.LoadingView;
30 35
31 import org.simple.eventbus.EventBus; 36 import org.simple.eventbus.EventBus;
32 37
33 import java.util.ArrayList; 38 import java.util.ArrayList;
34 import java.util.List; 39 import java.util.List;
35 40
36 import butterknife.ButterKnife; 41 import butterknife.ButterKnife;
37 import io.reactivex.disposables.CompositeDisposable; 42 import io.reactivex.disposables.CompositeDisposable;
38 import io.reactivex.disposables.Disposable; 43 import io.reactivex.disposables.Disposable;
39 44
40 45
41 /** 46 /**
42 * @author 描述:BaseActivity 47 * @author 描述:BaseActivity
43 */ 48 */
44 public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity implements INetEvent, BaseView { 49 public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity implements INetEvent, BaseView {
45 50
46 51
47 private LoadingView loading; 52 private LoadingView loading;
48 53
49 public static INetEvent mINetEvent; 54 public static INetEvent mINetEvent;
50 protected final String TAG = getClass().getSimpleName(); 55 protected final String TAG = getClass().getSimpleName();
51 private CompositeDisposable mCompositeDisposable; 56 private CompositeDisposable mCompositeDisposable;
52 protected P p; 57 protected P p;
53 58
54 /** 59 /**
55 * 获取布局文件 60 * 获取布局文件
56 * 61 *
57 * @return 62 * @return
58 */ 63 */
59 protected abstract int layoutResId(); 64 protected abstract int layoutResId();
60 65
61 /** 66 /**
62 * 让P层做相应需求 67 * 让P层做相应需求
63 */ 68 */
64 public abstract CONTRACT getContract(); 69 public abstract CONTRACT getContract();
65 70
66 /** 71 /**
67 * 子类获取具体契约 72 * 子类获取具体契约
68 */ 73 */
69 public abstract P getPresenter(); 74 public abstract P getPresenter();
70 75
71 @Override 76 @Override
72 protected void onCreate(@Nullable Bundle savedInstanceState) { 77 protected void onCreate(@Nullable Bundle savedInstanceState) {
73 super.onCreate(savedInstanceState); 78 super.onCreate(savedInstanceState);
74 setNetEvent(); 79 setNetEvent();
75 initPresenter(); 80 initPresenter();
76 // setWindow(); 81 // setWindow();
77 setContentView(layoutResId()); 82 setContentView(layoutResId());
78 ButterKnife.bind(this); 83 ButterKnife.bind(this);
79 registerEventBus(); 84 registerEventBus();
80 initView(); 85 initView();
81 initListener(); 86 initListener();
82 initData(); 87 initData();
83 88
84 } 89 }
85 90
86 91
87 @Override 92 @Override
88 protected void onResume() { 93 protected void onResume() {
89 super.onResume(); 94 super.onResume();
90 } 95 }
91 96
92 protected abstract void initView(); 97 protected abstract void initView();
93 98
94 protected abstract void initListener(); 99 protected abstract void initListener();
95 100
96 protected abstract void initData(); 101 protected abstract void initData();
97 102
98 103
99 private void setNetEvent() { 104 private void setNetEvent() {
100 mINetEvent = this; 105 mINetEvent = this;
101 } 106 }
102 107
103 private void initPresenter() { 108 private void initPresenter() {
104 p = getPresenter(); 109 p = getPresenter();
105 if (p != null) 110 if (p != null)
106 p.bindView(this); 111 p.bindView(this);
107 } 112 }
108 113
114 public void showDialog(String title, String message, String confirm, String cancel, DialogInterface.OnClickListener cancelListener, DialogInterface.OnClickListener listener) {
115 AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert);
116 builder.setTitle(title);
117 builder.setMessage(message);
118 builder.setCancelable(false);
119 if (!TextUtils.isEmpty(cancel)) {
120 builder.setNegativeButton(cancel, cancelListener);
121 }
122 builder.setPositiveButton(confirm, listener);
123 builder.show();
124 }
125
109 private void setWindow() { 126 private void setWindow() {
110 Window window = getWindow(); 127 Window window = getWindow();
111 WindowManager.LayoutParams params = window.getAttributes(); 128 WindowManager.LayoutParams params = window.getAttributes();
112 params.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN 129 params.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
113 ; 130 ;
114 window.setAttributes(params); 131 window.setAttributes(params);
115 } 132 }
116 133
117 134
118
119
120 private void addNavigationBar() { 135 private void addNavigationBar() {
121 //判断是否有浮窗权限 136 //判断是否有浮窗权限
122 if (PermissionUtils.requestWindowManager(this)) { 137 if (PermissionUtils.requestWindowManager(this)) {
123 //开启浮窗 138 //开启浮窗
124 // openFloatWindow(); 139 // openFloatWindow();
125 } else { 140 } else {
126 showAlertDialogOfFloatWindow(); 141 showAlertDialogOfFloatWindow();
127 } 142 }
128 } 143 }
129 144
130 // public void openFloatWindow() { 145 // public void openFloatWindow() {
131 // if (FloatWindow.get("navigation") == null) { 146 // if (FloatWindow.get("navigation") == null) {
132 // NavigationBarView navigationBarView = new NavigationBarView(this); 147 // NavigationBarView navigationBarView = new NavigationBarView(this);
133 // FloatWindow.with(CommonApplication.getAppContext()) 148 // FloatWindow.with(CommonApplication.getAppContext())
134 // .setView(navigationBarView) 149 // .setView(navigationBarView)
135 // .setWidth(Screen.width, 1) 150 // .setWidth(Screen.width, 1)
136 // .setHeight(WindowManager.LayoutParams.WRAP_CONTENT) 151 // .setHeight(WindowManager.LayoutParams.WRAP_CONTENT)
137 // .setX(0) 152 // .setX(0)
138 // .setY(0) 153 // .setY(0)
139 // .setMoveType(MoveType.inactive) 154 // .setMoveType(MoveType.inactive)
140 // .setDesktopShow(false) 155 // .setDesktopShow(false)
141 // .setTag("navigation") 156 // .setTag("navigation")
142 // .build(); 157 // .build();
143 // } 158 // }
144 // if (!FloatWindow.get("navigation").isShowing()) 159 // if (!FloatWindow.get("navigation").isShowing())
145 // FloatWindow.get("navigation").show(); 160 // FloatWindow.get("navigation").show();
146 // 161 //
147 // } 162 // }
148 163
149 164
150
151 public void showAlertDialogOfFloatWindow() { 165 public void showAlertDialogOfFloatWindow() {
152 //弹窗提示用户开启权限 166 //弹窗提示用户开启权限
153 // new AlertDialog(this).builder().setTitle(getString(R.string.need_permission)) 167 // new AlertDialog(this).builder().setTitle(getString(R.string.need_permission))
154 // .setMsg(getString(R.string.need_permission_window)) 168 // .setMsg(getString(R.string.need_permission_window))
155 // .setPositiveButton(getString(R.string.open), new View.OnClickListener() { 169 // .setPositiveButton(getString(R.string.open), new View.OnClickListener() {
156 // @Override 170 // @Override
157 // public void onClick(View v) { 171 // public void onClick(View v) {
158 // Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); 172 // Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
159 // intent.setData(Uri.parse("package:" + getPackageName())); 173 // intent.setData(Uri.parse("package:" + getPackageName()));
160 // startActivity(intent); 174 // startActivity(intent);
161 // } 175 // }
162 // }).setNegativeButton(getString(R.string.cancel), new View.OnClickListener() { 176 // }).setNegativeButton(getString(R.string.cancel), new View.OnClickListener() {
163 // @Override 177 // @Override
164 // public void onClick(View v) { 178 // public void onClick(View v) {
165 // } 179 // }
166 // }).show(); 180 // }).show();
167 LogUtil.toast("请开启浮窗权限"); 181 LogUtil.toast("请开启浮窗权限");
168 } 182 }
169 183
170 184
171 public void showLoading(String title) { 185 public void showLoading(String title) {
172 synchronized (this) { 186 synchronized (this) {
173 if (loading != null || !isLiving(this)) return; 187 if (loading != null || !isLiving(this)) return;
174 runOnUiThread(() -> { 188 runOnUiThread(() -> {
175 loading = new LoadingView(this, R.style.CustomDialog, title); 189 loading = new LoadingView(this, R.style.CustomDialog, title);
176 loading.show(); 190 loading.show();
177 ScreenUtils.hideBottomUIMenu(this); 191 ScreenUtils.hideBottomUIMenu(this);
178 ScreenUtils.hideDialogBottomUIMenu(loading); 192 ScreenUtils.hideDialogBottomUIMenu(loading);
179 }); 193 });
180 } 194 }
181 } 195 }
182 196
183 197
184 public void setCanAble(boolean canAble) { 198 public void setCanAble(boolean canAble) {
185 if (loading != null) 199 if (loading != null)
186 loading.setCancelable(canAble); 200 loading.setCancelable(canAble);
187 201
188 } 202 }
189 203
190 public boolean isShowLoading() { 204 public boolean isShowLoading() {
191 if (loading == null) return false; 205 if (loading == null) return false;
192 return loading.isShowing(); 206 return loading.isShowing();
193 } 207 }
194 208
195 public void dismissLoading() { 209 public void dismissLoading() {
196 runOnUiThread(() -> { 210 runOnUiThread(() -> {
197 if (loading == null || loading.isShowing() == false || !isLiving(this)) { 211 if (loading == null || loading.isShowing() == false || !isLiving(this)) {
198 Log.w(TAG, "loading == null" + 212 Log.w(TAG, "loading == null" +
199 " || loading.isShowing() == false >> return;"); 213 " || loading.isShowing() == false >> return;");
200 return; 214 return;
201 } 215 }
202 loading.dismiss(); 216 loading.dismiss();
203 loading = null; 217 loading = null;
204 218
205 }); 219 });
206 } 220 }
207 221
208 222
209 private static boolean isLiving(Activity activity) { 223 private static boolean isLiving(Activity activity) {
210 224
211 if (activity == null) { 225 if (activity == null) {
212 Log.d("wisely", "activity == null"); 226 Log.d("wisely", "activity == null");
213 return false; 227 return false;
214 } 228 }
215 229
216 if (activity.isFinishing()) { 230 if (activity.isFinishing()) {
217 Log.d("wisely", "activity is finishing"); 231 Log.d("wisely", "activity is finishing");
218 return false; 232 return false;
219 } 233 }
220 234
221 return true; 235 return true;
222 } 236 }
223 237
224 238
225 /** 239 /**
226 * 是否需要弹窗提示更新 240 * 是否需要弹窗提示更新
227 */ 241 */
228 protected void isNeedGetVersionUpdate() { 242 protected void isNeedGetVersionUpdate() {
229 // View view = findViewById(R.id.view_loading); 243 // View view = findViewById(R.id.view_loading);
230 //如果显示正在下载的页面,则不弹出更新弹窗 244 //如果显示正在下载的页面,则不弹出更新弹窗
231 // if (null == view || view.getVisibility() == View.VISIBLE) return; 245 // if (null == view || view.getVisibility() == View.VISIBLE) return;
232 // UpdateUtils.getVersion(this); 246 // UpdateUtils.getVersion(this);
233 } 247 }
234 248
235 249
236 /** 250 /**
237 * 全局检测网络广播的回调 处理网络变化 251 * 全局检测网络广播的回调 处理网络变化
238 * 注:在程序第一次启动的时候,没网并不会回调,需要自己在启动页面,或者主页自己再判断一次 252 * 注:在程序第一次启动的时候,没网并不会回调,需要自己在启动页面,或者主页自己再判断一次
239 * 253 *
240 * @param netWorkState 网络状态 -1:没网络 0:移动网络 1:WiFi网络 254 * @param netWorkState 网络状态 -1:没网络 0:移动网络 1:WiFi网络
241 */ 255 */
242 public abstract void onNetChanged(int netWorkState); 256 public abstract void onNetChanged(int netWorkState);
243 257
244 @Override 258 @Override
245 public void onNetChange(int netWorkState) { 259 public void onNetChange(int netWorkState) {
246 onNetChanged(netWorkState); 260 onNetChanged(netWorkState);
247 } 261 }
248 262
249 @Override 263 @Override
250 protected void onDestroy() { 264 protected void onDestroy() {
251 super.onDestroy(); 265 super.onDestroy();
252 unSubscribe(); 266 unSubscribe();
253 cleanFragment(); 267 cleanFragment();
254 unregisterEventBus(); 268 unregisterEventBus();
255 if (p != null) { 269 if (p != null) {
256 p.onBindView(); 270 p.onBindView();
257 p.cancelAllRequest(); 271 p.cancelAllRequest();
258 } 272 }
259 } 273 }
260 274
261 @Override 275 @Override
262 protected void onPause() { 276 protected void onPause() {
263 super.onPause(); 277 super.onPause();
264 278
265 } 279 }
266 280
267 private void registerEventBus(){ 281 private void registerEventBus() {
268 EventBus.getDefault().register(this); 282 EventBus.getDefault().register(this);
269 } 283 }
270 284
271 private void unregisterEventBus(){ 285 private void unregisterEventBus() {
272 EventBus.getDefault().unregister(this); 286 EventBus.getDefault().unregister(this);
273 } 287 }
274 288
275 public void showErrorToast() { 289 public void showErrorToast() {
276 // LogUtil.toast(MainApplication.getAppContext(), getString(R.string.service_error)); 290 // LogUtil.toast(MainApplication.getAppContext(), getString(R.string.service_error));
277 } 291 }
278 292
293 public void showToast(String s) {
294 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
295 }
296
279 private void unSubscribe() { 297 private void unSubscribe() {
280 if (mCompositeDisposable != null) { 298 if (mCompositeDisposable != null) {
281 mCompositeDisposable.clear(); 299 mCompositeDisposable.clear();
282 } 300 }
283 } 301 }
284 302
285 protected void addSubscribe(Disposable disposable) { 303 protected void addSubscribe(Disposable disposable) {
286 if (mCompositeDisposable == null) { 304 if (mCompositeDisposable == null) {
287 mCompositeDisposable = new CompositeDisposable(); 305 mCompositeDisposable = new CompositeDisposable();
288 } 306 }
289 mCompositeDisposable.add(disposable); 307 mCompositeDisposable.add(disposable);
290 } 308 }
291 309
292 protected void startActivity(Class clazz) { 310 protected void startActivity(Class clazz) {
293 startActivity(new Intent(this, clazz)); 311 startActivity(new Intent(this, clazz));
294 } 312 }
295 313
296 /******************** 处理fragment *******************************/ 314 /******************** 处理fragment *******************************/
297 List<Fragment> fragmentList = new ArrayList<>(); 315 List<Fragment> fragmentList = new ArrayList<>();
298 316
299 protected void showFragment(Fragment fragment, @IdRes int id) { 317 protected void showFragment(Fragment fragment, @IdRes int id) {
300 FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 318 FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
301 319
302 if (!fragmentList.contains(fragment)) { 320 if (!fragmentList.contains(fragment)) {
303 fragmentList.add(fragment); 321 fragmentList.add(fragment);
304 fragmentTransaction.add(id, fragment, fragment.getClass().getSimpleName()).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); 322 fragmentTransaction.add(id, fragment, fragment.getClass().getSimpleName()).setMaxLifecycle(fragment, Lifecycle.State.RESUMED);
305 } 323 }
306 324
307 fragmentTransaction.show(fragment).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); 325 fragmentTransaction.show(fragment).setMaxLifecycle(fragment, Lifecycle.State.RESUMED);
308 326
309 for (Fragment fragment1 : fragmentList) { 327 for (Fragment fragment1 : fragmentList) {
310 if (fragment1 != fragment) { 328 if (fragment1 != fragment) {
311 fragmentTransaction.hide(fragment1).setMaxLifecycle(fragment1, Lifecycle.State.STARTED); 329 fragmentTransaction.hide(fragment1).setMaxLifecycle(fragment1, Lifecycle.State.STARTED);
312 } 330 }
313 } 331 }
314 332
315 fragmentTransaction.commitAllowingStateLoss(); 333 fragmentTransaction.commitAllowingStateLoss();
316 334
317 } 335 }
318 336
319 protected void cleanFragment() { 337 protected void cleanFragment() {
320 FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 338 FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
321 if (fragmentList.size() > 0) { 339 if (fragmentList.size() > 0) {
322 for (Fragment fragment : fragmentList) { 340 for (Fragment fragment : fragmentList) {
323 fragmentTransaction.remove(fragment); 341 fragmentTransaction.remove(fragment);
324 } 342 }
325 try { 343 try {
326 fragmentTransaction.commitNowAllowingStateLoss(); 344 fragmentTransaction.commitNowAllowingStateLoss();
327 }catch (Exception e){e.printStackTrace();} 345 } catch (Exception e) {
346 e.printStackTrace();
347 }
328 } 348 }
329 fragmentList.clear(); 349 fragmentList.clear();
330 } 350 }
331 351
332 //************************* 用于隐藏键盘 ***************************************// 352 //************************* 用于隐藏键盘 ***************************************//
333 @Override 353 @Override
334 public boolean dispatchTouchEvent(MotionEvent ev) { 354 public boolean dispatchTouchEvent(MotionEvent ev) {
335 if (ev.getAction() == MotionEvent.ACTION_DOWN){ 355 if (ev.getAction() == MotionEvent.ACTION_DOWN) {
336 356
337 View v = getCurrentFocus(); 357 View v = getCurrentFocus();
338 if (isShouldHideInput(v,ev)){ 358 if (isShouldHideInput(v, ev)) {
339 hideSoftInput(v.getWindowToken()); 359 hideSoftInput(v.getWindowToken());
340 } 360 }
341 } 361 }
342 return super.dispatchTouchEvent(ev); 362 return super.dispatchTouchEvent(ev);
343 } 363 }
344 private boolean isShouldHideInput(View v,MotionEvent event){ 364
345 if(v !=null&&(v instanceof EditText)){ 365 private boolean isShouldHideInput(View v, MotionEvent event) {
346 int[] l ={0,0}; 366 if (v != null && (v instanceof EditText)) {
367 int[] l = {0, 0};
347 v.getLocationInWindow(l); 368 v.getLocationInWindow(l);
348 int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left 369 int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left
349 + v.getWidth(); 370 + v.getWidth();
350 if(event.getX()> left &&event.getX()< right 371 if (event.getX() > left && event.getX() < right
351 &&event.getY()> top &&event.getY()< bottom){ 372 && event.getY() > top && event.getY() < bottom) {
352 // 点击EditText的事件,忽略它。 373 // 点击EditText的事件,忽略它。
353 return false; 374 return false;
354 }else{ 375 } else {
355 return true; 376 return true;
356 } 377 }
357 } 378 }
358 379
359 return false; 380 return false;
360 } 381 }
361 382
362 /** 383 /**
363 * 多种隐藏软件盘方法的其中一种 384 * 多种隐藏软件盘方法的其中一种
364 * 385 *
365 * @param token 386 * @param token
366 */ 387 */
367 private void hideSoftInput(IBinder token){ 388 private void hideSoftInput(IBinder token) {
368 LogUtil.i(TAG,"隐藏键盘"); 389 LogUtil.i(TAG, "隐藏键盘");
369 if(token !=null){ 390 if (token != null) {
370 InputMethodManager im =(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 391 InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
371 im.hideSoftInputFromWindow(token, 392 im.hideSoftInputFromWindow(token,
372 InputMethodManager.HIDE_NOT_ALWAYS); 393 InputMethodManager.HIDE_NOT_ALWAYS);
373 } 394 }
374 } 395 }
375 396
376 //************************* 用于隐藏键盘 end***************************************// 397 //************************* 用于隐藏键盘 end***************************************//
377 398
libs/common/src/main/java/com/prws/common/bean/Teacher.java
File was created 1 package com.prws.common.bean;
2
3 public class Teacher {
4 private Integer id;
5 private String userName;
6 private String account;
7 private String nickName;
8 private String phone;
9 private String mail;
10 private String identity;
11 private String photo;
12 private String qrCode;
13 private Integer sex;
14
15 public Integer getId() {
16 return id;
17 }
18
19 public void setId(Integer id) {
20 this.id = id;
21 }
22
23 public String getUserName() {
24 return userName;
25 }
26
27 public void setUserName(String userName) {
28 this.userName = userName;
29 }
30
31 public String getAccount() {
32 return account;
33 }
34
35 public void setAccount(String account) {
36 this.account = account;
37 }
38
39 public String getNickName() {
40 return nickName;
41 }
42
43 public void setNickName(String nickName) {
44 this.nickName = nickName;
45 }
46
47 public String getPhone() {
48 return phone;
49 }
50
51 public void setPhone(String phone) {
52 this.phone = phone;
53 }
54
55 public String getMail() {
56 return mail;
57 }
58
59 public void setMail(String mail) {
60 this.mail = mail;
61 }
62
63 public String getIdentity() {
64 return identity;
65 }
66
67 public void setIdentity(String identity) {
68 this.identity = identity;
69 }
70
71 public String getPhoto() {
72 return photo;
73 }
74
75 public void setPhoto(String photo) {
76 this.photo = photo;
77 }
78
79 public String getQrCode() {
80 return qrCode;
81 }
82
83 public void setQrCode(String qrCode) {
84 this.qrCode = qrCode;
85 }
86
87 public Integer getSex() {
88 return sex;
89 }
90
91 public void setSex(Integer sex) {
92 this.sex = sex;
93 }
94 }
95
libs/common/src/main/java/com/prws/common/net/NetWorks.java
1 package com.prws.common.net; 1 package com.prws.common.net;
2 2
3 3
4 import com.google.gson.Gson; 4 import com.google.gson.Gson;
5 import com.prws.common.BuildConfig; 5 import com.prws.common.BuildConfig;
6 import com.prws.common.bean.BaseEntity; 6 import com.prws.common.bean.BaseEntity;
7 import com.prws.common.bean.GradeAndSubject; 7 import com.prws.common.bean.GradeAndSubject;
8 import com.prws.common.bean.ResponseResult; 8 import com.prws.common.bean.ResponseResult;
9 import com.prws.common.bean.ScheduleBean; 9 import com.prws.common.bean.ScheduleBean;
10 import com.prws.common.bean.Teacher;
10 import com.prws.common.utils.SharedPreferencesUtil; 11 import com.prws.common.utils.SharedPreferencesUtil;
11 12
12 import java.io.File; 13 import java.io.File;
13 import java.util.HashMap; 14 import java.util.HashMap;
14 import java.util.List; 15 import java.util.List;
15 import java.util.Map; 16 import java.util.Map;
16 17
17 import io.reactivex.Observable; 18 import io.reactivex.Observable;
18 import io.reactivex.Observer; 19 import io.reactivex.Observer;
19 import io.reactivex.android.schedulers.AndroidSchedulers; 20 import io.reactivex.android.schedulers.AndroidSchedulers;
20 import io.reactivex.schedulers.Schedulers; 21 import io.reactivex.schedulers.Schedulers;
21 import okhttp3.MediaType; 22 import okhttp3.MediaType;
22 import okhttp3.MultipartBody; 23 import okhttp3.MultipartBody;
23 import okhttp3.RequestBody; 24 import okhttp3.RequestBody;
24 import okhttp3.ResponseBody; 25 import okhttp3.ResponseBody;
25 import retrofit2.Call; 26 import retrofit2.Call;
26 import retrofit2.Callback; 27 import retrofit2.Callback;
27 import retrofit2.http.Body; 28 import retrofit2.http.Body;
28 import retrofit2.http.DELETE; 29 import retrofit2.http.DELETE;
29 import retrofit2.http.FieldMap; 30 import retrofit2.http.FieldMap;
30 import retrofit2.http.FormUrlEncoded; 31 import retrofit2.http.FormUrlEncoded;
31 import retrofit2.http.GET; 32 import retrofit2.http.GET;
32 import retrofit2.http.Header; 33 import retrofit2.http.Header;
33 import retrofit2.http.Headers; 34 import retrofit2.http.Headers;
34 import retrofit2.http.Multipart; 35 import retrofit2.http.Multipart;
35 import retrofit2.http.POST; 36 import retrofit2.http.POST;
36 import retrofit2.http.Part; 37 import retrofit2.http.Part;
37 import retrofit2.http.PartMap; 38 import retrofit2.http.PartMap;
38 import retrofit2.http.Path; 39 import retrofit2.http.Path;
39 import retrofit2.http.Query; 40 import retrofit2.http.Query;
40 import retrofit2.http.QueryMap; 41 import retrofit2.http.QueryMap;
41 import retrofit2.http.Streaming; 42 import retrofit2.http.Streaming;
42 import retrofit2.http.Url; 43 import retrofit2.http.Url;
43 44
44 /** 45 /**
45 * 类名称:NetWorks 46 * 类名称:NetWorks
46 * 创建人: 47 * 创建人:
47 * <p> 48 * <p>
48 * 类描述:网络请求的操作类 49 * 类描述:网络请求的操作类
49 */ 50 */
50 public class NetWorks extends RetrofitUtils { 51 public class NetWorks extends RetrofitUtils {
51 //服务器路径 52 //服务器路径
52 public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); 53 public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class);
53 54
54 //设缓存有效期为1天 55 //设缓存有效期为1天
55 protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; 56 protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1;
56 //查询缓存的Cache-Control设置,使用缓存 57 //查询缓存的Cache-Control设置,使用缓存
57 protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; 58 protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC;
58 //查询网络的Cache-Control设置。不使用缓存 59 //查询网络的Cache-Control设置。不使用缓存
59 protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; 60 protected static final String CACHE_CONTROL_NETWORK = "max-age=0";
60 61
61 62
62 private interface NetService { 63 private interface NetService {
63 64
64 65
65 @GET("/api/v1/user/logout") 66 @GET("/api/v1/user/logout")
66 Observable<ResponseBody> logout(); 67 Observable<ResponseBody> logout();
67 68
68 @Multipart 69 @Multipart
69 @POST("/api/v1/user/upLoadAvatar") 70 @POST("/api/v1/user/upLoadAvatar")
70 Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); 71 Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis);
71 72
72 73
73 @Headers("Content-Type: application/json") 74 @Headers("Content-Type: application/json")
74 @POST("/api/v1/user/editUser") 75 @POST("/api/v1/user/editUser")
75 Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); 76 Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body);
76 77
77 @Headers("Content-Type: application/json") 78 @Headers("Content-Type: application/json")
78 @POST("/api/v1/user/changePassword") 79 @POST("/api/v1/user/changePassword")
79 Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); 80 Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body);
80 81
81 82
82 @GET("/api/v1/user/searchById") 83 @GET("/api/v1/user/searchById")
83 Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); 84 Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId);
84 85
85 86
86 @Headers("Content-Type: application/json") 87 @Headers("Content-Type: application/json")
87 @POST("/api/v1/auth/login") 88 @POST("/api/v1/auth/login")
88 Observable<ResponseBody> login(@Body RequestBody body); 89 Observable<ResponseBody> login(@Body RequestBody body);
89 90
90 @GET("/api/v1/resource/listGradeAndSubject") 91 @GET("/api/v1/resource/listGradeAndSubject")
91 Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); 92 Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token);
92 93
93 94
94 @GET("/api/v1/manager/generalQrCode") 95 @GET("/api/v1/manager/generalQrCode")
95 Observable<ResponseBody> generalQrCode(); 96 Observable<ResponseBody> generalQrCode();
96 97
97 @GET("/api/v1/parent/scanAndLogin?") 98 @GET("/api/v1/parent/scanAndLogin?")
98 Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code); 99 Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code);
99 100
100 @GET("/api/v1/parent/getChildrenList") 101 @GET("/api/v1/parent/getChildrenList")
101 Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); 102 Observable<ResponseBody> getChildrenList(@Header("Authorization") String token);
102 103
103 104
104 @Headers("Content-Type: application/json") 105 @Headers("Content-Type: application/json")
105 @POST("/api/v1/parent/registerParent") 106 @POST("/api/v1/parent/registerParent")
106 Observable<ResponseBody> registerParent(@Body RequestBody body); 107 Observable<ResponseBody> registerParent(@Body RequestBody body);
107 108
108 109
109 @GET("/api/v1/parent/listChildren") 110 @GET("/api/v1/parent/listChildren")
110 Observable<ResponseBody> listChildren(@Header("Authorization") String token); 111 Observable<ResponseBody> listChildren(@Header("Authorization") String token);
111 112
112 113
113 @Headers("Content-Type: application/json") 114 @Headers("Content-Type: application/json")
114 @POST("/api/v1/parent/registerStudent") 115 @POST("/api/v1/parent/registerStudent")
115 Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); 116 Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body);
116 117
117 @Headers("Content-Type: application/json") 118 @Headers("Content-Type: application/json")
118 @POST("/api/v1/parent/bindTeacher") 119 @POST("/api/v1/parent/bindTeacher")
119 Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); 120 Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body);
120 121
121 @Multipart 122 @Multipart
122 @POST("/api/v1/user/upLoadAvatar") 123 @POST("/api/v1/user/upLoadAvatar")
123 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); 124 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file);
124 125
125 126
126 @Multipart 127 @Multipart
127 @POST("/api/v1/student/editStudentAvatar") 128 @POST("/api/v1/student/editStudentAvatar")
128 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); 129 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map);
129 130
130 @Headers("Content-Type: application/json") 131 @Headers("Content-Type: application/json")
131 @POST("/api/v1/parent/editChild") 132 @POST("/api/v1/parent/editChild")
132 Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); 133 Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body);
133 134
134 @GET("/api/v1/student/getStudyPlanForThisWeek") 135 @GET("/api/v1/student/getStudyPlanForThisWeek")
135 Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); 136 Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId);
137
138 @GET("api/v1/parent/searchTeacher")
139 Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone);
136 } 140 }
137 141
138 142
139 public static String getHeader() { 143 public static String getHeader() {
140 return (String) SharedPreferencesUtil.getData("token", ""); 144 return (String) SharedPreferencesUtil.getData("token", "");
141 } 145 }
142 146
147 public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) {
148 setSubscribe(service_url.searchTeacher(getHeader(), phone), observer);
149 }
150
143 public static void logout(Observer<ResponseBody> observer) { 151 public static void logout(Observer<ResponseBody> observer) {
144 setSubscribe(service_url.logout(), observer); 152 setSubscribe(service_url.logout(), observer);
145 } 153 }
146 154
147 public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { 155 public static void editStudent(RequestBody body, Observer<ResponseResult> observable) {
148 setSubscribe(service_url.editStudent(getHeader(), body), observable); 156 setSubscribe(service_url.editStudent(getHeader(), body), observable);
149 } 157 }
150 158
151 public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { 159 public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) {
152 setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); 160 setSubscribe(service_url.getWeekPlan(getHeader(), id), observer);
153 } 161 }
154 162
155 public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { 163 public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) {
156 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); 164 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
157 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); 165 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
158 Map<String, Object> map = new HashMap<>(); 166 Map<String, Object> map = new HashMap<>();
159 map.put("stuId", stuId); 167 map.put("stuId", stuId);
160 setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); 168 setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer);
161 } 169 }
162 170
163 public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { 171 public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) {
164 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); 172 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
165 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); 173 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
166 setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); 174 setSubscribe(service_url.uploadAvatar(getHeader(), part), observer);
167 } 175 }
168 176
169 public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { 177 public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) {
170 setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); 178 setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer);
171 } 179 }
172 180
173 181
174 public static void editUser(RequestBody body, Observer<ResponseBody> observer) { 182 public static void editUser(RequestBody body, Observer<ResponseBody> observer) {
175 setSubscribe(service_url.editUser(getHeader(), body), observer); 183 setSubscribe(service_url.editUser(getHeader(), body), observer);
176 } 184 }
177 185
178 public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { 186 public static void changePassword(RequestBody body, Observer<ResponseBody> observer) {
179 setSubscribe(service_url.changePassword(getHeader(), body), observer); 187 setSubscribe(service_url.changePassword(getHeader(), body), observer);
180 } 188 }
181 189
182 190
183 public static void searchById(String userId, Observer<ResponseBody> observer) { 191 public static void searchById(String userId, Observer<ResponseBody> observer) {
184 setSubscribe(service_url.searchById(getHeader(), userId), observer); 192 setSubscribe(service_url.searchById(getHeader(), userId), observer);
185 } 193 }
186 194
187 195
188 public static void login(RequestBody body, Observer<ResponseBody> observer) { 196 public static void login(RequestBody body, Observer<ResponseBody> observer) {
189 setSubscribe(service_url.login(body), observer); 197 setSubscribe(service_url.login(body), observer);
190 } 198 }
191 199
192 public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { 200 public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) {
193 setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); 201 setSubscribe(service_url.listGradeAndSubject(getHeader()), observer);
194 } 202 }
195 203
196 204
197 public static void scanAndLogin(String code, Observer<ResponseBody> observer) { 205 public static void scanAndLogin(String code, Observer<ResponseBody> observer) {
198 setSubscribe(service_url.scanAndLogin(getHeader(), code), observer); 206 setSubscribe(service_url.scanAndLogin(getHeader(), code), observer);
199 } 207 }
200 208
201 public static void getChildrenList(Observer<ResponseBody> observer) { 209 public static void getChildrenList(Observer<ResponseBody> observer) {
202 setSubscribe(service_url.getChildrenList(getHeader()), observer); 210 setSubscribe(service_url.getChildrenList(getHeader()), observer);
203 } 211 }
204 212
205 213
206 public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { 214 public static void registerParent(RequestBody body, Observer<ResponseBody> observer) {
207 setSubscribe(service_url.registerParent(body), observer); 215 setSubscribe(service_url.registerParent(body), observer);
208 } 216 }
209 217
210 218
211 public static void listChildren(Observer<ResponseBody> observer) { 219 public static void listChildren(Observer<ResponseBody> observer) {
212 setSubscribe(service_url.listChildren(getHeader()), observer); 220 setSubscribe(service_url.listChildren(getHeader()), observer);
213 } 221 }
214 222
215 223
216 public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { 224 public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) {
217 setSubscribe(service_url.registerStudent(getHeader(), body), observer); 225 setSubscribe(service_url.registerStudent(getHeader(), body), observer);
218 } 226 }
219 227
220 public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { 228 public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) {
221 setSubscribe(service_url.bindTeacher(getHeader(), body), observer); 229 setSubscribe(service_url.bindTeacher(getHeader(), body), observer);
222 } 230 }
223 231
224 232
225 public static RequestBody getMapRequestBody(Map map) { 233 public static RequestBody getMapRequestBody(Map map) {
226 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); 234 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map));
227 } 235 }
228 236
229 public static RequestBody getArrayRequestBody(List list) { 237 public static RequestBody getArrayRequestBody(List list) {
230 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); 238 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list));
231 } 239 }
232 240
233 public static RequestBody getFileRequestBody(File file) { 241 public static RequestBody getFileRequestBody(File file) {
234 return RequestBody.create(MediaType.parse("application/octet-stream"), file); 242 return RequestBody.create(MediaType.parse("application/octet-stream"), file);
235 } 243 }
236 244
237 public static RequestBody getFileRequestBody(byte[] bytes) { 245 public static RequestBody getFileRequestBody(byte[] bytes) {
238 return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); 246 return RequestBody.create(MediaType.parse("multipart/form-data"), bytes);
239 } 247 }
240 248
241 public static RequestBody getObjectRequestBody(Object obj) { 249 public static RequestBody getObjectRequestBody(Object obj) {
242 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); 250 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj));
243 } 251 }
244 252
245 public static RequestBody getStringRequestBody(String str) { 253 public static RequestBody getStringRequestBody(String str) {
246 return RequestBody.create(MediaType.parse("text/plain"), str); 254 return RequestBody.create(MediaType.parse("text/plain"), str);
247 } 255 }
248 256
249 /** 257 /**
250 * 插入观察者 258 * 插入观察者
251 * 259 *
252 * @param observable 260 * @param observable
253 * @param observer 261 * @param observer
254 * @param <T> 262 * @param <T>
255 */ 263 */
256 public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { 264 public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) {
257 observable.subscribeOn(Schedulers.io())//子线程访问网络 265 observable.subscribeOn(Schedulers.io())//子线程访问网络
258 .observeOn(AndroidSchedulers.mainThread())//回调到主线程 266 .observeOn(AndroidSchedulers.mainThread())//回调到主线程
259 .subscribe(observer); 267 .subscribe(observer);
260 } 268 }
261 269
262 } 270 }
263 271