Commit 19e49b3575d0c3e05d70ba23bbcf01a300be995a
1 parent
dbb1f52deb
Exists in
master
录入作业成功页面
Showing
5 changed files
with
32 additions
and
10 deletions
Show diff stats
app/src/main/java/com/hjx/parent/AddSuccessActivity.java
| ... | ... | @@ -33,8 +33,19 @@ public class AddSuccessActivity extends BaseActivity<ActivityAddSuccessBinding> |
| 33 | 33 | private int REQUEST_CODE_IMAGE = 123; |
| 34 | 34 | private String filePath; |
| 35 | 35 | |
| 36 | + private int type; | |
| 37 | + private String stuId; | |
| 38 | + | |
| 36 | 39 | @Override |
| 37 | 40 | public void initView(Bundle savedInstanceState) { |
| 41 | + type = getIntent().getIntExtra("type", 0); | |
| 42 | + stuId = getIntent().getStringExtra("stuId"); | |
| 43 | + if (type == 1) { | |
| 44 | + binding.tvMsg.setText("作业录入成功!"); | |
| 45 | + binding.tvAdd.setText("继续录入作业"); | |
| 46 | + binding.tvBook.setText("查看作业详情"); | |
| 47 | + } | |
| 48 | + | |
| 38 | 49 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
| 39 | 50 | @Override |
| 40 | 51 | public void onClick(View v) { |
| ... | ... | @@ -94,7 +105,11 @@ public class AddSuccessActivity extends BaseActivity<ActivityAddSuccessBinding> |
| 94 | 105 | binding.tvBook.setOnClickListener(new View.OnClickListener() { |
| 95 | 106 | @Override |
| 96 | 107 | public void onClick(View v) { |
| 97 | - startActivity(new Intent(context, ErrorListActivity.class)); | |
| 108 | + if (type == 0) { | |
| 109 | + startActivity(new Intent(context, ErrorListActivity.class)); | |
| 110 | + } else { | |
| 111 | + // TODO | |
| 112 | + } | |
| 98 | 113 | } |
| 99 | 114 | }); |
| 100 | 115 | } |
| ... | ... | @@ -113,6 +128,7 @@ public class AddSuccessActivity extends BaseActivity<ActivityAddSuccessBinding> |
| 113 | 128 | CommonUtil.saveBitmapToUri(b, path); |
| 114 | 129 | List<String> strings = new ArrayList<>(); |
| 115 | 130 | Intent intent = new Intent(context, ImageActivity.class); |
| 131 | + intent.putExtra("type", type); | |
| 116 | 132 | strings.add(path); |
| 117 | 133 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
| 118 | 134 | startActivity(intent); |
| ... | ... | @@ -145,6 +161,7 @@ public class AddSuccessActivity extends BaseActivity<ActivityAddSuccessBinding> |
| 145 | 161 | if (selectImage.size() == photoList.size()) { |
| 146 | 162 | List<String> strings = new ArrayList<>(); |
| 147 | 163 | Intent intent = new Intent(context, ImageActivity.class); |
| 164 | + intent.putExtra("type", type); | |
| 148 | 165 | for (ImageInfo imageInfo : selectImage) { |
| 149 | 166 | strings.add(imageInfo.getPath()); |
| 150 | 167 | } | ... | ... |
app/src/main/java/com/hjx/parent/ImageActivity.java
| ... | ... | @@ -354,8 +354,12 @@ public class ImageActivity extends BaseRxActivity<ActivityImageBinding> implemen |
| 354 | 354 | if (addHomeworkDialog == null) { |
| 355 | 355 | addHomeworkDialog = new AddHomeworkDialog(this); |
| 356 | 356 | } |
| 357 | - addHomeworkDialog.show(paths, () -> { | |
| 358 | - // TODO | |
| 357 | + addHomeworkDialog.show(paths, student -> { | |
| 358 | + Intent intent = new Intent(context, AddSuccessActivity.class); | |
| 359 | + intent.putExtra("type", type); | |
| 360 | + intent.putExtra("stuId", student.stuId); | |
| 361 | + startActivity(intent); | |
| 362 | + finish(); | |
| 359 | 363 | }); |
| 360 | 364 | } |
| 361 | 365 | } | ... | ... |
app/src/main/java/com/hjx/parent/dialog/AddHomeworkDialog.java
| ... | ... | @@ -16,6 +16,7 @@ import com.hjx.parent.R; |
| 16 | 16 | import com.hjx.parent.bean.StudentBean; |
| 17 | 17 | import com.hjx.parent.databinding.DialogAddHomeworkBinding; |
| 18 | 18 | import com.hjx.parent.function.Function0; |
| 19 | +import com.hjx.parent.function.Function1; | |
| 19 | 20 | import com.hjx.parent.rx.BaseRxActivity; |
| 20 | 21 | import com.prws.common.bean.GradeAndSubject; |
| 21 | 22 | import com.prws.common.bean.ResponseResult; |
| ... | ... | @@ -42,9 +43,7 @@ import io.reactivex.schedulers.Schedulers; |
| 42 | 43 | public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ |
| 43 | 44 | private final BaseRxActivity<?> activity; |
| 44 | 45 | |
| 45 | - private Function0 callback; | |
| 46 | - | |
| 47 | - String stuId; | |
| 46 | + private Function1<Student> callback; | |
| 48 | 47 | |
| 49 | 48 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA); |
| 50 | 49 | List<Student> studentList; |
| ... | ... | @@ -63,7 +62,7 @@ public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ |
| 63 | 62 | activity = context; |
| 64 | 63 | } |
| 65 | 64 | |
| 66 | - public void show(List<String> paths, Function0 callback) { | |
| 65 | + public void show(List<String> paths, Function1<Student> callback) { | |
| 67 | 66 | images = paths; |
| 68 | 67 | this.callback = callback; |
| 69 | 68 | super.show(); |
| ... | ... | @@ -73,7 +72,6 @@ public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ |
| 73 | 72 | @Override |
| 74 | 73 | public void initView() { |
| 75 | 74 | binding.btnClose.setOnClickListener(v -> dismiss()); |
| 76 | - stuId = getCurrentStuId(); | |
| 77 | 75 | binding.spStudent.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
| 78 | 76 | @Override |
| 79 | 77 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
| ... | ... | @@ -153,6 +151,7 @@ public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ |
| 153 | 151 | if (data != null && data.size() > 0) { |
| 154 | 152 | studentList = data; |
| 155 | 153 | int position = 0; |
| 154 | + String stuId = getCurrentStuId(); | |
| 156 | 155 | for (int i = 0; i < data.size(); i++) { |
| 157 | 156 | if (data.get(i).stuId.equals(stuId)) { |
| 158 | 157 | position = i; |
| ... | ... | @@ -267,7 +266,7 @@ public class AddHomeworkDialog extends BaseDialog<DialogAddHomeworkBinding>{ |
| 267 | 266 | if (response != null && response.getSuccess()) { |
| 268 | 267 | activity.cancelLoadingDialog(); |
| 269 | 268 | dismiss(); |
| 270 | - if (callback != null) callback.invoke(); | |
| 269 | + if (callback != null) callback.invoke(student); | |
| 271 | 270 | } else { |
| 272 | 271 | activity.loadFail("上传作业失败"); |
| 273 | 272 | } | ... | ... |
app/src/main/res/layout/activity_add_success.xml
libs/common/src/main/java/com/prws/common/net/RetrofitUtils.java
| ... | ... | @@ -44,12 +44,13 @@ public abstract class RetrofitUtils { |
| 44 | 44 | mStaOkHttpClient = OkHttp3Utils.getOkHttpClient(); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | + Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); | |
| 47 | 48 | //Retrofit2后使用build设计模式 |
| 48 | 49 | mStaRetrofit = new Retrofit.Builder() |
| 49 | 50 | //设置服务器路径 |
| 50 | 51 | .baseUrl( API_SERVER +"/") |
| 51 | 52 | //添加转化库,默认是Gson |
| 52 | - .addConverterFactory(GsonConverterFactory.create()) | |
| 53 | + .addConverterFactory(GsonConverterFactory.create(gson)) | |
| 53 | 54 | //添加回调库,采用RxJava |
| 54 | 55 | .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io())) |
| 55 | 56 | //设置使用okhttp网络请求 | ... | ... |