Commit d454c09d63fecb8d7955baf3073e787de73ef4d6
1 parent
079c5d473a
Exists in
master
首页-最近作业
Showing
36 changed files
with
808 additions
and
186 deletions
Show diff stats
.idea/inspectionProfiles/Project_Default.xml
File was created | 1 | <component name="InspectionProjectProfileManager"> | |
2 | <profile version="1.0"> | ||
3 | <option name="myName" value="Project Default" /> | ||
4 | <inspection_tool class="IgnoreResultOfCall" enabled="false" level="WARNING" enabled_by_default="false"> | ||
5 | <option name="m_reportAllNonLibraryCalls" value="false" /> | ||
6 | <option name="callCheckString" value="java.io.File,.*,java.io.InputStream,read|skip|available|markSupported,java.io.Reader,read|skip|ready|markSupported,java.lang.AbstractStringBuilder,capacity|codePointAt|codePointBefore|codePointCount|indexOf|lastIndexOf|offsetByCodePoints|substring|subSequence,java.lang.Boolean,.*,java.lang.Byte,.*,java.lang.Character,.*,java.lang.Double,.*,java.lang.Float,.*,java.lang.Integer,.*,java.lang.Long,.*,java.lang.Math,.*,java.lang.Object,equals|hashCode|toString,java.lang.Short,.*,java.lang.StrictMath,.*,java.lang.String,.*,java.lang.Thread,interrupted,java.math.BigDecimal,.*,java.math.BigInteger,.*,java.net.InetAddress,.*,java.net.URI,.*,java.nio.channels.AsynchronousChannelGroup,.*,java.nio.channels.Channel,isOpen,java.nio.channels.FileChannel,open|map|lock|tryLock|write,java.nio.channels.ScatteringByteChannel,read,java.nio.channels.SocketChannel,open|socket|isConnected|isConnectionPending,java.util.Arrays,.*,java.util.Collections,(?!addAll).*,java.util.List,of,java.util.Map,of|ofEntries|entry,java.util.Set,of,java.util.UUID,.*,java.util.concurrent.BlockingQueue,offer|remove,java.util.concurrent.CountDownLatch,await|getCount,java.util.concurrent.ExecutorService,awaitTermination|isShutdown|isTerminated,java.util.concurrent.ForkJoinPool,awaitQuiescence,java.util.concurrent.Semaphore,tryAcquire|availablePermits|isFair|hasQueuedThreads|getQueueLength|getQueuedThreads,java.util.concurrent.locks.Condition,await|awaitNanos|awaitUntil,java.util.concurrent.locks.Lock,tryLock|newCondition,java.util.regex.Matcher,pattern|toMatchResult|start|end|group|groupCount|matches|find|lookingAt|quoteReplacement|replaceAll|replaceFirst|regionStart|regionEnd|hasTransparentBounds|hasAnchoringBounds|hitEnd|requireEnd,java.util.regex.Pattern,.*,java.util.stream.BaseStream,.*,java.util.stream.DoubleStream,.*,java.util.stream.IntStream,.*,java.util.stream.LongStream,.*,java.util.stream.Stream,.*" /> | ||
7 | </inspection_tool> | ||
8 | </profile> | ||
9 | </component> |
app/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | apply from: '../config.gradle' | 2 | apply from: '../config.gradle' |
3 | 3 | ||
4 | 4 | ||
5 | def androidId = rootProject.ext.androidId | 5 | def androidId = rootProject.ext.androidId |
6 | def support = rootProject.ext.dependencies | 6 | def support = rootProject.ext.dependencies |
7 | def url = rootProject.ext.url | 7 | def url = rootProject.ext.url |
8 | 8 | ||
9 | 9 | ||
10 | android { | 10 | android { |
11 | signingConfigs { | 11 | signingConfigs { |
12 | 12 | ||
13 | config { | 13 | config { |
14 | keyAlias 'alias' | 14 | keyAlias 'alias' |
15 | keyPassword '123456' | 15 | keyPassword '123456' |
16 | storeFile file('key.jks') | 16 | storeFile file('key.jks') |
17 | storePassword '123456' | 17 | storePassword '123456' |
18 | } | 18 | } |
19 | debug { | 19 | debug { |
20 | } | 20 | } |
21 | } | 21 | } |
22 | compileSdk 32 | 22 | compileSdk 32 |
23 | 23 | ||
24 | defaultConfig { | 24 | defaultConfig { |
25 | applicationId "com.hjx.parent" | 25 | applicationId "com.hjx.parent" |
26 | minSdk 24 | 26 | minSdk 24 |
27 | targetSdk 32 | 27 | targetSdk 32 |
28 | versionCode 1005 | 28 | versionCode 1005 |
29 | versionName "1.0.0.5" | 29 | versionName "1.0.0.5" |
30 | 30 | ||
31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
32 | } | 32 | } |
33 | 33 | ||
34 | android.applicationVariants.all { | 34 | android.applicationVariants.all { |
35 | variant -> | 35 | variant -> |
36 | variant.outputs.all { | 36 | variant.outputs.all { |
37 | //在这里修改apk文件名 | 37 | //在这里修改apk文件名 |
38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
39 | } | 39 | } |
40 | } | 40 | } |
41 | buildTypes { | 41 | buildTypes { |
42 | debug { | 42 | debug { |
43 | debuggable true | 43 | debuggable true |
44 | minifyEnabled false | 44 | minifyEnabled false |
45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
46 | signingConfig signingConfigs.config | 46 | signingConfig signingConfigs.config |
47 | } | 47 | } |
48 | release { | 48 | release { |
49 | debuggable true | 49 | debuggable true |
50 | minifyEnabled false | 50 | minifyEnabled false |
51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
52 | signingConfig signingConfigs.config | 52 | signingConfig signingConfigs.config |
53 | } | 53 | } |
54 | } | 54 | } |
55 | lintOptions { | 55 | lintOptions { |
56 | checkReleaseBuilds false | 56 | checkReleaseBuilds false |
57 | abortOnError false | 57 | abortOnError false |
58 | } | 58 | } |
59 | buildFeatures { | 59 | buildFeatures { |
60 | viewBinding true | 60 | viewBinding true |
61 | } | 61 | } |
62 | compileOptions { | 62 | compileOptions { |
63 | sourceCompatibility JavaVersion.VERSION_1_8 | 63 | sourceCompatibility JavaVersion.VERSION_1_8 |
64 | targetCompatibility JavaVersion.VERSION_1_8 | 64 | targetCompatibility JavaVersion.VERSION_1_8 |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | dependencies { | 68 | dependencies { |
69 | support.each { k, v -> implementation v } | 69 | support.each { k, v -> implementation v } |
70 | api project(path: ':libs:common') | 70 | api project(path: ':libs:common') |
71 | implementation 'androidx.appcompat:appcompat:1.5.1' | 71 | implementation 'androidx.appcompat:appcompat:1.5.1' |
72 | implementation 'com.google.android.material:material:1.6.1' | 72 | implementation 'com.google.android.material:material:1.6.1' |
73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
77 | //使用的三方 | 77 | //使用的三方 |
78 | implementation 'com.yalantis:ucrop:2.2.0' | 78 | implementation 'com.yalantis:ucrop:2.2.0' |
79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
81 | |||
82 | // rx | ||
83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | ||
84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | ||
81 | } | 85 | } |
app/src/main/java/com/hjx/parent/adapter/ErrorAdapter.java
1 | package com.hjx.parent.adapter; | 1 | package com.hjx.parent.adapter; |
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.graphics.drawable.Drawable; | 5 | import android.graphics.drawable.Drawable; |
6 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
7 | import android.view.LayoutInflater; | 7 | import android.view.LayoutInflater; |
8 | import android.view.MotionEvent; | 8 | import android.view.MotionEvent; |
9 | import android.view.View; | 9 | import android.view.View; |
10 | import android.view.ViewGroup; | 10 | import android.view.ViewGroup; |
11 | import android.webkit.WebSettings; | 11 | import android.webkit.WebSettings; |
12 | import android.widget.LinearLayout; | 12 | import android.widget.LinearLayout; |
13 | 13 | ||
14 | import androidx.annotation.NonNull; | 14 | import androidx.annotation.NonNull; |
15 | import androidx.annotation.Nullable; | 15 | import androidx.annotation.Nullable; |
16 | import androidx.recyclerview.widget.RecyclerView; | 16 | import androidx.recyclerview.widget.RecyclerView; |
17 | 17 | ||
18 | import com.bumptech.glide.Glide; | 18 | import com.bumptech.glide.Glide; |
19 | import com.bumptech.glide.request.target.SimpleTarget; | 19 | import com.bumptech.glide.request.target.SimpleTarget; |
20 | import com.bumptech.glide.request.transition.Transition; | 20 | import com.bumptech.glide.request.transition.Transition; |
21 | import com.hjx.parent.ErrorDetailActivity; | 21 | import com.hjx.parent.ErrorDetailActivity; |
22 | import com.hjx.parent.R; | 22 | import com.hjx.parent.R; |
23 | import com.hjx.parent.databinding.ItemErrorBinding; | 23 | import com.hjx.parent.databinding.ItemErrorBinding; |
24 | import com.prws.common.bean.ErrorDetailBean; | 24 | import com.prws.common.bean.ErrorDetailBean; |
25 | import com.prws.common.bean.TopicBean; | 25 | import com.prws.common.bean.TopicBean; |
26 | import com.prws.common.utils.CommonUtil; | 26 | import com.prws.common.utils.CommonUtil; |
27 | import com.prws.common.utils.StringUtils; | 27 | import com.prws.common.utils.StringUtils; |
28 | 28 | ||
29 | import java.text.SimpleDateFormat; | 29 | import java.text.SimpleDateFormat; |
30 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
31 | import java.util.List; | 31 | import java.util.List; |
32 | 32 | ||
33 | public class ErrorAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | 33 | public class ErrorAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
34 | private List<TopicBean> list; | 34 | public List<TopicBean> list; |
35 | private Context context; | 35 | private Context context; |
36 | public boolean edit; | 36 | public boolean edit; |
37 | private CheckInterface checkInterface; | 37 | private CheckInterface checkInterface; |
38 | 38 | ||
39 | public interface CheckInterface { | 39 | public interface CheckInterface { |
40 | void onErrorCheck(); | 40 | void onErrorCheck(); |
41 | } | 41 | } |
42 | 42 | ||
43 | public ErrorAdapter(Context context, List<TopicBean> list, boolean edit, CheckInterface checkInterface) { | 43 | public ErrorAdapter(Context context, List<TopicBean> list, boolean edit, CheckInterface checkInterface) { |
44 | this.list = list; | 44 | this.list = list; |
45 | this.context = context; | 45 | this.context = context; |
46 | this.edit = edit; | 46 | this.edit = edit; |
47 | this.checkInterface = checkInterface; | 47 | this.checkInterface = checkInterface; |
48 | } | 48 | } |
49 | 49 | ||
50 | public ErrorAdapter(Context context, List<TopicBean> list, boolean edit) { | 50 | public ErrorAdapter(Context context, List<TopicBean> list, boolean edit) { |
51 | this.list = list; | 51 | this.list = list; |
52 | this.context = context; | 52 | this.context = context; |
53 | this.edit = edit; | 53 | this.edit = edit; |
54 | } | 54 | } |
55 | 55 | ||
56 | public void checkAll(boolean check) { | 56 | public void checkAll(boolean check) { |
57 | for (TopicBean topicBean : list) { | 57 | for (TopicBean topicBean : list) { |
58 | topicBean.setCheck(check); | 58 | topicBean.setCheck(check); |
59 | } | 59 | } |
60 | notifyDataSetChanged(); | 60 | notifyDataSetChanged(); |
61 | checkInterface.onErrorCheck(); | 61 | checkInterface.onErrorCheck(); |
62 | } | 62 | } |
63 | 63 | ||
64 | public List<TopicBean> getChecKList() { | 64 | public List<TopicBean> getChecKList() { |
65 | List<TopicBean> topicBeans = new ArrayList<>(); | 65 | List<TopicBean> topicBeans = new ArrayList<>(); |
66 | for (TopicBean topicBean : list) { | 66 | for (TopicBean topicBean : list) { |
67 | if (topicBean.isCheck()) { | 67 | if (topicBean.isCheck()) { |
68 | topicBeans.add(topicBean); | 68 | topicBeans.add(topicBean); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | return topicBeans; | 71 | return topicBeans; |
72 | } | 72 | } |
73 | 73 | ||
74 | public void setEdit(boolean edit) { | 74 | public void setEdit(boolean edit) { |
75 | this.edit = edit; | 75 | this.edit = edit; |
76 | notifyDataSetChanged(); | 76 | notifyDataSetChanged(); |
77 | } | 77 | } |
78 | 78 | ||
79 | public void addData(List<TopicBean> topicBeans) { | 79 | public void addData(List<TopicBean> topicBeans) { |
80 | list.addAll(topicBeans); | 80 | list.addAll(topicBeans); |
81 | notifyDataSetChanged(); | 81 | notifyDataSetChanged(); |
82 | } | 82 | } |
83 | 83 | ||
84 | public void refresh(List<TopicBean> list) { | 84 | public void refresh(List<TopicBean> list) { |
85 | this.list = list; | 85 | this.list = list; |
86 | notifyDataSetChanged(); | 86 | notifyDataSetChanged(); |
87 | } | 87 | } |
88 | 88 | ||
89 | @NonNull | 89 | @NonNull |
90 | @Override | 90 | @Override |
91 | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | 91 | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
92 | ItemErrorBinding itemTopicBinding = ItemErrorBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); | 92 | ItemErrorBinding itemTopicBinding = ItemErrorBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); |
93 | return new ErrorHolder(itemTopicBinding); | 93 | return new ErrorHolder(itemTopicBinding); |
94 | } | 94 | } |
95 | 95 | ||
96 | @Override | 96 | @Override |
97 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { | 97 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { |
98 | TopicBean topicBean = list.get(position); | 98 | TopicBean topicBean = list.get(position); |
99 | ErrorHolder holder = (ErrorHolder) viewHolder; | 99 | ErrorHolder holder = (ErrorHolder) viewHolder; |
100 | holder.binding.ivCheck.setVisibility(edit ? View.VISIBLE : View.GONE); | 100 | holder.binding.ivCheck.setVisibility(edit ? View.VISIBLE : View.GONE); |
101 | holder.binding.ivCheck.setImageResource(topicBean.isCheck() ? R.mipmap.ic_select : R.mipmap.ic_unselect); | 101 | holder.binding.ivCheck.setImageResource(topicBean.isCheck() ? R.mipmap.ic_select : R.mipmap.ic_unselect); |
102 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | 102 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
103 | if (position == 0 || !format.format(list.get(position - 1).getTime()).equals(format.format(topicBean.getTime()))) { | 103 | if (position == 0 || !format.format(list.get(position - 1).getTime()).equals(format.format(topicBean.getTime()))) { |
104 | holder.binding.tvTime.setVisibility(View.VISIBLE); | 104 | holder.binding.tvTime.setVisibility(View.VISIBLE); |
105 | holder.binding.tvTime.setText(format.format(topicBean.getTime())); | 105 | holder.binding.tvTime.setText(format.format(topicBean.getTime())); |
106 | } else { | 106 | } else { |
107 | holder.binding.tvTime.setVisibility(View.GONE); | 107 | holder.binding.tvTime.setVisibility(View.GONE); |
108 | } | 108 | } |
109 | if (topicBean.isDone()) { | 109 | if (topicBean.isDone()) { |
110 | holder.binding.tvType.setText(context.getString(R.string.text_done)); | 110 | holder.binding.tvType.setText(context.getString(R.string.text_done)); |
111 | holder.binding.tvType.setBackgroundResource(R.drawable.bg_done_text); | 111 | holder.binding.tvType.setBackgroundResource(R.drawable.bg_done_text); |
112 | } else { | 112 | } else { |
113 | holder.binding.tvType.setText(context.getString(R.string.text_undo)); | 113 | holder.binding.tvType.setText(context.getString(R.string.text_undo)); |
114 | holder.binding.tvType.setBackgroundResource(R.drawable.bg_undo_text); | 114 | holder.binding.tvType.setBackgroundResource(R.drawable.bg_undo_text); |
115 | } | 115 | } |
116 | holder.binding.tvReason.setText("错因:" + context.getResources().getStringArray(R.array.error_reason)[topicBean.getReason()]); | 116 | holder.binding.tvReason.setText("错因:" + context.getResources().getStringArray(R.array.error_reason)[topicBean.getReason()]); |
117 | if (topicBean.getBean() != null) { | 117 | if (topicBean.getBean() != null) { |
118 | ErrorDetailBean bean = topicBean.getBean(); | 118 | ErrorDetailBean bean = topicBean.getBean(); |
119 | holder.binding.ivTopic.setVisibility(View.GONE); | 119 | holder.binding.ivTopic.setVisibility(View.GONE); |
120 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; | 120 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; |
121 | StringBuilder sb = new StringBuilder(4096); | 121 | StringBuilder sb = new StringBuilder(4096); |
122 | if (!TextUtils.isEmpty(bean.getLabel())) { | 122 | if (!TextUtils.isEmpty(bean.getLabel())) { |
123 | sb.append(bean.getLabel()); | 123 | sb.append(bean.getLabel()); |
124 | } | 124 | } |
125 | sb.append(bean.getContent()); | 125 | sb.append(bean.getContent()); |
126 | if (bean.getOptions() != null && bean.getOptions().size() > 0) { | 126 | if (bean.getOptions() != null && bean.getOptions().size() > 0) { |
127 | sb.append("<div class='pt1'>"); | 127 | sb.append("<div class='pt1'>"); |
128 | sb.append(StringUtils.OptionsHtml(bean.getOptions(), null)); | 128 | sb.append(StringUtils.OptionsHtml(bean.getOptions(), null)); |
129 | sb.append("</div>"); | 129 | sb.append("</div>"); |
130 | } | 130 | } |
131 | String body = "<html><header>" + linkCss + "</header>" + sb.toString() + "</body></html>"; | 131 | String body = "<html><header>" + linkCss + "</header>" + sb.toString() + "</body></html>"; |
132 | WebSettings settings = holder.binding.webview.getSettings(); | 132 | WebSettings settings = holder.binding.webview.getSettings(); |
133 | // settings.setUseWideViewPort(true);//设定支持 viewport | 133 | // settings.setUseWideViewPort(true);//设定支持 viewport |
134 | // settings.setLoadWithOverviewMode(true); //自适应屏幕 | 134 | // settings.setLoadWithOverviewMode(true); //自适应屏幕 |
135 | // settings.setBuiltInZoomControls(true); | 135 | // settings.setBuiltInZoomControls(true); |
136 | // settings.setDisplayZoomControls(false); | 136 | // settings.setDisplayZoomControls(false); |
137 | // settings.setSupportZoom(false);//设定支持缩放 | 137 | // settings.setSupportZoom(false);//设定支持缩放 |
138 | holder.binding.webview.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); | 138 | holder.binding.webview.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); |
139 | holder.binding.webview.setVisibility(View.VISIBLE); | 139 | holder.binding.webview.setVisibility(View.VISIBLE); |
140 | holder.binding.webview.setOnTouchListener(new View.OnTouchListener() { | 140 | holder.binding.webview.setOnTouchListener(new View.OnTouchListener() { |
141 | @Override | 141 | @Override |
142 | public boolean onTouch(View v, MotionEvent event) { | 142 | public boolean onTouch(View v, MotionEvent event) { |
143 | if (event.getAction() == MotionEvent.ACTION_UP) { | 143 | if (event.getAction() == MotionEvent.ACTION_UP) { |
144 | if (edit) { | 144 | if (edit) { |
145 | list.get(position).setCheck(!topicBean.isCheck()); | 145 | list.get(position).setCheck(!topicBean.isCheck()); |
146 | notifyItemChanged(position); | 146 | notifyItemChanged(position); |
147 | checkInterface.onErrorCheck(); | 147 | checkInterface.onErrorCheck(); |
148 | } else { | 148 | } else { |
149 | Intent intent = new Intent(context, ErrorDetailActivity.class); | 149 | Intent intent = new Intent(context, ErrorDetailActivity.class); |
150 | intent.putExtra("errorBean", topicBean); | 150 | intent.putExtra("errorBean", topicBean); |
151 | context.startActivity(intent); | 151 | context.startActivity(intent); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | return true; | 154 | return true; |
155 | } | 155 | } |
156 | }); | 156 | }); |
157 | if (bean.getPoints().size() > 0) { | 157 | if (bean.getPoints().size() > 0) { |
158 | String topic = context.getString(R.string.topic_start); | 158 | String topic = context.getString(R.string.topic_start); |
159 | topic += ":"; | 159 | topic += ":"; |
160 | 160 | ||
161 | for (int j = 0; j < bean.getPoints().size(); j++) { | 161 | for (int j = 0; j < bean.getPoints().size(); j++) { |
162 | if (j > 0) { | 162 | if (j > 0) { |
163 | topic += "、"; | 163 | topic += "、"; |
164 | } | 164 | } |
165 | topic += bean.getPoints().get(j).getValue(); | 165 | topic += bean.getPoints().get(j).getValue(); |
166 | } | 166 | } |
167 | holder.binding.tvPoint.setText(topic); | 167 | holder.binding.tvPoint.setText(topic); |
168 | holder.binding.tvPoint.setVisibility(View.VISIBLE); | 168 | holder.binding.tvPoint.setVisibility(View.VISIBLE); |
169 | } else { | 169 | } else { |
170 | holder.binding.tvPoint.setVisibility(View.GONE); | 170 | holder.binding.tvPoint.setVisibility(View.GONE); |
171 | } | 171 | } |
172 | } else { | 172 | } else { |
173 | holder.binding.webview.setVisibility(View.GONE); | 173 | holder.binding.webview.setVisibility(View.GONE); |
174 | holder.binding.tvPoint.setVisibility(View.GONE); | 174 | holder.binding.tvPoint.setVisibility(View.GONE); |
175 | holder.binding.ivTopic.setVisibility(View.VISIBLE); | 175 | holder.binding.ivTopic.setVisibility(View.VISIBLE); |
176 | int maxWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); | 176 | int maxWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); |
177 | Glide.with(context).load(topicBean.getPath()).into(new SimpleTarget<Drawable>() { | 177 | Glide.with(context).load(topicBean.getPath()).into(new SimpleTarget<Drawable>() { |
178 | @Override | 178 | @Override |
179 | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { | 179 | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { |
180 | int width = resource.getIntrinsicWidth(); | 180 | int width = resource.getIntrinsicWidth(); |
181 | int height = resource.getIntrinsicHeight(); | 181 | int height = resource.getIntrinsicHeight(); |
182 | int newHeight = maxWidth * height / width; | 182 | int newHeight = maxWidth * height / width; |
183 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) holder.binding.ivTopic.getLayoutParams(); | 183 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) holder.binding.ivTopic.getLayoutParams(); |
184 | layoutParams.width = maxWidth; | 184 | layoutParams.width = maxWidth; |
185 | layoutParams.height = newHeight; | 185 | layoutParams.height = newHeight; |
186 | holder.binding.ivTopic.setLayoutParams(layoutParams); | 186 | holder.binding.ivTopic.setLayoutParams(layoutParams); |
187 | holder.binding.ivTopic.setImageDrawable(resource); | 187 | holder.binding.ivTopic.setImageDrawable(resource); |
188 | } | 188 | } |
189 | }); | 189 | }); |
190 | } | 190 | } |
191 | holder.itemView.setOnClickListener(new View.OnClickListener() { | 191 | holder.itemView.setOnClickListener(new View.OnClickListener() { |
192 | @Override | 192 | @Override |
193 | public void onClick(View v) { | 193 | public void onClick(View v) { |
194 | if (edit) { | 194 | if (edit) { |
195 | list.get(position).setCheck(!topicBean.isCheck()); | 195 | list.get(position).setCheck(!topicBean.isCheck()); |
196 | notifyItemChanged(position); | 196 | notifyItemChanged(position); |
197 | checkInterface.onErrorCheck(); | 197 | checkInterface.onErrorCheck(); |
198 | } else { | 198 | } else { |
199 | Intent intent = new Intent(context, ErrorDetailActivity.class); | 199 | Intent intent = new Intent(context, ErrorDetailActivity.class); |
200 | intent.putExtra("errorBean", topicBean); | 200 | intent.putExtra("errorBean", topicBean); |
201 | context.startActivity(intent); | 201 | context.startActivity(intent); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | }); | 204 | }); |
205 | } | 205 | } |
206 | 206 | ||
207 | @Override | 207 | @Override |
208 | public int getItemCount() { | 208 | public int getItemCount() { |
209 | return list.size(); | 209 | return list.size(); |
210 | } | 210 | } |
211 | 211 | ||
212 | static class ErrorHolder extends RecyclerView.ViewHolder { | 212 | static class ErrorHolder extends RecyclerView.ViewHolder { |
213 | ItemErrorBinding binding; | 213 | ItemErrorBinding binding; |
214 | 214 | ||
215 | public ErrorHolder(@NonNull ItemErrorBinding itemView) { | 215 | public ErrorHolder(@NonNull ItemErrorBinding itemView) { |
216 | super(itemView.getRoot()); | 216 | super(itemView.getRoot()); |
217 | binding = itemView; | 217 | binding = itemView; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 |
app/src/main/java/com/hjx/parent/adapter/HomeworkAdapter.java
File was created | 1 | package com.hjx.parent.adapter; | |
2 | |||
3 | import androidx.annotation.NonNull; | ||
4 | |||
5 | import com.chad.library.adapter.base.BaseQuickAdapter; | ||
6 | import com.chad.library.adapter.base.BaseViewHolder; | ||
7 | import com.hjx.parent.R; | ||
8 | import com.prws.common.bean.homework.HomeworkList; | ||
9 | |||
10 | public class HomeworkAdapter extends BaseQuickAdapter<HomeworkList, BaseViewHolder> { | ||
11 | |||
12 | public HomeworkAdapter() { | ||
13 | super(R.layout.item_homework); | ||
14 | } | ||
15 | |||
16 | @Override | ||
17 | protected void convert(@NonNull BaseViewHolder helper, HomeworkList homework) { | ||
18 | helper.setText(R.id.tvName, homework.getName()); | ||
19 | helper.setText(R.id.tvGrade, homework.getGrade() + "-" + homework.getTerm()); | ||
20 | int subjectImg; | ||
21 | switch (homework.getSubject()) { | ||
22 | case "语文": | ||
23 | subjectImg = R.drawable.ic_chinese; | ||
24 | break; | ||
25 | case "英语": | ||
26 | subjectImg = R.drawable.ic_english; | ||
27 | break; | ||
28 | case "物理": | ||
29 | subjectImg = R.drawable.ic_physics; | ||
30 | break; | ||
31 | case "化学": | ||
32 | subjectImg = R.drawable.ic_chemistry; | ||
33 | break; | ||
34 | case "数学": | ||
35 | default: | ||
36 | subjectImg = R.drawable.ic_math; | ||
37 | } | ||
38 | helper.setImageResource(R.id.ivSubject, subjectImg); | ||
39 | } | ||
40 | } | ||
41 |
app/src/main/java/com/hjx/parent/fragment/BaseBindingFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.view.LayoutInflater; | 4 | import android.view.LayoutInflater; |
5 | import android.view.View; | 5 | import android.view.View; |
6 | import android.view.ViewGroup; | 6 | import android.view.ViewGroup; |
7 | 7 | ||
8 | import androidx.annotation.NonNull; | 8 | import androidx.annotation.NonNull; |
9 | import androidx.annotation.Nullable; | 9 | import androidx.annotation.Nullable; |
10 | import androidx.fragment.app.Fragment; | 10 | import androidx.fragment.app.Fragment; |
11 | import androidx.viewbinding.ViewBinding; | 11 | import androidx.viewbinding.ViewBinding; |
12 | 12 | ||
13 | public abstract class BaseBindingFragment<T extends ViewBinding> extends Fragment { | 13 | public abstract class BaseBindingFragment<T extends ViewBinding> extends Fragment { |
14 | 14 | ||
15 | private T binding; | 15 | public T binding; |
16 | 16 | ||
17 | @Nullable | 17 | @Nullable |
18 | @Override | 18 | @Override |
19 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 19 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
20 | // 调用onCreateViewBinding方法获取binding | 20 | // 调用onCreateViewBinding方法获取binding |
21 | binding = onCreateViewBinding(inflater, container); | 21 | binding = onCreateViewBinding(inflater, container); |
22 | return binding.getRoot(); | 22 | return binding.getRoot(); |
23 | } | 23 | } |
24 | 24 | ||
25 | @Override | 25 | @Override |
26 | public void onDestroyView() { | 26 | public void onDestroyView() { |
27 | super.onDestroyView(); | 27 | super.onDestroyView(); |
28 | // 引用置空处理 | 28 | // 引用置空处理 |
29 | binding = null; | 29 | binding = null; |
30 | } | 30 | } |
31 | 31 | ||
32 | // 子类使用该方法来使用binding | 32 | // 子类使用该方法来使用binding |
33 | public T getBinding() { | 33 | public T getBinding() { |
34 | return binding; | 34 | return binding; |
35 | } | 35 | } |
36 | 36 | ||
37 | // 由子类去重写 | 37 | // 由子类去重写 |
38 | protected abstract T onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent); | 38 | protected abstract T onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent); |
39 | } | 39 | } |
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.content.Intent; | 6 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
7 | import android.graphics.BitmapFactory; | 8 | import android.graphics.BitmapFactory; |
8 | import android.net.Uri; | 9 | import android.net.Uri; |
9 | import android.os.Bundle; | 10 | import android.os.Bundle; |
10 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
11 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
12 | import android.util.Log; | 13 | import android.util.Log; |
13 | import android.view.LayoutInflater; | 14 | import android.view.LayoutInflater; |
14 | import android.view.View; | 15 | import android.view.View; |
15 | import android.view.ViewGroup; | 16 | import android.view.ViewGroup; |
16 | import android.widget.ImageView; | ||
17 | import android.widget.LinearLayout; | ||
18 | import android.widget.Toast; | 17 | import android.widget.Toast; |
19 | 18 | ||
20 | import androidx.annotation.NonNull; | 19 | import androidx.annotation.NonNull; |
21 | import androidx.annotation.Nullable; | 20 | import androidx.annotation.Nullable; |
22 | import androidx.core.content.FileProvider; | 21 | import androidx.core.content.FileProvider; |
23 | import androidx.recyclerview.widget.LinearLayoutManager; | ||
24 | import androidx.recyclerview.widget.RecyclerView; | 22 | import androidx.recyclerview.widget.RecyclerView; |
25 | 23 | ||
26 | import com.bumptech.glide.Glide; | 24 | import com.bumptech.glide.Glide; |
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 25 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
28 | import com.bumptech.glide.request.RequestOptions; | 26 | import com.bumptech.glide.request.RequestOptions; |
29 | import com.chad.library.adapter.base.BaseQuickAdapter; | 27 | import com.chad.library.adapter.base.BaseQuickAdapter; |
30 | import com.chad.library.adapter.base.BaseViewHolder; | 28 | import com.chad.library.adapter.base.BaseViewHolder; |
29 | import com.google.android.material.tabs.TabLayout; | ||
31 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
32 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
33 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
34 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
35 | import com.hjx.parent.ChooseActivity; | ||
36 | import com.hjx.parent.ErrorBookActivity; | ||
37 | import com.hjx.parent.ErrorListActivity; | 34 | import com.hjx.parent.ErrorListActivity; |
38 | import com.hjx.parent.ImageActivity; | 35 | import com.hjx.parent.ImageActivity; |
39 | import com.hjx.parent.R; | 36 | import com.hjx.parent.R; |
40 | import com.hjx.parent.TeacherChooseActivity; | 37 | import com.hjx.parent.TeacherChooseActivity; |
41 | import com.hjx.parent.adapter.ErrorAdapter; | 38 | import com.hjx.parent.adapter.ErrorAdapter; |
39 | import com.hjx.parent.adapter.HomeworkAdapter; | ||
42 | import com.hjx.parent.bean.StudentBean; | 40 | import com.hjx.parent.bean.StudentBean; |
43 | import com.hjx.parent.databinding.ActivityErrorBookBinding; | ||
44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 41 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
42 | import com.hjx.parent.rx.BaseRxFragment; | ||
45 | import com.prws.common.bean.PageInfo; | 43 | import com.prws.common.bean.PageInfo; |
46 | import com.prws.common.bean.ResponseResult; | 44 | import com.prws.common.bean.ResponseResult; |
47 | import com.prws.common.bean.TopicBean; | 45 | import com.prws.common.bean.TopicBean; |
48 | import com.prws.common.net.NetWorks; | 46 | import com.prws.common.net.NetWorks; |
49 | import com.prws.common.utils.BitmapUtils; | 47 | import com.prws.common.utils.BitmapUtils; |
50 | import com.prws.common.utils.CommonUtil; | 48 | import com.prws.common.utils.CommonUtil; |
51 | import com.prws.common.utils.ScreenUtils; | 49 | import com.prws.common.utils.ScreenUtils; |
52 | import com.prws.common.utils.SharedPreferencesUtil; | 50 | import com.prws.common.utils.SharedPreferencesUtil; |
53 | import com.prws.common.utils.dialog.MyButtomDialog; | 51 | import com.prws.common.utils.dialog.MyButtomDialog; |
52 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | ||
54 | import com.zhangteng.imagepicker.bean.ImageInfo; | 53 | import com.zhangteng.imagepicker.bean.ImageInfo; |
55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 54 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 55 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 56 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 57 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
59 | import com.zhangteng.utils.IHandlerCallBack; | 58 | import com.zhangteng.utils.IHandlerCallBack; |
60 | 59 | ||
61 | import java.io.File; | 60 | import java.io.File; |
62 | import java.util.ArrayList; | 61 | import java.util.ArrayList; |
63 | import java.util.Arrays; | 62 | import java.util.Arrays; |
64 | import java.util.HashMap; | 63 | import java.util.HashMap; |
65 | import java.util.List; | 64 | import java.util.List; |
66 | import java.util.Map; | 65 | import java.util.Map; |
67 | 66 | ||
68 | import io.reactivex.Observer; | 67 | import io.reactivex.Observer; |
68 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
69 | import io.reactivex.disposables.Disposable; | 69 | import io.reactivex.disposables.Disposable; |
70 | import io.reactivex.schedulers.Schedulers; | ||
70 | 71 | ||
71 | public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> { | 72 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
72 | StudentBean studentBean; | 73 | StudentBean studentBean; |
73 | private int subject; | 74 | private int subject; |
74 | private ErrorAdapter adapter; | 75 | private ErrorAdapter errorAdapter; |
76 | private HomeworkAdapter homeworkAdapter; | ||
75 | private int REQUEST_CODE_IMAGE = 123; | 77 | private int REQUEST_CODE_IMAGE = 123; |
76 | private String filePath; | 78 | private String filePath; |
77 | 79 | ||
78 | @Override | 80 | @Override |
79 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 81 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
80 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 82 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
81 | } | 83 | } |
82 | 84 | ||
83 | public void refreshStudent() { | 85 | public void refreshStudent() { |
84 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 86 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
85 | try { | 87 | try { |
86 | studentBean = new Gson().fromJson(student, StudentBean.class); | 88 | studentBean = new Gson().fromJson(student, StudentBean.class); |
87 | getBinding().tvChoose.setText(studentBean.getStuName()); | 89 | getBinding().tvChoose.setText(studentBean.getStuName()); |
88 | } catch (Exception e) { | 90 | } catch (Exception e) { |
89 | 91 | e.printStackTrace(); | |
90 | } | 92 | } |
91 | } | 93 | } |
92 | 94 | ||
93 | @Override | 95 | @Override |
94 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 96 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
95 | super.onViewCreated(view, savedInstanceState); | 97 | super.onViewCreated(view, savedInstanceState); |
96 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 98 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
97 | if (!TextUtils.isEmpty(photo)) { | 99 | if (!TextUtils.isEmpty(photo)) { |
98 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 100 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
99 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 101 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
100 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 102 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
101 | } | 103 | } |
102 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 104 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
103 | getBinding().tvName.setText(name); | 105 | getBinding().tvName.setText(name); |
104 | refreshStudent(); | 106 | refreshStudent(); |
105 | getBinding().rlTakePhoto.post(new Runnable() { | 107 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
106 | @Override | 108 | getBinding().rlTakePhoto.setOnClickListener(v -> { |
107 | public void run() { | 109 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
108 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getBinding().rlTakePhoto.getLayoutParams(); | 110 | XXPermissions.with(getContext()) |
109 | layoutParams.width = CommonUtil.getScreenWidth(getContext()); | 111 | // 申请多个权限 |
110 | layoutParams.height = CommonUtil.getScreenWidth(getContext()) * 20 / 37; | 112 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
111 | getBinding().rlTakePhoto.setLayoutParams(layoutParams); | 113 | @Override |
112 | } | 114 | public void onGranted(List<String> permissions, boolean all) { |
113 | }); | 115 | if (all) { |
114 | getBinding().tvChoose.setOnClickListener(new View.OnClickListener() { | 116 | //开启扫码界面 |
115 | @Override | 117 | showButtonDialog(); |
116 | public void onClick(View v) { | 118 | } else { |
117 | startActivity(new Intent(getContext(), TeacherChooseActivity.class)); | 119 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
118 | // getActivity().finish(); | ||
119 | } | ||
120 | }); | ||
121 | getBinding().rlTakePhoto.setOnClickListener(new View.OnClickListener() { | ||
122 | @Override | ||
123 | public void onClick(View v) { | ||
124 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | ||
125 | XXPermissions.with(getContext()) | ||
126 | // 申请多个权限 | ||
127 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | ||
128 | @Override | ||
129 | public void onGranted(List<String> permissions, boolean all) { | ||
130 | if (all) { | ||
131 | //开启扫码界面 | ||
132 | showButtonDialog(); | ||
133 | } else { | ||
134 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | @Override | ||
139 | public void onDenied(List<String> permissions, boolean never) { | ||
140 | XXPermissions.startPermissionActivity(getContext(), permissions); | ||
141 | } | 120 | } |
142 | }); | 121 | } |
143 | } else { | ||
144 | showButtonDialog(); | ||
145 | } | ||
146 | 122 | ||
123 | @Override | ||
124 | public void onDenied(List<String> permissions, boolean never) { | ||
125 | XXPermissions.startPermissionActivity(getContext(), permissions); | ||
126 | } | ||
127 | }); | ||
128 | } else { | ||
129 | showButtonDialog(); | ||
147 | } | 130 | } |
131 | |||
148 | }); | 132 | }); |
149 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 133 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
150 | @Override | 134 | @Override |
151 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 135 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
152 | 136 | ||
153 | } | 137 | } |
154 | 138 | ||
155 | @Override | 139 | @Override |
156 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 140 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
157 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 141 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
158 | switch (item.getAdapterPosition()) { | 142 | switch (item.getAdapterPosition()) { |
159 | case 0: | 143 | case 0: |
160 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 144 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
161 | break; | 145 | break; |
162 | case 1: | 146 | case 1: |
163 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 147 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
164 | break; | 148 | break; |
165 | case 2: | 149 | case 2: |
166 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 150 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
167 | break; | 151 | break; |
168 | case 3: | 152 | case 3: |
169 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 153 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
170 | break; | 154 | break; |
171 | case 4: | 155 | case 4: |
172 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 156 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
173 | break; | 157 | break; |
174 | } | 158 | } |
175 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 159 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
176 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 160 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
177 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 161 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
178 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 162 | item.getConvertView().setOnClickListener(v -> { |
179 | @Override | 163 | if (subject != item.getAdapterPosition()) { |
180 | public void onClick(View v) { | 164 | subject = item.getAdapterPosition(); |
181 | if (subject != item.getAdapterPosition()) { | 165 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
182 | subject = item.getAdapterPosition(); | 166 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
183 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 167 | getError(subStr); |
168 | } else { | ||
169 | // nothing can do | ||
184 | } | 170 | } |
185 | } | 171 | } |
186 | }); | 172 | }); |
187 | } | 173 | } |
188 | }; | 174 | }; |
189 | getBinding().recycleSubject.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | 175 | getBinding().rvSubject.setAdapter(adapter); |
190 | getBinding().recycleSubject.setAdapter(adapter); | ||
191 | subject = 0; | 176 | subject = 0; |
192 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 177 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
193 | getBinding().llAll.setOnClickListener(new View.OnClickListener() { | 178 | getBinding().llAll.setOnClickListener(v -> { |
179 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | ||
180 | startActivity(intent); | ||
181 | }); | ||
182 | |||
183 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | ||
184 | homeworkAdapter = new HomeworkAdapter(); | ||
185 | binding.rvMain.setAdapter(errorAdapter); | ||
186 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | ||
187 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | ||
188 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | ||
194 | @Override | 189 | @Override |
195 | public void onClick(View v) { | 190 | public void onTabSelected(TabLayout.Tab tab) { |
196 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 191 | if (tab.getPosition() == 0) { |
197 | startActivity(intent); | 192 | binding.rvMain.setAdapter(errorAdapter); |
193 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | ||
194 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | ||
195 | } else { | ||
196 | binding.rvMain.setAdapter(homeworkAdapter); | ||
197 | binding.rvMain.setVisibility(View.VISIBLE); | ||
198 | binding.llEmpty.setVisibility(View.GONE); | ||
199 | } | ||
200 | } | ||
201 | @Override | ||
202 | public void onTabUnselected(TabLayout.Tab tab) { | ||
203 | } | ||
204 | @Override | ||
205 | public void onTabReselected(TabLayout.Tab tab) { | ||
198 | } | 206 | } |
199 | }); | 207 | }); |
200 | } | 208 | } |
201 | 209 | ||
202 | private void showButtonDialog() { | 210 | private void showButtonDialog() { |
203 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 211 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
204 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 212 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
205 | dialog.setContentView(bottomView); | 213 | dialog.setContentView(bottomView); |
206 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 214 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
207 | @Override | 215 | @Override |
208 | public void onClick(View view) { | 216 | public void onClick(View view) { |
209 | dialog.dismiss(); | 217 | dialog.dismiss(); |
210 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 218 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
211 | //确保有相机来处理Intent | 219 | //确保有相机来处理Intent |
212 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 220 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
213 | File photoFile = new File(filePath); | 221 | File photoFile = new File(filePath); |
214 | if (photoFile != null) { | 222 | if (photoFile != null) { |
215 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 223 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
216 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); | 224 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); |
217 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 225 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
218 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 226 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
219 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 227 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
220 | } | 228 | } |
221 | } | 229 | } |
222 | }); | 230 | }); |
223 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 231 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
224 | @Override | 232 | @Override |
225 | public void onClick(View view) { | 233 | public void onClick(View view) { |
226 | dialog.dismiss(); | 234 | dialog.dismiss(); |
227 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 235 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
228 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 236 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
229 | .multiSelect(true) //是否多选 | 237 | .multiSelect(true) //是否多选 |
230 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 238 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
231 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 239 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
232 | .maxImageSelectable(5) //图片可选择数 | 240 | .maxImageSelectable(5) //图片可选择数 |
233 | .maxHeight(1920) //图片最大高度 | 241 | .maxHeight(1920) //图片最大高度 |
234 | .maxWidth(1920) //图片最大宽度 | 242 | .maxWidth(1920) //图片最大宽度 |
235 | .maxImageSize(3) //图片最大大小Mb | 243 | .maxImageSize(3) //图片最大大小Mb |
236 | .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(); | 244 | .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(); |
237 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 245 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
238 | 246 | ||
239 | } | 247 | } |
240 | }); | 248 | }); |
241 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 249 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
242 | @Override | 250 | @Override |
243 | public void onClick(View view) { | 251 | public void onClick(View view) { |
244 | dialog.dismiss(); | 252 | dialog.dismiss(); |
245 | } | 253 | } |
246 | }); | 254 | }); |
247 | dialog.show(); | 255 | dialog.show(); |
248 | } | 256 | } |
249 | 257 | ||
250 | private void getError(String subject) { | 258 | @SuppressLint("CheckResult") |
251 | if (studentBean != null) { | 259 | protected void getHomework() { |
252 | Map map = new HashMap(); | 260 | if (studentBean == null) return; |
253 | map.put("subject", subject); | 261 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
254 | map.put("stuId", studentBean.getStuId()); | 262 | .subscribeOn(Schedulers.io()) |
255 | map.put("pageSize", 5); | 263 | .observeOn(AndroidSchedulers.mainThread()) |
256 | map.put("pageNum", 1); | 264 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
257 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 265 | .map(ResponseResult::getData) |
258 | @Override | 266 | .subscribe((data, th) -> { |
259 | public void onSubscribe(Disposable d) { | 267 | if (th != null) th.printStackTrace(); |
260 | 268 | homeworkAdapter.setNewData(data); | |
261 | } | 269 | }); |
270 | } | ||
262 | 271 | ||
263 | @Override | 272 | private void getError(String subject) { |
264 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 273 | if (studentBean == null) { |
265 | if (result.getData() != null && result.getCode() == 200) { | 274 | return; |
266 | List<TopicBean> topicBeans = result.getData().getList(); | 275 | } |
267 | loadError(topicBeans); | 276 | Map<String, Object> map = new HashMap<>(); |
277 | map.put("subject", subject); | ||
278 | map.put("stuId", studentBean.getStuId()); | ||
279 | map.put("pageSize", 5); | ||
280 | map.put("pageNum", 1); | ||
281 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | ||
282 | @Override | ||
283 | public void onSubscribe(Disposable d) { | ||
284 | } | ||
285 | @Override | ||
286 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | ||
287 | if (result.getData() != null && result.getCode() == 200) { | ||
288 | List<TopicBean> topicBeans = result.getData().getList(); | ||
289 | errorAdapter.refresh(topicBeans); | ||
290 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | ||
291 | if (topicBeans.size() > 0) { | ||
292 | getBinding().rvMain.setVisibility(View.VISIBLE); | ||
293 | getBinding().llEmpty.setVisibility(View.GONE); | ||
294 | } else { | ||
295 | getBinding().rvMain.setVisibility(View.GONE); | ||
296 | getBinding().llEmpty.setVisibility(View.VISIBLE); | ||
297 | } | ||
268 | } | 298 | } |
269 | } | 299 | } |
270 | |||
271 | @Override | ||
272 | public void onError(Throwable e) { | ||
273 | e.toString(); | ||
274 | } | ||
275 | |||
276 | @Override | ||
277 | public void onComplete() { | ||
278 | |||
279 | } | ||
280 | }); | ||
281 | } | ||
282 | } | ||
283 | |||
284 | private void loadError(List<TopicBean> list) { | ||
285 | if (list.size() > 0) { | ||
286 | getBinding().recycleError.setVisibility(View.VISIBLE); | ||
287 | getBinding().llEmpty.setVisibility(View.GONE); | ||
288 | if (adapter != null) { | ||
289 | adapter.refresh(list); | ||
290 | } else { | ||
291 | adapter = new ErrorAdapter(getActivity(), list, false); | ||
292 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false)); | ||
293 | getBinding().recycleError.setAdapter(adapter); | ||
294 | } | 300 | } |
295 | } else { | 301 | @Override |
296 | getBinding().recycleError.setVisibility(View.GONE); | 302 | public void onError(Throwable e) { |
297 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 303 | e.printStackTrace(); |
298 | } | 304 | } |
305 | @Override | ||
306 | public void onComplete() { | ||
307 | } | ||
308 | }); | ||
299 | } | 309 | } |
300 | 310 | ||
301 | @Override | 311 | @Override |
302 | public void onResume() { | 312 | public void onResume() { |
303 | super.onResume(); | 313 | super.onResume(); |
304 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 314 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
315 | getHomework(); |
app/src/main/java/com/hjx/parent/function/Function0.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function0 { | ||
4 | void invoke(); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function1.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function1<A> { | ||
4 | void invoke(A a); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function10.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function10<T> { | ||
4 | T invoke(); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function11.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function11<T, A> { | ||
4 | T invoke(A a); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function12.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function12<T, A, B> { | ||
4 | T invoke(A a, B b); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function13.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function13<T, A, B, C> { | ||
4 | T invoke(A a, B b, C c); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function2.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function2<A, B> { | ||
4 | void invoke(A a, B b); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function3.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function3<A, B, C> { | ||
4 | void invoke(A a, B b, C c); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/function/Function5.java
File was created | 1 | package com.hjx.parent.function; | |
2 | |||
3 | public interface Function5<A, B, C, D, E> { | ||
4 | void invoke(A a, B b, C c, D d, E e); | ||
5 | } | ||
6 |
app/src/main/java/com/hjx/parent/rx/BaseRxActivity.java
File was created | 1 | package com.hjx.parent.rx; | |
2 | |||
3 | import android.os.Bundle; | ||
4 | |||
5 | import androidx.annotation.Nullable; | ||
6 | import androidx.viewbinding.ViewBinding; | ||
7 | |||
8 | import com.hjx.parent.BaseActivity; | ||
9 | import com.trello.rxlifecycle2.android.ActivityEvent; | ||
10 | |||
11 | import io.reactivex.subjects.BehaviorSubject; | ||
12 | |||
13 | public abstract class BaseRxActivity<VB extends ViewBinding> extends BaseActivity<VB> implements ILifecycleActivity { | ||
14 | private BehaviorSubject<ActivityEvent> rxLifecycle = BehaviorSubject.create(); | ||
15 | |||
16 | @Override | ||
17 | public BehaviorSubject<ActivityEvent> getRxLifecycle() { | ||
18 | return rxLifecycle; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
23 | super.onCreate(savedInstanceState); | ||
24 | rxLifecycle.onNext(ActivityEvent.CREATE); | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | protected void onStart() { | ||
29 | super.onStart(); | ||
30 | rxLifecycle.onNext(ActivityEvent.START); | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | protected void onResume() { | ||
35 | super.onResume(); | ||
36 | rxLifecycle.onNext(ActivityEvent.RESUME); | ||
37 | } | ||
38 | |||
39 | @Override | ||
40 | protected void onPause() { | ||
41 | super.onPause(); | ||
42 | rxLifecycle.onNext(ActivityEvent.PAUSE); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | protected void onStop() { | ||
47 | super.onStop(); | ||
48 | rxLifecycle.onNext(ActivityEvent.STOP); | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | protected void onDestroy() { | ||
53 | super.onDestroy(); | ||
54 | rxLifecycle.onNext(ActivityEvent.DESTROY); | ||
55 | } | ||
56 | |||
57 | } | ||
58 |
app/src/main/java/com/hjx/parent/rx/BaseRxFragment.java
File was created | 1 | package com.hjx.parent.rx; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.os.Bundle; | ||
5 | import android.view.View; | ||
6 | |||
7 | import androidx.annotation.NonNull; | ||
8 | import androidx.annotation.Nullable; | ||
9 | import androidx.viewbinding.ViewBinding; | ||
10 | |||
11 | import com.hjx.parent.fragment.BaseBindingFragment; | ||
12 | import com.trello.rxlifecycle2.android.FragmentEvent; | ||
13 | |||
14 | import io.reactivex.subjects.BehaviorSubject; | ||
15 | |||
16 | public abstract class BaseRxFragment<VB extends ViewBinding> extends BaseBindingFragment<VB> implements ILifecycleFragment { | ||
17 | private BehaviorSubject<FragmentEvent> rxLifecycle = BehaviorSubject.create(); | ||
18 | |||
19 | @Override | ||
20 | public BehaviorSubject<FragmentEvent> getRxLifecycle() { | ||
21 | return rxLifecycle; | ||
22 | } | ||
23 | |||
24 | @Override | ||
25 | public void onAttach(@NonNull Context context) { | ||
26 | super.onAttach(context); | ||
27 | rxLifecycle.onNext(FragmentEvent.ATTACH); | ||
28 | } | ||
29 | |||
30 | @Override | ||
31 | public void onCreate(@Nullable Bundle savedInstanceState) { | ||
32 | super.onCreate(savedInstanceState); | ||
33 | rxLifecycle.onNext(FragmentEvent.CREATE); | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
38 | super.onViewCreated(view, savedInstanceState); | ||
39 | rxLifecycle.onNext(FragmentEvent.CREATE_VIEW); | ||
40 | } | ||
41 | |||
42 | @Override | ||
43 | public void onStart() { | ||
44 | super.onStart(); | ||
45 | rxLifecycle.onNext(FragmentEvent.START); | ||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public void onResume() { | ||
50 | super.onResume(); | ||
51 | rxLifecycle.onNext(FragmentEvent.RESUME); | ||
52 | } | ||
53 | |||
54 | @Override | ||
55 | public void onPause() { | ||
56 | super.onPause(); | ||
57 | rxLifecycle.onNext(FragmentEvent.PAUSE); | ||
58 | } | ||
59 | |||
60 | @Override | ||
61 | public void onStop() { | ||
62 | super.onStop(); | ||
63 | rxLifecycle.onNext(FragmentEvent.STOP); | ||
64 | } | ||
65 | |||
66 | @Override | ||
67 | public void onDestroyView() { | ||
68 | super.onDestroyView(); | ||
69 | rxLifecycle.onNext(FragmentEvent.DESTROY_VIEW); | ||
70 | } | ||
71 | |||
72 | @Override | ||
73 | public void onDestroy() { | ||
74 | super.onDestroy(); | ||
75 | rxLifecycle.onNext(FragmentEvent.DESTROY); | ||
76 | } | ||
77 | |||
78 | @Override | ||
79 | public void onDetach() { | ||
80 | super.onDetach(); | ||
81 | rxLifecycle.onNext(FragmentEvent.DETACH); | ||
82 | } | ||
83 | |||
84 | } | ||
85 |
app/src/main/java/com/hjx/parent/rx/ILifecycleActivity.java
File was created | 1 | package com.hjx.parent.rx; | |
2 | |||
3 | import com.trello.rxlifecycle2.android.ActivityEvent; | ||
4 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | ||
5 | |||
6 | import io.reactivex.Observable; | ||
7 | import io.reactivex.Observer; | ||
8 | import io.reactivex.Single; | ||
9 | import io.reactivex.SingleObserver; | ||
10 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
11 | import io.reactivex.disposables.Disposable; | ||
12 | import io.reactivex.functions.Consumer; | ||
13 | import io.reactivex.schedulers.Schedulers; | ||
14 | import retrofit2.Call; | ||
15 | |||
16 | // 抽象 | ||
17 | public interface ILifecycleActivity { | ||
18 | Observable<ActivityEvent> getRxLifecycle(); | ||
19 | |||
20 | default <T> Single<T> getSingleResult(Call<T> call) { | ||
21 | return Single.just(call) | ||
22 | .map(t -> t.execute().body()) | ||
23 | .subscribeOn(Schedulers.io()) | ||
24 | .observeOn(AndroidSchedulers.mainThread()) | ||
25 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())); | ||
26 | } | ||
27 | |||
28 | default <T> void subscribeSingle(Single<T> single, SingleObserver<T> observer) { | ||
29 | single.subscribeOn(Schedulers.io()) | ||
30 | .observeOn(AndroidSchedulers.mainThread()) | ||
31 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | ||
32 | .subscribe(observer); | ||
33 | } | ||
34 | |||
35 | default <T> void subscribeRx(Observable<T> observable, Observer<T> observer) { | ||
36 | observable.subscribeOn(Schedulers.io()) | ||
37 | .observeOn(AndroidSchedulers.mainThread()) | ||
38 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | ||
39 | .subscribe(observer); | ||
40 | } | ||
41 | |||
42 | default <T> Disposable subscribeRx(Observable<T> observable, Consumer<T> onNext) { | ||
43 | return observable.subscribeOn(Schedulers.io()) | ||
44 | .observeOn(AndroidSchedulers.mainThread()) | ||
45 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | ||
46 | .subscribe(onNext); | ||
47 | } | ||
48 | } | ||
49 |
app/src/main/java/com/hjx/parent/rx/ILifecycleFragment.java
File was created | 1 | package com.hjx.parent.rx; | |
2 | |||
3 | import com.trello.rxlifecycle2.android.FragmentEvent; | ||
4 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | ||
5 | |||
6 | import io.reactivex.Observable; | ||
7 | import io.reactivex.Observer; | ||
8 | import io.reactivex.Single; | ||
9 | import io.reactivex.SingleObserver; | ||
10 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
11 | import io.reactivex.disposables.Disposable; | ||
12 | import io.reactivex.functions.Consumer; | ||
13 | import io.reactivex.schedulers.Schedulers; | ||
14 | import retrofit2.Call; | ||
15 | |||
16 | // 抽象 | ||
17 | public interface ILifecycleFragment { | ||
18 | Observable<FragmentEvent> getRxLifecycle(); | ||
19 | |||
20 | default <T> Single<T> getSingleResult(Call<T> call) { | ||
21 | return Single.just(call) | ||
22 | .map(t -> t.execute().body()) | ||
23 | .subscribeOn(Schedulers.io()) | ||
24 | .observeOn(AndroidSchedulers.mainThread()) | ||
25 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())); | ||
26 | } | ||
27 | |||
28 | default <T> void subscribeSingle(Single<T> single, SingleObserver<T> observer) { | ||
29 | single.subscribeOn(Schedulers.io()) | ||
30 | .observeOn(AndroidSchedulers.mainThread()) | ||
31 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | ||
32 | .subscribe(observer); | ||
33 | } | ||
34 | |||
35 | default <T> void subscribeRx(Observable<T> observable, Observer<T> observer) { | ||
36 | observable.subscribeOn(Schedulers.io()) | ||
37 | .observeOn(AndroidSchedulers.mainThread()) | ||
38 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | ||
39 | .subscribe(observer); | ||
40 | } | ||
41 | |||
42 | default <T> Disposable subscribeRx(Observable<T> observable, Consumer<T> onNext) { | ||
43 | return observable.subscribeOn(Schedulers.io()) | ||
44 | .observeOn(AndroidSchedulers.mainThread()) | ||
45 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | ||
46 | .subscribe(onNext); | ||
47 | } | ||
48 | } | ||
49 |
app/src/main/res/drawable/bg_homework.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:radius="10dp"/> | ||
4 | <stroke android:width="1dp" android:color="#EEE"/> | ||
5 | </shape> |
app/src/main/res/drawable/bg_tab_home.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | |||
4 | <corners android:topLeftRadius="10dp" android:topRightRadius="10dp"/> | ||
5 | <solid android:color="#201C90F3"/> | ||
6 | |||
7 | </shape> |
app/src/main/res/drawable/ic_chemistry.png
74.3 KB
app/src/main/res/drawable/ic_chinese.png
73.7 KB
app/src/main/res/drawable/ic_english.png
79.7 KB
app/src/main/res/drawable/ic_math.png
73 KB
app/src/main/res/drawable/ic_physics.png
71 KB
app/src/main/res/drawable/png_entry_error.png
205 KB
app/src/main/res/drawable/png_entry_homework.png
203 KB
app/src/main/res/drawable/shape_radius_10.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:radius="10dp"/> | ||
4 | </shape> |
app/src/main/res/layout/empty_homework.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <FrameLayout | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | xmlns:tools="http://schemas.android.com/tools" | ||
5 | android:layout_width="match_parent" | ||
6 | android:layout_height="match_parent"> | ||
7 | <LinearLayout | ||
8 | android:id="@+id/ll_empty" | ||
9 | android:layout_width="wrap_content" | ||
10 | android:layout_height="wrap_content" | ||
11 | android:layout_gravity="center_horizontal" | ||
12 | android:orientation="vertical" | ||
13 | tools:ignore="UseCompoundDrawables,UselessParent"> | ||
14 | |||
15 | <ImageView | ||
16 | android:layout_width="155dp" | ||
17 | android:layout_height="130dp" | ||
18 | android:src="@mipmap/ic_empty" | ||
19 | android:importantForAccessibility="no" /> | ||
20 | |||
21 | <TextView | ||
22 | android:layout_width="wrap_content" | ||
23 | android:layout_height="wrap_content" | ||
24 | android:layout_gravity="center_horizontal" | ||
25 | android:text="暂无作业~" | ||
26 | tools:ignore="HardcodedText" /> | ||
27 | </LinearLayout> | ||
28 | </FrameLayout> |
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 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
3 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
4 | android:orientation="vertical"> | 5 | xmlns:app="http://schemas.android.com/apk/res-auto" |
6 | android:orientation="vertical" | ||
7 | tools:ignore="HardcodedText,ContentDescription,UseCompoundDrawables"> | ||
5 | 8 | ||
6 | <RelativeLayout | 9 | <RelativeLayout |
7 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
8 | android:layout_height="40dp" | 11 | android:layout_height="40dp" |
9 | android:layout_marginTop="30dp"> | 12 | android:layout_marginTop="30dp"> |
10 | 13 | ||
11 | <ImageView | 14 | <ImageView |
12 | android:id="@+id/iv_student" | 15 | android:id="@+id/iv_student" |
13 | android:layout_width="35dp" | 16 | android:layout_width="35dp" |
14 | android:layout_height="35dp" | 17 | android:layout_height="35dp" |
15 | android:layout_centerVertical="true" | 18 | android:layout_centerVertical="true" |
16 | android:layout_marginLeft="15dp" /> | 19 | android:layout_marginStart="15dp" /> |
17 | 20 | ||
18 | <TextView | 21 | <TextView |
19 | android:id="@+id/tv_name" | 22 | android:id="@+id/tv_name" |
20 | android:layout_width="wrap_content" | 23 | android:layout_width="wrap_content" |
21 | android:layout_height="wrap_content" | 24 | android:layout_height="wrap_content" |
22 | android:layout_centerVertical="true" | 25 | android:layout_centerVertical="true" |
23 | android:layout_marginLeft="10dp" | 26 | android:layout_marginStart="10dp" |
24 | android:layout_toRightOf="@+id/iv_student" | 27 | android:layout_toEndOf="@+id/iv_student" |
25 | android:textColor="#333333" | 28 | android:textColor="#333333" |
26 | android:textSize="16sp" /> | 29 | android:textSize="16sp" |
30 | tools:ignore="RelativeOverlap" /> | ||
27 | 31 | ||
28 | <TextView | 32 | <androidx.appcompat.widget.AppCompatTextView |
29 | android:id="@+id/tv_choose" | 33 | android:id="@+id/tv_choose" |
30 | android:layout_width="wrap_content" | 34 | android:layout_width="wrap_content" |
31 | android:layout_height="wrap_content" | 35 | android:layout_height="wrap_content" |
32 | android:layout_alignParentRight="true" | 36 | android:layout_alignParentEnd="true" |
33 | android:layout_centerVertical="true" | 37 | android:layout_centerVertical="true" |
34 | android:layout_marginRight="15dp" | 38 | android:layout_marginEnd="15dp" |
35 | android:drawableRight="@drawable/ic_filter_black" | 39 | android:drawableEnd="@drawable/ic_filter_black" |
36 | android:drawablePadding="5dp" | 40 | android:drawablePadding="5dp" |
37 | android:text="选择学生" | 41 | android:text="选择学生" |
38 | android:textColor="#333333" | 42 | android:textColor="#333333" |
39 | android:textSize="14sp" /> | 43 | android:textSize="14sp" /> |
40 | 44 | ||
41 | </RelativeLayout> | 45 | </RelativeLayout> |
42 | 46 | ||
43 | <RelativeLayout | 47 | <LinearLayout |
44 | android:id="@+id/rl_take_photo" | 48 | android:orientation="horizontal" |
49 | android:weightSum="2" | ||
45 | android:layout_width="match_parent" | 50 | android:layout_width="match_parent" |
46 | android:layout_height="200dp" | 51 | android:layout_height="wrap_content" |
47 | android:background="@mipmap/ic_take_photo"> | 52 | android:baselineAligned="false"> |
53 | <FrameLayout | ||
54 | android:id="@+id/rl_take_photo" | ||
55 | android:layout_width="0dp" | ||
56 | android:layout_weight="1" | ||
57 | android:layout_height="wrap_content"> | ||
58 | <ImageView | ||
59 | android:src="@drawable/png_entry_error" | ||
60 | android:adjustViewBounds="true" | ||
61 | android:layout_width="match_parent" | ||
62 | android:layout_height="wrap_content"/> | ||
48 | 63 | ||
49 | <TextView | 64 | <TextView |
50 | android:layout_width="wrap_content" | 65 | android:layout_width="wrap_content" |
51 | android:layout_height="wrap_content" | 66 | android:layout_height="wrap_content" |
52 | android:layout_alignParentRight="true" | 67 | android:layout_gravity="center_horizontal|bottom" |
53 | android:layout_centerVertical="true" | 68 | android:layout_marginBottom="38dp" |
54 | android:layout_marginRight="70dp" | 69 | android:text="录入错题" |
55 | android:text="录入错题" | 70 | android:textColor="#EDF6FF" |
56 | android:textColor="#EDF6FF" | 71 | android:textSize="20sp" |
57 | android:textSize="22sp" | 72 | android:textStyle="bold" /> |
58 | android:textStyle="bold" /> | 73 | </FrameLayout> |
59 | </RelativeLayout> | 74 | |
75 | <FrameLayout | ||
76 | android:id="@+id/flEntryHomework" | ||
77 | android:layout_width="0dp" | ||
78 | android:layout_weight="1" | ||
79 | android:layout_height="wrap_content"> | ||
80 | <ImageView | ||
81 | android:src="@drawable/png_entry_homework" | ||
82 | android:adjustViewBounds="true" | ||
83 | android:layout_width="match_parent" | ||
84 | android:layout_height="wrap_content"/> | ||
60 | 85 | ||
61 | <RelativeLayout | 86 | <TextView |
87 | android:layout_width="wrap_content" | ||
88 | android:layout_height="wrap_content" | ||
89 | android:layout_gravity="center_horizontal|bottom" | ||
90 | android:layout_marginBottom="38dp" | ||
91 | android:text="录入作业" | ||
92 | android:textColor="#EDF6FF" | ||
93 | android:textSize="20sp" | ||
94 | android:textStyle="bold" /> | ||
95 | </FrameLayout> | ||
96 | </LinearLayout> | ||
97 | |||
98 | <LinearLayout | ||
99 | android:orientation="vertical" | ||
100 | android:background="@drawable/shape_radius_10" | ||
101 | android:backgroundTint="@color/white" | ||
102 | android:layout_marginHorizontal="15dp" | ||
103 | android:layout_marginTop="10dp" | ||
104 | android:layout_marginBottom="15dp" | ||
62 | android:layout_width="match_parent" | 105 | android:layout_width="match_parent" |
63 | android:layout_height="25dp"> | 106 | android:layout_height="match_parent"> |
64 | 107 | ||
65 | <TextView | 108 | <com.google.android.material.tabs.TabLayout |
66 | android:layout_width="wrap_content" | 109 | android:id="@+id/tabLayout" |
67 | android:layout_height="wrap_content" | 110 | app:tabMode="fixed" |
68 | android:layout_marginLeft="15dp" | 111 | app:tabGravity="fill" |
69 | android:text="最近录入错题" | 112 | app:tabIndicatorFullWidth="false" |
70 | android:textColor="#333333" | 113 | app:tabIndicatorColor="#1C90F3" |
71 | android:textSize="16sp" | 114 | app:tabTextColor="#333" |
72 | android:textStyle="bold" /> | 115 | app:tabSelectedTextColor="#1C90F3" |
116 | app:tabTextAppearance="@style/tab_home_item" | ||
117 | app:tabRippleColor="@color/transparent" | ||
118 | android:background="@drawable/bg_tab_home" | ||
119 | android:paddingBottom="4dp" | ||
120 | android:layout_width="match_parent" | ||
121 | android:layout_height="36dp"/> | ||
73 | 122 | ||
74 | <LinearLayout | 123 | <androidx.recyclerview.widget.RecyclerView |
75 | android:id="@+id/ll_all" | 124 | android:id="@+id/rvSubject" |
76 | android:layout_width="wrap_content" | 125 | android:orientation="horizontal" |
77 | android:layout_height="wrap_content" | 126 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
78 | android:layout_alignParentRight="true" | 127 | android:layout_marginTop="15dp" |
79 | android:layout_centerVertical="true" | 128 | android:layout_width="match_parent" |
80 | android:layout_marginRight="15dp"> | 129 | android:layout_height="wrap_content" /> |
81 | 130 | ||
131 | <LinearLayout | ||
132 | android:layout_marginTop="16dp" | ||
133 | android:layout_marginHorizontal="10dp" | ||
134 | android:layout_width="match_parent" | ||
135 | android:layout_height="25dp"> | ||
82 | <TextView | 136 | <TextView |
137 | android:id="@+id/tvListTitle" | ||
83 | android:layout_width="wrap_content" | 138 | android:layout_width="wrap_content" |
84 | android:layout_height="wrap_content" | 139 | android:layout_height="wrap_content" |
85 | android:layout_gravity="center_vertical" | 140 | android:text="最近录入错题" |
86 | android:text="查看全部" | 141 | android:textColor="#333333" |
87 | android:textColor="#666666" | 142 | android:textSize="16sp" |
88 | android:textSize="12sp" /> | 143 | android:textStyle="bold" /> |
89 | |||
90 | <ImageView | ||
91 | android:layout_width="9dp" | ||
92 | android:layout_height="10dp" | ||
93 | android:layout_gravity="center_vertical" | ||
94 | android:layout_marginLeft="5dp" | ||
95 | android:src="@mipmap/ic_arrow_right" /> | ||
96 | </LinearLayout> | ||
97 | </RelativeLayout> | ||
98 | 144 | ||
99 | <androidx.recyclerview.widget.RecyclerView | 145 | <Space style="@style/empty_space"/> |
100 | android:id="@+id/recycle_subject" | ||
101 | android:layout_width="match_parent" | ||
102 | android:layout_height="wrap_content" | ||
103 | android:layout_marginLeft="15dp" | ||
104 | android:layout_marginTop="15dp" | ||
105 | android:layout_marginRight="15dp" /> | ||
106 | 146 | ||
107 | <RelativeLayout | 147 | <LinearLayout |
108 | android:layout_width="match_parent" | 148 | android:id="@+id/ll_all" |
109 | android:layout_height="match_parent"> | 149 | android:layout_width="wrap_content" |
150 | android:layout_height="wrap_content" | ||
151 | android:layout_gravity="center_vertical"> | ||
152 | |||
153 | <TextView | ||
154 | android:layout_width="wrap_content" | ||
155 | android:layout_height="wrap_content" | ||
156 | android:layout_gravity="center_vertical" | ||
157 | android:text="查看全部" | ||
158 | android:textColor="#666666" | ||
159 | android:textSize="12sp" /> | ||
160 | |||
161 | <ImageView | ||
162 | android:layout_width="9dp" | ||
163 | android:layout_height="10dp" | ||
164 | android:layout_gravity="center_vertical" | ||
165 | android:layout_marginStart="5dp" | ||
166 | android:src="@mipmap/ic_arrow_right" /> | ||
167 | </LinearLayout> | ||
168 | </LinearLayout> | ||
110 | 169 | ||
111 | <androidx.recyclerview.widget.RecyclerView | 170 | <androidx.recyclerview.widget.RecyclerView |
112 | android:id="@+id/recycle_error" | 171 | android:id="@+id/rvMain" |
172 | android:orientation="vertical" | ||
173 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
113 | android:layout_width="match_parent" | 174 | android:layout_width="match_parent" |
114 | android:layout_height="wrap_content" | 175 | android:layout_height="match_parent" |
115 | android:layout_marginTop="15dp" /> | 176 | android:layout_marginTop="15dp" /> |
116 | 177 | ||
117 | <LinearLayout | 178 | <LinearLayout |
118 | android:id="@+id/ll_empty" | 179 | android:id="@+id/ll_empty" |
119 | android:layout_width="wrap_content" | 180 | android:layout_width="wrap_content" |
120 | android:layout_height="wrap_content" | 181 | android:layout_height="wrap_content" |
121 | android:layout_centerHorizontal="true" | 182 | android:layout_gravity="center_horizontal" |
122 | android:layout_marginTop="30dp" | 183 | android:layout_marginTop="30dp" |
123 | android:orientation="vertical" | 184 | android:orientation="vertical" |
124 | android:visibility="gone"> | 185 | android:visibility="gone"> |
app/src/main/res/layout/item_homework.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <LinearLayout | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
5 | xmlns:tools="http://schemas.android.com/tools" | ||
6 | android:orientation="vertical" | ||
7 | android:paddingHorizontal="10dp" | ||
8 | android:layout_marginVertical="8dp" | ||
9 | android:layout_width="match_parent" | ||
10 | android:layout_height="wrap_content" | ||
11 | tools:ignore="SmallSp"> | ||
12 | |||
13 | <TextView | ||
14 | android:id="@+id/tvDate" | ||
15 | android:visibility="gone" | ||
16 | tools:visibility="visible" | ||
17 | tools:text="2024-09-25" | ||
18 | android:textSize="12sp" | ||
19 | android:textColor="#999" | ||
20 | android:layout_marginBottom="15dp" | ||
21 | android:layout_width="wrap_content" | ||
22 | android:layout_height="wrap_content"/> | ||
23 | |||
24 | <LinearLayout | ||
25 | android:orientation="horizontal" | ||
26 | android:gravity="center_vertical" | ||
27 | android:background="@drawable/bg_homework" | ||
28 | android:layout_width="match_parent" | ||
29 | android:layout_height="75dp"> | ||
30 | <ImageView | ||
31 | android:id="@+id/ivSubject" | ||
32 | tools:src="@drawable/ic_math" | ||
33 | android:layout_marginStart="10dp" | ||
34 | android:layout_width="44dp" | ||
35 | android:layout_height="56dp" | ||
36 | android:importantForAccessibility="no" /> | ||
37 | <LinearLayout | ||
38 | android:orientation="vertical" | ||
39 | android:layout_marginStart="14dp" | ||
40 | android:layout_marginVertical="16dp" | ||
41 | android:layout_width="wrap_content" | ||
42 | android:layout_height="match_parent"> | ||
43 | <TextView | ||
44 | android:id="@+id/tvName" | ||
45 | tools:text="作业名称" | ||
46 | android:textSize="13sp" | ||
47 | android:textColor="#333" | ||
48 | android:layout_width="wrap_content" | ||
49 | android:layout_height="wrap_content"/> | ||
50 | <Space style="@style/empty_space"/> | ||
51 | <TextView | ||
52 | android:id="@+id/tvGrade" | ||
53 | tools:text="七年级-上学期" | ||
54 | android:textSize="10sp" | ||
55 | android:textColor="#666" | ||
56 | android:layout_width="wrap_content" | ||
57 | android:layout_height="wrap_content" /> | ||
58 | </LinearLayout> | ||
59 | <Space style="@style/empty_space"/> | ||
60 | <TextView | ||
61 | android:text=">" | ||
62 | android:textSize="20sp" | ||
63 | android:textColor="#333" | ||
64 | android:layout_marginEnd="10dp" | ||
65 | android:layout_width="wrap_content" | ||
66 | android:layout_height="wrap_content" | ||
67 | tools:ignore="HardcodedText" /> | ||
68 | </LinearLayout> | ||
69 | |||
70 | </LinearLayout> |
app/src/main/res/values/appearance.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <resources> | ||
3 | |||
4 | <style name="tab_home_item"> | ||
5 | <item name="android:textSize">16sp</item> | ||
6 | <item name="android:textStyle">bold</item> | ||
7 | </style> | ||
8 | |||
9 | </resources> |
app/src/main/res/values/styles.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <resources> | 2 | <resources> |
3 | 3 | ||
4 | 4 | ||
5 | <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar"> | 5 | <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar"> |
6 | <item name="android:windowBackground">@drawable/welcome_bg</item> | 6 | <item name="android:windowBackground">@drawable/welcome_bg</item> |
7 | <item name="colorPrimaryDark">@android:color/transparent</item> | 7 | <item name="colorPrimaryDark">@android:color/transparent</item> |
8 | <item name="windowActionBar">false</item> | 8 | <item name="windowActionBar">false</item> |
9 | <item name="windowNoTitle">true</item> | 9 | <item name="windowNoTitle">true</item> |
10 | <item name="android:windowFullscreen">true</item> | 10 | <item name="android:windowFullscreen">true</item> |
11 | </style> | 11 | </style> |
12 | 12 | ||
13 | <style name="main_bottom_navigaton_menu_item"> | 13 | <style name="main_bottom_navigaton_menu_item"> |
14 | <item name="android:layout_width">0dp</item> | 14 | <item name="android:layout_width">0dp</item> |
15 | <item name="android:layout_weight">1</item> | 15 | <item name="android:layout_weight">1</item> |
16 | <item name="android:layout_height">match_parent</item> | 16 | <item name="android:layout_height">match_parent</item> |
17 | <item name="android:background">@android:color/transparent</item> | 17 | <item name="android:background">@android:color/transparent</item> |
18 | <item name="android:button">@null</item> | 18 | <item name="android:button">@null</item> |
19 | <item name="android:gravity">center</item> | 19 | <item name="android:gravity">center</item> |
20 | <item name="android:textSize">11dp</item> | 20 | <item name="android:textSize">11dp</item> |
21 | <item name="android:drawablePadding">2dp</item> | 21 | <item name="android:drawablePadding">2dp</item> |
22 | </style> | 22 | </style> |
23 | <!--实现BottomSheetDialog圆角效果--> | 23 | <!--实现BottomSheetDialog圆角效果--> |
24 | <style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog"> | 24 | <style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog"> |
25 | <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item> | 25 | <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item> |
26 | </style> | 26 | </style> |
27 | 27 | ||
28 | <style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal"> | 28 | <style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal"> |
29 | <item name="android:background">@android:color/transparent</item> | 29 | <item name="android:background">@android:color/transparent</item> |
30 | <item name="android:navigationBarColor">@android:color/transparent</item> | 30 | <item name="android:navigationBarColor">@android:color/transparent</item> |
31 | <item name="behavior_peekHeight">500dp</item> | 31 | <item name="behavior_peekHeight">500dp</item> |
32 | </style> | 32 | </style> |
33 | 33 | ||
34 | <style name="MyAlertDialog" parent="android:Theme.Material.Dialog.Alert"> | 34 | <style name="MyAlertDialog" parent="android:Theme.Material.Dialog.Alert"> |
35 | <!--背景颜色及和透明程度--> | 35 | <!--背景颜色及和透明程度--> |
36 | <item name="android:windowBackground">@null</item> | 36 | <item name="android:windowBackground">@null</item> |
37 | <!--是否去除标题 --> | 37 | <!--是否去除标题 --> |
38 | <item name="android:windowNoTitle">true</item> | 38 | <item name="android:windowNoTitle">true</item> |
39 | <!--是否去除边框--> | 39 | <!--是否去除边框--> |
40 | <item name="android:windowFrame">@null</item> | 40 | <item name="android:windowFrame">@null</item> |
41 | <!--是否浮现在activity之上--> | 41 | <!--是否浮现在activity之上--> |
42 | <item name="android:windowIsFloating">true</item> | 42 | <item name="android:windowIsFloating">true</item> |
43 | <!--是否模糊--> | 43 | <!--是否模糊--> |
44 | <item name="android:backgroundDimEnabled">true</item> | 44 | <item name="android:backgroundDimEnabled">true</item> |
45 | <item name="android:windowIsTranslucent">true</item><!--半透明--> | 45 | <item name="android:windowIsTranslucent">true</item><!--半透明--> |
46 | <item name="android:windowSoftInputMode">stateVisible|adjustPan</item> | 46 | <item name="android:windowSoftInputMode">stateVisible|adjustPan</item> |
47 | </style> | 47 | </style> |
48 | 48 | ||
49 | <style name="customSpinnerStyle" parent="android:Widget.ListView.DropDown"> | 49 | <style name="customSpinnerStyle" parent="android:Widget.ListView.DropDown"> |
50 | <item name="divider">@color/border</item> | 50 | <item name="divider">@color/border</item> |
51 | <item name="android:scrollbars">none</item> | 51 | <item name="android:scrollbars">none</item> |
52 | <item name="android:dividerHeight">1dp</item> | 52 | <item name="android:dividerHeight">1dp</item> |
53 | <item name="android:textSize">15sp</item> | 53 | <item name="android:textSize">15sp</item> |
54 | </style> | 54 | </style> |
55 | 55 | ||
56 | <style name="empty_space"> | ||
57 | <item name="android:layout_width">0dp</item> | ||
58 | <item name="android:layout_height">0dp</item> | ||
59 | <item name="android:layout_weight">1</item> | ||
60 | </style> | ||
56 | 61 | ||
57 | </resources> | 62 | </resources> |
libs/common/src/main/java/com/prws/common/bean/homework/HomeworkList.java
File was created | 1 | package com.prws.common.bean.homework; | |
2 | |||
3 | import com.google.gson.annotations.SerializedName; | ||
4 | |||
5 | import java.util.Date; | ||
6 | |||
7 | public class HomeworkList { | ||
8 | |||
9 | @SerializedName(value = "homeworkId", alternate = "id") | ||
10 | private Integer homeworkId; | ||
11 | @SerializedName(value = "name", alternate = "homeworkName") | ||
12 | private String name; | ||
13 | @SerializedName("grade") | ||
14 | private String grade; | ||
15 | @SerializedName("term") | ||
16 | private String term; | ||
17 | @SerializedName("subject") | ||
18 | private String subject; | ||
19 | private int completeFlag; | ||
20 | |||
21 | private Integer total; | ||
22 | private Integer right; | ||
23 | |||
24 | public Date uploadTime; | ||
25 | |||
26 | public Integer getTotal() { | ||
27 | return total; | ||
28 | } | ||
29 | |||
30 | public Integer getRight() { | ||
31 | return right; | ||
32 | } | ||
33 | |||
34 | public void setRight(Integer right) { | ||
35 | this.right = right; | ||
36 | } | ||
37 | |||
38 | public void setTotal(Integer total) { | ||
39 | this.total = total; | ||
40 | } | ||
41 | |||
42 | public void setId(Integer id) { | ||
43 | this.homeworkId = id; | ||
44 | } | ||
45 | |||
46 | public void setName(String name) { | ||
47 | this.name = name; | ||
48 | } | ||
49 | |||
50 | public void setGrade(String grade) { | ||
51 | this.grade = grade; | ||
52 | } | ||
53 | |||
54 | public void setTerm(String term) { | ||
55 | this.term = term; | ||
56 | } | ||
57 | |||
58 | public void setSubject(String subject) { | ||
59 | this.subject = subject; | ||
60 | } | ||
61 | |||
62 | public void setCompleteFlag(int completeFlag) { | ||
63 | this.completeFlag = completeFlag; | ||
64 | } | ||
65 | |||
66 | public Integer getId() { | ||
67 | return homeworkId; | ||
68 | } | ||
69 | |||
70 | public String getName() { | ||
71 | return name; | ||
72 | } | ||
73 | |||
74 | public String getGrade() { | ||
75 | return grade; | ||
76 | } | ||
77 | |||
78 | public String getTerm() { | ||
79 | return term; | ||
80 | } | ||
81 | |||
82 | public String getSubject() { | ||
83 | return subject; | ||
84 | } | ||
85 | |||
86 | public int getCompleteFlag() { | ||
87 | return completeFlag; | ||
88 | } | ||
89 | |||
90 | } | ||
91 |
libs/common/src/main/java/com/prws/common/net/NetWorks.java
1 | package com.prws.common.net; | 1 | package com.prws.common.net; |
2 | 2 | ||
3 | 3 | ||
4 | import com.google.gson.Gson; | 4 | import com.google.gson.Gson; |
5 | import com.google.gson.JsonObject; | 5 | import com.google.gson.JsonObject; |
6 | import com.prws.common.BuildConfig; | 6 | import com.prws.common.BuildConfig; |
7 | import com.prws.common.bean.BaseEntity; | ||
8 | import com.prws.common.bean.CutPicBean; | 7 | import com.prws.common.bean.CutPicBean; |
9 | import com.prws.common.bean.GradeAndSubject; | 8 | import com.prws.common.bean.GradeAndSubject; |
10 | import com.prws.common.bean.PageInfo; | 9 | import com.prws.common.bean.PageInfo; |
11 | import com.prws.common.bean.ResponseResult; | 10 | import com.prws.common.bean.ResponseResult; |
12 | import com.prws.common.bean.ScheduleBean; | 11 | import com.prws.common.bean.ScheduleBean; |
13 | import com.prws.common.bean.Teacher; | 12 | import com.prws.common.bean.Teacher; |
14 | import com.prws.common.bean.TopicBean; | 13 | import com.prws.common.bean.TopicBean; |
15 | import com.prws.common.bean.UpdateBean; | 14 | import com.prws.common.bean.UpdateBean; |
15 | import com.prws.common.bean.homework.HomeworkList; | ||
16 | import com.prws.common.utils.SharedPreferencesUtil; | 16 | import com.prws.common.utils.SharedPreferencesUtil; |
17 | 17 | ||
18 | import java.io.File; | 18 | import java.io.File; |
19 | import java.util.HashMap; | 19 | import java.util.HashMap; |
20 | import java.util.List; | 20 | import java.util.List; |
21 | import java.util.Map; | 21 | import java.util.Map; |
22 | 22 | ||
23 | import io.reactivex.Observable; | 23 | import io.reactivex.Observable; |
24 | import io.reactivex.Observer; | 24 | import io.reactivex.Observer; |
25 | import io.reactivex.Single; | ||
25 | import io.reactivex.android.schedulers.AndroidSchedulers; | 26 | import io.reactivex.android.schedulers.AndroidSchedulers; |
26 | import io.reactivex.schedulers.Schedulers; | 27 | import io.reactivex.schedulers.Schedulers; |
27 | import okhttp3.MediaType; | 28 | import okhttp3.MediaType; |
28 | import okhttp3.MultipartBody; | 29 | import okhttp3.MultipartBody; |
29 | import okhttp3.RequestBody; | 30 | import okhttp3.RequestBody; |
30 | import okhttp3.ResponseBody; | 31 | import okhttp3.ResponseBody; |
31 | import retrofit2.Call; | 32 | import retrofit2.Call; |
32 | import retrofit2.Callback; | 33 | import retrofit2.Callback; |
33 | import retrofit2.http.Body; | 34 | import retrofit2.http.Body; |
34 | import retrofit2.http.DELETE; | ||
35 | import retrofit2.http.FieldMap; | ||
36 | import retrofit2.http.FormUrlEncoded; | ||
37 | import retrofit2.http.GET; | 35 | import retrofit2.http.GET; |
38 | import retrofit2.http.Header; | 36 | import retrofit2.http.Header; |
39 | import retrofit2.http.HeaderMap; | ||
40 | import retrofit2.http.Headers; | 37 | import retrofit2.http.Headers; |
41 | import retrofit2.http.Multipart; | 38 | import retrofit2.http.Multipart; |
42 | import retrofit2.http.POST; | 39 | import retrofit2.http.POST; |
43 | import retrofit2.http.PUT; | 40 | import retrofit2.http.PUT; |
44 | import retrofit2.http.Part; | 41 | import retrofit2.http.Part; |
45 | import retrofit2.http.PartMap; | 42 | import retrofit2.http.PartMap; |
46 | import retrofit2.http.Path; | ||
47 | import retrofit2.http.Query; | 43 | import retrofit2.http.Query; |
48 | import retrofit2.http.QueryMap; | ||
49 | import retrofit2.http.Streaming; | ||
50 | import retrofit2.http.Url; | 44 | import retrofit2.http.Url; |
51 | 45 | ||
52 | /** | 46 | /** |
53 | * 类名称:NetWorks | 47 | * 类名称:NetWorks |
54 | * 创建人: | 48 | * 创建人: |
55 | * <p> | 49 | * <p> |
56 | * 类描述:网络请求的操作类 | 50 | * 类描述:网络请求的操作类 |
57 | */ | 51 | */ |
58 | public class NetWorks extends RetrofitUtils { | 52 | public class NetWorks extends RetrofitUtils { |
59 | //服务器路径 | 53 | //服务器路径 |
60 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); | 54 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); |
61 | 55 | ||
62 | //设缓存有效期为1天 | 56 | //设缓存有效期为1天 |
63 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | 57 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; |
64 | //查询缓存的Cache-Control设置,使用缓存 | 58 | //查询缓存的Cache-Control设置,使用缓存 |
65 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | 59 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; |
66 | //查询网络的Cache-Control设置。不使用缓存 | 60 | //查询网络的Cache-Control设置。不使用缓存 |
67 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | 61 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
68 | 62 | ||
69 | 63 | ||
70 | private interface NetService { | 64 | public interface NetService { |
71 | 65 | ||
72 | 66 | ||
73 | @GET("/api/v1/user/logout") | 67 | @GET("/api/v1/user/logout") |
74 | Observable<ResponseBody> logout(); | 68 | Observable<ResponseBody> logout(); |
75 | 69 | ||
76 | @Multipart | 70 | @Multipart |
77 | @POST("/api/v1/user/upLoadAvatar") | 71 | @POST("/api/v1/user/upLoadAvatar") |
78 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); | 72 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); |
79 | 73 | ||
80 | 74 | ||
81 | @Headers("Content-Type: application/json") | 75 | @Headers("Content-Type: application/json") |
82 | @POST("/api/v1/user/editUser") | 76 | @POST("/api/v1/user/editUser") |
83 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); | 77 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); |
84 | 78 | ||
85 | @Headers("Content-Type: application/json") | 79 | @Headers("Content-Type: application/json") |
86 | @POST("/api/v1/user/changePassword") | 80 | @POST("/api/v1/user/changePassword") |
87 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); | 81 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); |
88 | 82 | ||
89 | 83 | ||
90 | @GET("/api/v1/user/searchById") | 84 | @GET("/api/v1/user/searchById") |
91 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); | 85 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); |
92 | 86 | ||
93 | 87 | ||
94 | @Headers("Content-Type: application/json") | 88 | @Headers("Content-Type: application/json") |
95 | @POST("/api/v1/auth/login") | 89 | @POST("/api/v1/auth/login") |
96 | Observable<ResponseBody> login(@Body RequestBody body); | 90 | Observable<ResponseBody> login(@Body RequestBody body); |
97 | 91 | ||
98 | @GET("/api/v1/resource/listGradeAndSubject") | 92 | @GET("/api/v1/resource/listGradeAndSubject") |
99 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); | 93 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); |
100 | 94 | ||
101 | 95 | ||
102 | @GET("/api/v1/manager/generalQrCode") | 96 | @GET("/api/v1/manager/generalQrCode") |
103 | Observable<ResponseBody> generalQrCode(); | 97 | Observable<ResponseBody> generalQrCode(); |
104 | 98 | ||
105 | @GET("/api/v1/parent/scanAndLogin?") | 99 | @GET("/api/v1/parent/scanAndLogin?") |
106 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); | 100 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); |
107 | 101 | ||
108 | @GET("/api/v1/parent/getChildrenList") | 102 | @GET("/api/v1/parent/getChildrenList") |
109 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); | 103 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); |
110 | 104 | ||
111 | 105 | ||
112 | @Headers("Content-Type: application/json") | 106 | @Headers("Content-Type: application/json") |
113 | @POST("/api/v1/parent/registerParent") | 107 | @POST("/api/v1/parent/registerParent") |
114 | Observable<ResponseBody> registerParent(@Body RequestBody body); | 108 | Observable<ResponseBody> registerParent(@Body RequestBody body); |
115 | 109 | ||
116 | 110 | ||
117 | @GET("/api/v1/parent/listChildren") | 111 | @GET("/api/v1/parent/listChildren") |
118 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); | 112 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); |
119 | 113 | ||
120 | 114 | ||
121 | @Headers("Content-Type: application/json") | 115 | @Headers("Content-Type: application/json") |
122 | @POST("/api/v1/parent/registerStudent") | 116 | @POST("/api/v1/parent/registerStudent") |
123 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); | 117 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); |
124 | 118 | ||
125 | @Headers("Content-Type: application/json") | 119 | @Headers("Content-Type: application/json") |
126 | @POST("/api/v1/parent/bindTeacher") | 120 | @POST("/api/v1/parent/bindTeacher") |
127 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); | 121 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); |
128 | 122 | ||
129 | @Multipart | 123 | @Multipart |
130 | @POST("/api/v1/user/upLoadAvatar") | 124 | @POST("/api/v1/user/upLoadAvatar") |
131 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); | 125 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); |
132 | 126 | ||
133 | 127 | ||
134 | @Multipart | 128 | @Multipart |
135 | @POST("/api/v1/student/editStudentAvatar") | 129 | @POST("/api/v1/student/editStudentAvatar") |
136 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 130 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
137 | 131 | ||
138 | @Headers("Content-Type: application/json") | 132 | @Headers("Content-Type: application/json") |
139 | @POST("/api/v1/parent/editChild") | 133 | @POST("/api/v1/parent/editChild") |
140 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); | 134 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); |
141 | 135 | ||
142 | @GET("/api/v1/student/getStudyPlanForThisWeek") | 136 | @GET("/api/v1/student/getStudyPlanForThisWeek") |
143 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); | 137 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); |
144 | 138 | ||
145 | @GET("api/v1/parent/searchTeacher") | 139 | @GET("api/v1/parent/searchTeacher") |
146 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); | 140 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); |
147 | 141 | ||
148 | @POST("api/v1/question/listErrorBook") | 142 | @POST("api/v1/question/listErrorBook") |
149 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); | 143 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); |
150 | 144 | ||
151 | @POST | 145 | @POST |
152 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); | 146 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); |
153 | 147 | ||
154 | @POST | 148 | @POST |
155 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); | 149 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); |
156 | 150 | ||
157 | @POST | 151 | @POST |
158 | Observable<JsonObject> getBaiduToken(@Url String url); | 152 | Observable<JsonObject> getBaiduToken(@Url String url); |
159 | 153 | ||
160 | @Multipart | 154 | @Multipart |
161 | @POST("api/v1/pad/addErrorBook") | 155 | @POST("api/v1/pad/addErrorBook") |
162 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 156 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
163 | 157 | ||
164 | @POST("api/v1/pad/deleteStuErrorBook") | 158 | @POST("api/v1/pad/deleteStuErrorBook") |
165 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); | 159 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); |
166 | 160 | ||
167 | @PUT("api/v1/pad/updateStuErrorBookInfo") | 161 | @PUT("api/v1/pad/updateStuErrorBookInfo") |
168 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); | 162 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); |
169 | 163 | ||
170 | @POST("api/v1/question/editErrorBook") | 164 | @POST("api/v1/question/editErrorBook") |
171 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); | 165 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); |
172 | 166 | ||
173 | @GET("api/v1/resource/checkUpdate") | 167 | @GET("api/v1/resource/checkUpdate") |
174 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); | 168 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); |
175 | 169 | ||
176 | @GET("api/v1/teacher/getStudentList") | 170 | @GET("api/v1/teacher/getStudentList") |
177 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); | 171 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); |
178 | 172 | ||
179 | @GET("api/v1/answer/listRecordForTeacher") | 173 | @GET("api/v1/answer/listRecordForTeacher") |
180 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); | 174 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); |
175 | |||
176 | @GET("api/v1/homework/listHomeworkByStuId") | ||
177 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); | ||
178 | |||
181 | } | 179 | } |
182 | 180 | ||
183 | 181 | ||
184 | public static String getHeader() { | 182 | public static String getHeader() { |
185 | return (String) SharedPreferencesUtil.getData("token", ""); | 183 | return (String) SharedPreferencesUtil.getData("token", ""); |
186 | } | 184 | } |
187 | 185 | ||
188 | public static String getBaiduToken() { | 186 | public static String getBaiduToken() { |
189 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); | 187 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); |
190 | } | 188 | } |
191 | 189 | ||
192 | 190 | ||
193 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { | 191 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { |
194 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); | 192 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); |
195 | } | 193 | } |
196 | 194 | ||
197 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { | 195 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { |
198 | File file = new File(path); | 196 | File file = new File(path); |
199 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 197 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
200 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 198 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
201 | Map<String, Object> map = new HashMap<>(); | 199 | Map<String, Object> map = new HashMap<>(); |
202 | map.put("condition", param); | 200 | map.put("condition", param); |
203 | setSubscribe(service_url.addError(part, map), observer); | 201 | setSubscribe(service_url.addError(part, map), observer); |
204 | } | 202 | } |
205 | 203 | ||
206 | 204 | ||
207 | public static void cut(String base64, Observer<CutPicBean> observer) { | 205 | public static void cut(String base64, Observer<CutPicBean> observer) { |
208 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 206 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
209 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); | 207 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); |
210 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); | 208 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); |
211 | } | 209 | } |
212 | 210 | ||
213 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | 211 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { |
214 | setSubscribe(service_url.editError(getHeader(), map), observer); | 212 | setSubscribe(service_url.editError(getHeader(), map), observer); |
215 | } | 213 | } |
216 | 214 | ||
217 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { | 215 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { |
218 | setSubscribe(service_url.updateError(getHeader(), map), observer); | 216 | setSubscribe(service_url.updateError(getHeader(), map), observer); |
219 | } | 217 | } |
220 | 218 | ||
221 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { | 219 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { |
222 | setSubscribe(service_url.deleteError(getHeader(), map), observer); | 220 | setSubscribe(service_url.deleteError(getHeader(), map), observer); |
223 | } | 221 | } |
224 | 222 | ||
225 | public static void getBaiduToken(Observer<JsonObject> observer) { | 223 | public static void getBaiduToken(Observer<JsonObject> observer) { |
226 | setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer); | 224 | setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer); |
227 | } | 225 | } |
228 | 226 | ||
229 | public static void removeWriting(String base64, Observer<JsonObject> observer) { | 227 | public static void removeWriting(String base64, Observer<JsonObject> observer) { |
230 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 228 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
231 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | 229 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); |
232 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); | 230 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); |
233 | } | 231 | } |
234 | 232 | ||
235 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | 233 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { |
236 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); | 234 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); |
237 | } | 235 | } |
238 | 236 | ||
239 | public static void logout(Observer<ResponseBody> observer) { | 237 | public static void logout(Observer<ResponseBody> observer) { |
240 | setSubscribe(service_url.logout(), observer); | 238 | setSubscribe(service_url.logout(), observer); |
241 | } | 239 | } |
242 | 240 | ||
243 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { | 241 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { |
244 | setSubscribe(service_url.editStudent(getHeader(), body), observable); | 242 | setSubscribe(service_url.editStudent(getHeader(), body), observable); |
245 | } | 243 | } |
246 | 244 | ||
247 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { | 245 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { |
248 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); | 246 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); |
249 | } | 247 | } |
250 | 248 | ||
251 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { | 249 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { |
252 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 250 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
253 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 251 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
254 | Map<String, Object> map = new HashMap<>(); | 252 | Map<String, Object> map = new HashMap<>(); |
255 | map.put("stuId", stuId); | 253 | map.put("stuId", stuId); |
256 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); | 254 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); |
257 | } | 255 | } |
258 | 256 | ||
259 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { | 257 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { |
260 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 258 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
261 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 259 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
262 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); | 260 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); |
263 | } | 261 | } |
264 | 262 | ||
265 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | 263 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { |
266 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); | 264 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); |
267 | } | 265 | } |
268 | 266 | ||
269 | 267 | ||
270 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { | 268 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { |
271 | setSubscribe(service_url.editUser(getHeader(), body), observer); | 269 | setSubscribe(service_url.editUser(getHeader(), body), observer); |
272 | } | 270 | } |
273 | 271 | ||
274 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { | 272 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { |
275 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | 273 | setSubscribe(service_url.changePassword(getHeader(), body), observer); |
276 | } | 274 | } |
277 | 275 | ||
278 | 276 | ||
279 | public static void searchById(String userId, Observer<ResponseBody> observer) { | 277 | public static void searchById(String userId, Observer<ResponseBody> observer) { |
280 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | 278 | setSubscribe(service_url.searchById(getHeader(), userId), observer); |
281 | } | 279 | } |
282 | 280 | ||
283 | 281 | ||
284 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | 282 | public static void login(RequestBody body, Observer<ResponseBody> observer) { |
285 | setSubscribe(service_url.login(body), observer); | 283 | setSubscribe(service_url.login(body), observer); |
286 | } | 284 | } |
287 | 285 | ||
288 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { | 286 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { |
289 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | 287 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); |
290 | } | 288 | } |
291 | 289 | ||
292 | 290 | ||
293 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { | 291 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { |
294 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); | 292 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); |
295 | } | 293 | } |
296 | 294 | ||
297 | public static void getChildrenList(Observer<ResponseBody> observer) { | 295 | public static void getChildrenList(Observer<ResponseBody> observer) { |
298 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | 296 | setSubscribe(service_url.getChildrenList(getHeader()), observer); |
299 | } | 297 | } |
300 | 298 | ||
301 | 299 | ||
302 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { | 300 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { |
303 | setSubscribe(service_url.registerParent(body), observer); | 301 | setSubscribe(service_url.registerParent(body), observer); |
304 | } | 302 | } |
305 | 303 | ||
306 | 304 | ||
307 | public static void listChildren(Observer<ResponseBody> observer) { | 305 | public static void listChildren(Observer<ResponseBody> observer) { |
308 | setSubscribe(service_url.listChildren(getHeader()), observer); | 306 | setSubscribe(service_url.listChildren(getHeader()), observer); |
309 | } | 307 | } |
310 | 308 | ||
311 | public static void listStudent(Observer<ResponseBody> observer) { | 309 | public static void listStudent(Observer<ResponseBody> observer) { |
312 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 310 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
313 | } | 311 | } |
314 | 312 | ||
315 | public static void listRecord(Observer<ResponseBody> observer) { | 313 | public static void listRecord(Observer<ResponseBody> observer) { |
316 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 314 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
317 | } | 315 | } |
318 | 316 | ||
319 | 317 | ||
320 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { | 318 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { |
321 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | 319 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); |
322 | } | 320 | } |
323 | 321 | ||
324 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { | 322 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { |
325 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | 323 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); |
326 | } | 324 | } |
327 | 325 | ||
328 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { | 326 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { |
329 | setSubscribe(service_url.getError(getHeader(), map), observer); | 327 | setSubscribe(service_url.getError(getHeader(), map), observer); |
330 | } | 328 | } |
331 | 329 | ||
332 | 330 | ||
333 | public static RequestBody getMapRequestBody(Map map) { | 331 | public static RequestBody getMapRequestBody(Map map) { |
334 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | 332 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); |
335 | } | 333 | } |
336 | 334 | ||
337 | 335 | ||
338 | public static RequestBody getArrayRequestBody(List list) { | 336 | public static RequestBody getArrayRequestBody(List list) { |
339 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | 337 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); |
340 | } | 338 | } |
341 | 339 | ||
342 | public static RequestBody getFileRequestBody(File file) { | 340 | public static RequestBody getFileRequestBody(File file) { |
343 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | 341 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); |
344 | } | 342 | } |
345 | 343 | ||
346 | public static RequestBody getFileRequestBody(byte[] bytes) { | 344 | public static RequestBody getFileRequestBody(byte[] bytes) { |
347 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | 345 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); |
348 | } | 346 | } |
349 | 347 | ||
350 | public static RequestBody getObjectRequestBody(Object obj) { | 348 | public static RequestBody getObjectRequestBody(Object obj) { |
351 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | 349 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); |
352 | } | 350 | } |
353 | 351 | ||
354 | public static RequestBody getStringRequestBody(String str) { | 352 | public static RequestBody getStringRequestBody(String str) { |
355 | return RequestBody.create(MediaType.parse("text/plain"), str); | 353 | return RequestBody.create(MediaType.parse("text/plain"), str); |
356 | } | 354 | } |
357 | 355 | ||
358 | 356 | ||
359 | /** | 357 | /** |
360 | * 插入观察者 | 358 | * 插入观察者 |
361 | * | 359 | * |
362 | * @param observable | 360 | * @param observable |
363 | * @param observer | 361 | * @param observer |
364 | * @param <T> | 362 | * @param <T> |
365 | */ | 363 | */ |
366 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | 364 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { |
367 | observable.subscribeOn(Schedulers.io())//子线程访问网络 | 365 | observable.subscribeOn(Schedulers.io())//子线程访问网络 |