Commit 0aa2b2aeb67bdfeca1e2b9f62ef7a5e335fb211d
1 parent
e33341bbcc
Exists in
master
tab样式调整
Showing
4 changed files
with
16 additions
and
6 deletions
Show diff stats
app/src/main/java/com/hjx/parent/fragment/ErrorFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import static android.app.Activity.RESULT_OK; | 3 | import static android.app.Activity.RESULT_OK; |
4 | 4 | ||
5 | import android.annotation.SuppressLint; | 5 | import android.annotation.SuppressLint; |
6 | import android.content.Intent; | 6 | import android.content.Intent; |
7 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
8 | import android.graphics.BitmapFactory; | 8 | import android.graphics.BitmapFactory; |
9 | import android.net.Uri; | 9 | import android.net.Uri; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
13 | import android.util.Log; | 13 | import android.util.Log; |
14 | import android.view.LayoutInflater; | 14 | import android.view.LayoutInflater; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | import android.view.ViewGroup; | 16 | import android.view.ViewGroup; |
17 | import android.widget.TextView; | 17 | import android.widget.TextView; |
18 | import android.widget.Toast; | 18 | import android.widget.Toast; |
19 | 19 | ||
20 | import androidx.annotation.NonNull; | 20 | import androidx.annotation.NonNull; |
21 | import androidx.annotation.Nullable; | 21 | import androidx.annotation.Nullable; |
22 | import androidx.core.content.FileProvider; | 22 | import androidx.core.content.FileProvider; |
23 | import androidx.recyclerview.widget.RecyclerView; | 23 | import androidx.recyclerview.widget.RecyclerView; |
24 | 24 | ||
25 | import com.bumptech.glide.Glide; | 25 | import com.bumptech.glide.Glide; |
26 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 26 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
27 | import com.bumptech.glide.request.RequestOptions; | 27 | import com.bumptech.glide.request.RequestOptions; |
28 | import com.chad.library.adapter.base.BaseQuickAdapter; | 28 | import com.chad.library.adapter.base.BaseQuickAdapter; |
29 | import com.chad.library.adapter.base.BaseViewHolder; | 29 | import com.chad.library.adapter.base.BaseViewHolder; |
30 | import com.google.android.material.tabs.TabLayout; | 30 | import com.google.android.material.tabs.TabLayout; |
31 | import com.google.gson.Gson; | 31 | import com.google.gson.Gson; |
32 | import com.hjq.permissions.OnPermissionCallback; | 32 | import com.hjq.permissions.OnPermissionCallback; |
33 | import com.hjq.permissions.Permission; | 33 | import com.hjq.permissions.Permission; |
34 | import com.hjq.permissions.XXPermissions; | 34 | import com.hjq.permissions.XXPermissions; |
35 | import com.hjx.parent.ErrorListActivity; | 35 | import com.hjx.parent.ErrorListActivity; |
36 | import com.hjx.parent.HomeworkDetailActivity; | 36 | import com.hjx.parent.HomeworkDetailActivity; |
37 | import com.hjx.parent.HomeworkShareActivity; | 37 | import com.hjx.parent.HomeworkShareActivity; |
38 | import com.hjx.parent.ImageActivity; | 38 | import com.hjx.parent.ImageActivity; |
39 | import com.hjx.parent.R; | 39 | import com.hjx.parent.R; |
40 | import com.hjx.parent.StuHomeworkActivity; | 40 | import com.hjx.parent.StuHomeworkActivity; |
41 | import com.hjx.parent.TeacherChooseActivity; | 41 | import com.hjx.parent.TeacherChooseActivity; |
42 | import com.hjx.parent.adapter.ErrorAdapter; | 42 | import com.hjx.parent.adapter.ErrorAdapter; |
43 | import com.hjx.parent.adapter.HomeworkAdapter; | 43 | import com.hjx.parent.adapter.HomeworkAdapter; |
44 | import com.hjx.parent.bean.StudentBean; | 44 | import com.hjx.parent.bean.StudentBean; |
45 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 45 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
46 | import com.hjx.parent.rx.BaseRxFragment; | 46 | import com.hjx.parent.rx.BaseRxFragment; |
47 | import com.prws.common.bean.PageInfo; | 47 | import com.prws.common.bean.PageInfo; |
48 | import com.prws.common.bean.ResponseResult; | 48 | import com.prws.common.bean.ResponseResult; |
49 | import com.prws.common.bean.Student; | 49 | import com.prws.common.bean.Student; |
50 | import com.prws.common.bean.TopicBean; | 50 | import com.prws.common.bean.TopicBean; |
51 | import com.prws.common.bean.homework.HomeworkList; | 51 | import com.prws.common.bean.homework.HomeworkList; |
52 | import com.prws.common.net.NetWorks; | 52 | import com.prws.common.net.NetWorks; |
53 | import com.prws.common.utils.BitmapUtils; | 53 | import com.prws.common.utils.BitmapUtils; |
54 | import com.prws.common.utils.CommonUtil; | 54 | import com.prws.common.utils.CommonUtil; |
55 | import com.prws.common.utils.ScreenUtils; | 55 | import com.prws.common.utils.ScreenUtils; |
56 | import com.prws.common.utils.SharedPreferencesUtil; | 56 | import com.prws.common.utils.SharedPreferencesUtil; |
57 | import com.prws.common.utils.dialog.MyButtomDialog; | 57 | import com.prws.common.utils.dialog.MyButtomDialog; |
58 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 58 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
59 | import com.zhangteng.imagepicker.bean.ImageInfo; | 59 | import com.zhangteng.imagepicker.bean.ImageInfo; |
60 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 60 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
61 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 61 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
62 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 62 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
63 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 63 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
64 | import com.zhangteng.utils.IHandlerCallBack; | 64 | import com.zhangteng.utils.IHandlerCallBack; |
65 | 65 | ||
66 | import java.io.File; | 66 | import java.io.File; |
67 | import java.text.SimpleDateFormat; | 67 | import java.text.SimpleDateFormat; |
68 | import java.util.ArrayList; | 68 | import java.util.ArrayList; |
69 | import java.util.Arrays; | 69 | import java.util.Arrays; |
70 | import java.util.HashMap; | 70 | import java.util.HashMap; |
71 | import java.util.List; | 71 | import java.util.List; |
72 | import java.util.Locale; | 72 | import java.util.Locale; |
73 | import java.util.Map; | 73 | import java.util.Map; |
74 | 74 | ||
75 | import io.reactivex.Observable; | 75 | import io.reactivex.Observable; |
76 | import io.reactivex.Observer; | 76 | import io.reactivex.Observer; |
77 | import io.reactivex.android.schedulers.AndroidSchedulers; | 77 | import io.reactivex.android.schedulers.AndroidSchedulers; |
78 | import io.reactivex.disposables.Disposable; | 78 | import io.reactivex.disposables.Disposable; |
79 | import io.reactivex.schedulers.Schedulers; | 79 | import io.reactivex.schedulers.Schedulers; |
80 | 80 | ||
81 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | 81 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
82 | StudentBean studentBean; | 82 | StudentBean studentBean; |
83 | private int subject; | 83 | private int subject; |
84 | private ErrorAdapter errorAdapter; | 84 | private ErrorAdapter errorAdapter; |
85 | private HomeworkAdapter homeworkAdapter; | 85 | private HomeworkAdapter homeworkAdapter; |
86 | private String filePath; | 86 | private String filePath; |
87 | 87 | ||
88 | @Override | 88 | @Override |
89 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 89 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
90 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 90 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
91 | } | 91 | } |
92 | 92 | ||
93 | public void refreshStudent() { | 93 | public void refreshStudent() { |
94 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 94 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
95 | try { | 95 | try { |
96 | studentBean = new Gson().fromJson(student, StudentBean.class); | 96 | studentBean = new Gson().fromJson(student, StudentBean.class); |
97 | getBinding().tvChoose.setText(studentBean.getStuName()); | 97 | getBinding().tvChoose.setText(studentBean.getStuName()); |
98 | } catch (Exception e) { | 98 | } catch (Exception e) { |
99 | e.printStackTrace(); | 99 | e.printStackTrace(); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | @Override | 103 | @Override |
104 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 104 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
105 | super.onViewCreated(view, savedInstanceState); | 105 | super.onViewCreated(view, savedInstanceState); |
106 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 106 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
107 | if (!TextUtils.isEmpty(photo)) { | 107 | if (!TextUtils.isEmpty(photo)) { |
108 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 108 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
109 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 109 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
110 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 110 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
111 | } | 111 | } |
112 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 112 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
113 | getBinding().tvName.setText(name); | 113 | getBinding().tvName.setText(name); |
114 | refreshStudent(); | 114 | refreshStudent(); |
115 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | 115 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
116 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); | 116 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); |
117 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); | 117 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); |
118 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 118 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
119 | @Override | 119 | @Override |
120 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 120 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | @Override | 124 | @Override |
125 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 125 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
126 | int position = item.getBindingAdapterPosition(); | 126 | int position = item.getBindingAdapterPosition(); |
127 | String name = getResources().getStringArray(R.array.filter_subject)[position]; | 127 | String name = getResources().getStringArray(R.array.filter_subject)[position]; |
128 | item.setText(R.id.tv_subject, name); | 128 | item.setText(R.id.tv_subject, name); |
129 | switch (name) { | 129 | switch (name) { |
130 | case "语文": | 130 | case "语文": |
131 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_chinese); | 131 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_chinese); |
132 | break; | 132 | break; |
133 | case "数学": | 133 | case "数学": |
134 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_math); | 134 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_math); |
135 | break; | 135 | break; |
136 | case "英语": | 136 | case "英语": |
137 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_english); | 137 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_english); |
138 | break; | 138 | break; |
139 | case "物理": | 139 | case "物理": |
140 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_physics); | 140 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_physics); |
141 | break; | 141 | break; |
142 | case "化学": | 142 | case "化学": |
143 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_chemistry); | 143 | item.setImageResource(R.id.iv_subject, R.drawable.state_ic_chemistry); |
144 | break; | 144 | break; |
145 | } | 145 | } |
146 | item.itemView.setActivated(subject == position); | 146 | item.itemView.setActivated(subject == position); |
147 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 147 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
148 | layoutParams.width = (CommonUtil.getScreenWidth(mContext) - CommonUtil.dpToPx(mContext, 30)) / 4; | 148 | layoutParams.width = (CommonUtil.getScreenWidth(mContext) - CommonUtil.dpToPx(mContext, 30)) / 4; |
149 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 149 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
150 | item.itemView.setOnClickListener(v -> { | 150 | item.itemView.setOnClickListener(v -> { |
151 | if (subject != position) { | 151 | if (subject != position) { |
152 | subject = position; | 152 | subject = position; |
153 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 153 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
154 | getError(subStr); | 154 | getError(subStr); |
155 | getHomework(subStr); | 155 | getHomework(subStr); |
156 | notifyDataSetChanged(); | 156 | notifyDataSetChanged(); |
157 | } | 157 | } |
158 | }); | 158 | }); |
159 | } | 159 | } |
160 | }; | 160 | }; |
161 | getBinding().rvSubject.setAdapter(adapter); | 161 | getBinding().rvSubject.setAdapter(adapter); |
162 | subject = 0; | 162 | subject = 0; |
163 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 163 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
164 | getBinding().llAll.setOnClickListener(v -> { | 164 | getBinding().llAll.setOnClickListener(v -> { |
165 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 165 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
166 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 166 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
167 | startActivity(intent); | 167 | startActivity(intent); |
168 | } else { | 168 | } else { |
169 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); | 169 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); |
170 | startActivity(intent); | 170 | startActivity(intent); |
171 | } | 171 | } |
172 | }); | 172 | }); |
173 | 173 | ||
174 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | 174 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); |
175 | homeworkAdapter = new HomeworkAdapter(); | 175 | homeworkAdapter = new HomeworkAdapter(); |
176 | homeworkAdapter.setOnItemClickListener((baseQuickAdapter, view1, i) -> { | 176 | homeworkAdapter.setOnItemClickListener((baseQuickAdapter, view1, i) -> { |
177 | HomeworkList data = homeworkAdapter.getData().get(i); | 177 | HomeworkList data = homeworkAdapter.getData().get(i); |
178 | Gson gson = new Gson(); | 178 | Gson gson = new Gson(); |
179 | String json = gson.toJson(studentBean); | 179 | String json = gson.toJson(studentBean); |
180 | Student s = gson.fromJson(json, Student.class); | 180 | Student s = gson.fromJson(json, Student.class); |
181 | if (data.getRight() == null) { | 181 | if (data.getRight() == null) { |
182 | Intent intent = new Intent(requireContext(), HomeworkDetailActivity.class); | 182 | Intent intent = new Intent(requireContext(), HomeworkDetailActivity.class); |
183 | intent.putExtra("student", s); | 183 | intent.putExtra("student", s); |
184 | intent.putExtra("data", data); | 184 | intent.putExtra("data", data); |
185 | startActivity(intent); | 185 | startActivity(intent); |
186 | } else { | 186 | } else { |
187 | Intent intent = new Intent(requireContext(), HomeworkShareActivity.class); | 187 | Intent intent = new Intent(requireContext(), HomeworkShareActivity.class); |
188 | intent.putExtra("student", s); | 188 | intent.putExtra("student", s); |
189 | intent.putExtra("id", data.getId()); | 189 | intent.putExtra("id", data.getId()); |
190 | intent.putExtra("grade", data.getGrade()); | 190 | intent.putExtra("grade", data.getGrade()); |
191 | intent.putExtra("subject", data.getSubject()); | 191 | intent.putExtra("subject", data.getSubject()); |
192 | String name1 = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(data.uploadTime); | 192 | String name1 = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(data.uploadTime); |
193 | intent.putExtra("name", name1); | 193 | intent.putExtra("name", name1); |
194 | startActivity(intent); | 194 | startActivity(intent); |
195 | } | 195 | } |
196 | }); | 196 | }); |
197 | binding.rvMain.setAdapter(errorAdapter); | 197 | binding.rvMain.setAdapter(errorAdapter); |
198 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | 198 | // binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); |
199 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | 199 | // binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); |
200 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | 200 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
201 | @Override | 201 | @Override |
202 | public void onTabSelected(TabLayout.Tab tab) { | 202 | public void onTabSelected(TabLayout.Tab tab) { |
203 | if (tab.getPosition() == 0) { | 203 | if (tab.getPosition() == 0) { |
204 | binding.rvMain.setAdapter(errorAdapter); | 204 | binding.rvMain.setAdapter(errorAdapter); |
205 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | 205 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); |
206 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | 206 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); |
207 | binding.tvListTitle.setText("最近错题"); | 207 | binding.tvListTitle.setText("最近错题"); |
208 | binding.tvEmpty.setText("暂无错题~"); | 208 | binding.tvEmpty.setText("暂无错题~"); |
209 | } else { | 209 | } else { |
210 | binding.rvMain.setAdapter(homeworkAdapter); | 210 | binding.rvMain.setAdapter(homeworkAdapter); |
211 | binding.rvMain.setVisibility(homeworkAdapter.getData().isEmpty() ? View.GONE : View.VISIBLE); | 211 | binding.rvMain.setVisibility(homeworkAdapter.getData().isEmpty() ? View.GONE : View.VISIBLE); |
212 | binding.llEmpty.setVisibility(homeworkAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE); | 212 | binding.llEmpty.setVisibility(homeworkAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE); |
213 | binding.tvListTitle.setText("最近作业"); | 213 | binding.tvListTitle.setText("最近作业"); |
214 | binding.tvEmpty.setText("暂无作业~"); | 214 | binding.tvEmpty.setText("暂无作业~"); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | @Override | 217 | @Override |
218 | public void onTabUnselected(TabLayout.Tab tab) { | 218 | public void onTabUnselected(TabLayout.Tab tab) { |
219 | } | 219 | } |
220 | @Override | 220 | @Override |
221 | public void onTabReselected(TabLayout.Tab tab) { | 221 | public void onTabReselected(TabLayout.Tab tab) { |
222 | } | 222 | } |
223 | }); | 223 | }); |
224 | } | 224 | } |
225 | 225 | ||
226 | private void takePhoto(int type) { | 226 | private void takePhoto(int type) { |
227 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 227 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
228 | XXPermissions.with(getContext()) | 228 | XXPermissions.with(getContext()) |
229 | // 申请多个权限 | 229 | // 申请多个权限 |
230 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 230 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
231 | @Override | 231 | @Override |
232 | public void onGranted(List<String> permissions, boolean all) { | 232 | public void onGranted(List<String> permissions, boolean all) { |
233 | if (all) { | 233 | if (all) { |
234 | //开启扫码界面 | 234 | //开启扫码界面 |
235 | showButtonDialog(type); | 235 | showButtonDialog(type); |
236 | } else { | 236 | } else { |
237 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 237 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | @Override | 241 | @Override |
242 | public void onDenied(List<String> permissions, boolean never) { | 242 | public void onDenied(List<String> permissions, boolean never) { |
243 | XXPermissions.startPermissionActivity(getContext(), permissions); | 243 | XXPermissions.startPermissionActivity(getContext(), permissions); |
244 | } | 244 | } |
245 | }); | 245 | }); |
246 | } else { | 246 | } else { |
247 | showButtonDialog(type); | 247 | showButtonDialog(type); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | private void showButtonDialog(int type) { | 251 | private void showButtonDialog(int type) { |
252 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 252 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
253 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 253 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
254 | dialog.setContentView(bottomView); | 254 | dialog.setContentView(bottomView); |
255 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 255 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
256 | @Override | 256 | @Override |
257 | public void onClick(View view) { | 257 | public void onClick(View view) { |
258 | dialog.dismiss(); | 258 | dialog.dismiss(); |
259 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 259 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
260 | //确保有相机来处理Intent | 260 | //确保有相机来处理Intent |
261 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 261 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
262 | File photoFile = new File(filePath); | 262 | File photoFile = new File(filePath); |
263 | 263 | ||
264 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 264 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
265 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); | 265 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); |
266 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 266 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
267 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 267 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
268 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); | 268 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); |
269 | } | 269 | } |
270 | }); | 270 | }); |
271 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 271 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
272 | @Override | 272 | @Override |
273 | public void onClick(View view) { | 273 | public void onClick(View view) { |
274 | dialog.dismiss(); | 274 | dialog.dismiss(); |
275 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 275 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
276 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) | 276 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) |
277 | .multiSelect(true) //是否多选 | 277 | .multiSelect(true) //是否多选 |
278 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 278 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
279 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 279 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
280 | .maxImageSelectable(5) //图片可选择数 | 280 | .maxImageSelectable(5) //图片可选择数 |
281 | .maxHeight(1920) //图片最大高度 | 281 | .maxHeight(1920) //图片最大高度 |
282 | .maxWidth(1920) //图片最大宽度 | 282 | .maxWidth(1920) //图片最大宽度 |
283 | .maxImageSize(3) //图片最大大小Mb | 283 | .maxImageSize(3) //图片最大大小Mb |
284 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | 284 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); |
285 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 285 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
286 | 286 | ||
287 | } | 287 | } |
288 | }); | 288 | }); |
289 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 289 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
290 | @Override | 290 | @Override |
291 | public void onClick(View view) { | 291 | public void onClick(View view) { |
292 | dialog.dismiss(); | 292 | dialog.dismiss(); |
293 | } | 293 | } |
294 | }); | 294 | }); |
295 | dialog.show(); | 295 | dialog.show(); |
296 | } | 296 | } |
297 | 297 | ||
298 | @SuppressLint("CheckResult") | 298 | @SuppressLint("CheckResult") |
299 | protected void getHomework(String subject) { | 299 | protected void getHomework(String subject) { |
300 | if (studentBean == null) return; | 300 | if (studentBean == null) return; |
301 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | 301 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
302 | .subscribeOn(Schedulers.io()) | 302 | .subscribeOn(Schedulers.io()) |
303 | .observeOn(AndroidSchedulers.mainThread()) | 303 | .observeOn(AndroidSchedulers.mainThread()) |
304 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | 304 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
305 | .map(ResponseResult::getData) | 305 | .map(ResponseResult::getData) |
306 | .toObservable() | 306 | .toObservable() |
307 | .concatMap(Observable::fromIterable) | 307 | .concatMap(Observable::fromIterable) |
308 | .filter(data -> subject.equals(data.getSubject())) | 308 | .filter(data -> subject.equals(data.getSubject())) |
309 | //.filter(data -> data.getRight() == null) | 309 | //.filter(data -> data.getRight() == null) |
310 | .take(5) | 310 | .take(5) |
311 | .toList() | 311 | .toList() |
312 | .subscribe((data, th) -> { | 312 | .subscribe((data, th) -> { |
313 | if (th != null) th.printStackTrace(); | 313 | if (th != null) th.printStackTrace(); |
314 | homeworkAdapter.setNewData(data); | 314 | homeworkAdapter.setNewData(data); |
315 | if (binding.tabLayout.getSelectedTabPosition() == 1) { | 315 | if (binding.tabLayout.getSelectedTabPosition() == 1) { |
316 | binding.rvMain.setVisibility(data == null || data.isEmpty() ? View.GONE : View.VISIBLE); | 316 | binding.rvMain.setVisibility(data == null || data.isEmpty() ? View.GONE : View.VISIBLE); |
317 | binding.llEmpty.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE); | 317 | binding.llEmpty.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE); |
318 | } | 318 | } |
319 | }); | 319 | }); |
320 | } | 320 | } |
321 | 321 | ||
322 | private void getError(String subject) { | 322 | private void getError(String subject) { |
323 | if (studentBean == null) { | 323 | if (studentBean == null) { |
324 | return; | 324 | return; |
325 | } | 325 | } |
326 | Map<String, Object> map = new HashMap<>(); | 326 | Map<String, Object> map = new HashMap<>(); |
327 | map.put("subject", subject); | 327 | map.put("subject", subject); |
328 | map.put("stuId", studentBean.getStuId()); | 328 | map.put("stuId", studentBean.getStuId()); |
329 | map.put("pageSize", 5); | 329 | map.put("pageSize", 5); |
330 | map.put("pageNum", 1); | 330 | map.put("pageNum", 1); |
331 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 331 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
332 | @Override | 332 | @Override |
333 | public void onSubscribe(Disposable d) { | 333 | public void onSubscribe(Disposable d) { |
334 | } | 334 | } |
335 | @Override | 335 | @Override |
336 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 336 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
337 | if (result.getData() != null && result.getCode() == 200) { | 337 | if (result.getData() != null && result.getCode() == 200) { |
338 | List<TopicBean> topicBeans = result.getData().getList(); | 338 | List<TopicBean> topicBeans = result.getData().getList(); |
339 | errorAdapter.refresh(topicBeans); | 339 | errorAdapter.refresh(topicBeans); |
340 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 340 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
341 | if (topicBeans.size() > 0) { | 341 | if (topicBeans.size() > 0) { |
342 | getBinding().rvMain.setVisibility(View.VISIBLE); | 342 | getBinding().rvMain.setVisibility(View.VISIBLE); |
343 | getBinding().llEmpty.setVisibility(View.GONE); | 343 | getBinding().llEmpty.setVisibility(View.GONE); |
344 | } else { | 344 | } else { |
345 | getBinding().rvMain.setVisibility(View.GONE); | 345 | getBinding().rvMain.setVisibility(View.GONE); |
346 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 346 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | } | 349 | } |
350 | } | 350 | } |
351 | @Override | 351 | @Override |
352 | public void onError(Throwable e) { | 352 | public void onError(Throwable e) { |
353 | e.printStackTrace(); | 353 | e.printStackTrace(); |
354 | } | 354 | } |
355 | @Override | 355 | @Override |
356 | public void onComplete() { | 356 | public void onComplete() { |
357 | } | 357 | } |
358 | }); | 358 | }); |
359 | } | 359 | } |
360 | 360 | ||
361 | @Override | 361 | @Override |
362 | public void onResume() { | 362 | public void onResume() { |
363 | super.onResume(); | 363 | super.onResume(); |
364 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 364 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
365 | getError(subStr); | 365 | getError(subStr); |
366 | getHomework(subStr); | 366 | getHomework(subStr); |
367 | } | 367 | } |
368 | 368 | ||
369 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 369 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
370 | int type; | 370 | int type; |
371 | public HandlerCallBack(int type) { | 371 | public HandlerCallBack(int type) { |
372 | this.type = type; | 372 | this.type = type; |
373 | } | 373 | } |
374 | 374 | ||
375 | private String TAG = "---ImagePicker---"; | 375 | private String TAG = "---ImagePicker---"; |
376 | List<ImageInfo> photoList = new ArrayList<>(); | 376 | List<ImageInfo> photoList = new ArrayList<>(); |
377 | 377 | ||
378 | @Override | 378 | @Override |
379 | public void onStart() { | 379 | public void onStart() { |
380 | Log.i(TAG, "onStart: 开启"); | 380 | Log.i(TAG, "onStart: 开启"); |
381 | } | 381 | } |
382 | 382 | ||
383 | @Override | 383 | @Override |
384 | public void onSuccess(List<ImageInfo> photoList) { | 384 | public void onSuccess(List<ImageInfo> photoList) { |
385 | this.photoList = photoList; | 385 | this.photoList = photoList; |
386 | Log.i(TAG, "onSuccess: 返回数据"); | 386 | Log.i(TAG, "onSuccess: 返回数据"); |
387 | } | 387 | } |
388 | 388 | ||
389 | @Override | 389 | @Override |
390 | public void onCancel() { | 390 | public void onCancel() { |
391 | Log.i(TAG, "onCancel: 取消"); | 391 | Log.i(TAG, "onCancel: 取消"); |
392 | } | 392 | } |
393 | 393 | ||
394 | @Override | 394 | @Override |
395 | public void onFinish(List<ImageInfo> selectImage) { | 395 | public void onFinish(List<ImageInfo> selectImage) { |
396 | if (selectImage.size() == photoList.size()) { | 396 | if (selectImage.size() == photoList.size()) { |
397 | ArrayList<String> strings = new ArrayList<>(); | 397 | ArrayList<String> strings = new ArrayList<>(); |
398 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 398 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
399 | for (ImageInfo imageInfo : selectImage) { | 399 | for (ImageInfo imageInfo : selectImage) { |
400 | strings.add(imageInfo.getPath()); | 400 | strings.add(imageInfo.getPath()); |
401 | } | 401 | } |
402 | intent.putStringArrayListExtra("images", strings); | 402 | intent.putStringArrayListExtra("images", strings); |
403 | intent.putExtra("type", type); | 403 | intent.putExtra("type", type); |
404 | startActivity(intent); | 404 | startActivity(intent); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | @Override | 408 | @Override |
409 | public void onError() { | 409 | public void onError() { |
410 | Log.i(TAG, "onError: 出错"); | 410 | Log.i(TAG, "onError: 出错"); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | @Override | 414 | @Override |
415 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 415 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
416 | super.onActivityResult(requestCode, resultCode, data); | 416 | super.onActivityResult(requestCode, resultCode, data); |
417 | if (resultCode != RESULT_OK) return; | 417 | if (resultCode != RESULT_OK) return; |
418 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { | 418 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { |
419 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 419 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
420 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 420 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
421 | CommonUtil.saveBitmapToUri(b, path); | 421 | CommonUtil.saveBitmapToUri(b, path); |
422 | ArrayList<String> strings = new ArrayList<>(); | 422 | ArrayList<String> strings = new ArrayList<>(); |
423 | Intent intent = new Intent(getContext(), ImageActivity.class); | 423 | Intent intent = new Intent(getContext(), ImageActivity.class); |
424 | strings.add(path); | 424 | strings.add(path); |
425 | intent.putStringArrayListExtra("images", strings); | 425 | intent.putStringArrayListExtra("images", strings); |
426 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); | 426 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); |
427 | startActivity(intent); | 427 | startActivity(intent); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | } | 430 | } |
431 | 431 |
app/src/main/res/layout/activity_student_homework.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout 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 | xmlns:tools="http://schemas.android.com/tools" | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | android:orientation="vertical" | 5 | android:orientation="vertical" |
6 | android:layout_width="match_parent" | 6 | android:layout_width="match_parent" |
7 | android:layout_height="match_parent" | 7 | android:layout_height="match_parent" |
8 | tools:ignore="HardcodedText"> | 8 | tools:ignore="HardcodedText"> |
9 | 9 | ||
10 | <androidx.appcompat.widget.Toolbar | 10 | <androidx.appcompat.widget.Toolbar |
11 | android:id="@+id/toolbar" | 11 | android:id="@+id/toolbar" |
12 | app:navigationIcon="@drawable/svg_back" | 12 | app:navigationIcon="@drawable/svg_back" |
13 | android:paddingStart="-8dp" | 13 | android:paddingStart="-8dp" |
14 | android:paddingEnd="-8dp" | 14 | android:paddingEnd="-8dp" |
15 | android:background="@color/white" | 15 | android:background="@color/white" |
16 | android:layout_width="match_parent" | 16 | android:layout_width="match_parent" |
17 | android:layout_height="40dp"> | 17 | android:layout_height="40dp"> |
18 | <TextView | 18 | <TextView |
19 | android:id="@+id/tvTitle" | 19 | android:id="@+id/tvTitle" |
20 | tools:text="小明的全部作业" | 20 | tools:text="小明的全部作业" |
21 | android:textSize="18sp" | 21 | android:textSize="18sp" |
22 | android:textColor="#333" | 22 | android:textColor="#333" |
23 | android:textStyle="bold" | 23 | android:textStyle="bold" |
24 | android:layout_marginEnd="6dp" | 24 | android:layout_marginEnd="6dp" |
25 | android:layout_gravity="center" | 25 | android:layout_gravity="center" |
26 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
27 | android:layout_height="wrap_content"/> | 27 | android:layout_height="wrap_content"/> |
28 | <ImageView | 28 | <ImageView |
29 | android:id="@+id/btnChangeStudent" | 29 | android:id="@+id/btnChangeStudent" |
30 | android:src="@drawable/png_ic_change_student" | 30 | android:src="@drawable/png_ic_change_student" |
31 | android:layout_gravity="center" | 31 | android:layout_gravity="center" |
32 | android:layout_width="20dp" | 32 | android:layout_width="20dp" |
33 | android:layout_height="20dp"/> | 33 | android:layout_height="20dp"/> |
34 | </androidx.appcompat.widget.Toolbar> | 34 | </androidx.appcompat.widget.Toolbar> |
35 | <com.google.android.material.tabs.TabLayout | 35 | <com.google.android.material.tabs.TabLayout |
36 | android:id="@+id/tabLayout" | 36 | android:id="@+id/tabLayout" |
37 | app:tabMode="fixed" | 37 | app:tabMode="scrollable" |
38 | app:tabGravity="fill" | 38 | app:tabGravity="start" |
39 | android:paddingHorizontal="8dp" | ||
39 | app:tabTextColor="#333333" | 40 | app:tabTextColor="#333333" |
40 | app:tabSelectedTextColor="#1C90F3" | 41 | app:tabSelectedTextColor="#1C90F3" |
41 | app:tabIndicatorColor="#1C90F3" | 42 | app:tabIndicatorColor="#1C90F3" |
42 | app:tabIndicatorHeight="2dp" | 43 | app:tabIndicatorHeight="2dp" |
43 | app:tabIndicatorFullWidth="false" | 44 | app:tabIndicatorFullWidth="false" |
44 | app:tabTextAppearance="@style/tab_homework" | 45 | app:tabTextAppearance="@style/tab_homework" |
45 | app:tabRippleColor="@color/transparent" | 46 | app:tabRippleColor="@color/transparent" |
46 | android:background="@color/white" | 47 | android:background="@color/white" |
47 | android:layout_width="match_parent" | 48 | android:layout_width="match_parent" |
48 | android:layout_height="45dp"/> | 49 | android:layout_height="45dp"/> |
49 | <LinearLayout | 50 | <LinearLayout |
50 | android:id="@+id/filterBar" | 51 | android:id="@+id/filterBar" |
51 | android:orientation="horizontal" | 52 | android:orientation="horizontal" |
52 | android:background="@color/white" | 53 | android:background="@color/white" |
53 | android:paddingHorizontal="15dp" | 54 | android:paddingHorizontal="15dp" |
54 | android:paddingVertical="11dp" | 55 | android:paddingVertical="11dp" |
55 | android:layout_width="match_parent" | 56 | android:layout_width="match_parent" |
56 | android:layout_height="wrap_content"> | 57 | android:layout_height="wrap_content"> |
57 | <androidx.appcompat.widget.AppCompatTextView | 58 | <androidx.appcompat.widget.AppCompatTextView |
58 | android:id="@+id/ftSubject" | 59 | android:id="@+id/ftSubject" |
59 | android:text="学科" | 60 | android:text="学科" |
60 | style="@style/tv_StudentHomeworkFilter"/> | 61 | style="@style/tv_StudentHomeworkFilter"/> |
61 | <Space style="@style/empty_space"/> | 62 | <Space style="@style/empty_space"/> |
62 | <androidx.appcompat.widget.AppCompatTextView | 63 | <androidx.appcompat.widget.AppCompatTextView |
63 | android:id="@+id/ftGrade" | 64 | android:id="@+id/ftGrade" |
64 | android:text="年级" | 65 | android:text="年级" |
65 | style="@style/tv_StudentHomeworkFilter"/> | 66 | style="@style/tv_StudentHomeworkFilter"/> |
66 | <Space style="@style/empty_space"/> | 67 | <Space style="@style/empty_space"/> |
67 | <androidx.appcompat.widget.AppCompatTextView | 68 | <androidx.appcompat.widget.AppCompatTextView |
68 | android:id="@+id/ftTerm" | 69 | android:id="@+id/ftTerm" |
69 | android:text="学期" | 70 | android:text="学期" |
70 | style="@style/tv_StudentHomeworkFilter"/> | 71 | style="@style/tv_StudentHomeworkFilter"/> |
71 | <Space style="@style/empty_space"/> | 72 | <Space style="@style/empty_space"/> |
72 | <androidx.appcompat.widget.AppCompatTextView | 73 | <androidx.appcompat.widget.AppCompatTextView |
73 | android:id="@+id/ftFeedback" | 74 | android:id="@+id/ftFeedback" |
74 | android:text="反馈状态" | 75 | android:text="反馈状态" |
75 | style="@style/tv_StudentHomeworkFilter"/> | 76 | style="@style/tv_StudentHomeworkFilter"/> |
76 | </LinearLayout> | 77 | </LinearLayout> |
77 | <androidx.legacy.widget.Space | 78 | <androidx.legacy.widget.Space |
78 | android:id="@+id/anchorView" | 79 | android:id="@+id/anchorView" |
79 | android:layout_width="0dp" | 80 | android:layout_width="0dp" |
80 | android:layout_height="0dp"/> | 81 | android:layout_height="0dp"/> |
81 | 82 | ||
82 | <FrameLayout | 83 | <FrameLayout |
83 | android:id="@+id/weekBar" | 84 | android:id="@+id/weekBar" |
84 | android:visibility="gone" | 85 | android:visibility="gone" |
85 | android:layout_width="match_parent" | 86 | android:layout_width="match_parent" |
86 | android:layout_height="wrap_content"> | 87 | android:layout_height="wrap_content"> |
87 | <TextView | 88 | <TextView |
88 | android:id="@+id/btnGeneralHuyou" | 89 | android:id="@+id/btnGeneralHuyou" |
89 | android:visibility="gone" | 90 | android:visibility="gone" |
90 | tools:visibility="visible" | 91 | tools:visibility="visible" |
91 | android:text="生成本周作业总结" | 92 | android:text="生成本周作业总结" |
92 | android:textSize="13sp" | 93 | android:textSize="13sp" |
93 | android:textColor="#1C90F3" | 94 | android:textColor="#1C90F3" |
94 | android:gravity="center" | 95 | android:gravity="center" |
95 | android:textStyle="bold" | 96 | android:textStyle="bold" |
96 | android:background="@drawable/btn_general_huyou" | 97 | android:background="@drawable/btn_general_huyou" |
97 | android:layout_marginTop="16dp" | 98 | android:layout_marginTop="16dp" |
98 | android:layout_marginHorizontal="30dp" | 99 | android:layout_marginHorizontal="30dp" |
99 | android:layout_width="match_parent" | 100 | android:layout_width="match_parent" |
100 | android:layout_height="35dp" | 101 | android:layout_height="35dp" |
101 | tools:ignore="HardcodedText" /> | 102 | tools:ignore="HardcodedText" /> |
102 | </FrameLayout> | 103 | </FrameLayout> |
103 | 104 | ||
104 | <FrameLayout | 105 | <FrameLayout |
105 | android:id="@+id/stageBar" | 106 | android:id="@+id/stageBar" |
106 | android:visibility="gone" | 107 | android:visibility="gone" |
107 | android:layout_width="match_parent" | 108 | android:layout_width="match_parent" |
108 | android:layout_height="wrap_content"> | 109 | android:layout_height="wrap_content"> |
109 | <TextView | 110 | <TextView |
110 | android:id="@+id/btnStageHuyou" | 111 | android:id="@+id/btnStageHuyou" |
111 | android:text="生成阶段性作业总结" | 112 | android:text="生成阶段性作业总结" |
112 | android:textSize="13sp" | 113 | android:textSize="13sp" |
113 | android:textColor="#1C90F3" | 114 | android:textColor="#1C90F3" |
114 | android:gravity="center" | 115 | android:gravity="center" |
115 | android:textStyle="bold" | 116 | android:textStyle="bold" |
116 | android:background="@drawable/btn_general_huyou" | 117 | android:background="@drawable/btn_general_huyou" |
117 | android:layout_marginTop="16dp" | 118 | android:layout_marginTop="16dp" |
118 | android:layout_marginHorizontal="30dp" | 119 | android:layout_marginHorizontal="30dp" |
119 | android:layout_width="match_parent" | 120 | android:layout_width="match_parent" |
120 | android:layout_height="35dp" | 121 | android:layout_height="35dp" |
121 | tools:ignore="HardcodedText" /> | 122 | tools:ignore="HardcodedText" /> |
122 | </FrameLayout> | 123 | </FrameLayout> |
123 | 124 | ||
124 | <androidx.recyclerview.widget.RecyclerView | 125 | <androidx.recyclerview.widget.RecyclerView |
125 | android:id="@+id/recyclerView" | 126 | android:id="@+id/recyclerView" |
126 | android:background="#F8F8F8" | 127 | android:background="#F8F8F8" |
127 | android:orientation="vertical" | 128 | android:orientation="vertical" |
128 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | 129 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
129 | android:layout_width="match_parent" | 130 | android:layout_width="match_parent" |
130 | android:layout_height="match_parent"/> | 131 | android:layout_height="match_parent"/> |
131 | </LinearLayout> | 132 | </LinearLayout> |
app/src/main/res/layout/fragment_error_book.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | xmlns:tools="http://schemas.android.com/tools" | 2 | xmlns:tools="http://schemas.android.com/tools" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | 5 | xmlns:app="http://schemas.android.com/apk/res-auto" |
6 | android:orientation="vertical" | 6 | android:orientation="vertical" |
7 | tools:ignore="HardcodedText,ContentDescription,UseCompoundDrawables"> | 7 | tools:ignore="HardcodedText,ContentDescription,UseCompoundDrawables"> |
8 | 8 | ||
9 | <RelativeLayout | 9 | <RelativeLayout |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="40dp" | 11 | android:layout_height="40dp" |
12 | android:layout_marginTop="30dp"> | 12 | android:layout_marginTop="30dp"> |
13 | 13 | ||
14 | <ImageView | 14 | <ImageView |
15 | android:id="@+id/iv_student" | 15 | android:id="@+id/iv_student" |
16 | android:layout_width="35dp" | 16 | android:layout_width="35dp" |
17 | android:layout_height="35dp" | 17 | android:layout_height="35dp" |
18 | android:layout_centerVertical="true" | 18 | android:layout_centerVertical="true" |
19 | android:layout_marginStart="15dp" /> | 19 | android:layout_marginStart="15dp" /> |
20 | 20 | ||
21 | <TextView | 21 | <TextView |
22 | android:id="@+id/tv_name" | 22 | android:id="@+id/tv_name" |
23 | android:layout_width="wrap_content" | 23 | android:layout_width="wrap_content" |
24 | android:layout_height="wrap_content" | 24 | android:layout_height="wrap_content" |
25 | android:layout_centerVertical="true" | 25 | android:layout_centerVertical="true" |
26 | android:layout_marginStart="10dp" | 26 | android:layout_marginStart="10dp" |
27 | android:layout_toEndOf="@+id/iv_student" | 27 | android:layout_toEndOf="@+id/iv_student" |
28 | android:textColor="#333333" | 28 | android:textColor="#333333" |
29 | android:textSize="16sp" | 29 | android:textSize="16sp" |
30 | tools:ignore="RelativeOverlap" /> | 30 | tools:ignore="RelativeOverlap" /> |
31 | 31 | ||
32 | <androidx.appcompat.widget.AppCompatTextView | 32 | <androidx.appcompat.widget.AppCompatTextView |
33 | android:id="@+id/tv_choose" | 33 | android:id="@+id/tv_choose" |
34 | android:layout_width="wrap_content" | 34 | android:layout_width="wrap_content" |
35 | android:layout_height="wrap_content" | 35 | android:layout_height="wrap_content" |
36 | android:layout_alignParentEnd="true" | 36 | android:layout_alignParentEnd="true" |
37 | android:layout_centerVertical="true" | 37 | android:layout_centerVertical="true" |
38 | android:layout_marginEnd="15dp" | 38 | android:layout_marginEnd="15dp" |
39 | android:drawableEnd="@drawable/ic_filter_black" | 39 | android:drawableEnd="@drawable/ic_filter_black" |
40 | android:drawablePadding="5dp" | 40 | android:drawablePadding="5dp" |
41 | android:text="选择学生" | 41 | android:text="选择学生" |
42 | android:textColor="#333333" | 42 | android:textColor="#333333" |
43 | android:textSize="14sp" /> | 43 | android:textSize="14sp" /> |
44 | 44 | ||
45 | </RelativeLayout> | 45 | </RelativeLayout> |
46 | 46 | ||
47 | <LinearLayout | 47 | <LinearLayout |
48 | android:orientation="horizontal" | 48 | android:orientation="horizontal" |
49 | android:weightSum="2" | 49 | android:weightSum="2" |
50 | android:layout_width="match_parent" | 50 | android:layout_width="match_parent" |
51 | android:layout_height="wrap_content" | 51 | android:layout_height="wrap_content" |
52 | android:baselineAligned="false"> | 52 | android:baselineAligned="false"> |
53 | <FrameLayout | 53 | <FrameLayout |
54 | android:id="@+id/rl_take_photo" | 54 | android:id="@+id/rl_take_photo" |
55 | android:layout_width="0dp" | 55 | android:layout_width="0dp" |
56 | android:layout_weight="1" | 56 | android:layout_weight="1" |
57 | android:layout_height="wrap_content"> | 57 | android:layout_height="wrap_content"> |
58 | <ImageView | 58 | <ImageView |
59 | android:src="@drawable/png_entry_error" | 59 | android:src="@drawable/png_entry_error" |
60 | android:adjustViewBounds="true" | 60 | android:adjustViewBounds="true" |
61 | android:layout_width="match_parent" | 61 | android:layout_width="match_parent" |
62 | android:layout_height="wrap_content"/> | 62 | android:layout_height="wrap_content"/> |
63 | </FrameLayout> | 63 | </FrameLayout> |
64 | 64 | ||
65 | <FrameLayout | 65 | <FrameLayout |
66 | android:id="@+id/flEntryHomework" | 66 | android:id="@+id/flEntryHomework" |
67 | android:layout_width="0dp" | 67 | android:layout_width="0dp" |
68 | android:layout_weight="1" | 68 | android:layout_weight="1" |
69 | android:layout_height="wrap_content"> | 69 | android:layout_height="wrap_content"> |
70 | <ImageView | 70 | <ImageView |
71 | android:src="@drawable/png_entry_homework" | 71 | android:src="@drawable/png_entry_homework" |
72 | android:adjustViewBounds="true" | 72 | android:adjustViewBounds="true" |
73 | android:layout_width="match_parent" | 73 | android:layout_width="match_parent" |
74 | android:layout_height="wrap_content"/> | 74 | android:layout_height="wrap_content"/> |
75 | 75 | ||
76 | </FrameLayout> | 76 | </FrameLayout> |
77 | </LinearLayout> | 77 | </LinearLayout> |
78 | 78 | ||
79 | <LinearLayout | 79 | <LinearLayout |
80 | android:orientation="vertical" | 80 | android:orientation="vertical" |
81 | android:background="@drawable/shape_radius_10" | 81 | android:background="@drawable/shape_radius_10" |
82 | android:backgroundTint="@color/white" | 82 | android:backgroundTint="@color/white" |
83 | android:layout_marginHorizontal="15dp" | 83 | android:layout_marginHorizontal="15dp" |
84 | android:layout_marginTop="10dp" | 84 | android:layout_marginTop="10dp" |
85 | android:layout_marginBottom="15dp" | 85 | android:layout_marginBottom="15dp" |
86 | android:layout_width="match_parent" | 86 | android:layout_width="match_parent" |
87 | android:layout_height="match_parent"> | 87 | android:layout_height="match_parent"> |
88 | 88 | ||
89 | <com.google.android.material.tabs.TabLayout | 89 | <com.google.android.material.tabs.TabLayout |
90 | android:id="@+id/tabLayout" | 90 | android:id="@+id/tabLayout" |
91 | app:tabMode="fixed" | 91 | app:tabMode="fixed" |
92 | app:tabGravity="fill" | 92 | app:tabGravity="fill" |
93 | app:tabIndicatorFullWidth="false" | 93 | app:tabIndicatorFullWidth="false" |
94 | app:tabIndicatorColor="#1C90F3" | 94 | app:tabIndicatorColor="#1C90F3" |
95 | app:tabTextColor="#333" | 95 | app:tabTextColor="#333" |
96 | app:tabSelectedTextColor="#1C90F3" | 96 | app:tabSelectedTextColor="#1C90F3" |
97 | app:tabTextAppearance="@style/tab_home_item" | 97 | app:tabTextAppearance="@style/tab_home_item" |
98 | app:tabRippleColor="@color/transparent" | 98 | app:tabRippleColor="@color/transparent" |
99 | android:background="@drawable/bg_tab_home" | 99 | android:background="@drawable/bg_tab_home" |
100 | app:tabIndicatorHeight="2dp" | 100 | app:tabIndicatorHeight="2dp" |
101 | android:paddingVertical="8dp" | 101 | android:paddingVertical="8dp" |
102 | android:layout_width="match_parent" | 102 | android:layout_width="match_parent" |
103 | android:layout_height="48dp"/> | 103 | android:layout_height="48dp"> |
104 | <com.google.android.material.tabs.TabItem | ||
105 | android:text="最近错题" | ||
106 | android:layout_width="wrap_content" | ||
107 | android:layout_height="wrap_content"/> | ||
108 | <com.google.android.material.tabs.TabItem | ||
109 | android:text="最近作业" | ||
110 | android:layout_width="wrap_content" | ||
111 | android:layout_height="wrap_content"/> | ||
112 | </com.google.android.material.tabs.TabLayout> | ||
104 | 113 | ||
105 | <androidx.core.widget.NestedScrollView | 114 | <androidx.core.widget.NestedScrollView |
106 | android:layout_width="match_parent" | 115 | android:layout_width="match_parent" |
107 | android:layout_height="match_parent"> | 116 | android:layout_height="match_parent"> |
108 | <LinearLayout | 117 | <LinearLayout |
109 | android:orientation="vertical" | 118 | android:orientation="vertical" |
110 | android:layout_width="match_parent" | 119 | android:layout_width="match_parent" |
111 | android:layout_height="wrap_content"> | 120 | android:layout_height="wrap_content"> |
112 | 121 | ||
113 | <androidx.recyclerview.widget.RecyclerView | 122 | <androidx.recyclerview.widget.RecyclerView |
114 | android:id="@+id/rvSubject" | 123 | android:id="@+id/rvSubject" |
115 | android:orientation="horizontal" | 124 | android:orientation="horizontal" |
116 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | 125 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
117 | android:layout_marginTop="15dp" | 126 | android:layout_marginTop="15dp" |
118 | android:layout_width="match_parent" | 127 | android:layout_width="match_parent" |
119 | android:layout_height="wrap_content" /> | 128 | android:layout_height="wrap_content" /> |
120 | 129 | ||
121 | <LinearLayout | 130 | <LinearLayout |
122 | android:layout_marginTop="16dp" | 131 | android:layout_marginTop="16dp" |
123 | android:layout_marginHorizontal="10dp" | 132 | android:layout_marginHorizontal="10dp" |
124 | android:layout_width="match_parent" | 133 | android:layout_width="match_parent" |
125 | android:layout_height="25dp"> | 134 | android:layout_height="25dp"> |
126 | <TextView | 135 | <TextView |
127 | android:id="@+id/tvListTitle" | 136 | android:id="@+id/tvListTitle" |
128 | android:layout_width="wrap_content" | 137 | android:layout_width="wrap_content" |
129 | android:layout_height="wrap_content" | 138 | android:layout_height="wrap_content" |
130 | android:text="最近错题" | 139 | android:text="最近错题" |
131 | android:textColor="#333333" | 140 | android:textColor="#333333" |
132 | android:textSize="16sp" | 141 | android:textSize="16sp" |
133 | android:textStyle="bold" /> | 142 | android:textStyle="bold" /> |
134 | 143 | ||
135 | <Space style="@style/empty_space"/> | 144 | <Space style="@style/empty_space"/> |
136 | 145 | ||
137 | <LinearLayout | 146 | <LinearLayout |
138 | android:id="@+id/ll_all" | 147 | android:id="@+id/ll_all" |
139 | android:layout_width="wrap_content" | 148 | android:layout_width="wrap_content" |
140 | android:layout_height="wrap_content" | 149 | android:layout_height="wrap_content" |
141 | android:layout_gravity="center_vertical"> | 150 | android:layout_gravity="center_vertical"> |
142 | 151 | ||
143 | <TextView | 152 | <TextView |
144 | android:layout_width="wrap_content" | 153 | android:layout_width="wrap_content" |
145 | android:layout_height="wrap_content" | 154 | android:layout_height="wrap_content" |
146 | android:layout_gravity="center_vertical" | 155 | android:layout_gravity="center_vertical" |
147 | android:text="查看全部" | 156 | android:text="查看全部" |
148 | android:textColor="#666666" | 157 | android:textColor="#666666" |
149 | android:textSize="12sp" /> | 158 | android:textSize="12sp" /> |
150 | 159 | ||
151 | <ImageView | 160 | <ImageView |
152 | android:layout_width="9dp" | 161 | android:layout_width="9dp" |
153 | android:layout_height="10dp" | 162 | android:layout_height="10dp" |
154 | android:layout_gravity="center_vertical" | 163 | android:layout_gravity="center_vertical" |
155 | android:layout_marginStart="5dp" | 164 | android:layout_marginStart="5dp" |
156 | android:src="@mipmap/ic_arrow_right" /> | 165 | android:src="@mipmap/ic_arrow_right" /> |
157 | </LinearLayout> | 166 | </LinearLayout> |
158 | </LinearLayout> | 167 | </LinearLayout> |
159 | 168 | ||
160 | <androidx.recyclerview.widget.RecyclerView | 169 | <androidx.recyclerview.widget.RecyclerView |
161 | android:id="@+id/rvMain" | 170 | android:id="@+id/rvMain" |
162 | android:orientation="vertical" | 171 | android:orientation="vertical" |
163 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | 172 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
164 | android:layout_width="match_parent" | 173 | android:layout_width="match_parent" |
165 | android:layout_height="wrap_content" | 174 | android:layout_height="wrap_content" |
166 | android:layout_marginTop="15dp" /> | 175 | android:layout_marginTop="15dp" /> |
167 | 176 | ||
168 | <LinearLayout | 177 | <LinearLayout |
169 | android:id="@+id/ll_empty" | 178 | android:id="@+id/ll_empty" |
170 | android:layout_width="wrap_content" | 179 | android:layout_width="wrap_content" |
171 | android:layout_height="wrap_content" | 180 | android:layout_height="wrap_content" |
172 | android:layout_gravity="center_horizontal" | 181 | android:layout_gravity="center_horizontal" |
173 | android:layout_marginTop="30dp" | 182 | android:layout_marginTop="30dp" |
174 | android:orientation="vertical" | 183 | android:orientation="vertical" |
175 | android:visibility="gone"> | 184 | android:visibility="gone"> |
176 | 185 | ||
177 | <ImageView | 186 | <ImageView |
178 | android:layout_width="155dp" | 187 | android:layout_width="155dp" |
179 | android:layout_height="130dp" | 188 | android:layout_height="130dp" |
180 | android:src="@mipmap/ic_empty" /> | 189 | android:src="@mipmap/ic_empty" /> |
181 | 190 | ||
182 | <TextView | 191 | <TextView |
183 | android:id="@+id/tvEmpty" | 192 | android:id="@+id/tvEmpty" |
184 | android:layout_width="wrap_content" | 193 | android:layout_width="wrap_content" |
185 | android:layout_height="wrap_content" | 194 | android:layout_height="wrap_content" |
186 | android:layout_gravity="center_horizontal" | 195 | android:layout_gravity="center_horizontal" |
187 | android:text="暂无错题~" /> | 196 | android:text="暂无错题~" /> |
188 | </LinearLayout> | 197 | </LinearLayout> |
189 | 198 | ||
190 | </LinearLayout> | 199 | </LinearLayout> |
191 | </androidx.core.widget.NestedScrollView> | 200 | </androidx.core.widget.NestedScrollView> |
192 | </LinearLayout> | 201 | </LinearLayout> |
193 | </LinearLayout> | 202 | </LinearLayout> |
app/src/main/res/values/appearance.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <resources> | 2 | <resources> |
3 | 3 | ||
4 | <style name="tab_home_item"> | 4 | <style name="tab_home_item"> |
5 | <item name="android:textSize">16sp</item> | 5 | <item name="android:textSize">16sp</item> |
6 | <item name="android:textStyle">bold</item> | 6 | <item name="android:textStyle">bold</item> |
7 | </style> | 7 | </style> |
8 | 8 | ||
9 | <style name="tab_homework"> | 9 | <style name="tab_homework"> |
10 | <item name="android:textSize">13sp</item> | 10 | <item name="android:textSize">15sp</item> |
11 | </style> | 11 | </style> |
12 | 12 | ||
13 | </resources> | 13 | </resources> |