Commit 49236c7b5f9a58c97bf8cbefcd376ad86c9407cc
1 parent
0471108b6a
Exists in
master
去掉绑定老师功能
Showing
2 changed files
with
1 additions
and
53 deletions
Show diff stats
app/src/main/java/com/hjx/parent/EditStudentActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | import android.content.DialogInterface; | 4 | import android.content.DialogInterface; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.Color; | 7 | import android.graphics.Color; |
8 | import android.net.Uri; | 8 | import android.net.Uri; |
9 | import android.os.Build; | 9 | import android.os.Build; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.os.Environment; | 11 | import android.os.Environment; |
12 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
14 | import android.util.Log; | 14 | import android.util.Log; |
15 | import android.view.LayoutInflater; | 15 | import android.view.LayoutInflater; |
16 | import android.view.View; | 16 | import android.view.View; |
17 | import android.widget.Button; | 17 | import android.widget.Button; |
18 | import android.widget.ImageView; | 18 | import android.widget.ImageView; |
19 | import android.widget.LinearLayout; | 19 | import android.widget.LinearLayout; |
20 | import android.widget.RelativeLayout; | 20 | import android.widget.RelativeLayout; |
21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
23 | 23 | ||
24 | import androidx.core.content.FileProvider; | 24 | import androidx.core.content.FileProvider; |
25 | 25 | ||
26 | import com.bumptech.glide.Glide; | 26 | import com.bumptech.glide.Glide; |
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
28 | import com.bumptech.glide.request.RequestOptions; | 28 | import com.bumptech.glide.request.RequestOptions; |
29 | import com.google.android.material.bottomsheet.BottomSheetDialog; | 29 | import com.google.android.material.bottomsheet.BottomSheetDialog; |
30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
31 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
32 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
33 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
34 | import com.hjx.parent.bean.StudentBean; | 34 | import com.hjx.parent.bean.StudentBean; |
35 | import com.prws.common.base.BaseActivity; | 35 | import com.prws.common.base.BaseActivity; |
36 | import com.prws.common.base.BasePresenter; | 36 | import com.prws.common.base.BasePresenter; |
37 | import com.prws.common.bean.ResponseResult; | 37 | import com.prws.common.bean.ResponseResult; |
38 | import com.prws.common.bean.Teacher; | 38 | import com.prws.common.bean.Teacher; |
39 | import com.prws.common.net.NetWorks; | 39 | import com.prws.common.net.NetWorks; |
40 | import com.prws.common.utils.LogUtil; | 40 | import com.prws.common.utils.LogUtil; |
41 | import com.prws.common.utils.ScreenUtils; | 41 | import com.prws.common.utils.ScreenUtils; |
42 | import com.prws.common.utils.SharedPreferencesUtil; | 42 | import com.prws.common.utils.SharedPreferencesUtil; |
43 | 43 | ||
44 | import org.json.JSONObject; | 44 | import org.json.JSONObject; |
45 | 45 | ||
46 | import java.io.File; | 46 | import java.io.File; |
47 | import java.io.FileOutputStream; | 47 | import java.io.FileOutputStream; |
48 | import java.io.IOException; | 48 | import java.io.IOException; |
49 | import java.util.HashMap; | 49 | import java.util.HashMap; |
50 | import java.util.List; | 50 | import java.util.List; |
51 | import java.util.Map; | 51 | import java.util.Map; |
52 | 52 | ||
53 | import butterknife.BindView; | 53 | import butterknife.BindView; |
54 | import butterknife.OnClick; | 54 | import butterknife.OnClick; |
55 | import io.reactivex.Observer; | 55 | import io.reactivex.Observer; |
56 | import io.reactivex.disposables.Disposable; | 56 | import io.reactivex.disposables.Disposable; |
57 | 57 | ||
58 | public class EditStudentActivity extends BaseActivity { | 58 | public class EditStudentActivity extends BaseActivity { |
59 | View view_2; | 59 | View view_2; |
60 | View view_3; | 60 | View view_3; |
61 | View view_4; | 61 | View view_4; |
62 | View view_5; | 62 | View view_5; |
63 | Button btn_next; | 63 | Button btn_next; |
64 | TextView tv_name, tv_sex, tv_nian, tv_shen; | 64 | TextView tv_name, tv_sex, tv_nian, tv_shen; |
65 | @BindView(R.id.iv_avatar) | 65 | @BindView(R.id.iv_avatar) |
66 | ImageView iv_avatar; | 66 | ImageView iv_avatar; |
67 | @BindView(R.id.tv_teacher) | 67 | @BindView(R.id.tv_teacher) |
68 | TextView tv_teacher; | 68 | TextView tv_teacher; |
69 | @BindView(R.id.iv_teacher) | 69 | @BindView(R.id.iv_teacher) |
70 | ImageView iv_teacher; | 70 | ImageView iv_teacher; |
71 | @BindView(R.id.rl_teacher) | 71 | @BindView(R.id.rl_teacher) |
72 | RelativeLayout rl_teacher; | 72 | RelativeLayout rl_teacher; |
73 | @BindView(R.id.tv_bind) | ||
74 | TextView tv_bind; | ||
75 | @BindView(R.id.view_6) | 73 | @BindView(R.id.view_6) |
76 | LinearLayout view_6; | 74 | LinearLayout view_6; |
77 | private static int CAMERA_REQUEST_CODE = 343; | 75 | private static int CAMERA_REQUEST_CODE = 343; |
78 | private static int ALBUM_REQUEST_CODE = 456; | 76 | private static int ALBUM_REQUEST_CODE = 456; |
79 | private static int CROP_REQUEST_CODE = 234; | 77 | private static int CROP_REQUEST_CODE = 234; |
80 | 78 | ||
81 | private static int BIND_TEACHER_CODE = 345; | 79 | private static int BIND_TEACHER_CODE = 345; |
82 | private File tempFile; | 80 | private File tempFile; |
83 | private String path; | 81 | private String path; |
84 | StudentBean studentBean; | 82 | StudentBean studentBean; |
85 | private Teacher teacher; | 83 | private Teacher teacher; |
86 | 84 | ||
87 | @Override | 85 | @Override |
88 | protected int layoutResId() { | 86 | protected int layoutResId() { |
89 | return R.layout.activity_edit_stu; | 87 | return R.layout.activity_edit_stu; |
90 | } | 88 | } |
91 | 89 | ||
92 | @Override | 90 | @Override |
93 | public Object getContract() { | 91 | public Object getContract() { |
94 | return null; | 92 | return null; |
95 | } | 93 | } |
96 | 94 | ||
97 | @Override | 95 | @Override |
98 | public BasePresenter getPresenter() { | 96 | public BasePresenter getPresenter() { |
99 | return null; | 97 | return null; |
100 | } | 98 | } |
101 | 99 | ||
102 | @Override | 100 | @Override |
103 | protected void initView() { | 101 | protected void initView() { |
104 | view_2 = findViewById(R.id.view_2); | 102 | view_2 = findViewById(R.id.view_2); |
105 | view_3 = findViewById(R.id.view_3); | 103 | view_3 = findViewById(R.id.view_3); |
106 | view_4 = findViewById(R.id.view_4); | 104 | view_4 = findViewById(R.id.view_4); |
107 | view_5 = findViewById(R.id.view_5); | 105 | view_5 = findViewById(R.id.view_5); |
108 | tv_name = findViewById(R.id.tv_name); | 106 | tv_name = findViewById(R.id.tv_name); |
109 | tv_sex = findViewById(R.id.tv_sex); | 107 | tv_sex = findViewById(R.id.tv_sex); |
110 | tv_nian = findViewById(R.id.tv_nian); | 108 | tv_nian = findViewById(R.id.tv_nian); |
111 | tv_shen = findViewById(R.id.tv_shen); | 109 | tv_shen = findViewById(R.id.tv_shen); |
112 | btn_next = findViewById(R.id.btn_next); | 110 | btn_next = findViewById(R.id.btn_next); |
113 | } | 111 | } |
114 | 112 | ||
115 | @SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables"}) | 113 | @SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables"}) |
116 | @Override | 114 | @Override |
117 | protected void onStart() { | 115 | protected void onStart() { |
118 | super.onStart(); | 116 | super.onStart(); |
119 | String name = (String) SharedPreferencesUtil.getData("setName", ""); | 117 | String name = (String) SharedPreferencesUtil.getData("setName", ""); |
120 | String sex = (String) SharedPreferencesUtil.getData("setSex", ""); | 118 | String sex = (String) SharedPreferencesUtil.getData("setSex", ""); |
121 | String nian = (String) SharedPreferencesUtil.getData("setNian", ""); | 119 | String nian = (String) SharedPreferencesUtil.getData("setNian", ""); |
122 | String shen = (String) SharedPreferencesUtil.getData("setShen", ""); | 120 | String shen = (String) SharedPreferencesUtil.getData("setShen", ""); |
123 | String xueq = (String) SharedPreferencesUtil.getData("setXueq", ""); | 121 | String xueq = (String) SharedPreferencesUtil.getData("setXueq", ""); |
124 | btn_next.setTextColor(Color.WHITE); | 122 | btn_next.setTextColor(Color.WHITE); |
125 | btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn)); | 123 | btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn)); |
126 | studentBean = new Gson().fromJson(getIntent().getStringExtra("student"), StudentBean.class); | 124 | studentBean = new Gson().fromJson(getIntent().getStringExtra("student"), StudentBean.class); |
127 | if (name != null && name.length() > 0) { | 125 | if (name != null && name.length() > 0) { |
128 | studentBean.setNickName(name); | 126 | studentBean.setNickName(name); |
129 | } | 127 | } |
130 | if (sex != null && sex.length() > 0) { | 128 | if (sex != null && sex.length() > 0) { |
131 | studentBean.setGender(sex); | 129 | studentBean.setGender(sex); |
132 | } | 130 | } |
133 | if (nian != null && nian.length() > 0) { | 131 | if (nian != null && nian.length() > 0) { |
134 | studentBean.setGrade(nian); | 132 | studentBean.setGrade(nian); |
135 | } | 133 | } |
136 | if (xueq != null && xueq.length() > 0) { | 134 | if (xueq != null && xueq.length() > 0) { |
137 | studentBean.setTerm(xueq); | 135 | studentBean.setTerm(xueq); |
138 | } | 136 | } |
139 | if (shen != null && shen.length() > 0) { | 137 | if (shen != null && shen.length() > 0) { |
140 | studentBean.setParentIdentity(shen); | 138 | studentBean.setParentIdentity(shen); |
141 | } | 139 | } |
142 | tv_name.setText(studentBean.getNickName()); | 140 | tv_name.setText(studentBean.getNickName()); |
143 | tv_nian.setText(studentBean.getGrade() + studentBean.getTerm()); | 141 | tv_nian.setText(studentBean.getGrade() + studentBean.getTerm()); |
144 | tv_sex.setText(studentBean.getGender()); | 142 | tv_sex.setText(studentBean.getGender()); |
145 | tv_shen.setText(studentBean.getParentIdentity()); | 143 | tv_shen.setText(studentBean.getParentIdentity()); |
146 | if (!TextUtils.isEmpty(studentBean.getPhoto())) { | 144 | if (!TextUtils.isEmpty(studentBean.getPhoto())) { |
147 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 45)); | 145 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 45)); |
148 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 146 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
149 | Glide.with(this).load(studentBean.getPhoto()).apply(options).into(iv_avatar); | 147 | Glide.with(this).load(studentBean.getPhoto()).apply(options).into(iv_avatar); |
150 | } else { | 148 | } else { |
151 | iv_avatar.setImageResource("男".equals(studentBean.getGender()) ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | 149 | iv_avatar.setImageResource("男".equals(studentBean.getGender()) ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); |
152 | } | 150 | } |
153 | if (studentBean.getIsIntention() == 1) { | 151 | if (studentBean.getIsIntention() == 1) { |
154 | rl_teacher.setVisibility(View.VISIBLE); | 152 | rl_teacher.setVisibility(View.VISIBLE); |
155 | tv_bind.setText("重新绑定"); | ||
156 | tv_teacher.setText(studentBean.getTeacherName()); | 153 | tv_teacher.setText(studentBean.getTeacherName()); |
157 | if (!TextUtils.isEmpty(studentBean.getTeacherAvatar())) { | 154 | if (!TextUtils.isEmpty(studentBean.getTeacherAvatar())) { |
158 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 25)); | 155 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(this, 25)); |
159 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 156 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
160 | Glide.with(this).load(studentBean.getTeacherAvatar()).apply(options).into(iv_teacher); | 157 | Glide.with(this).load(studentBean.getTeacherAvatar()).apply(options).into(iv_teacher); |
161 | } else { | 158 | } else { |
162 | iv_teacher.setImageResource(R.mipmap.ic_teacher_female); | 159 | iv_teacher.setImageResource(R.mipmap.ic_teacher_female); |
163 | } | 160 | } |
164 | } else { | 161 | } else { |
165 | rl_teacher.setVisibility(View.GONE); | 162 | rl_teacher.setVisibility(View.GONE); |
166 | if ((studentBean.getState() != null && studentBean.getState() == 0)) { | 163 | if ((studentBean.getState() != null && studentBean.getState() == 0)) { |
167 | tv_bind.setText("待通过"); | ||
168 | tv_bind.setTextColor(Color.parseColor("#FF3737")); | ||
169 | view_6.setEnabled(false); | 164 | view_6.setEnabled(false); |
170 | } | 165 | } |
171 | } | 166 | } |
172 | 167 | ||
173 | } | 168 | } |
174 | 169 | ||
175 | @Override | 170 | @Override |
176 | protected void initListener() { | 171 | protected void initListener() { |
177 | view_2.setOnClickListener(view -> startActivity(NickActivity.class)); | 172 | view_2.setOnClickListener(view -> startActivity(NickActivity.class)); |
178 | view_3.setOnClickListener(view -> startActivity(SexActivity.class)); | 173 | view_3.setOnClickListener(view -> startActivity(SexActivity.class)); |
179 | view_4.setOnClickListener(view -> startActivity(NianActivity.class)); | 174 | view_4.setOnClickListener(view -> startActivity(NianActivity.class)); |
180 | view_5.setOnClickListener(view -> startActivity(ShenActivity.class)); | 175 | view_5.setOnClickListener(view -> startActivity(ShenActivity.class)); |
181 | findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); | 176 | findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); |
182 | btn_next.setOnClickListener(view -> { | 177 | btn_next.setOnClickListener(view -> { |
183 | if (teacher != null || studentBean.getIsIntention() == 1 || (studentBean.getState() != null && studentBean.getState() == 0)) { | 178 | editStudent(); |
184 | editStudent(); | ||
185 | } else { | ||
186 | showDialog("温馨提示", "您还未绑定老师,是否绑定?", "去绑定", "暂不绑定", new DialogInterface.OnClickListener() { | ||
187 | @Override | ||
188 | public void onClick(DialogInterface dialogInterface, int i) { | ||
189 | dialogInterface.dismiss(); | ||
190 | showDialog("温馨提示", "您暂未绑定老师,如需绑定老师\n" + "请联系400-800-3813", "确定", "", null, new DialogInterface.OnClickListener() { | ||
191 | @Override | ||
192 | public void onClick(DialogInterface dialogInterface, int i) { | ||
193 | editStudent(); | ||
194 | } | ||
195 | }); | ||
196 | } | ||
197 | }, new DialogInterface.OnClickListener() { | ||
198 | @Override | ||
199 | public void onClick(DialogInterface dialogInterface, int i) { | ||
200 | Intent intent = new Intent(EditStudentActivity.this, AddTeacherActivity.class); | ||
201 | startActivityForResult(intent, BIND_TEACHER_CODE); | ||
202 | } | ||
203 | }); | ||
204 | } | ||
205 | }); | 179 | }); |
206 | } | 180 | } |
207 | 181 | ||
208 | @OnClick(R.id.view_6) | ||
209 | public void toAddTeacher(View view) { | ||
210 | Intent intent = new Intent(EditStudentActivity.this, AddTeacherActivity.class); | ||
211 | startActivityForResult(intent, BIND_TEACHER_CODE); | ||
212 | } | ||
213 | |||
214 | public void editStudent() { | 182 | public void editStudent() { |
215 | Map<String, Object> map = new HashMap<>(); | 183 | Map<String, Object> map = new HashMap<>(); |
216 | map.put("nickName", studentBean.getNickName()); | 184 | map.put("nickName", studentBean.getNickName()); |
217 | map.put("gender", studentBean.getGender()); | 185 | map.put("gender", studentBean.getGender()); |
218 | map.put("parentIdentity", studentBean.getParentIdentity()); | 186 | map.put("parentIdentity", studentBean.getParentIdentity()); |
219 | map.put("term", studentBean.getTerm()); | 187 | map.put("term", studentBean.getTerm()); |
220 | if (teacher != null) { | 188 | if (teacher != null) { |
221 | map.put("teacherId", teacher.getId()); | 189 | map.put("teacherId", teacher.getId()); |
222 | } | 190 | } |
223 | map.put("stuId", studentBean.getStuId()); | 191 | map.put("stuId", studentBean.getStuId()); |
224 | NetWorks.editStudent(NetWorks.getMapRequestBody(map), new Observer<ResponseResult>() { | 192 | NetWorks.editStudent(NetWorks.getMapRequestBody(map), new Observer<ResponseResult>() { |
225 | @Override | 193 | @Override |
226 | public void onSubscribe(Disposable d) { | 194 | public void onSubscribe(Disposable d) { |
227 | 195 | ||
228 | } | 196 | } |
229 | 197 | ||
230 | @Override | 198 | @Override |
231 | public void onNext(ResponseResult responseResult) { | 199 | public void onNext(ResponseResult responseResult) { |
232 | try { | 200 | try { |
233 | boolean isSucceed = responseResult.getSuccess(); | 201 | boolean isSucceed = responseResult.getSuccess(); |
234 | if (isSucceed) { | 202 | if (isSucceed) { |
235 | finish(); | 203 | finish(); |
236 | } else { | 204 | } else { |
237 | Toast.makeText(EditStudentActivity.this, responseResult.getMsg(), Toast.LENGTH_SHORT).show(); | 205 | Toast.makeText(EditStudentActivity.this, responseResult.getMsg(), Toast.LENGTH_SHORT).show(); |
238 | } | 206 | } |
239 | } catch (Exception e) { | 207 | } catch (Exception e) { |
240 | 208 | ||
241 | } | 209 | } |
242 | } | 210 | } |
243 | 211 | ||
244 | @Override | 212 | @Override |
245 | public void onError(Throwable e) { | 213 | public void onError(Throwable e) { |
246 | 214 | ||
247 | } | 215 | } |
248 | 216 | ||
249 | @Override | 217 | @Override |
250 | public void onComplete() { | 218 | public void onComplete() { |
251 | 219 | ||
252 | } | 220 | } |
253 | }); | 221 | }); |
254 | } | 222 | } |
255 | 223 | ||
256 | @Override | 224 | @Override |
257 | protected void initData() { | 225 | protected void initData() { |
258 | 226 | ||
259 | } | 227 | } |
260 | 228 | ||
261 | @Override | 229 | @Override |
262 | public void onNetChanged(int netWorkState) { | 230 | public void onNetChanged(int netWorkState) { |
263 | 231 | ||
264 | } | 232 | } |
265 | 233 | ||
266 | private void cropPhoto(Uri uri) { | 234 | private void cropPhoto(Uri uri) { |
267 | Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg")); | 235 | Uri contentUri = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg")); |
268 | Intent intent = new Intent("com.android.camera.action.CROP"); | 236 | Intent intent = new Intent("com.android.camera.action.CROP"); |
269 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 237 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
270 | //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片 | 238 | //Android 7.0需要临时添加读取Url的权限, 添加此属性是为了解决:调用裁剪框时候提示:图片无法加载或者加载图片失败或者无法加载此图片 |
271 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 239 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
272 | } | 240 | } |
273 | intent.setDataAndType(uri, "image/*"); | 241 | intent.setDataAndType(uri, "image/*"); |
274 | intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪 | 242 | intent.putExtra("crop", "true");//发送裁剪信号,去掉也能进行裁剪 |
275 | intent.putExtra("scale", true);// 设置缩放 | 243 | intent.putExtra("scale", true);// 设置缩放 |
276 | intent.putExtra("scaleUpIfNeeded", true);// 去黑边 | 244 | intent.putExtra("scaleUpIfNeeded", true);// 去黑边 |
277 | intent.putExtra("aspectX", 1); | 245 | intent.putExtra("aspectX", 1); |
278 | intent.putExtra("aspectY", 1); | 246 | intent.putExtra("aspectY", 1); |
279 | //上述两个属性控制裁剪框的缩放比例。 | 247 | //上述两个属性控制裁剪框的缩放比例。 |
280 | //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。 | 248 | //当用户用手拉伸裁剪框时候,裁剪框会按照上述比例缩放。 |
281 | intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。 | 249 | intent.putExtra("outputX", 300);//属性控制裁剪完毕,保存的图片的大小格式。 |
282 | intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存, | 250 | intent.putExtra("outputY", 300);//你按照1:1的比例来裁剪的,如果最后成像是800*400,那么按照2:1的样式保存, |
283 | intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式 | 251 | intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出裁剪文件的格式 |
284 | intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap | 252 | intent.putExtra("return-data", true);//是否返回裁剪后图片的Bitmap |
285 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径 | 253 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);//设置输出路径 |
286 | startActivityForResult(intent, CROP_REQUEST_CODE); | 254 | startActivityForResult(intent, CROP_REQUEST_CODE); |
287 | } | 255 | } |
288 | 256 | ||
289 | @Override | 257 | @Override |
290 | protected void onActivityResult(int requestCode, int resultCode, Intent intent) { | 258 | protected void onActivityResult(int requestCode, int resultCode, Intent intent) { |
291 | super.onActivityResult(requestCode, resultCode, intent); | 259 | super.onActivityResult(requestCode, resultCode, intent); |
292 | if (requestCode == CAMERA_REQUEST_CODE) { | 260 | if (requestCode == CAMERA_REQUEST_CODE) { |
293 | if (resultCode == RESULT_OK) { | 261 | if (resultCode == RESULT_OK) { |
294 | //用相机返回的照片去调用剪裁也需要对Uri进行处理 | 262 | //用相机返回的照片去调用剪裁也需要对Uri进行处理 |
295 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 263 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
296 | Uri contentUri = FileProvider.getUriForFile(this, | 264 | Uri contentUri = FileProvider.getUriForFile(this, |
297 | this.getPackageName() + ".fileprovider", tempFile); | 265 | this.getPackageName() + ".fileprovider", tempFile); |
298 | cropPhoto(contentUri); | 266 | cropPhoto(contentUri); |
299 | } else { | 267 | } else { |
300 | cropPhoto(Uri.fromFile(tempFile)); | 268 | cropPhoto(Uri.fromFile(tempFile)); |
301 | } | 269 | } |
302 | } | 270 | } |
303 | } else if (requestCode == ALBUM_REQUEST_CODE) { | 271 | } else if (requestCode == ALBUM_REQUEST_CODE) { |
304 | if (resultCode == RESULT_OK) { | 272 | if (resultCode == RESULT_OK) { |
305 | Uri uri = intent.getData(); | 273 | Uri uri = intent.getData(); |
306 | cropPhoto(uri); | 274 | cropPhoto(uri); |
307 | } | 275 | } |
308 | } else if (requestCode == CROP_REQUEST_CODE) { | 276 | } else if (requestCode == CROP_REQUEST_CODE) { |
309 | if (intent == null) { | 277 | if (intent == null) { |
310 | return; | 278 | return; |
311 | } | 279 | } |
312 | Bundle bundle = intent.getExtras(); | 280 | Bundle bundle = intent.getExtras(); |
313 | if (bundle != null) { | 281 | if (bundle != null) { |
314 | //在这里获得了剪裁后的Bitmap对象,可以用于上传 | 282 | //在这里获得了剪裁后的Bitmap对象,可以用于上传 |
315 | Bitmap image = bundle.getParcelable("data"); | 283 | Bitmap image = bundle.getParcelable("data"); |
316 | //设置到ImageView上 | 284 | //设置到ImageView上 |
317 | //也可以进行一些保存、压缩等操作后上传 | 285 | //也可以进行一些保存、压缩等操作后上传 |
318 | File file = saveImage("head_output", image); | 286 | File file = saveImage("head_output", image); |
319 | uploadAvatar(file); | 287 | uploadAvatar(file); |
320 | // Log.d("dsadsadsa",path); | 288 | // Log.d("dsadsadsa",path); |
321 | } | 289 | } |
322 | } else if (requestCode == BIND_TEACHER_CODE && resultCode == 1000) { | 290 | } else if (requestCode == BIND_TEACHER_CODE && resultCode == 1000) { |
323 | String t = intent.getStringExtra("teacher"); | 291 | String t = intent.getStringExtra("teacher"); |
324 | teacher = new Gson().fromJson(t, Teacher.class); | 292 | teacher = new Gson().fromJson(t, Teacher.class); |
325 | rl_teacher.setVisibility(View.VISIBLE); | 293 | rl_teacher.setVisibility(View.VISIBLE); |
326 | tv_bind.setText("重新绑定"); | ||
327 | tv_teacher.setText(teacher.getUserName()); | 294 | tv_teacher.setText(teacher.getUserName()); |
328 | if (!TextUtils.isEmpty(teacher.getPhoto())) { | 295 | if (!TextUtils.isEmpty(teacher.getPhoto())) { |
329 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(EditStudentActivity.this, 20)); | 296 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(EditStudentActivity.this, 20)); |
330 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 297 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
331 | Glide.with(EditStudentActivity.this).load(teacher.getPhoto()).apply(options).into(iv_teacher); | 298 | Glide.with(EditStudentActivity.this).load(teacher.getPhoto()).apply(options).into(iv_teacher); |
332 | } | 299 | } |
333 | } | 300 | } |
334 | } | 301 | } |
335 | 302 | ||
336 | private void uploadAvatar(File file) { | 303 | private void uploadAvatar(File file) { |
337 | NetWorks.uploadStudentAvatar(file, studentBean.getStuId(), new Observer<ResponseResult<Map<String, String>>>() { | 304 | NetWorks.uploadStudentAvatar(file, studentBean.getStuId(), new Observer<ResponseResult<Map<String, String>>>() { |
338 | @Override | 305 | @Override |
339 | public void onSubscribe(Disposable d) { | 306 | public void onSubscribe(Disposable d) { |
340 | 307 | ||
341 | } | 308 | } |
342 | 309 | ||
343 | @Override | 310 | @Override |
344 | public void onNext(ResponseResult<Map<String, String>> responseBody) { | 311 | public void onNext(ResponseResult<Map<String, String>> responseBody) { |
345 | if (responseBody.getData() != null && responseBody.getCode() == 200) { | 312 | if (responseBody.getData() != null && responseBody.getCode() == 200) { |
346 | String filePath = responseBody.getData().get("imageUrl"); | 313 | String filePath = responseBody.getData().get("imageUrl"); |
347 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(EditStudentActivity.this, 45)); | 314 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(EditStudentActivity.this, 45)); |
348 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 315 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
349 | Glide.with(EditStudentActivity.this).load(filePath).apply(options).into(iv_avatar); | 316 | Glide.with(EditStudentActivity.this).load(filePath).apply(options).into(iv_avatar); |
350 | } | 317 | } |
351 | } | 318 | } |
352 | 319 | ||
353 | @Override | 320 | @Override |
354 | public void onError(Throwable e) { | 321 | public void onError(Throwable e) { |
355 | e.toString(); | 322 | e.toString(); |
356 | } | 323 | } |
357 | 324 | ||
358 | @Override | 325 | @Override |
359 | public void onComplete() { | 326 | public void onComplete() { |
360 | 327 | ||
361 | } | 328 | } |
362 | }); | 329 | }); |
363 | } | 330 | } |
364 | 331 | ||
365 | public File saveImage(String name, Bitmap bmp) { | 332 | public File saveImage(String name, Bitmap bmp) { |
366 | File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath()); | 333 | File appDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath()); |
367 | if (!appDir.exists()) { | 334 | if (!appDir.exists()) { |
368 | appDir.mkdir(); | 335 | appDir.mkdir(); |
369 | } | 336 | } |
370 | String fileName = name + ".jpg"; | 337 | String fileName = name + ".jpg"; |
371 | File file = new File(appDir, fileName); | 338 | File file = new File(appDir, fileName); |
372 | try { | 339 | try { |
373 | FileOutputStream fos = new FileOutputStream(file); | 340 | FileOutputStream fos = new FileOutputStream(file); |
374 | bmp.compress(Bitmap.CompressFormat.PNG, 100, fos); | 341 | bmp.compress(Bitmap.CompressFormat.PNG, 100, fos); |
375 | fos.flush(); | 342 | fos.flush(); |
376 | fos.close(); | 343 | fos.close(); |
377 | return file; | 344 | return file; |
378 | } catch (IOException e) { | 345 | } catch (IOException e) { |
379 | Log.d("dsadsadsa", e.getLocalizedMessage()); | 346 | Log.d("dsadsadsa", e.getLocalizedMessage()); |
380 | e.printStackTrace(); | 347 | e.printStackTrace(); |
381 | } | 348 | } |
382 | return null; | 349 | return null; |
383 | } | 350 | } |
384 | 351 | ||
385 | private void getPicFromCamera() { | 352 | private void getPicFromCamera() { |
386 | //用于保存调用相机拍照后所生成的文件 | 353 | //用于保存调用相机拍照后所生成的文件 |
387 | tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"); | 354 | tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"); |
388 | //跳转到调用系统相机 | 355 | //跳转到调用系统相机 |
389 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 356 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
390 | //判断版本 | 357 | //判断版本 |
391 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri | 358 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //如果在Android7.0以上,使用FileProvider获取Uri |
392 | intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 359 | intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
393 | Uri contentUri = FileProvider.getUriForFile(this, | 360 | Uri contentUri = FileProvider.getUriForFile(this, |
394 | this.getPackageName() + ".fileprovider", tempFile); | 361 | this.getPackageName() + ".fileprovider", tempFile); |
395 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); | 362 | intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); |
396 | } else { //否则使用Uri.fromFile(file)方法获取Uri | 363 | } else { //否则使用Uri.fromFile(file)方法获取Uri |
397 | intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); | 364 | intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); |
398 | } | 365 | } |
399 | startActivityForResult(intent, CAMERA_REQUEST_CODE); | 366 | startActivityForResult(intent, CAMERA_REQUEST_CODE); |
400 | } | 367 | } |
401 | 368 | ||
402 | /** | 369 | /** |
403 | * 从相册获取图片 | 370 | * 从相册获取图片 |
404 | */ | 371 | */ |
405 | private void getPicFromAlbm() { | 372 | private void getPicFromAlbm() { |
406 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); | 373 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
407 | photoPickerIntent.setType("image/*"); | 374 | photoPickerIntent.setType("image/*"); |
408 | startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE); | 375 | startActivityForResult(photoPickerIntent, ALBUM_REQUEST_CODE); |
409 | } | 376 | } |
410 | 377 | ||
411 | @Override | 378 | @Override |
412 | protected void onDestroy() { | 379 | protected void onDestroy() { |
413 | super.onDestroy(); | 380 | super.onDestroy(); |
414 | SharedPreferencesUtil.putData("setName", ""); | 381 | SharedPreferencesUtil.putData("setName", ""); |
415 | SharedPreferencesUtil.putData("setSex", ""); | 382 | SharedPreferencesUtil.putData("setSex", ""); |
416 | SharedPreferencesUtil.putData("setNian", ""); | 383 | SharedPreferencesUtil.putData("setNian", ""); |
417 | SharedPreferencesUtil.putData("setShen", ""); | 384 | SharedPreferencesUtil.putData("setShen", ""); |
418 | SharedPreferencesUtil.putData("setXueq", ""); | 385 | SharedPreferencesUtil.putData("setXueq", ""); |
419 | SharedPreferencesUtil.putData("grade", 0); | 386 | SharedPreferencesUtil.putData("grade", 0); |
420 | } | 387 | } |
421 | 388 | ||
422 | @OnClick(R.id.iv_avatar) | 389 | @OnClick(R.id.iv_avatar) |
423 | public void showButtonDialog(View view) { | 390 | public void showButtonDialog(View view) { |
424 | BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog); | 391 | BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog); |
425 | View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null); | 392 | View bottomView = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_layout, null); |
426 | dialog.setContentView(bottomView); | 393 | dialog.setContentView(bottomView); |
427 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 394 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
428 | @Override | 395 | @Override |
429 | public void onClick(View view) { | 396 | public void onClick(View view) { |
430 | dialog.dismiss(); | 397 | dialog.dismiss(); |
431 | if (!XXPermissions.isGranted(EditStudentActivity.this, Permission.CAMERA)) { | 398 | if (!XXPermissions.isGranted(EditStudentActivity.this, Permission.CAMERA)) { |
432 | XXPermissions.with(EditStudentActivity.this) | 399 | XXPermissions.with(EditStudentActivity.this) |
433 | // 申请多个权限 | 400 | // 申请多个权限 |
434 | .permission(Permission.CAMERA) | 401 | .permission(Permission.CAMERA) |
435 | .request(new OnPermissionCallback() { | 402 | .request(new OnPermissionCallback() { |
436 | @Override | 403 | @Override |
437 | public void onGranted(List<String> permissions, boolean all) { | 404 | public void onGranted(List<String> permissions, boolean all) { |
438 | if (all) { | 405 | if (all) { |
439 | //开启扫码界面 | 406 | //开启扫码界面 |
440 | getPicFromCamera(); | 407 | getPicFromCamera(); |
441 | } else { | 408 | } else { |
442 | Toast.makeText(EditStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); | 409 | Toast.makeText(EditStudentActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); |
443 | } | 410 | } |
444 | } | 411 | } |
445 | 412 | ||
446 | @Override | 413 | @Override |
447 | public void onDenied(List<String> permissions, boolean never) { | 414 | public void onDenied(List<String> permissions, boolean never) { |
448 | XXPermissions.startPermissionActivity(EditStudentActivity.this, permissions); | 415 | XXPermissions.startPermissionActivity(EditStudentActivity.this, permissions); |
449 | } | 416 | } |
450 | }); | 417 | }); |
451 | } else { | 418 | } else { |
452 | getPicFromCamera(); | 419 | getPicFromCamera(); |
453 | } | 420 | } |
454 | 421 | ||
455 | } | 422 | } |
456 | }); | 423 | }); |
457 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 424 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
458 | @Override | 425 | @Override |
459 | public void onClick(View view) { | 426 | public void onClick(View view) { |
460 | dialog.dismiss(); | 427 | dialog.dismiss(); |
461 | getPicFromAlbm(); | 428 | getPicFromAlbm(); |
462 | } | 429 | } |
463 | }); | 430 | }); |
464 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 431 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
465 | @Override | 432 | @Override |
466 | public void onClick(View view) { | 433 | public void onClick(View view) { |
467 | dialog.dismiss(); | 434 | dialog.dismiss(); |
468 | } | 435 | } |
469 | }); | 436 | }); |
470 | dialog.show(); | 437 | dialog.show(); |
471 | } | 438 | } |
472 | 439 | ||
473 | 440 | ||
474 | } | 441 | } |
475 | 442 |
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 | <LinearLayout | 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_height="wrap_content" |
248 | android:layout_marginLeft="15dp" | 248 | android:layout_marginLeft="15dp" |
249 | android:layout_marginTop="460dp" | 249 | android:layout_marginTop="460dp" |
250 | android:layout_marginRight="15dp" | 250 | android:layout_marginRight="15dp" |
251 | android:background="@drawable/bg_solid_white_10" | 251 | android:background="@drawable/bg_solid_white_10" |
252 | android:orientation="vertical" | 252 | android:orientation="vertical" |
253 | app:layout_constraintLeft_toLeftOf="parent" | 253 | app:layout_constraintLeft_toLeftOf="parent" |
254 | app:layout_constraintRight_toRightOf="parent" | 254 | app:layout_constraintRight_toRightOf="parent" |
255 | app:layout_constraintTop_toTopOf="parent"> | 255 | app:layout_constraintTop_toTopOf="parent"> |
256 | 256 | ||
257 | <RelativeLayout | 257 | <RelativeLayout |
258 | android:layout_width="match_parent" | 258 | android:layout_width="match_parent" |
259 | android:layout_height="50dp"> | 259 | android:layout_height="50dp"> |
260 | 260 | ||
261 | <ImageView | ||
262 | android:layout_width="15dp" | ||
263 | android:layout_height="15dp" | ||
264 | android:layout_centerVertical="true" | ||
265 | android:layout_marginRight="5dp" | ||
266 | android:layout_toLeftOf="@+id/tv_bind" | ||
267 | android:src="@mipmap/ic_bind_teacher" /> | ||
268 | |||
269 | <TextView | ||
270 | android:id="@+id/tv_bind" | ||
271 | android:layout_width="wrap_content" | ||
272 | android:layout_height="wrap_content" | ||
273 | android:layout_alignParentRight="true" | ||
274 | android:layout_centerVertical="true" | ||
275 | android:layout_marginRight="15dp" | ||
276 | android:text="去绑定" | ||
277 | android:textColor="#333333" | ||
278 | android:textSize="16dp" /> | ||
279 | |||
280 | <TextView | 261 | <TextView |
281 | android:layout_width="wrap_content" | 262 | android:layout_width="wrap_content" |
282 | android:layout_height="wrap_content" | 263 | android:layout_height="wrap_content" |
283 | android:layout_centerVertical="true" | 264 | android:layout_centerVertical="true" |
284 | android:layout_marginLeft="15dp" | 265 | android:layout_marginLeft="15dp" |
285 | android:text="我的老师" | 266 | android:text="我的老师" |
286 | android:textColor="#666666" | 267 | android:textColor="#666666" |
287 | android:textSize="16dp" /> | 268 | android:textSize="16dp" /> |
288 | </RelativeLayout> | 269 | </RelativeLayout> |
289 | 270 | ||
290 | <RelativeLayout | 271 | <RelativeLayout |
291 | android:id="@+id/rl_teacher" | 272 | android:id="@+id/rl_teacher" |
292 | android:layout_width="match_parent" | 273 | android:layout_width="match_parent" |
293 | android:layout_height="35dp" | 274 | android:layout_height="35dp" |
294 | android:layout_marginBottom="15dp" | 275 | android:layout_marginBottom="15dp" |
295 | android:visibility="gone"> | 276 | android:visibility="gone"> |
296 | 277 | ||
297 | <ImageView | 278 | <ImageView |
298 | android:id="@+id/iv_teacher" | 279 | android:id="@+id/iv_teacher" |
299 | android:layout_width="35dp" | 280 | android:layout_width="35dp" |
300 | android:layout_height="35dp" | 281 | android:layout_height="35dp" |
301 | android:layout_marginLeft="15dp" | 282 | android:layout_marginLeft="15dp" |
302 | android:src="@mipmap/ic_teacher_male" /> | 283 | android:src="@mipmap/ic_teacher_male" /> |
303 | 284 | ||
304 | <TextView | 285 | <TextView |
305 | android:id="@+id/tv_teacher" | 286 | android:id="@+id/tv_teacher" |
306 | android:layout_width="wrap_content" | 287 | android:layout_width="wrap_content" |
307 | android:layout_height="wrap_content" | 288 | android:layout_height="wrap_content" |
308 | android:layout_alignParentRight="true" | 289 | android:layout_alignParentRight="true" |
309 | android:layout_centerVertical="true" | 290 | android:layout_centerVertical="true" |
310 | android:layout_marginRight="15dp" | 291 | android:layout_marginRight="15dp" |
311 | android:textColor="#999999" | 292 | android:textColor="#999999" |
312 | android:textSize="16dp" /> | 293 | android:textSize="16dp" /> |
313 | </RelativeLayout> | 294 | </RelativeLayout> |
314 | </LinearLayout> | 295 | </LinearLayout> |
315 | 296 | ||
316 | 297 | ||
317 | <Button | 298 | <Button |
318 | android:id="@+id/btn_next" | 299 | android:id="@+id/btn_next" |
319 | android:layout_width="180dp" | 300 | android:layout_width="180dp" |
320 | android:layout_height="40dp" | 301 | android:layout_height="40dp" |
321 | android:layout_marginTop="570dp" | 302 | android:layout_marginTop="570dp" |
322 | android:background="@drawable/bg_solid_btn_grad" | 303 | android:background="@drawable/bg_solid_btn_grad" |
323 | android:text="确认" | 304 | android:text="确认" |
324 | android:textColor="#999999" | 305 | android:textColor="#999999" |
325 | android:textSize="16dp" | 306 | android:textSize="16dp" |
326 | app:layout_constraintLeft_toLeftOf="parent" | 307 | app:layout_constraintLeft_toLeftOf="parent" |
327 | app:layout_constraintRight_toRightOf="parent" | 308 | app:layout_constraintRight_toRightOf="parent" |
328 | app:layout_constraintTop_toTopOf="parent" /> | 309 | app:layout_constraintTop_toTopOf="parent" /> |
329 | 310 | ||
330 | 311 | ||
331 | </androidx.constraintlayout.widget.ConstraintLayout> | 312 | </androidx.constraintlayout.widget.ConstraintLayout> |