Commit 16e0ba49f45d8f5fe19c5290c7eda46ceecc364d
1 parent
15a3967b69
Exists in
master
入库重复时, 不再上传图片
Showing
2 changed files
with
14 additions
and
6 deletions
Show diff stats
app/src/main/java/com/hjx/parent/dialog/AddHomeworkDialog.java
| 1 | package com.hjx.parent.dialog; | 1 | package com.hjx.parent.dialog; |
| 2 | 2 | ||
| 3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| 5 | import android.util.Pair; | 5 | import android.util.Pair; |
| 6 | import android.view.View; | 6 | import android.view.View; |
| 7 | import android.view.WindowManager; | 7 | import android.view.WindowManager; |
| 8 | import android.widget.AdapterView; | 8 | import android.widget.AdapterView; |
| 9 | import android.widget.ArrayAdapter; | 9 | import android.widget.ArrayAdapter; |
| 10 | import android.widget.Toast; | 10 | import android.widget.Toast; |
| 11 | 11 | ||
| 12 | import androidx.annotation.NonNull; | 12 | import androidx.annotation.NonNull; |
| 13 | 13 | ||
| 14 | import com.bigkoo.pickerview.builder.TimePickerBuilder; | 14 | import com.bigkoo.pickerview.builder.TimePickerBuilder; |
| 15 | import com.google.gson.Gson; | 15 | import com.google.gson.Gson; |
| 16 | import com.hjx.parent.R; | 16 | import com.hjx.parent.R; |
| 17 | import com.hjx.parent.bean.StudentBean; | 17 | import com.hjx.parent.bean.StudentBean; |
| 18 | import com.hjx.parent.databinding.DialogAddHomeworkBinding; | 18 | import com.hjx.parent.databinding.DialogAddHomeworkBinding; |
| 19 | import com.hjx.parent.function.Function0; | 19 | import com.hjx.parent.function.Function0; |
| 20 | import com.hjx.parent.function.Function1; | 20 | import com.hjx.parent.function.Function1; |
| 21 | import com.hjx.parent.rx.BaseRxActivity; | 21 | import com.hjx.parent.rx.BaseRxActivity; |
| 22 | import com.prws.common.bean.GradeAndSubject; | 22 | import com.prws.common.bean.GradeAndSubject; |
| 23 | import com.prws.common.bean.ResponseResult; | 23 | import com.prws.common.bean.ResponseResult; |
| 24 | import com.prws.common.bean.Student; | 24 | import com.prws.common.bean.Student; |
| 25 | import com.prws.common.bean.Subject; | 25 | import com.prws.common.bean.Subject; |
| 26 | import com.prws.common.bean.baidu.BaiduInput; | 26 | import com.prws.common.bean.baidu.BaiduInput; |
| 27 | import com.prws.common.net.NetWorks; | 27 | import com.prws.common.net.NetWorks; |
| 28 | import com.prws.common.utils.SharedPreferencesUtil; | 28 | import com.prws.common.utils.SharedPreferencesUtil; |
| 29 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 29 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
| 30 | 30 | ||
| 31 | import java.io.File; | 31 | import java.io.File; |
| 32 | import java.text.SimpleDateFormat; | 32 | import java.text.SimpleDateFormat; |
| 33 | import java.util.ArrayList; | 33 | import java.util.ArrayList; |
| 34 | import java.util.Date; | 34 | import java.util.Date; |
| 35 | import java.util.HashMap; | 35 | import java.util.HashMap; |
| 36 | import java.util.List; | 36 | import java.util.List; |
| 37 | import java.util.Locale; | 37 | import java.util.Locale; |
| 38 | import java.util.Map; | 38 | import java.util.Map; |
| 39 | 39 | ||
| 40 | import io.reactivex.Observable; | 40 | import io.reactivex.Observable; |
| 41 | import io.reactivex.android.schedulers.AndroidSchedulers; | 41 | import io.reactivex.android.schedulers.AndroidSchedulers; |
| 42 | import io.reactivex.schedulers.Schedulers; | 42 | import io.reactivex.schedulers.Schedulers; |
| 43 | 43 | ||
| 44 | public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ | 44 | public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ |
| 45 | private final BaseRxActivity<?> activity; | 45 | private final BaseRxActivity<?> activity; |
| 46 | 46 | ||
| 47 | private Function1<Student> callback; | 47 | private Function1<Student> callback; |
| 48 | 48 | ||
| 49 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA); | 49 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA); |
| 50 | List<Student> studentList; | 50 | List<Student> studentList; |
| 51 | List<GradeAndSubject> gradeAndSubjectList; | 51 | List<GradeAndSubject> gradeAndSubjectList; |
| 52 | 52 | ||
| 53 | List<String> images; | 53 | List<String> images; |
| 54 | 54 | ||
| 55 | Student student; | 55 | Student student; |
| 56 | String grade; | 56 | String grade; |
| 57 | String term; | 57 | String term; |
| 58 | String subject; | 58 | String subject; |
| 59 | Date uploadTime = new Date(); | 59 | Date uploadTime = new Date(); |
| 60 | 60 | ||
| 61 | public AddHomeworkDialog(BaseRxActivity<?> context) { | 61 | public AddHomeworkDialog(BaseRxActivity<?> context) { |
| 62 | super((Context) context); | 62 | super((Context) context); |
| 63 | activity = context; | 63 | activity = context; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | public void show(List<String> paths, Function1<Student> callback) { | 66 | public void show(List<String> paths, Function1<Student> callback) { |
| 67 | images = paths; | 67 | images = paths; |
| 68 | this.callback = callback; | 68 | this.callback = callback; |
| 69 | super.show(); | 69 | super.show(); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | @SuppressLint("SetTextI18n") | 72 | @SuppressLint("SetTextI18n") |
| 73 | @Override | 73 | @Override |
| 74 | public void initView() { | 74 | public void initView() { |
| 75 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); | 75 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); |
| 76 | binding.btnClose.setOnClickListener(v -> dismiss()); | 76 | binding.btnClose.setOnClickListener(v -> dismiss()); |
| 77 | binding.spStudent.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 77 | binding.spStudent.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
| 78 | @Override | 78 | @Override |
| 79 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 79 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
| 80 | student = studentList.get(position); | 80 | student = studentList.get(position); |
| 81 | if (gradeAndSubjectList == null) return; | 81 | if (gradeAndSubjectList == null) return; |
| 82 | int p = 0; | 82 | int p = 0; |
| 83 | for (GradeAndSubject it: gradeAndSubjectList) { | 83 | for (GradeAndSubject it: gradeAndSubjectList) { |
| 84 | if (it.getGrade().getGrade().equals(student.grade)) { | 84 | if (it.getGrade().getGrade().equals(student.grade)) { |
| 85 | p = gradeAndSubjectList.indexOf(it); | 85 | p = gradeAndSubjectList.indexOf(it); |
| 86 | break; | 86 | break; |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | binding.spGrade.setSelection(p); | 89 | binding.spGrade.setSelection(p); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | @Override | 92 | @Override |
| 93 | public void onNothingSelected(AdapterView<?> parent) { | 93 | public void onNothingSelected(AdapterView<?> parent) { |
| 94 | } | 94 | } |
| 95 | }); | 95 | }); |
| 96 | binding.spTerm.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 96 | binding.spTerm.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
| 97 | @Override | 97 | @Override |
| 98 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 98 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
| 99 | term = getContext().getResources().getStringArray(R.array.grade_array)[position]; | 99 | term = getContext().getResources().getStringArray(R.array.grade_array)[position]; |
| 100 | } | 100 | } |
| 101 | @Override | 101 | @Override |
| 102 | public void onNothingSelected(AdapterView<?> parent) { | 102 | public void onNothingSelected(AdapterView<?> parent) { |
| 103 | } | 103 | } |
| 104 | }); | 104 | }); |
| 105 | binding.spGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 105 | binding.spGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
| 106 | @Override | 106 | @Override |
| 107 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 107 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
| 108 | grade = gradeAndSubjectList.get(position).getGrade().getGrade(); | 108 | grade = gradeAndSubjectList.get(position).getGrade().getGrade(); |
| 109 | refreshSubjects(position); | 109 | refreshSubjects(position); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | @Override | 112 | @Override |
| 113 | public void onNothingSelected(AdapterView<?> parent) { | 113 | public void onNothingSelected(AdapterView<?> parent) { |
| 114 | } | 114 | } |
| 115 | }); | 115 | }); |
| 116 | 116 | ||
| 117 | binding.tvDate.setText(dateFormat.format(uploadTime)); | 117 | binding.tvDate.setText(dateFormat.format(uploadTime)); |
| 118 | binding.tvDate.setOnClickListener(v -> { | 118 | binding.tvDate.setOnClickListener(v -> { |
| 119 | new TimePickerBuilder(getContext(), (date, v1) -> { | 119 | new TimePickerBuilder(getContext(), (date, v1) -> { |
| 120 | uploadTime = date; | 120 | uploadTime = date; |
| 121 | binding.tvDate.setText(dateFormat.format(uploadTime)); | 121 | binding.tvDate.setText(dateFormat.format(uploadTime)); |
| 122 | binding.etName.setText(dateFormat.format(uploadTime) + subject + "作业"); | 122 | binding.etName.setText(dateFormat.format(uploadTime) + subject + "作业"); |
| 123 | }).setType(new boolean[]{true, true, true, false, false, false}).isDialog(true).build().show(); | 123 | }).setType(new boolean[]{true, true, true, false, false, false}).isDialog(true).build().show(); |
| 124 | }); | 124 | }); |
| 125 | 125 | ||
| 126 | binding.btnConfirm.setOnClickListener(v -> { | 126 | binding.btnConfirm.setOnClickListener(v -> { |
| 127 | String name = binding.etName.getText().toString().trim(); | 127 | String name = binding.etName.getText().toString().trim(); |
| 128 | if (name.isEmpty()) { | 128 | if (name.isEmpty()) { |
| 129 | Toast.makeText(getContext(), "请输入作业名称", Toast.LENGTH_SHORT).show(); | 129 | Toast.makeText(getContext(), "请输入作业名称", Toast.LENGTH_SHORT).show(); |
| 130 | return; | 130 | return; |
| 131 | } | 131 | } |
| 132 | uploadImage(name); | 132 | uploadImage(name); |
| 133 | }); | 133 | }); |
| 134 | 134 | ||
| 135 | getGrade(); | 135 | getGrade(); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | private String getCurrentStuId() { | 138 | private String getCurrentStuId() { |
| 139 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 139 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
| 140 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); | 140 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); |
| 141 | return studentBean.getStuId(); | 141 | return studentBean.getStuId(); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | @SuppressLint("CheckResult") | 144 | @SuppressLint("CheckResult") |
| 145 | private void getStudents() { | 145 | private void getStudents() { |
| 146 | NetWorks.listStudent() | 146 | NetWorks.listStudent() |
| 147 | .subscribeOn(Schedulers.io()) | 147 | .subscribeOn(Schedulers.io()) |
| 148 | .observeOn(AndroidSchedulers.mainThread()) | 148 | .observeOn(AndroidSchedulers.mainThread()) |
| 149 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) | 149 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) |
| 150 | .map(ResponseResult::getData) | 150 | .map(ResponseResult::getData) |
| 151 | .subscribe((data, th) -> { | 151 | .subscribe((data, th) -> { |
| 152 | if (th != null) th.printStackTrace(); | 152 | if (th != null) th.printStackTrace(); |
| 153 | if (data != null && data.size() > 0) { | 153 | if (data != null && data.size() > 0) { |
| 154 | studentList = data; | 154 | studentList = data; |
| 155 | int position = 0; | 155 | int position = 0; |
| 156 | String stuId = getCurrentStuId(); | 156 | String stuId = getCurrentStuId(); |
| 157 | for (int i = 0; i < data.size(); i++) { | 157 | for (int i = 0; i < data.size(); i++) { |
| 158 | if (data.get(i).stuId.equals(stuId)) { | 158 | if (data.get(i).stuId.equals(stuId)) { |
| 159 | position = i; | 159 | position = i; |
| 160 | break; | 160 | break; |
| 161 | } | 161 | } |
| 162 | } | 162 | } |
| 163 | binding.spStudent.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, data)); | 163 | binding.spStudent.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, data)); |
| 164 | binding.spStudent.setSelection(position); | 164 | binding.spStudent.setSelection(position); |
| 165 | } | 165 | } |
| 166 | }); | 166 | }); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | @SuppressLint("CheckResult") | 169 | @SuppressLint("CheckResult") |
| 170 | private void getGrade() { | 170 | private void getGrade() { |
| 171 | NetWorks.service_url.listGradeAndSubject(NetWorks.getHeader()) | 171 | NetWorks.service_url.listGradeAndSubject(NetWorks.getHeader()) |
| 172 | .subscribeOn(Schedulers.io()) | 172 | .subscribeOn(Schedulers.io()) |
| 173 | .observeOn(AndroidSchedulers.mainThread()) | 173 | .observeOn(AndroidSchedulers.mainThread()) |
| 174 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) | 174 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) |
| 175 | .map(ResponseResult::getData) | 175 | .map(ResponseResult::getData) |
| 176 | .firstOrError() | 176 | .firstOrError() |
| 177 | .subscribe((data, th) -> { | 177 | .subscribe((data, th) -> { |
| 178 | if (th != null) th.printStackTrace(); | 178 | if (th != null) th.printStackTrace(); |
| 179 | if (data != null && data.size() > 0) { | 179 | if (data != null && data.size() > 0) { |
| 180 | gradeAndSubjectList = data; | 180 | gradeAndSubjectList = data; |
| 181 | List<String> grades = new ArrayList<>(); | 181 | List<String> grades = new ArrayList<>(); |
| 182 | for (GradeAndSubject it: data) { | 182 | for (GradeAndSubject it: data) { |
| 183 | grades.add(it.getGrade().getGrade()); | 183 | grades.add(it.getGrade().getGrade()); |
| 184 | } | 184 | } |
| 185 | binding.spGrade.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, grades)); | 185 | binding.spGrade.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, grades)); |
| 186 | } | 186 | } |
| 187 | getStudents(); | 187 | getStudents(); |
| 188 | }); | 188 | }); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | private void refreshSubjects(int gradePosition) { | 191 | private void refreshSubjects(int gradePosition) { |
| 192 | if (gradeAndSubjectList == null) return; | 192 | if (gradeAndSubjectList == null) return; |
| 193 | List<Subject> subjectList = gradeAndSubjectList.get(gradePosition).getSubjects(); | 193 | List<Subject> subjectList = gradeAndSubjectList.get(gradePosition).getSubjects(); |
| 194 | List<String> subjects = new ArrayList<>(); | 194 | List<String> subjects = new ArrayList<>(); |
| 195 | for (Subject s: subjectList) { | 195 | for (Subject s: subjectList) { |
| 196 | subjects.add(s.getSubject()); | 196 | subjects.add(s.getSubject()); |
| 197 | } | 197 | } |
| 198 | binding.spSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 198 | binding.spSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
| 199 | @SuppressLint("SetTextI18n") | 199 | @SuppressLint("SetTextI18n") |
| 200 | @Override | 200 | @Override |
| 201 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 201 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
| 202 | subject = subjects.get(position); | 202 | subject = subjects.get(position); |
| 203 | binding.etName.setText(dateFormat.format(uploadTime) + subject + "作业"); | 203 | binding.etName.setText(dateFormat.format(uploadTime) + subject + "作业"); |
| 204 | } | 204 | } |
| 205 | @Override | 205 | @Override |
| 206 | public void onNothingSelected(AdapterView<?> parent) { | 206 | public void onNothingSelected(AdapterView<?> parent) { |
| 207 | } | 207 | } |
| 208 | }); | 208 | }); |
| 209 | binding.spSubject.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, subjects)); | 209 | binding.spSubject.setAdapter(new ArrayAdapter<>(getContext(), R.layout.item_spinner, subjects)); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | @SuppressLint("CheckResult") | 212 | @SuppressLint("CheckResult") |
| 213 | public void uploadImage(String name) { | 213 | public void uploadImage(String name) { |
| 214 | activity.showLoadingDialog("上传作业中..."); | 214 | activity.showLoadingDialog("上传作业中..."); |
| 215 | Observable.fromIterable(images) | 215 | Observable.fromIterable(images) |
| 216 | .map(path -> { | 216 | .map(path -> { |
| 217 | int index = images.indexOf(path); | 217 | int index = images.indexOf(path); |
| 218 | return new Pair<>(index, path); | 218 | return new Pair<>(index, path); |
| 219 | }) | 219 | }) |
| 220 | .subscribeOn(Schedulers.io()) | 220 | .subscribeOn(Schedulers.io()) |
| 221 | .flatMap(pair -> { | 221 | .flatMap(pair -> { |
| 222 | int index = pair.first; | 222 | int index = pair.first; |
| 223 | String path = pair.second; | 223 | String path = pair.second; |
| 224 | File file = new File(path); | 224 | File file = new File(path); |
| 225 | String id = file.getName().substring(0, file.getName().lastIndexOf(".")); | ||
| 226 | return Observable.just(file) | 225 | return Observable.just(file) |
| 227 | .map(var -> { | 226 | .map(var -> { |
| 227 | String id = file.getName().substring(0, file.getName().lastIndexOf(".")); | ||
| 228 | BaiduInput baiduInput = NetWorks.inputImage(path, id).blockingGet(); | 228 | BaiduInput baiduInput = NetWorks.inputImage(path, id).blockingGet(); |
| 229 | if (baiduInput.getError_code() != null && baiduInput.getBrief() == null) { | 229 | if (baiduInput.getError_code() != null && baiduInput.getBrief() == null) { |
| 230 | throw new RuntimeException("图片入库失败"); | 230 | throw new RuntimeException("图片入库失败"); |
| 231 | } | ||
| 232 | if (baiduInput.getBrief() != null) { | ||
| 233 | id = baiduInput.briefId(); | ||
| 231 | } else { | 234 | } else { |
| 232 | return baiduInput; | 235 | NetWorks.uploadImage(path, id).blockingGet(); |
| 233 | } | 236 | } |
| 234 | }) | 237 | |
| 235 | .map(var -> NetWorks.uploadImage(path, id).blockingGet()) | ||
| 236 | .map(var -> { | ||
| 237 | Map<String, Object> map = new HashMap<>(); | 238 | Map<String, Object> map = new HashMap<>(); |
| 238 | map.put("brief", id); | 239 | map.put("brief", id); |
| 239 | map.put("sort", index); | 240 | map.put("sort", index); |
| 240 | return map; | 241 | return map; |
| 241 | }); | 242 | }); |
| 242 | }, 2) | 243 | }, 2) |
| 243 | .toList() | 244 | .toList() |
| 244 | .map(list -> { | 245 | .map(list -> { |
| 245 | List<String> stuIds = new ArrayList<>(); | 246 | List<String> stuIds = new ArrayList<>(); |
| 246 | stuIds.add(student.stuId); | 247 | stuIds.add(student.stuId); |
| 247 | String userId = NetWorks.getUserId(); | 248 | String userId = NetWorks.getUserId(); |
| 248 | 249 | ||
| 249 | Map<String, Object> map = new HashMap<>(); | 250 | Map<String, Object> map = new HashMap<>(); |
| 250 | map.put("name", name); | 251 | map.put("name", name); |
| 251 | map.put("grade", grade); | 252 | map.put("grade", grade); |
| 252 | map.put("term", term); | 253 | map.put("term", term); |
| 253 | map.put("subject", subject); | 254 | map.put("subject", subject); |
| 254 | map.put("userId", userId); | 255 | map.put("userId", userId); |
| 255 | map.put("stuIds", stuIds); | 256 | map.put("stuIds", stuIds); |
| 256 | map.put("briefList", list); | 257 | map.put("briefList", list); |
| 257 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); | 258 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); |
| 258 | map.put("uploadTime", format.format(uploadTime)); | 259 | map.put("uploadTime", format.format(uploadTime)); |
| 259 | return map; | 260 | return map; |
| 260 | }) | 261 | }) |
| 261 | .flatMap(body -> { | 262 | .flatMap(body -> { |
| 262 | return NetWorks.service_url.uploadHomework(NetWorks.getHeader(), body); | 263 | return NetWorks.service_url.uploadHomework(NetWorks.getHeader(), body); |
| 263 | }) | 264 | }) |
| 264 | .observeOn(AndroidSchedulers.mainThread()) | 265 | .observeOn(AndroidSchedulers.mainThread()) |
| 265 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) | 266 | .compose(RxLifecycleAndroid.bindActivity(activity.getRxLifecycle())) |
| 266 | .subscribe((response, th) -> { | 267 | .subscribe((response, th) -> { |
| 267 | if (th != null) th.printStackTrace(); | 268 | if (th != null) th.printStackTrace(); |
| 268 | if (response != null && response.getSuccess()) { | 269 | if (response != null && response.getSuccess()) { |
| 269 | activity.cancelLoadingDialog(); | 270 | activity.cancelLoadingDialog(); |
| 270 | dismiss(); | 271 | dismiss(); |
| 271 | if (callback != null) callback.invoke(student); | 272 | if (callback != null) callback.invoke(student); |
| 272 | } else { | 273 | } else { |
| 273 | activity.loadFail("上传作业失败"); | 274 | activity.loadFail("上传作业失败"); |
| 274 | } | 275 | } |
| 275 | }) | 276 | }) |
| 276 | ; | 277 | ; |
| 277 | } | 278 | } |
| 278 | 279 | ||
| 279 | @NonNull | 280 | @NonNull |
| 280 | @Override | 281 | @Override |
| 281 | public DialogAddHomeworkBinding getBinding() { | 282 | public DialogAddHomeworkBinding getBinding() { |
| 282 | return DialogAddHomeworkBinding.inflate(getLayoutInflater()); | 283 | return DialogAddHomeworkBinding.inflate(getLayoutInflater()); |
libs/common/src/main/java/com/prws/common/bean/baidu/BaiduInput.java
| 1 | package com.prws.common.bean.baidu; | 1 | package com.prws.common.bean.baidu; |
| 2 | 2 | ||
| 3 | import com.google.gson.Gson; | ||
| 4 | |||
| 3 | public class BaiduInput { | 5 | public class BaiduInput { |
| 4 | String brief; | 6 | String brief; |
| 5 | String error_code; | 7 | String error_code; |
| 6 | String cont_sign; | 8 | String cont_sign; |
| 7 | String log_id; | 9 | String log_id; |
| 8 | 10 | ||
| 9 | public void setBrief(String brief) { | 11 | public void setBrief(String brief) { |
| 10 | this.brief = brief; | 12 | this.brief = brief; |
| 11 | } | 13 | } |
| 12 | 14 | ||
| 13 | public void setError_code(String error_code) { | 15 | public void setError_code(String error_code) { |
| 14 | this.error_code = error_code; | 16 | this.error_code = error_code; |
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | public void setCont_sign(String cont_sign) { | 19 | public void setCont_sign(String cont_sign) { |
| 18 | this.cont_sign = cont_sign; | 20 | this.cont_sign = cont_sign; |
| 19 | } | 21 | } |
| 20 | 22 | ||
| 21 | public void setLog_id(String log_id) { | 23 | public void setLog_id(String log_id) { |
| 22 | this.log_id = log_id; | 24 | this.log_id = log_id; |
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | public String getBrief() { | 27 | public String getBrief() { |
| 26 | return brief; | 28 | return brief; |
| 27 | } | 29 | } |
| 28 | 30 | ||
| 31 | public String briefId() { | ||
| 32 | Brief briefBean = new Gson().fromJson(brief, Brief.class); | ||
| 33 | return briefBean.id; | ||
| 34 | } | ||
| 35 | |||
| 29 | public String getError_code() { | 36 | public String getError_code() { |
| 30 | return error_code; | 37 | return error_code; |
| 31 | } | 38 | } |
| 32 | 39 | ||
| 33 | public String getCont_sign() { | 40 | public String getCont_sign() { |
| 34 | return cont_sign; | 41 | return cont_sign; |
| 35 | } | 42 | } |
| 36 | 43 | ||
| 37 | public String getLog_id() { | 44 | public String getLog_id() { |
| 38 | return log_id; | 45 | return log_id; |
| 39 | } | 46 | } |
| 40 | 47 | ||
| 41 | public class Brief { | 48 | public static class Brief { |
| 42 | String name; | 49 | String name; |
| 43 | String id; | 50 | String id; |
| 44 | 51 | ||
| 45 | public void setName(String name) { | 52 | public void setName(String name) { |
| 46 | this.name = name; | 53 | this.name = name; |
| 47 | } | 54 | } |
| 48 | 55 | ||
| 49 | public String getName() { | 56 | public String getName() { |
| 50 | return name; | 57 | return name; |
| 51 | } | 58 | } |
| 52 | 59 | ||
| 53 | public String getId() { | 60 | public String getId() { |
| 54 | return id; | 61 | return id; |
| 55 | } | 62 | } |
| 56 | } | 63 | } |
| 57 | } | 64 | } |
| 58 | 65 |