Commit 66afddedbad0cbf77732c0f72b627efc8f466c89
1 parent
2bbfadef84
Exists in
master
教师端,UI修改
Showing
48 changed files
with
2061 additions
and
191 deletions
Show diff stats
app/src/main/AndroidManifest.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:tools="http://schemas.android.com/tools" | 3 | xmlns:tools="http://schemas.android.com/tools" |
4 | package="com.hjx.parent"> | 4 | package="com.hjx.parent"> |
5 | 5 | ||
6 | 6 | ||
7 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> | 7 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> |
8 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> | 8 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> |
9 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> | 9 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> |
10 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> | 10 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> |
11 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> | 11 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> |
12 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | 12 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
13 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | 13 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
14 | <uses-permission android:name="android.permission.INTERNET" /> | 14 | <uses-permission android:name="android.permission.INTERNET" /> |
15 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> | 15 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> |
16 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 16 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
17 | 17 | ||
18 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | 18 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> |
19 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 19 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
20 | <uses-permission android:name="android.permission.WAKE_LOCK" /> | 20 | <uses-permission android:name="android.permission.WAKE_LOCK" /> |
21 | <uses-permission android:name="android.permission.CAMERA" /> | 21 | <uses-permission android:name="android.permission.CAMERA" /> |
22 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | 22 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> |
23 | <uses-permission android:name="android.permission.VIBRATE" /> | 23 | <uses-permission android:name="android.permission.VIBRATE" /> |
24 | <uses-permission | 24 | <uses-permission |
25 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" | 25 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" |
26 | tools:ignore="ScopedStorage" /> | 26 | tools:ignore="ScopedStorage" /> |
27 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> | 27 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> |
28 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> | 28 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> |
29 | 29 | ||
30 | <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" | 30 | <uses-permission |
31 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" | ||
31 | tools:ignore="ScopedStorage" /> | 32 | tools:ignore="ScopedStorage" /> |
33 | |||
32 | <application | 34 | <application |
33 | android:name=".App" | 35 | android:name=".App" |
34 | android:allowBackup="true" | 36 | android:allowBackup="true" |
35 | android:icon="@mipmap/icon" | 37 | android:icon="@mipmap/icon" |
36 | android:label="@string/app_name" | 38 | android:label="@string/app_name" |
37 | android:networkSecurityConfig="@xml/network_security_config" | 39 | android:networkSecurityConfig="@xml/network_security_config" |
38 | android:supportsRtl="true" | 40 | android:supportsRtl="true" |
39 | android:theme="@style/Theme.Parent"> | 41 | android:theme="@style/Theme.Parent"> |
40 | <activity | 42 | <activity |
41 | android:name=".LoginActivity" | 43 | android:name=".LoginActivity" |
42 | android:exported="true" | 44 | android:exported="true" |
43 | android:theme="@style/ThemeSplash"> | 45 | android:theme="@style/ThemeSplash"> |
44 | <intent-filter> | 46 | <intent-filter> |
45 | <action android:name="android.intent.action.MAIN" /> | 47 | <action android:name="android.intent.action.MAIN" /> |
46 | <category android:name="android.intent.category.LAUNCHER" /> | 48 | <category android:name="android.intent.category.LAUNCHER" /> |
47 | </intent-filter> | 49 | </intent-filter> |
48 | </activity> | 50 | </activity> |
49 | <activity | 51 | <activity |
50 | android:name=".MainActivity" | 52 | android:name=".MainActivity" |
51 | android:launchMode="singleTask" | 53 | android:launchMode="singleTask" |
52 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 54 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
53 | <activity | 55 | <activity |
54 | android:name=".RegisterActivity" | 56 | android:name=".RegisterActivity" |
55 | android:theme="@style/ThemeSplash" /> | 57 | android:theme="@style/ThemeSplash" /> |
56 | <activity | 58 | <activity |
57 | android:name=".UserActivity" | 59 | android:name=".UserActivity" |
58 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 60 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
59 | <activity | 61 | <activity |
60 | android:name=".YinsiActivity" | 62 | android:name=".YinsiActivity" |
61 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 63 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
62 | <activity | 64 | <activity |
63 | android:name=".QRActivity" | 65 | android:name=".QRActivity" |
64 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 66 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
65 | <activity | 67 | <activity |
66 | android:name=".AddStudentActivity" | 68 | android:name=".AddStudentActivity" |
67 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 69 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
68 | <activity | 70 | <activity |
69 | android:name=".NickActivity" | 71 | android:name=".NickActivity" |
70 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 72 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
71 | <activity | 73 | <activity |
72 | android:name=".SexActivity" | 74 | android:name=".SexActivity" |
73 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 75 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
74 | <activity | 76 | <activity |
75 | android:name=".NianActivity" | 77 | android:name=".NianActivity" |
76 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 78 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
77 | <activity | 79 | <activity |
78 | android:name=".ShenActivity" | 80 | android:name=".ShenActivity" |
79 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 81 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
80 | <activity | 82 | <activity |
81 | android:name=".UserAgreementActivity" | 83 | android:name=".UserAgreementActivity" |
82 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 84 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
83 | <activity | 85 | <activity |
84 | android:name=".AccountActivity" | 86 | android:name=".AccountActivity" |
85 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 87 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
86 | 88 | ||
87 | <activity | 89 | <activity |
88 | android:name=".ChangePwdActivity" | 90 | android:name=".ChangePwdActivity" |
89 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 91 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
90 | <activity | 92 | <activity |
91 | android:name=".EditStudentActivity" | 93 | android:name=".EditStudentActivity" |
92 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 94 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
93 | <activity | 95 | <activity |
94 | android:name=".ChooseActivity" | 96 | android:name=".ChooseActivity" |
95 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 97 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
96 | <activity | 98 | <activity |
97 | android:name=".AddTeacherActivity" | 99 | android:name=".AddTeacherActivity" |
98 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 100 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
99 | <activity | 101 | <activity |
100 | android:name=".ErrorBookActivity" | 102 | android:name=".ErrorBookActivity" |
101 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 103 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
102 | <activity | 104 | <activity |
103 | android:name=".ImageActivity" | 105 | android:name=".ImageActivity" |
104 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 106 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
105 | <activity | 107 | <activity |
106 | android:name=".ImageEditActivity" | 108 | android:name=".ImageEditActivity" |
107 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 109 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
108 | <activity | 110 | <activity |
109 | android:name=".ImageSelectActivity" | 111 | android:name=".ImageSelectActivity" |
110 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 112 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
111 | <activity | 113 | <activity |
112 | android:name=".AddSuccessActivity" | 114 | android:name=".AddSuccessActivity" |
113 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 115 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
114 | <activity | 116 | <activity |
115 | android:name=".ErrorListActivity" | 117 | android:name=".ErrorListActivity" |
116 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 118 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
117 | <activity | 119 | <activity |
118 | android:name=".ErrorDetailActivity" | 120 | android:name=".ErrorDetailActivity" |
119 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 121 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
122 | <activity | ||
123 | android:name=".TeacherChooseActivity" | ||
124 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | ||
125 | <activity | ||
126 | android:name=".TeacherMainActivity" | ||
127 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | ||
120 | 128 | ||
121 | <provider | 129 | <provider |
122 | android:name="androidx.core.content.FileProvider" | 130 | android:name="androidx.core.content.FileProvider" |
123 | android:authorities="com.hjx.parent.fileprovider" | 131 | android:authorities="com.hjx.parent.fileprovider" |
124 | android:exported="false" | 132 | android:exported="false" |
125 | android:grantUriPermissions="true" | 133 | android:grantUriPermissions="true" |
126 | tools:replace="android:authorities"> | 134 | tools:replace="android:authorities"> |
127 | <meta-data | 135 | <meta-data |
128 | android:name="android.support.FILE_PROVIDER_PATHS" | 136 | android:name="android.support.FILE_PROVIDER_PATHS" |
129 | android:resource="@xml/file_provider_paths" | 137 | android:resource="@xml/file_provider_paths" |
130 | tools:replace="android:resource" /> | 138 | tools:replace="android:resource" /> |
131 | </provider> | 139 | </provider> |
132 | </application> | 140 | </application> |
133 | 141 | ||
134 | </manifest> | 142 | </manifest> |
app/src/main/java/com/hjx/parent/ChooseActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.text.TextUtils; | 4 | import android.text.TextUtils; |
5 | import android.view.View; | 5 | import android.view.View; |
6 | import android.widget.ImageView; | 6 | import android.widget.ImageView; |
7 | import android.widget.ListView; | ||
7 | 8 | ||
8 | import androidx.annotation.NonNull; | 9 | import androidx.annotation.NonNull; |
9 | import androidx.recyclerview.widget.LinearLayoutManager; | 10 | import androidx.recyclerview.widget.LinearLayoutManager; |
10 | import androidx.recyclerview.widget.RecyclerView; | 11 | import androidx.recyclerview.widget.RecyclerView; |
11 | 12 | ||
12 | import com.bumptech.glide.Glide; | 13 | import com.bumptech.glide.Glide; |
13 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 14 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
14 | import com.bumptech.glide.request.RequestOptions; | 15 | import com.bumptech.glide.request.RequestOptions; |
15 | import com.chad.library.adapter.base.BaseQuickAdapter; | 16 | import com.chad.library.adapter.base.BaseQuickAdapter; |
16 | import com.chad.library.adapter.base.BaseViewHolder; | 17 | import com.chad.library.adapter.base.BaseViewHolder; |
17 | import com.google.gson.Gson; | 18 | import com.google.gson.Gson; |
18 | import com.hjx.parent.bean.StudentBean; | 19 | import com.hjx.parent.bean.StudentBean; |
19 | import com.prws.common.base.BaseActivity; | 20 | import com.prws.common.base.BaseActivity; |
20 | import com.prws.common.base.BasePresenter; | 21 | import com.prws.common.base.BasePresenter; |
21 | import com.prws.common.net.NetWorks; | 22 | import com.prws.common.net.NetWorks; |
22 | import com.prws.common.utils.LogUtil; | 23 | import com.prws.common.utils.LogUtil; |
23 | import com.prws.common.utils.ScreenUtils; | 24 | import com.prws.common.utils.ScreenUtils; |
24 | import com.prws.common.utils.SharedPreferencesUtil; | 25 | import com.prws.common.utils.SharedPreferencesUtil; |
25 | 26 | ||
26 | import org.json.JSONArray; | 27 | import org.json.JSONArray; |
27 | import org.json.JSONObject; | 28 | import org.json.JSONObject; |
28 | 29 | ||
29 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
30 | 31 | ||
31 | import butterknife.BindView; | 32 | import butterknife.BindView; |
32 | import butterknife.OnClick; | 33 | import butterknife.OnClick; |
33 | import io.reactivex.Observer; | 34 | import io.reactivex.Observer; |
34 | import io.reactivex.disposables.Disposable; | 35 | import io.reactivex.disposables.Disposable; |
35 | import okhttp3.ResponseBody; | 36 | import okhttp3.ResponseBody; |
36 | 37 | ||
37 | public class ChooseActivity extends BaseActivity { | 38 | public class ChooseActivity extends BaseActivity { |
38 | @BindView(R.id.recycle) | 39 | @BindView(R.id.recycle) |
39 | RecyclerView recycle; | 40 | RecyclerView recycle; |
40 | private int select = 0; | 41 | private int select = 0; |
41 | 42 | ||
42 | @Override | 43 | @Override |
43 | protected int layoutResId() { | 44 | protected int layoutResId() { |
44 | return R.layout.choose_activity; | 45 | return R.layout.choose_activity; |
45 | } | 46 | } |
46 | 47 | ||
47 | @Override | 48 | @Override |
48 | public Object getContract() { | 49 | public Object getContract() { |
49 | return null; | 50 | return null; |
50 | } | 51 | } |
51 | 52 | ||
52 | @Override | 53 | @Override |
53 | public BasePresenter getPresenter() { | 54 | public BasePresenter getPresenter() { |
54 | return null; | 55 | return null; |
55 | } | 56 | } |
56 | 57 | ||
57 | @Override | 58 | @Override |
58 | protected void initView() { | 59 | protected void initView() { |
59 | 60 | ||
60 | } | 61 | } |
61 | 62 | ||
62 | @Override | 63 | @Override |
63 | protected void initListener() { | 64 | protected void initListener() { |
64 | 65 | ||
65 | } | 66 | } |
66 | 67 | ||
67 | @Override | 68 | @Override |
68 | protected void initData() { | 69 | protected void initData() { |
69 | 70 | ||
70 | } | 71 | } |
71 | 72 | ||
72 | @Override | 73 | @Override |
73 | public void onNetChanged(int netWorkState) { | 74 | public void onNetChanged(int netWorkState) { |
74 | 75 | ||
75 | } | 76 | } |
76 | 77 | ||
77 | @Override | 78 | @Override |
78 | protected void onResume() { | 79 | protected void onResume() { |
79 | super.onResume(); | 80 | super.onResume(); |
80 | loadChildList(); | 81 | loadChildList(); |
81 | } | 82 | } |
82 | 83 | ||
83 | ArrayList<StudentBean> alist = new ArrayList<>(); | 84 | ArrayList<StudentBean> alist = new ArrayList<>(); |
84 | 85 | ||
85 | public void loadChildList() { | 86 | public void loadChildList() { |
86 | NetWorks.listChildren(new Observer<ResponseBody>() { | 87 | NetWorks.listChildren(new Observer<ResponseBody>() { |
87 | @Override | 88 | @Override |
88 | public void onSubscribe(Disposable d) { | 89 | public void onSubscribe(Disposable d) { |
89 | 90 | ||
90 | } | 91 | } |
91 | 92 | ||
92 | @Override | 93 | @Override |
93 | public void onNext(ResponseBody responseBody) { | 94 | public void onNext(ResponseBody responseBody) { |
94 | try { | 95 | try { |
95 | String str = responseBody.string().toString(); | 96 | String str = responseBody.string().toString(); |
96 | LogUtil.e("TAG", "----" + str); | 97 | LogUtil.e("TAG", "----" + str); |
97 | JSONObject jo = new JSONObject(str); | 98 | JSONObject jo = new JSONObject(str); |
98 | boolean isSucceed = jo.getBoolean("success"); | 99 | boolean isSucceed = jo.getBoolean("success"); |
99 | if (isSucceed) { | 100 | if (isSucceed) { |
100 | JSONArray jarr = jo.getJSONArray("data"); | 101 | JSONArray jarr = jo.getJSONArray("data"); |
101 | alist.clear(); | 102 | alist.clear(); |
102 | for (int i = 0; i < jarr.length(); i++) { | 103 | for (int i = 0; i < jarr.length(); i++) { |
103 | JSONObject jo2 = jarr.getJSONObject(i); | 104 | JSONObject jo2 = jarr.getJSONObject(i); |
104 | Gson gson = new Gson(); | 105 | Gson gson = new Gson(); |
105 | StudentBean sb = gson.fromJson(jo2.toString(), StudentBean.class); | 106 | StudentBean sb = gson.fromJson(jo2.toString(), StudentBean.class); |
106 | alist.add(sb); | 107 | alist.add(sb); |
107 | } | 108 | } |
108 | loadList(); | 109 | loadList(); |
109 | } else { | 110 | } else { |
110 | 111 | ||
111 | } | 112 | } |
112 | } catch (Exception e) { | 113 | } catch (Exception e) { |
113 | e.printStackTrace(); | 114 | e.printStackTrace(); |
114 | } | 115 | } |
115 | } | 116 | } |
116 | 117 | ||
117 | @Override | 118 | @Override |
118 | public void onError(Throwable e) { | 119 | public void onError(Throwable e) { |
119 | 120 | ||
120 | } | 121 | } |
121 | 122 | ||
122 | @Override | 123 | @Override |
123 | public void onComplete() { | 124 | public void onComplete() { |
124 | 125 | ||
125 | } | 126 | } |
126 | }); | 127 | }); |
127 | } | 128 | } |
128 | 129 | ||
129 | public void loadList() { | 130 | public void loadList() { |
130 | StudentBean sb = new StudentBean(); | 131 | StudentBean sb = new StudentBean(); |
131 | sb.setNickName("添加学生"); | 132 | sb.setNickName("添加学生"); |
132 | alist.add(sb); | 133 | alist.add(sb); |
133 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 134 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
134 | try { | 135 | try { |
135 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); | 136 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); |
136 | for (int i = 0; i < alist.size(); i++) { | 137 | for (int i = 0; i < alist.size(); i++) { |
137 | if (studentBean.getStuId().equals(alist.get(i).getStuId())) { | 138 | if (studentBean.getStuId().equals(alist.get(i).getStuId())) { |
138 | select = i; | 139 | select = i; |
139 | break; | 140 | break; |
140 | } | 141 | } |
141 | } | 142 | } |
142 | } catch (Exception e) { | 143 | } catch (Exception e) { |
143 | 144 | ||
144 | } | 145 | } |
145 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_child_choose, alist) { | 146 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_child_choose, alist) { |
146 | @Override | 147 | @Override |
148 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | ||
149 | |||
150 | } | ||
151 | |||
152 | @Override | ||
147 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 153 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
148 | StudentBean studentBean = alist.get(item.getAdapterPosition()); | 154 | StudentBean studentBean = alist.get(item.getAdapterPosition()); |
149 | item.setText(R.id.tv_name, studentBean.getNickName()); | 155 | item.setText(R.id.tv_name, studentBean.getNickName()); |
150 | if (TextUtils.isEmpty(studentBean.getStuId())) { | 156 | if (TextUtils.isEmpty(studentBean.getStuId())) { |
151 | item.setVisible(R.id.rl_add, true); | 157 | item.setVisible(R.id.rl_add, true); |
152 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 158 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
153 | @Override | 159 | @Override |
154 | public void onClick(View view) { | 160 | public void onClick(View view) { |
155 | startActivity(new Intent(ChooseActivity.this, AddStudentActivity.class)); | 161 | startActivity(new Intent(ChooseActivity.this, AddStudentActivity.class)); |
156 | } | 162 | } |
157 | }); | 163 | }); |
158 | } else { | 164 | } else { |
159 | item.setBackgroundRes(R.id.rl_child, select == item.getAdapterPosition() ? R.drawable.bg_solid_white_10_or : R.drawable.bg_solid_white_10); | 165 | item.setBackgroundRes(R.id.rl_child, select == item.getAdapterPosition() ? R.drawable.bg_solid_white_10_or : R.drawable.bg_solid_white_10); |
160 | item.setImageResource(R.id.iv_select, select == item.getAdapterPosition() ? R.mipmap.gx : R.mipmap.wsyq); | 166 | item.setImageResource(R.id.iv_select, select == item.getAdapterPosition() ? R.mipmap.gx : R.mipmap.wsyq); |
161 | item.setVisible(R.id.rl_add, false); | 167 | item.setVisible(R.id.rl_add, false); |
162 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | 168 | if (TextUtils.isEmpty(studentBean.getPhoto())) { |
163 | item.setImageResource(R.id.iv_avatar, studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | 169 | item.setImageResource(R.id.iv_avatar, studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); |
164 | } else { | 170 | } else { |
165 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(ChooseActivity.this, 45)); | 171 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(ChooseActivity.this, 45)); |
166 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 172 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
167 | Glide.with(ChooseActivity.this).load(studentBean.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_avatar)); | 173 | Glide.with(ChooseActivity.this).load(studentBean.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_avatar)); |
168 | } | 174 | } |
169 | item.setVisible(R.id.iv_vip, !"虚拟".equals(studentBean.getTeacherIdentity())); | 175 | item.setVisible(R.id.iv_vip, !"虚拟".equals(studentBean.getTeacherIdentity())); |
170 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 176 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
171 | @Override | 177 | @Override |
172 | public void onClick(View view) { | 178 | public void onClick(View view) { |
173 | select = item.getAdapterPosition(); | 179 | select = item.getAdapterPosition(); |
174 | notifyDataSetChanged(); | 180 | notifyDataSetChanged(); |
175 | } | 181 | } |
176 | }); | 182 | }); |
177 | } | 183 | } |
178 | } | 184 | } |
179 | }; | 185 | }; |
180 | recycle.setLayoutManager(new LinearLayoutManager(ChooseActivity.this, LinearLayoutManager.VERTICAL, false)); | 186 | recycle.setLayoutManager(new LinearLayoutManager(ChooseActivity.this, LinearLayoutManager.VERTICAL, false)); |
181 | recycle.setAdapter(adapter); | 187 | recycle.setAdapter(adapter); |
182 | } | 188 | } |
183 | 189 | ||
184 | @OnClick(R.id.tv_confirm) | 190 | @OnClick(R.id.tv_confirm) |
185 | public void confirm(View view) { | 191 | public void confirm(View view) { |
186 | if (alist.size() > 0 && alist.size() - 1 >= select && alist.get(select) != null) { | 192 | if (alist.size() > 0 && alist.size() - 1 >= select && alist.get(select) != null) { |
187 | StudentBean studentBean = alist.get(select); | 193 | StudentBean studentBean = alist.get(select); |
188 | if (studentBean.getStuId() != null) { | 194 | if (studentBean.getStuId() != null) { |
189 | Intent intent = new Intent(ChooseActivity.this, MainActivity.class); | 195 | if (getIntent().getBooleanExtra("needBack", false)) { |
190 | SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); | 196 | SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); |
191 | startActivity(intent); | 197 | } else { |
198 | Intent intent = new Intent(ChooseActivity.this, MainActivity.class); | ||
199 | SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); | ||
200 | startActivity(intent); | ||
201 | } | ||
192 | finish(); | 202 | finish(); |
193 | } | 203 | } |
194 | } | 204 | } |
195 | } | 205 | } |
196 | } | 206 | } |
197 | 207 |
app/src/main/java/com/hjx/parent/ErrorListActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.DialogInterface; | 4 | import android.content.DialogInterface; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
8 | import android.graphics.Color; | 8 | import android.graphics.Color; |
9 | import android.graphics.drawable.Drawable; | 9 | import android.graphics.drawable.Drawable; |
10 | import android.net.Uri; | 10 | import android.net.Uri; |
11 | import android.os.Bundle; | 11 | import android.os.Bundle; |
12 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
14 | import android.util.Log; | 14 | import android.util.Log; |
15 | import android.view.KeyEvent; | 15 | import android.view.KeyEvent; |
16 | import android.view.LayoutInflater; | 16 | import android.view.LayoutInflater; |
17 | import android.view.View; | 17 | import android.view.View; |
18 | import android.widget.CompoundButton; | 18 | import android.widget.CompoundButton; |
19 | import android.widget.RadioButton; | 19 | import android.widget.RadioButton; |
20 | import android.widget.RadioGroup; | 20 | import android.widget.RadioGroup; |
21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
23 | 23 | ||
24 | import androidx.annotation.Nullable; | 24 | import androidx.annotation.Nullable; |
25 | import androidx.core.content.FileProvider; | 25 | import androidx.core.content.FileProvider; |
26 | import androidx.recyclerview.widget.GridLayoutManager; | 26 | import androidx.recyclerview.widget.GridLayoutManager; |
27 | import androidx.recyclerview.widget.LinearLayoutManager; | 27 | import androidx.recyclerview.widget.LinearLayoutManager; |
28 | import androidx.recyclerview.widget.RecyclerView; | 28 | import androidx.recyclerview.widget.RecyclerView; |
29 | 29 | ||
30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
31 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
32 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
33 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
34 | import com.hjx.parent.adapter.ErrorAdapter; | 34 | import com.hjx.parent.adapter.ErrorAdapter; |
35 | import com.hjx.parent.adapter.FilterAdapter; | 35 | import com.hjx.parent.adapter.FilterAdapter; |
36 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; | 36 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; |
37 | import com.hjx.parent.bean.StudentBean; | 37 | import com.hjx.parent.bean.StudentBean; |
38 | import com.hjx.parent.databinding.ActivityErrorListBinding; | 38 | import com.hjx.parent.databinding.ActivityErrorListBinding; |
39 | import com.hjx.parent.dialog.ErrorEditDialog; | 39 | import com.hjx.parent.dialog.ErrorEditDialog; |
40 | import com.hjx.parent.dialog.TipDialog; | 40 | import com.hjx.parent.dialog.TipDialog; |
41 | import com.prws.common.bean.GradeAndSubject; | 41 | import com.prws.common.bean.GradeAndSubject; |
42 | import com.prws.common.bean.PageInfo; | 42 | import com.prws.common.bean.PageInfo; |
43 | import com.prws.common.bean.ResponseResult; | 43 | import com.prws.common.bean.ResponseResult; |
44 | import com.prws.common.bean.Subject; | 44 | import com.prws.common.bean.Subject; |
45 | import com.prws.common.bean.TopicBean; | 45 | import com.prws.common.bean.TopicBean; |
46 | import com.prws.common.net.NetWorks; | 46 | import com.prws.common.net.NetWorks; |
47 | import com.prws.common.utils.BitmapUtils; | 47 | import com.prws.common.utils.BitmapUtils; |
48 | import com.prws.common.utils.CommonUtil; | 48 | import com.prws.common.utils.CommonUtil; |
49 | import com.prws.common.utils.SharedPreferencesUtil; | 49 | import com.prws.common.utils.SharedPreferencesUtil; |
50 | import com.prws.common.utils.dialog.MyButtomDialog; | 50 | import com.prws.common.utils.dialog.MyButtomDialog; |
51 | import com.zhangteng.imagepicker.bean.ImageInfo; | 51 | import com.zhangteng.imagepicker.bean.ImageInfo; |
52 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 52 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
53 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 53 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
54 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 54 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
55 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 55 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
56 | import com.zhangteng.utils.IHandlerCallBack; | 56 | import com.zhangteng.utils.IHandlerCallBack; |
57 | 57 | ||
58 | import java.io.File; | 58 | import java.io.File; |
59 | import java.util.ArrayList; | 59 | import java.util.ArrayList; |
60 | import java.util.HashMap; | 60 | import java.util.HashMap; |
61 | import java.util.List; | 61 | import java.util.List; |
62 | import java.util.Map; | 62 | import java.util.Map; |
63 | 63 | ||
64 | import io.reactivex.Observer; | 64 | import io.reactivex.Observer; |
65 | import io.reactivex.disposables.Disposable; | 65 | import io.reactivex.disposables.Disposable; |
66 | 66 | ||
67 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { | 67 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { |
68 | private TextView last; | 68 | private TextView last; |
69 | private String subject; | 69 | private String subject; |
70 | private String grade; | 70 | private String grade; |
71 | private String manger; | 71 | private String manger; |
72 | private String type = "全部"; | 72 | private String type = "全部"; |
73 | private String time = "全部"; | 73 | private String time = "全部"; |
74 | private FilterAdapter filterAdapter; | 74 | private FilterAdapter filterAdapter; |
75 | StudentBean studentBean; | 75 | StudentBean studentBean; |
76 | private int page = 1; | 76 | private int page = 1; |
77 | private ErrorAdapter adapter; | 77 | private ErrorAdapter adapter; |
78 | private int total; | 78 | private int total; |
79 | private int REQUEST_CODE_IMAGE = 123; | 79 | private int REQUEST_CODE_IMAGE = 123; |
80 | private String filePath; | 80 | private String filePath; |
81 | 81 | ||
82 | @Override | 82 | @Override |
83 | public void initView(Bundle savedInstanceState) { | 83 | public void initView(Bundle savedInstanceState) { |
84 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 84 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
85 | try { | 85 | try { |
86 | studentBean = new Gson().fromJson(student, StudentBean.class); | 86 | studentBean = new Gson().fromJson(student, StudentBean.class); |
87 | } catch (Exception e) { | 87 | } catch (Exception e) { |
88 | 88 | ||
89 | } | 89 | } |
90 | binding.ivBack.setOnClickListener(this); | 90 | binding.ivBack.setOnClickListener(this); |
91 | binding.tvFilterGrade.setOnClickListener(this); | 91 | binding.tvFilterGrade.setOnClickListener(this); |
92 | binding.tvFilterSubject.setOnClickListener(this); | 92 | binding.tvFilterSubject.setOnClickListener(this); |
93 | binding.tvFilterMore.setOnClickListener(this); | 93 | binding.tvFilterMore.setOnClickListener(this); |
94 | binding.tvFilterManage.setOnClickListener(this); | 94 | binding.tvFilterManage.setOnClickListener(this); |
95 | binding.tvEdit.setOnClickListener(this); | 95 | binding.tvEdit.setOnClickListener(this); |
96 | binding.tvAdd.setOnClickListener(this); | 96 | binding.tvAdd.setOnClickListener(this); |
97 | binding.llDelete.setOnClickListener(this); | 97 | binding.llDelete.setOnClickListener(this); |
98 | binding.tvSave.setOnClickListener(this); | 98 | binding.tvSave.setOnClickListener(this); |
99 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); | ||
99 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | 100 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
100 | @Override | 101 | @Override |
101 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | 102 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
102 | adapter.checkAll(isChecked); | 103 | adapter.checkAll(isChecked); |
103 | } | 104 | } |
104 | }); | 105 | }); |
105 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); | 106 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); |
106 | timeButton.setChecked(true); | 107 | timeButton.setChecked(true); |
107 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 108 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
108 | @Override | 109 | @Override |
109 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 110 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
110 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 111 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
111 | time = rcheck.getText().toString(); | 112 | time = rcheck.getText().toString(); |
112 | refreshError(); | 113 | refreshError(); |
113 | } | 114 | } |
114 | }); | 115 | }); |
115 | 116 | ||
116 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); | 117 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); |
117 | typeButton.setChecked(true); | 118 | typeButton.setChecked(true); |
118 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 119 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
119 | @Override | 120 | @Override |
120 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 121 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
121 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 122 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
122 | type = rcheck.getText().toString(); | 123 | type = rcheck.getText().toString(); |
123 | refreshError(); | 124 | refreshError(); |
124 | } | 125 | } |
125 | }); | 126 | }); |
126 | refreshError(); | 127 | refreshError(); |
128 | binding.ivChange.setOnClickListener(new View.OnClickListener() { | ||
129 | @Override | ||
130 | public void onClick(View v) { | ||
131 | if (SharedPreferencesUtil.getData("role", "").equals("parent")) { | ||
132 | Intent intent = new Intent(context, ChooseActivity.class); | ||
133 | intent.putExtra("needBack", true); | ||
134 | startActivity(intent); | ||
135 | } else { | ||
136 | Intent intent = new Intent(context, TeacherChooseActivity.class); | ||
137 | intent.putExtra("needBack", true); | ||
138 | startActivity(intent); | ||
139 | } | ||
140 | } | ||
141 | }); | ||
127 | } | 142 | } |
128 | 143 | ||
129 | @Override | 144 | @Override |
130 | protected ActivityErrorListBinding getViewBinding() { | 145 | protected ActivityErrorListBinding getViewBinding() { |
131 | return ActivityErrorListBinding.inflate(getLayoutInflater()); | 146 | return ActivityErrorListBinding.inflate(getLayoutInflater()); |
132 | } | 147 | } |
133 | 148 | ||
134 | 149 | ||
135 | |||
136 | @Override | 150 | @Override |
137 | public void onClick(View v) { | 151 | public void onClick(View v) { |
138 | switch (v.getId()) { | 152 | switch (v.getId()) { |
139 | case R.id.iv_back: | 153 | case R.id.iv_back: |
140 | finish(); | 154 | finish(); |
141 | break; | 155 | break; |
142 | case R.id.tv_filter_grade: | 156 | case R.id.tv_filter_grade: |
143 | List<String> grades = new ArrayList<>(); | 157 | List<String> grades = new ArrayList<>(); |
144 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | 158 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { |
145 | grades.add(gradeAndSubject.getGrade().getGrade()); | 159 | grades.add(gradeAndSubject.getGrade().getGrade()); |
146 | } | 160 | } |
147 | grades.add("全部"); | 161 | grades.add("全部"); |
148 | setFilterAdapter(grades, binding.tvFilterGrade, grade); | 162 | setFilterAdapter(grades, binding.tvFilterGrade, grade); |
149 | break; | 163 | break; |
150 | case R.id.tv_filter_subject: | 164 | case R.id.tv_filter_subject: |
151 | List<String> subjects = new ArrayList<>(); | 165 | List<String> subjects = new ArrayList<>(); |
152 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | 166 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { |
153 | for (Subject subject : gradeAndSubject.getSubjects()) { | 167 | for (Subject subject : gradeAndSubject.getSubjects()) { |
154 | if (!subjects.contains(subject.getSubject())) { | 168 | if (!subjects.contains(subject.getSubject())) { |
155 | subjects.add(subject.getSubject()); | 169 | subjects.add(subject.getSubject()); |
156 | } | 170 | } |
157 | } | 171 | } |
158 | } | 172 | } |
159 | subjects.add("全部"); | 173 | subjects.add("全部"); |
160 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); | 174 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); |
161 | break; | 175 | break; |
162 | case R.id.tv_filter_manage: | 176 | case R.id.tv_filter_manage: |
163 | List<String> manages = new ArrayList<>(); | 177 | List<String> manages = new ArrayList<>(); |
164 | manages.add("已掌握"); | 178 | manages.add("已掌握"); |
165 | manages.add("未掌握"); | 179 | manages.add("未掌握"); |
166 | manages.add("全部"); | 180 | manages.add("全部"); |
167 | setFilterAdapter(manages, binding.tvFilterManage, manger); | 181 | setFilterAdapter(manages, binding.tvFilterManage, manger); |
168 | break; | 182 | break; |
169 | case R.id.tv_filter_more: | 183 | case R.id.tv_filter_more: |
170 | showFilterMore(); | 184 | showFilterMore(); |
171 | break; | 185 | break; |
172 | case R.id.tv_edit: | 186 | case R.id.tv_edit: |
173 | if (adapter.edit) { | 187 | if (adapter.edit) { |
174 | adapter.setEdit(false); | 188 | adapter.setEdit(false); |
175 | binding.tvSave.setVisibility(View.GONE); | 189 | binding.tvSave.setVisibility(View.GONE); |
176 | binding.tvAdd.setVisibility(View.VISIBLE); | 190 | binding.tvAdd.setVisibility(View.VISIBLE); |
177 | binding.checkbox.setVisibility(View.GONE); | 191 | binding.checkbox.setVisibility(View.GONE); |
178 | binding.llDelete.setVisibility(View.GONE); | 192 | binding.llDelete.setVisibility(View.GONE); |
179 | binding.ivBack.setVisibility(View.VISIBLE); | 193 | binding.ivBack.setVisibility(View.VISIBLE); |
180 | binding.tvEdit.setText("编辑"); | 194 | binding.tvEdit.setText("编辑"); |
181 | } else { | 195 | } else { |
182 | adapter.setEdit(true); | 196 | adapter.setEdit(true); |
183 | binding.tvSave.setVisibility(View.VISIBLE); | 197 | binding.tvSave.setVisibility(View.VISIBLE); |
184 | binding.tvAdd.setVisibility(View.GONE); | 198 | binding.tvAdd.setVisibility(View.GONE); |
185 | binding.llDelete.setVisibility(View.VISIBLE); | 199 | binding.llDelete.setVisibility(View.VISIBLE); |
186 | binding.checkbox.setVisibility(View.VISIBLE); | 200 | binding.checkbox.setVisibility(View.VISIBLE); |
187 | binding.ivBack.setVisibility(View.GONE); | 201 | binding.ivBack.setVisibility(View.GONE); |
188 | binding.tvEdit.setText("取消"); | 202 | binding.tvEdit.setText("取消"); |
189 | } | 203 | } |
190 | adapter.notifyDataSetChanged(); | 204 | adapter.notifyDataSetChanged(); |
191 | break; | 205 | break; |
192 | case R.id.ll_delete: | 206 | case R.id.ll_delete: |
193 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { | 207 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { |
194 | @Override | 208 | @Override |
195 | public void onConfirm(Dialog dialog) { | 209 | public void onConfirm(Dialog dialog) { |
196 | deleteError(adapter.getChecKList()); | 210 | deleteError(adapter.getChecKList()); |
197 | dialog.dismiss(); | 211 | dialog.dismiss(); |
198 | } | 212 | } |
199 | 213 | ||
200 | @Override | 214 | @Override |
201 | public void onCancel(Dialog dialog) { | 215 | public void onCancel(Dialog dialog) { |
202 | dialog.dismiss(); | 216 | dialog.dismiss(); |
203 | } | 217 | } |
204 | }); | 218 | }); |
205 | break; | 219 | break; |
206 | case R.id.tv_add: | 220 | case R.id.tv_add: |
207 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { | 221 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { |
208 | XXPermissions.with(context) | 222 | XXPermissions.with(context) |
209 | // 申请多个权限 | 223 | // 申请多个权限 |
210 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) | 224 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) |
211 | .request(new OnPermissionCallback() { | 225 | .request(new OnPermissionCallback() { |
212 | @Override | 226 | @Override |
213 | public void onGranted(List<String> permissions, boolean all) { | 227 | public void onGranted(List<String> permissions, boolean all) { |
214 | if (all) { | 228 | if (all) { |
215 | //开启扫码界面 | 229 | //开启扫码界面 |
216 | showButtonDialog(); | 230 | showButtonDialog(); |
217 | } else { | 231 | } else { |
218 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | 232 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); |
219 | } | 233 | } |
220 | } | 234 | } |
221 | 235 | ||
222 | @Override | 236 | @Override |
223 | public void onDenied(List<String> permissions, boolean never) { | 237 | public void onDenied(List<String> permissions, boolean never) { |
224 | XXPermissions.startPermissionActivity(context, permissions); | 238 | XXPermissions.startPermissionActivity(context, permissions); |
225 | } | 239 | } |
226 | }); | 240 | }); |
227 | } else { | 241 | } else { |
228 | showButtonDialog(); | 242 | showButtonDialog(); |
229 | } | 243 | } |
230 | break; | 244 | break; |
231 | case R.id.tv_save: | 245 | case R.id.tv_save: |
232 | if (adapter.getChecKList().size() > 0) { | 246 | if (adapter.getChecKList().size() > 0) { |
233 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { | 247 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { |
234 | @Override | 248 | @Override |
235 | public void edit(String s, int i) { | 249 | public void edit(String s, int i) { |
236 | adapter.setEdit(false); | 250 | adapter.setEdit(false); |
237 | binding.tvSave.setVisibility(View.GONE); | 251 | binding.tvSave.setVisibility(View.GONE); |
238 | binding.tvAdd.setVisibility(View.VISIBLE); | 252 | binding.tvAdd.setVisibility(View.VISIBLE); |
239 | binding.checkbox.setVisibility(View.GONE); | 253 | binding.checkbox.setVisibility(View.GONE); |
240 | binding.llDelete.setVisibility(View.GONE); | 254 | binding.llDelete.setVisibility(View.GONE); |
241 | binding.ivBack.setVisibility(View.VISIBLE); | 255 | binding.ivBack.setVisibility(View.VISIBLE); |
242 | binding.tvEdit.setText("编辑"); | 256 | binding.tvEdit.setText("编辑"); |
243 | page = 1; | 257 | page = 1; |
244 | refreshError(); | 258 | refreshError(); |
245 | } | 259 | } |
246 | }); | 260 | }); |
247 | errorEditDialog.show(); | 261 | errorEditDialog.show(); |
248 | } | 262 | } |
249 | break; | 263 | break; |
250 | } | 264 | } |
251 | } | 265 | } |
252 | 266 | ||
253 | private void showButtonDialog() { | 267 | private void showButtonDialog() { |
254 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 268 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
255 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 269 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
256 | dialog.setContentView(bottomView); | 270 | dialog.setContentView(bottomView); |
257 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 271 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
258 | @Override | 272 | @Override |
259 | public void onClick(View view) { | 273 | public void onClick(View view) { |
260 | dialog.dismiss(); | 274 | dialog.dismiss(); |
261 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 275 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
262 | //确保有相机来处理Intent | 276 | //确保有相机来处理Intent |
263 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 277 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
264 | File photoFile = new File(filePath); | 278 | File photoFile = new File(filePath); |
265 | if (photoFile != null) { | 279 | if (photoFile != null) { |
266 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 280 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
267 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 281 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
268 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 282 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
269 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 283 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
270 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 284 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
271 | } | 285 | } |
272 | } | 286 | } |
273 | }); | 287 | }); |
274 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 288 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
275 | @Override | 289 | @Override |
276 | public void onClick(View view) { | 290 | public void onClick(View view) { |
277 | dialog.dismiss(); | 291 | dialog.dismiss(); |
278 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 292 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
279 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 293 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
280 | .multiSelect(true) //是否多选 | 294 | .multiSelect(true) //是否多选 |
281 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 295 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
282 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 296 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
283 | .maxImageSelectable(9) //图片可选择数 | 297 | .maxImageSelectable(9) //图片可选择数 |
284 | .maxHeight(1920) //图片最大高度 | 298 | .maxHeight(1920) //图片最大高度 |
285 | .maxWidth(1920) //图片最大宽度 | 299 | .maxWidth(1920) //图片最大宽度 |
286 | .maxImageSize(10) //图片最大大小Mb | 300 | .maxImageSize(10) //图片最大大小Mb |
287 | .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(); | 301 | .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(); |
288 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); | 302 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); |
289 | 303 | ||
290 | } | 304 | } |
291 | }); | 305 | }); |
292 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 306 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
293 | @Override | 307 | @Override |
294 | public void onClick(View view) { | 308 | public void onClick(View view) { |
295 | dialog.dismiss(); | 309 | dialog.dismiss(); |
296 | } | 310 | } |
297 | }); | 311 | }); |
298 | dialog.show(); | 312 | dialog.show(); |
299 | } | 313 | } |
300 | 314 | ||
301 | private void deleteError(List<TopicBean> topicBeans) { | 315 | private void deleteError(List<TopicBean> topicBeans) { |
302 | List<String> list = new ArrayList<>(); | 316 | List<String> list = new ArrayList<>(); |
303 | for (int i = 0; i < topicBeans.size(); i++) { | 317 | for (int i = 0; i < topicBeans.size(); i++) { |
304 | list.add(topicBeans.get(i).getId()); | 318 | list.add(topicBeans.get(i).getId()); |
305 | } | 319 | } |
306 | NetWorks.deleteError(list, new Observer<ResponseResult>() { | 320 | NetWorks.deleteError(list, new Observer<ResponseResult>() { |
307 | @Override | 321 | @Override |
308 | public void onSubscribe(Disposable d) { | 322 | public void onSubscribe(Disposable d) { |
309 | 323 | ||
310 | } | 324 | } |
311 | 325 | ||
312 | @Override | 326 | @Override |
313 | public void onNext(ResponseResult responseResult) { | 327 | public void onNext(ResponseResult responseResult) { |
314 | if (responseResult.getCode() == 200) { | 328 | if (responseResult.getCode() == 200) { |
315 | adapter.setEdit(false); | 329 | adapter.setEdit(false); |
316 | binding.tvSave.setVisibility(View.GONE); | 330 | binding.tvSave.setVisibility(View.GONE); |
317 | binding.tvAdd.setVisibility(View.VISIBLE); | 331 | binding.tvAdd.setVisibility(View.VISIBLE); |
318 | binding.checkbox.setVisibility(View.GONE); | 332 | binding.checkbox.setVisibility(View.GONE); |
319 | binding.llDelete.setVisibility(View.GONE); | 333 | binding.llDelete.setVisibility(View.GONE); |
320 | binding.ivBack.setVisibility(View.VISIBLE); | 334 | binding.ivBack.setVisibility(View.VISIBLE); |
321 | binding.tvEdit.setText("编辑"); | 335 | binding.tvEdit.setText("编辑"); |
322 | page = 1; | 336 | page = 1; |
323 | refreshError(); | 337 | refreshError(); |
324 | } | 338 | } |
325 | } | 339 | } |
326 | 340 | ||
327 | @Override | 341 | @Override |
328 | public void onError(Throwable e) { | 342 | public void onError(Throwable e) { |
329 | 343 | ||
330 | } | 344 | } |
331 | 345 | ||
332 | @Override | 346 | @Override |
333 | public void onComplete() { | 347 | public void onComplete() { |
334 | 348 | ||
335 | } | 349 | } |
336 | }); | 350 | }); |
337 | } | 351 | } |
338 | 352 | ||
339 | private void showFilterMore() { | 353 | private void showFilterMore() { |
340 | binding.recycleFilter.setVisibility(View.GONE); | 354 | binding.recycleFilter.setVisibility(View.GONE); |
341 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { | 355 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { |
342 | binding.llFilterMore.setVisibility(View.GONE); | 356 | binding.llFilterMore.setVisibility(View.GONE); |
343 | } else { | 357 | } else { |
344 | binding.llFilterMore.setVisibility(View.VISIBLE); | 358 | binding.llFilterMore.setVisibility(View.VISIBLE); |
345 | if (last != null) { | 359 | if (last != null) { |
346 | last.setTextColor(getColor(R.color.text_title)); | 360 | last.setTextColor(getColor(R.color.text_title)); |
347 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 361 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
348 | // 这一步必须要做,否则不会显示. | 362 | // 这一步必须要做,否则不会显示. |
349 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 363 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
350 | last.setCompoundDrawables(null, null, drawable, null); | 364 | last.setCompoundDrawables(null, null, drawable, null); |
351 | } | 365 | } |
352 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); | 366 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); |
353 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 367 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
354 | // 这一步必须要做,否则不会显示. | 368 | // 这一步必须要做,否则不会显示. |
355 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | 369 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); |
356 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); | 370 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); |
357 | last = binding.tvFilterMore; | 371 | last = binding.tvFilterMore; |
358 | } | 372 | } |
359 | } | 373 | } |
360 | 374 | ||
361 | private void setFilterAdapter(List<String> list, TextView textView, String select) { | 375 | private void setFilterAdapter(List<String> list, TextView textView, String select) { |
362 | if (TextUtils.isEmpty(select)) { | 376 | if (TextUtils.isEmpty(select)) { |
363 | select = "全部"; | 377 | select = "全部"; |
364 | } | 378 | } |
365 | binding.llFilterMore.setVisibility(View.GONE); | 379 | binding.llFilterMore.setVisibility(View.GONE); |
366 | if (last != null && last.getId() == R.id.tv_filter_more) { | 380 | if (last != null && last.getId() == R.id.tv_filter_more) { |
367 | last.setTextColor(getColor(R.color.text_title)); | 381 | last.setTextColor(getColor(R.color.text_title)); |
368 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 382 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
369 | // 这一步必须要做,否则不会显示. | 383 | // 这一步必须要做,否则不会显示. |
370 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 384 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
371 | last.setCompoundDrawables(null, null, drawable, null); | 385 | last.setCompoundDrawables(null, null, drawable, null); |
372 | } | 386 | } |
373 | if (binding.recycleFilter.getVisibility() == View.GONE) { | 387 | if (binding.recycleFilter.getVisibility() == View.GONE) { |
374 | if (filterAdapter != null) { | 388 | if (filterAdapter != null) { |
375 | filterAdapter.refresh(list, textView, select); | 389 | filterAdapter.refresh(list, textView, select); |
376 | } else { | 390 | } else { |
377 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { | 391 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { |
378 | @Override | 392 | @Override |
379 | public void onSelect(TextView type, String select) { | 393 | public void onSelect(TextView type, String select) { |
380 | switch (type.getId()) { | 394 | switch (type.getId()) { |
381 | case R.id.tv_filter_grade: | 395 | case R.id.tv_filter_grade: |
382 | grade = select; | 396 | grade = select; |
383 | break; | 397 | break; |
384 | case R.id.tv_filter_subject: | 398 | case R.id.tv_filter_subject: |
385 | subject = select; | 399 | subject = select; |
386 | break; | 400 | break; |
387 | case R.id.tv_filter_manage: | 401 | case R.id.tv_filter_manage: |
388 | manger = select; | 402 | manger = select; |
389 | break; | 403 | break; |
390 | } | 404 | } |
391 | page = 1; | 405 | page = 1; |
392 | filterAdapter.refresh(select); | 406 | filterAdapter.refresh(select); |
393 | refreshError(); | 407 | refreshError(); |
394 | } | 408 | } |
395 | }, list, textView, select); | 409 | }, list, textView, select); |
396 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); | 410 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); |
397 | binding.recycleFilter.setAdapter(filterAdapter); | 411 | binding.recycleFilter.setAdapter(filterAdapter); |
398 | } | 412 | } |
399 | binding.recycleFilter.setVisibility(View.VISIBLE); | 413 | binding.recycleFilter.setVisibility(View.VISIBLE); |
400 | textView.setTextColor(Color.parseColor("#1C90F3")); | 414 | textView.setTextColor(Color.parseColor("#1C90F3")); |
401 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); | 415 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); |
402 | // 这一步必须要做,否则不会显示. | 416 | // 这一步必须要做,否则不会显示. |
403 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 417 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
404 | textView.setCompoundDrawables(null, null, drawable, null); | 418 | textView.setCompoundDrawables(null, null, drawable, null); |
405 | last = textView; | 419 | last = textView; |
406 | } else { | 420 | } else { |
407 | if (textView.getId() == last.getId()) { | 421 | if (textView.getId() == last.getId()) { |
408 | binding.recycleFilter.setVisibility(View.GONE); | 422 | binding.recycleFilter.setVisibility(View.GONE); |
409 | textView.setTextColor(getColor(R.color.text_title)); | 423 | textView.setTextColor(getColor(R.color.text_title)); |
410 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 424 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
411 | // 这一步必须要做,否则不会显示. | 425 | // 这一步必须要做,否则不会显示. |
412 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 426 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
413 | textView.setCompoundDrawables(null, null, drawable, null); | 427 | textView.setCompoundDrawables(null, null, drawable, null); |
414 | } else { | 428 | } else { |
415 | filterAdapter.refresh(list, textView, select); | 429 | filterAdapter.refresh(list, textView, select); |
416 | last.setTextColor(getColor(R.color.text_title)); | 430 | last.setTextColor(getColor(R.color.text_title)); |
417 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 431 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
418 | // 这一步必须要做,否则不会显示. | 432 | // 这一步必须要做,否则不会显示. |
419 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 433 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
420 | last.setCompoundDrawables(null, null, drawable, null); | 434 | last.setCompoundDrawables(null, null, drawable, null); |
421 | textView.setTextColor(Color.parseColor("#1C90F3")); | 435 | textView.setTextColor(Color.parseColor("#1C90F3")); |
422 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 436 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
423 | // 这一步必须要做,否则不会显示. | 437 | // 这一步必须要做,否则不会显示. |
424 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 438 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
425 | textView.setCompoundDrawables(null, null, drawable1, null); | 439 | textView.setCompoundDrawables(null, null, drawable1, null); |
426 | last = textView; | 440 | last = textView; |
427 | } | 441 | } |
428 | } | 442 | } |
429 | } | 443 | } |
430 | 444 | ||
431 | private void refreshError() { | 445 | private void refreshError() { |
432 | Map map = new HashMap(); | 446 | Map map = new HashMap(); |
433 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { | 447 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { |
434 | map.put("subject", subject); | 448 | map.put("subject", subject); |
435 | } | 449 | } |
436 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { | 450 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { |
437 | map.put("grade", grade); | 451 | map.put("grade", grade); |
438 | } | 452 | } |
439 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { | 453 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { |
440 | if ("一周内".equals(time)) { | 454 | if ("一周内".equals(time)) { |
441 | map.put("time", 6); | 455 | map.put("time", 6); |
442 | } else if ("一个月内".equals(time)) { | 456 | } else if ("一个月内".equals(time)) { |
443 | map.put("time", 30); | 457 | map.put("time", 30); |
444 | } else if ("三个月内".equals(time)) { | 458 | } else if ("三个月内".equals(time)) { |
445 | map.put("time", 90); | 459 | map.put("time", 90); |
446 | } | 460 | } |
447 | } | 461 | } |
448 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { | 462 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { |
449 | map.put("type", "课内".equals(type) ? 0 : 1); | 463 | map.put("type", "课内".equals(type) ? 0 : 1); |
450 | } | 464 | } |
451 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { | 465 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { |
452 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); | 466 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); |
453 | } | 467 | } |
454 | map.put("stuId", studentBean.getStuId()); | 468 | map.put("stuId", studentBean.getStuId()); |
455 | map.put("pageSize", 10); | 469 | map.put("pageSize", 10); |
456 | map.put("pageNum", page); | 470 | map.put("pageNum", page); |
457 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 471 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
458 | @Override | 472 | @Override |
459 | public void onSubscribe(Disposable d) { | 473 | public void onSubscribe(Disposable d) { |
460 | 474 | ||
461 | } | 475 | } |
462 | 476 | ||
463 | @Override | 477 | @Override |
464 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 478 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
465 | if (result.getData() != null && result.getCode() == 200) { | 479 | if (result.getData() != null && result.getCode() == 200) { |
466 | total = result.getData().getTotal(); | 480 | total = result.getData().getTotal(); |
467 | List<TopicBean> topicBeans = result.getData().getList(); | 481 | List<TopicBean> topicBeans = result.getData().getList(); |
468 | loadError(topicBeans); | 482 | loadError(topicBeans); |
469 | } | 483 | } |
470 | } | 484 | } |
471 | 485 | ||
472 | @Override | 486 | @Override |
473 | public void onError(Throwable e) { | 487 | public void onError(Throwable e) { |
474 | e.toString(); | 488 | e.toString(); |
475 | } | 489 | } |
476 | 490 | ||
477 | @Override | 491 | @Override |
478 | public void onComplete() { | 492 | public void onComplete() { |
479 | 493 | ||
480 | } | 494 | } |
481 | }); | 495 | }); |
482 | } | 496 | } |
483 | 497 | ||
484 | private void loadError(List<TopicBean> list) { | 498 | private void loadError(List<TopicBean> list) { |
485 | if (list.size() > 0) { | 499 | if (list.size() > 0) { |
486 | binding.recycle.setVisibility(View.VISIBLE); | 500 | binding.recycle.setVisibility(View.VISIBLE); |
487 | binding.llEmpty.setVisibility(View.GONE); | 501 | binding.llEmpty.setVisibility(View.GONE); |
488 | if (adapter != null) { | 502 | if (adapter != null) { |
489 | if (page > 1) { | 503 | if (page > 1) { |
490 | adapter.addData(list); | 504 | adapter.addData(list); |
491 | } else { | 505 | } else { |
492 | adapter.refresh(list); | 506 | adapter.refresh(list); |
493 | } | 507 | } |
494 | } else { | 508 | } else { |
495 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { | 509 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { |
496 | @Override | 510 | @Override |
497 | public void onErrorCheck() { | 511 | public void onErrorCheck() { |
498 | if (adapter.getChecKList().size() > 0) { | 512 | if (adapter.getChecKList().size() > 0) { |
499 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); | 513 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); |
500 | } else { | 514 | } else { |
501 | binding.tvSave.setText("批量修改标签"); | 515 | binding.tvSave.setText("批量修改标签"); |
502 | } | 516 | } |
503 | } | 517 | } |
504 | }); | 518 | }); |
505 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); | 519 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); |
506 | binding.recycle.setLayoutManager(linearLayoutManager); | 520 | binding.recycle.setLayoutManager(linearLayoutManager); |
507 | binding.recycle.setAdapter(adapter); | 521 | binding.recycle.setAdapter(adapter); |
508 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { | 522 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { |
509 | @Override | 523 | @Override |
510 | public void onLoadMore(int currentPage) { | 524 | public void onLoadMore(int currentPage) { |
511 | if (currentPage > page) { | 525 | if (currentPage > page) { |
512 | new Thread(new Runnable() { | 526 | new Thread(new Runnable() { |
513 | @Override | 527 | @Override |
514 | public void run() { | 528 | public void run() { |
515 | try { | 529 | try { |
516 | runOnUiThread(new Runnable() { | 530 | runOnUiThread(new Runnable() { |
517 | @Override | 531 | @Override |
518 | public void run() { | 532 | public void run() { |
519 | if (page * 10 < total) { | 533 | if (page * 10 < total) { |
520 | page++; | 534 | page++; |
521 | refreshError(); | 535 | refreshError(); |
522 | } | 536 | } |
523 | } | 537 | } |
524 | }); | 538 | }); |
525 | } catch (Exception e) { | 539 | } catch (Exception e) { |
526 | e.printStackTrace(); | 540 | e.printStackTrace(); |
527 | } | 541 | } |
528 | } | 542 | } |
529 | }).start(); | 543 | }).start(); |
530 | } | 544 | } |
531 | } | 545 | } |
532 | }); | 546 | }); |
533 | } | 547 | } |
534 | } else { | 548 | } else { |
535 | if (page == 1) { | 549 | if (page == 1) { |
536 | binding.recycle.setVisibility(View.GONE); | 550 | binding.recycle.setVisibility(View.GONE); |
537 | binding.llEmpty.setVisibility(View.VISIBLE); | 551 | binding.llEmpty.setVisibility(View.VISIBLE); |
538 | } | 552 | } |
539 | } | 553 | } |
540 | } | 554 | } |
541 | 555 | ||
542 | @Override | 556 | @Override |
543 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 557 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
544 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 558 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
545 | if (adapter != null && adapter.edit) { | 559 | if (adapter != null && adapter.edit) { |
546 | adapter.setEdit(false); | 560 | adapter.setEdit(false); |
547 | binding.tvSave.setVisibility(View.GONE); | 561 | binding.tvSave.setVisibility(View.GONE); |
548 | binding.tvAdd.setVisibility(View.VISIBLE); | 562 | binding.tvAdd.setVisibility(View.VISIBLE); |
549 | binding.checkbox.setVisibility(View.GONE); | 563 | binding.checkbox.setVisibility(View.GONE); |
550 | binding.llDelete.setVisibility(View.GONE); | 564 | binding.llDelete.setVisibility(View.GONE); |
551 | binding.ivBack.setVisibility(View.VISIBLE); | 565 | binding.ivBack.setVisibility(View.VISIBLE); |
552 | binding.tvEdit.setText("编辑"); | 566 | binding.tvEdit.setText("编辑"); |
553 | adapter.notifyDataSetChanged(); | 567 | adapter.notifyDataSetChanged(); |
554 | } else { | 568 | } else { |
555 | finish(); | 569 | finish(); |
556 | } | 570 | } |
557 | return true; | 571 | return true; |
558 | } | 572 | } |
559 | return super.onKeyDown(keyCode, event); | 573 | return super.onKeyDown(keyCode, event); |
560 | } | 574 | } |
561 | 575 | ||
562 | @Override | 576 | @Override |
563 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 577 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
564 | super.onActivityResult(requestCode, resultCode, data); | 578 | super.onActivityResult(requestCode, resultCode, data); |
565 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 579 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
566 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 580 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
567 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 581 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
568 | CommonUtil.saveBitmapToUri(b, path); | 582 | CommonUtil.saveBitmapToUri(b, path); |
569 | List<String> strings = new ArrayList<>(); | 583 | List<String> strings = new ArrayList<>(); |
570 | Intent intent = new Intent(context, ImageActivity.class); | 584 | Intent intent = new Intent(context, ImageActivity.class); |
571 | strings.add(path); | 585 | strings.add(path); |
572 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 586 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
573 | startActivity(intent); | 587 | startActivity(intent); |
574 | } | 588 | } |
575 | } | 589 | } |
576 | 590 | ||
577 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 591 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
578 | private String TAG = "---ImagePicker---"; | 592 | private String TAG = "---ImagePicker---"; |
579 | List<ImageInfo> photoList = new ArrayList<>(); | 593 | List<ImageInfo> photoList = new ArrayList<>(); |
580 | 594 | ||
581 | @Override | 595 | @Override |
582 | public void onStart() { | 596 | public void onStart() { |
583 | Log.i(TAG, "onStart: 开启"); | 597 | Log.i(TAG, "onStart: 开启"); |
584 | } | 598 | } |
585 | 599 | ||
586 | @Override | 600 | @Override |
587 | public void onSuccess(List<ImageInfo> photoList) { | 601 | public void onSuccess(List<ImageInfo> photoList) { |
588 | this.photoList = photoList; | 602 | this.photoList = photoList; |
589 | Log.i(TAG, "onSuccess: 返回数据"); | 603 | Log.i(TAG, "onSuccess: 返回数据"); |
590 | } | 604 | } |
591 | 605 | ||
592 | @Override | 606 | @Override |
593 | public void onCancel() { | 607 | public void onCancel() { |
594 | Log.i(TAG, "onCancel: 取消"); | 608 | Log.i(TAG, "onCancel: 取消"); |
595 | } | 609 | } |
596 | 610 | ||
597 | @Override | 611 | @Override |
598 | public void onFinish(List<ImageInfo> selectImage) { | 612 | public void onFinish(List<ImageInfo> selectImage) { |
599 | if (selectImage.size() == photoList.size()) { | 613 | if (selectImage.size() == photoList.size()) { |
600 | List<String> strings = new ArrayList<>(); | 614 | List<String> strings = new ArrayList<>(); |
601 | Intent intent = new Intent(context, ImageActivity.class); | 615 | Intent intent = new Intent(context, ImageActivity.class); |
602 | for (ImageInfo imageInfo : selectImage) { | 616 | for (ImageInfo imageInfo : selectImage) { |
603 | strings.add(imageInfo.getPath()); | 617 | strings.add(imageInfo.getPath()); |
604 | } | 618 | } |
605 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 619 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
606 | startActivity(intent); | 620 | startActivity(intent); |
607 | } | 621 | } |
608 | } | 622 | } |
609 | 623 | ||
610 | @Override | 624 | @Override |
611 | public void onError() { | 625 | public void onError() { |
612 | Log.i(TAG, "onError: 出错"); | 626 | Log.i(TAG, "onError: 出错"); |
613 | } | 627 | } |
614 | } | 628 | } |
615 | 629 | ||
616 | @Override | 630 | @Override |
617 | protected void onResume() { | 631 | protected void onResume() { |
632 | String student = (String) SharedPreferencesUtil.getData("student", ""); | ||
633 | try { | ||
634 | studentBean = new Gson().fromJson(student, StudentBean.class); | ||
635 | } catch (Exception e) { | ||
636 | |||
637 | } | ||
638 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); | ||
618 | refreshError(); | 639 | refreshError(); |
619 | super.onResume(); | 640 | super.onResume(); |
620 | } | 641 | } |
621 | } | 642 | } |
app/src/main/java/com/hjx/parent/LoginActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.telephony.PhoneNumberUtils; | 5 | import android.telephony.PhoneNumberUtils; |
6 | import android.text.InputType; | 6 | import android.text.InputType; |
7 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
8 | import android.text.method.HideReturnsTransformationMethod; | 8 | import android.text.method.HideReturnsTransformationMethod; |
9 | import android.text.method.PasswordTransformationMethod; | 9 | import android.text.method.PasswordTransformationMethod; |
10 | import android.widget.Button; | 10 | import android.widget.Button; |
11 | import android.widget.CheckBox; | 11 | import android.widget.CheckBox; |
12 | import android.widget.EditText; | 12 | import android.widget.EditText; |
13 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
14 | import android.widget.TextView; | 14 | import android.widget.TextView; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import androidx.appcompat.app.AppCompatActivity; | 17 | import androidx.appcompat.app.AppCompatActivity; |
18 | 18 | ||
19 | import com.prws.common.base.BaseActivity; | 19 | import com.prws.common.base.BaseActivity; |
20 | import com.prws.common.base.BasePresenter; | 20 | import com.prws.common.base.BasePresenter; |
21 | import com.prws.common.bean.BaseEntity; | 21 | import com.prws.common.bean.BaseEntity; |
22 | import com.prws.common.net.NetWorks; | 22 | import com.prws.common.net.NetWorks; |
23 | import com.prws.common.utils.LogUtil; | 23 | import com.prws.common.utils.LogUtil; |
24 | import com.prws.common.utils.SharedPreferencesUtil; | 24 | import com.prws.common.utils.SharedPreferencesUtil; |
25 | import com.prws.common.utils.acmanager.ActivityManager; | 25 | import com.prws.common.utils.acmanager.ActivityManager; |
26 | 26 | ||
27 | import org.json.JSONObject; | 27 | import org.json.JSONObject; |
28 | 28 | ||
29 | import java.io.IOException; | 29 | import java.io.IOException; |
30 | import java.util.HashMap; | 30 | import java.util.HashMap; |
31 | import java.util.Map; | 31 | import java.util.Map; |
32 | 32 | ||
33 | import io.reactivex.Observer; | 33 | import io.reactivex.Observer; |
34 | import io.reactivex.disposables.Disposable; | 34 | import io.reactivex.disposables.Disposable; |
35 | import okhttp3.ResponseBody; | 35 | import okhttp3.ResponseBody; |
36 | 36 | ||
37 | 37 | ||
38 | public class LoginActivity extends BaseActivity { | 38 | public class LoginActivity extends BaseActivity { |
39 | 39 | ||
40 | 40 | ||
41 | EditText et_phone; | 41 | EditText et_phone; |
42 | EditText et_pwd; | 42 | EditText et_pwd; |
43 | ImageView iv_show; | 43 | ImageView iv_show; |
44 | ImageView iv_delete; | 44 | ImageView iv_delete; |
45 | Button btn_login; | 45 | Button btn_login; |
46 | TextView tv_reg; | 46 | TextView tv_reg; |
47 | CheckBox cb_1; | 47 | CheckBox cb_1; |
48 | TextView tv_user; | 48 | TextView tv_user; |
49 | TextView tv_ys; | 49 | TextView tv_ys; |
50 | 50 | ||
51 | 51 | ||
52 | @Override | 52 | @Override |
53 | protected int layoutResId() { | 53 | protected int layoutResId() { |
54 | return R.layout.activity_login; | 54 | return R.layout.activity_login; |
55 | } | 55 | } |
56 | 56 | ||
57 | @Override | 57 | @Override |
58 | public Object getContract() { | 58 | public Object getContract() { |
59 | return null; | 59 | return null; |
60 | } | 60 | } |
61 | 61 | ||
62 | @Override | 62 | @Override |
63 | public BasePresenter getPresenter() { | 63 | public BasePresenter getPresenter() { |
64 | return null; | 64 | return null; |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | @Override | 68 | @Override |
69 | protected void initView() { | 69 | protected void initView() { |
70 | et_phone = findViewById(R.id.et_phone); | 70 | et_phone = findViewById(R.id.et_phone); |
71 | et_pwd = findViewById(R.id.et_pwd); | 71 | et_pwd = findViewById(R.id.et_pwd); |
72 | iv_show = findViewById(R.id.iv_4); | 72 | iv_show = findViewById(R.id.iv_4); |
73 | iv_delete = findViewById(R.id.iv_2); | 73 | iv_delete = findViewById(R.id.iv_2); |
74 | btn_login = findViewById(R.id.btn_1); | 74 | btn_login = findViewById(R.id.btn_1); |
75 | tv_reg = findViewById(R.id.tv_2); | 75 | tv_reg = findViewById(R.id.tv_2); |
76 | cb_1 = findViewById(R.id.cb_1); | 76 | cb_1 = findViewById(R.id.cb_1); |
77 | tv_user = findViewById(R.id.tv_4); | 77 | tv_user = findViewById(R.id.tv_4); |
78 | tv_ys = findViewById(R.id.tv_6); | 78 | tv_ys = findViewById(R.id.tv_6); |
79 | 79 | ||
80 | 80 | ||
81 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 81 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
82 | 82 | ||
83 | if (!TextUtils.isEmpty(student)) { | 83 | if (!TextUtils.isEmpty(student)) { |
84 | LogUtil.e(TAG, "role 不是空----"); | 84 | LogUtil.e(TAG, "role 不是空----"); |
85 | Intent intent = new Intent(this, MainActivity.class); | 85 | if ((SharedPreferencesUtil.getData("role", "")).equals("parent")) { |
86 | startActivity(intent); | 86 | Intent intent = new Intent(this, MainActivity.class); |
87 | finish(); | 87 | startActivity(intent); |
88 | finish(); | ||
89 | } else { | ||
90 | Intent intent = new Intent(this, TeacherMainActivity.class); | ||
91 | startActivity(intent); | ||
92 | finish(); | ||
93 | } | ||
88 | return; | 94 | return; |
89 | } else { | 95 | } else { |
90 | LogUtil.e(TAG, "role 是空----"); | 96 | LogUtil.e(TAG, "role 是空----"); |
91 | } | 97 | } |
92 | 98 | ||
93 | 99 | ||
94 | } | 100 | } |
95 | 101 | ||
96 | @Override | 102 | @Override |
97 | protected void initListener() { | 103 | protected void initListener() { |
98 | iv_delete.setOnClickListener(view -> { | 104 | iv_delete.setOnClickListener(view -> { |
99 | et_phone.setText(""); | 105 | et_phone.setText(""); |
100 | }); | 106 | }); |
101 | iv_show.setOnClickListener(view -> { | 107 | iv_show.setOnClickListener(view -> { |
102 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { | 108 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { |
103 | iv_show.setBackgroundResource(R.mipmap.yc); | 109 | iv_show.setBackgroundResource(R.mipmap.yc); |
104 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); | 110 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); |
105 | et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); | 111 | et_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
106 | } else { | 112 | } else { |
107 | iv_show.setBackgroundResource(R.mipmap.xs); | 113 | iv_show.setBackgroundResource(R.mipmap.xs); |
108 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); | 114 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); |
109 | et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); | 115 | et_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
110 | } | 116 | } |
111 | }); | 117 | }); |
112 | 118 | ||
113 | 119 | ||
114 | btn_login.setOnClickListener(view -> { | 120 | btn_login.setOnClickListener(view -> { |
115 | 121 | ||
116 | String phone = et_phone.getText().toString().trim(); | 122 | String phone = et_phone.getText().toString().trim(); |
117 | String pwd = et_pwd.getText().toString().trim(); | 123 | String pwd = et_pwd.getText().toString().trim(); |
118 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { | 124 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { |
119 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); | 125 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); |
120 | return; | 126 | return; |
121 | } | 127 | } |
122 | 128 | ||
123 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { | 129 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { |
124 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); | 130 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); |
125 | return; | 131 | return; |
126 | } | 132 | } |
127 | 133 | ||
128 | if (!cb_1.isChecked()) { | 134 | if (!cb_1.isChecked()) { |
129 | Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); | 135 | Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); |
130 | return; | 136 | return; |
131 | } | 137 | } |
132 | 138 | ||
133 | login(phone, pwd); | 139 | login(phone, pwd); |
134 | 140 | ||
135 | }); | 141 | }); |
136 | 142 | ||
137 | tv_reg.setOnClickListener(view -> { | 143 | tv_reg.setOnClickListener(view -> { |
138 | startActivity(RegisterActivity.class); | 144 | startActivity(RegisterActivity.class); |
139 | finish(); | 145 | finish(); |
140 | }); | 146 | }); |
141 | 147 | ||
142 | tv_ys.setOnClickListener(view -> { | 148 | tv_ys.setOnClickListener(view -> { |
143 | startActivity(YinsiActivity.class); | 149 | startActivity(YinsiActivity.class); |
144 | }); | 150 | }); |
145 | tv_user.setOnClickListener(view -> { | 151 | tv_user.setOnClickListener(view -> { |
146 | startActivity(UserAgreementActivity.class); | 152 | startActivity(UserAgreementActivity.class); |
147 | }); | 153 | }); |
148 | } | 154 | } |
149 | 155 | ||
150 | public void login(final String phone, String pwd) { | 156 | public void login(final String phone, String pwd) { |
151 | 157 | ||
152 | Map map = new HashMap(); | 158 | Map map = new HashMap(); |
153 | map.put("username", phone); | 159 | map.put("username", phone); |
154 | map.put("password", pwd); | 160 | map.put("password", pwd); |
155 | 161 | ||
156 | 162 | ||
157 | NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | 163 | NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { |
158 | @Override | 164 | @Override |
159 | public void onSubscribe(Disposable d) { | 165 | public void onSubscribe(Disposable d) { |
160 | 166 | ||
161 | } | 167 | } |
162 | 168 | ||
163 | @Override | 169 | @Override |
164 | public void onNext(ResponseBody responseBody) { | 170 | public void onNext(ResponseBody responseBody) { |
165 | try { | 171 | try { |
166 | String str = responseBody.string().toString(); | 172 | String str = responseBody.string().toString(); |
167 | LogUtil.e(TAG, "----" + str); | 173 | LogUtil.e(TAG, "----" + str); |
168 | JSONObject jo = new JSONObject(str); | 174 | JSONObject jo = new JSONObject(str); |
169 | boolean isSucceed = jo.getBoolean("success"); | 175 | boolean isSucceed = jo.getBoolean("success"); |
170 | if (isSucceed) { | 176 | if (isSucceed) { |
171 | JSONObject jo2 = jo.getJSONObject("data"); | 177 | JSONObject jo2 = jo.getJSONObject("data"); |
172 | SharedPreferencesUtil.putData("phone", phone); | 178 | if ("parent".equals(jo2.getString("role"))) { |
173 | SharedPreferencesUtil.putData("role", jo2.getString("role")); | 179 | SharedPreferencesUtil.putData("phone", phone); |
174 | SharedPreferencesUtil.putData("userId", jo2.getString("userId")); | 180 | SharedPreferencesUtil.putData("role", jo2.getString("role")); |
175 | SharedPreferencesUtil.putData("token", jo2.getString("token")); | 181 | SharedPreferencesUtil.putData("userId", jo2.getString("userId")); |
176 | JSONObject user = new JSONObject(jo2.getString("user")); | 182 | SharedPreferencesUtil.putData("token", jo2.getString("token")); |
177 | SharedPreferencesUtil.putData("photo", user.getString("photo")); | 183 | JSONObject user = new JSONObject(jo2.getString("user")); |
178 | startActivity(ChooseActivity.class); | 184 | SharedPreferencesUtil.putData("photo", user.getString("photo")); |
179 | finish(); | 185 | SharedPreferencesUtil.putData("name", user.getString("userName")); |
186 | startActivity(ChooseActivity.class); | ||
187 | finish(); | ||
188 | } else if ("member_advisor".equals(jo2.getString("role")) || "teaching_supervision".equals(jo2.getString("role"))) { | ||
189 | SharedPreferencesUtil.putData("phone", phone); | ||
190 | SharedPreferencesUtil.putData("role", jo2.getString("role")); | ||
191 | SharedPreferencesUtil.putData("userId", jo2.getString("userId")); | ||
192 | SharedPreferencesUtil.putData("token", jo2.getString("token")); | ||
193 | JSONObject user = new JSONObject(jo2.getString("user")); | ||
194 | SharedPreferencesUtil.putData("name", user.getString("userName")); | ||
195 | SharedPreferencesUtil.putData("photo", user.getString("photo")); | ||
196 | startActivity(TeacherChooseActivity.class); | ||
197 | finish(); | ||
198 | } else { | ||
199 | showToast("您没有权限"); | ||
200 | } | ||
201 | |||
180 | } else { | 202 | } else { |
181 | Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | 203 | Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); |
182 | } | 204 | } |
183 | } catch (Exception e) { | 205 | } catch (Exception e) { |
184 | e.printStackTrace(); | 206 | e.printStackTrace(); |
185 | Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); | 207 | Toast.makeText(LoginActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); |
186 | } | 208 | } |
187 | } | 209 | } |
188 | 210 | ||
189 | @Override | 211 | @Override |
190 | public void onError(Throwable e) { | 212 | public void onError(Throwable e) { |
191 | 213 | ||
192 | } | 214 | } |
193 | 215 | ||
194 | @Override | 216 | @Override |
195 | public void onComplete() { | 217 | public void onComplete() { |
196 | 218 | ||
197 | } | 219 | } |
198 | }); | 220 | }); |
199 | } | 221 | } |
200 | 222 | ||
201 | 223 | ||
202 | @Override | 224 | @Override |
203 | protected void initData() { | 225 | protected void initData() { |
204 | 226 | ||
205 | } | 227 | } |
206 | 228 | ||
207 | @Override | 229 | @Override |
208 | public void onNetChanged(int netWorkState) { | 230 | public void onNetChanged(int netWorkState) { |
209 | 231 | ||
210 | } | 232 | } |
211 | } | 233 | } |
app/src/main/java/com/hjx/parent/MainActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import androidx.annotation.Nullable; | ||
3 | import androidx.appcompat.app.AppCompatActivity; | 4 | import androidx.appcompat.app.AppCompatActivity; |
4 | import androidx.constraintlayout.widget.ConstraintLayout; | 5 | import androidx.constraintlayout.widget.ConstraintLayout; |
5 | import androidx.core.content.FileProvider; | 6 | import androidx.core.content.FileProvider; |
6 | 7 | ||
7 | import android.app.Dialog; | 8 | import android.app.Dialog; |
8 | import android.app.ProgressDialog; | 9 | import android.app.ProgressDialog; |
9 | import android.content.Intent; | 10 | import android.content.Intent; |
10 | import android.graphics.Color; | 11 | import android.graphics.Color; |
11 | import android.net.Uri; | 12 | import android.net.Uri; |
12 | import android.os.Build; | 13 | import android.os.Build; |
13 | import android.os.Bundle; | 14 | import android.os.Bundle; |
14 | import android.os.Looper; | 15 | import android.os.Looper; |
15 | import android.widget.ImageView; | 16 | import android.widget.ImageView; |
16 | import android.widget.TextView; | 17 | import android.widget.TextView; |
17 | import android.widget.Toast; | 18 | import android.widget.Toast; |
18 | 19 | ||
19 | import com.google.gson.JsonObject; | 20 | import com.google.gson.JsonObject; |
20 | import com.hjq.permissions.OnPermissionCallback; | 21 | import com.hjq.permissions.OnPermissionCallback; |
21 | import com.hjq.permissions.Permission; | 22 | import com.hjq.permissions.Permission; |
22 | import com.hjq.permissions.XXPermissions; | 23 | import com.hjq.permissions.XXPermissions; |
23 | import com.hjx.parent.dialog.TipDialog; | 24 | import com.hjx.parent.dialog.TipDialog; |
24 | import com.hjx.parent.fragment.HomeFragment; | 25 | import com.hjx.parent.fragment.HomeFragment; |
25 | import com.hjx.parent.fragment.MeFragment; | 26 | import com.hjx.parent.fragment.MeFragment; |
26 | import com.prws.common.base.BaseActivity; | 27 | import com.prws.common.base.BaseActivity; |
27 | import com.prws.common.base.BasePresenter; | 28 | import com.prws.common.base.BasePresenter; |
28 | import com.prws.common.bean.GradeAndSubject; | 29 | import com.prws.common.bean.GradeAndSubject; |
29 | import com.prws.common.bean.ResponseResult; | 30 | import com.prws.common.bean.ResponseResult; |
30 | import com.prws.common.bean.UpdateBean; | 31 | import com.prws.common.bean.UpdateBean; |
31 | import com.prws.common.net.NetWorks; | 32 | import com.prws.common.net.NetWorks; |
32 | import com.prws.common.utils.DownloadUtil; | 33 | import com.prws.common.utils.DownloadUtil; |
33 | import com.prws.common.utils.SharedPreferencesUtil; | 34 | import com.prws.common.utils.SharedPreferencesUtil; |
34 | 35 | ||
35 | import java.io.File; | 36 | import java.io.File; |
36 | import java.util.List; | 37 | import java.util.List; |
37 | 38 | ||
38 | import io.reactivex.Observer; | 39 | import io.reactivex.Observer; |
39 | import io.reactivex.disposables.Disposable; | 40 | import io.reactivex.disposables.Disposable; |
40 | import retrofit2.Call; | 41 | import retrofit2.Call; |
41 | import retrofit2.Callback; | 42 | import retrofit2.Callback; |
42 | import retrofit2.Response; | 43 | import retrofit2.Response; |
43 | 44 | ||
44 | public class MainActivity extends BaseActivity { | 45 | public class MainActivity extends BaseActivity { |
45 | 46 | ||
46 | @Override | 47 | @Override |
47 | protected int layoutResId() { | 48 | protected int layoutResId() { |
48 | return R.layout.activity_main; | 49 | return R.layout.activity_main; |
49 | } | 50 | } |
50 | 51 | ||
51 | @Override | 52 | @Override |
52 | public Object getContract() { | 53 | public Object getContract() { |
53 | return null; | 54 | return null; |
54 | } | 55 | } |
55 | 56 | ||
56 | @Override | 57 | @Override |
57 | public BasePresenter getPresenter() { | 58 | public BasePresenter getPresenter() { |
58 | return null; | 59 | return null; |
59 | } | 60 | } |
60 | 61 | ||
61 | 62 | ||
62 | HomeFragment homeFragment; | 63 | HomeFragment homeFragment; |
63 | MeFragment meFragment; | 64 | MeFragment meFragment; |
64 | ConstraintLayout cl_home; | 65 | ConstraintLayout cl_home; |
65 | ConstraintLayout cl_me; | 66 | ConstraintLayout cl_me; |
66 | ImageView iv_3, iv_4; | 67 | ImageView iv_3, iv_4; |
67 | TextView tv_1, tv_4; | 68 | TextView tv_1, tv_4; |
68 | 69 | ||
70 | |||
71 | @Override | ||
72 | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
73 | super.onCreate(savedInstanceState); | ||
74 | fullScreen(); | ||
75 | } | ||
76 | |||
69 | @Override | 77 | @Override |
70 | protected void initView() { | 78 | protected void initView() { |
71 | showFragment(getHomeFragment(), R.id.rl_content); | 79 | showFragment(getHomeFragment(), R.id.rl_content); |
72 | cl_home = findViewById(R.id.cl_home); | 80 | cl_home = findViewById(R.id.cl_home); |
73 | cl_me = findViewById(R.id.cl_me); | 81 | cl_me = findViewById(R.id.cl_me); |
74 | iv_3 = findViewById(R.id.iv_3); | 82 | iv_3 = findViewById(R.id.iv_3); |
75 | iv_4 = findViewById(R.id.iv_4); | 83 | iv_4 = findViewById(R.id.iv_4); |
76 | tv_1 = findViewById(R.id.tv_1); | 84 | tv_1 = findViewById(R.id.tv_1); |
77 | tv_4 = findViewById(R.id.tv_4); | 85 | tv_4 = findViewById(R.id.tv_4); |
78 | iv_3.setBackgroundResource(R.mipmap.hoss); | 86 | iv_3.setBackgroundResource(R.mipmap.hoss); |
79 | tv_1.setTextColor(Color.parseColor("#FE5E09")); | 87 | tv_1.setTextColor(Color.parseColor("#FE5E09")); |
80 | NetWorks.getBaiduToken(new Observer<JsonObject>() { | 88 | NetWorks.getBaiduToken(new Observer<JsonObject>() { |
81 | @Override | 89 | @Override |
82 | public void onSubscribe(Disposable d) { | 90 | public void onSubscribe(Disposable d) { |
83 | 91 | ||
84 | } | 92 | } |
85 | 93 | ||
86 | @Override | 94 | @Override |
87 | public void onNext(JsonObject jsonObject) { | 95 | public void onNext(JsonObject jsonObject) { |
88 | SharedPreferencesUtil.putData("baiduToken", jsonObject.get("access_token").getAsString()); | 96 | SharedPreferencesUtil.putData("baiduToken", jsonObject.get("access_token").getAsString()); |
89 | } | 97 | } |
90 | 98 | ||
91 | @Override | 99 | @Override |
92 | public void onError(Throwable e) { | 100 | public void onError(Throwable e) { |
93 | 101 | ||
94 | } | 102 | } |
95 | 103 | ||
96 | @Override | 104 | @Override |
97 | public void onComplete() { | 105 | public void onComplete() { |
98 | 106 | ||
99 | } | 107 | } |
100 | }); | 108 | }); |
101 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { | 109 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { |
102 | @Override | 110 | @Override |
103 | public void onSubscribe(Disposable d) { | 111 | public void onSubscribe(Disposable d) { |
104 | 112 | ||
105 | } | 113 | } |
106 | 114 | ||
107 | @Override | 115 | @Override |
108 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { | 116 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { |
109 | App.getInstance().setGradeAndSubjects(listResponseResult.getData()); | 117 | App.getInstance().setGradeAndSubjects(listResponseResult.getData()); |
110 | } | 118 | } |
111 | 119 | ||
112 | @Override | 120 | @Override |
113 | public void onError(Throwable e) { | 121 | public void onError(Throwable e) { |
114 | e.toString(); | 122 | e.toString(); |
115 | } | 123 | } |
116 | 124 | ||
117 | @Override | 125 | @Override |
118 | public void onComplete() { | 126 | public void onComplete() { |
119 | 127 | ||
120 | } | 128 | } |
121 | }); | 129 | }); |
122 | checkUpdate(); | 130 | checkUpdate(); |
123 | } | 131 | } |
124 | 132 | ||
125 | public HomeFragment getHomeFragment() { | 133 | public HomeFragment getHomeFragment() { |
126 | if (homeFragment == null) | 134 | if (homeFragment == null) |
127 | homeFragment = new HomeFragment(); | 135 | homeFragment = new HomeFragment(); |
128 | return homeFragment; | 136 | return homeFragment; |
129 | } | 137 | } |
130 | 138 | ||
131 | public MeFragment getMeFragment() { | 139 | public MeFragment getMeFragment() { |
132 | if (meFragment == null) | 140 | if (meFragment == null) |
133 | meFragment = new MeFragment(); | 141 | meFragment = new MeFragment(); |
134 | return meFragment; | 142 | return meFragment; |
135 | } | 143 | } |
136 | 144 | ||
137 | 145 | ||
138 | @Override | 146 | @Override |
139 | protected void initListener() { | 147 | protected void initListener() { |
140 | cl_home.setOnClickListener(view -> { | 148 | cl_home.setOnClickListener(view -> { |
149 | fullScreen(); | ||
141 | showFragment(getHomeFragment(), R.id.rl_content); | 150 | showFragment(getHomeFragment(), R.id.rl_content); |
142 | iv_3.setBackgroundResource(R.mipmap.hoss); | 151 | iv_3.setBackgroundResource(R.mipmap.hoss); |
143 | tv_1.setTextColor(Color.parseColor("#FE5E09")); | 152 | tv_1.setTextColor(Color.parseColor("#1C90F3")); |
144 | iv_4.setBackgroundResource(R.mipmap.wmus); | 153 | iv_4.setBackgroundResource(R.mipmap.wmus); |
145 | tv_4.setTextColor(Color.parseColor("#333333")); | 154 | tv_4.setTextColor(Color.parseColor("#333333")); |
146 | }); | 155 | }); |
147 | 156 | ||
148 | cl_me.setOnClickListener(view -> { | 157 | cl_me.setOnClickListener(view -> { |
158 | blackBar(); | ||
149 | showFragment(getMeFragment(), R.id.rl_content); | 159 | showFragment(getMeFragment(), R.id.rl_content); |
150 | iv_3.setBackgroundResource(R.mipmap.hous); | 160 | iv_3.setBackgroundResource(R.mipmap.hous); |
151 | tv_1.setTextColor(Color.parseColor("#333333")); | 161 | tv_1.setTextColor(Color.parseColor("#333333")); |
152 | iv_4.setBackgroundResource(R.mipmap.wmss); | 162 | iv_4.setBackgroundResource(R.mipmap.wmss); |
153 | tv_4.setTextColor(Color.parseColor("#FE5E09")); | 163 | tv_4.setTextColor(Color.parseColor("#1C90F3")); |
154 | }); | 164 | }); |
155 | } | 165 | } |
156 | 166 | ||
157 | @Override | 167 | @Override |
158 | protected void initData() { | 168 | protected void initData() { |
159 | 169 | ||
160 | } | 170 | } |
161 | 171 | ||
162 | @Override | 172 | @Override |
163 | public void onNetChanged(int netWorkState) { | 173 | public void onNetChanged(int netWorkState) { |
164 | 174 | ||
165 | } | 175 | } |
166 | 176 | ||
167 | public void downloadApk(String url, int versionCode) { | 177 | public void downloadApk(String url, int versionCode) { |
168 | String filepath = getExternalFilesDir("apk").getPath() + "/" + versionCode + ".apk"; | 178 | String filepath = getExternalFilesDir("apk").getPath() + "/" + versionCode + ".apk"; |
169 | ProgressDialog dialog = new ProgressDialog(this); | 179 | ProgressDialog dialog = new ProgressDialog(this); |
170 | dialog.setTitle("版本更新"); | 180 | dialog.setTitle("版本更新"); |
171 | dialog.setMessage("正在下载新版本,请稍后"); | 181 | dialog.setMessage("正在下载新版本,请稍后"); |
172 | dialog.setMax(100); | 182 | dialog.setMax(100); |
173 | dialog.setProgress(0); | 183 | dialog.setProgress(0); |
174 | dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | 184 | dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); |
175 | dialog.show(); | 185 | dialog.show(); |
176 | DownloadUtil.download(url, filepath, new DownloadUtil.OnDownloadListener() { | 186 | DownloadUtil.download(url, filepath, new DownloadUtil.OnDownloadListener() { |
177 | @Override | 187 | @Override |
178 | public void onDownloadSuccess(String path) { | 188 | public void onDownloadSuccess(String path) { |
179 | dialog.setProgress(100); | 189 | dialog.setProgress(100); |
180 | dialog.dismiss(); | 190 | dialog.dismiss(); |
181 | installApk(filepath); | 191 | installApk(filepath); |
182 | } | 192 | } |
183 | 193 | ||
184 | @Override | 194 | @Override |
185 | public void onDownloading(int progress) { | 195 | public void onDownloading(int progress) { |
186 | dialog.setProgress(progress); | 196 | dialog.setProgress(progress); |
187 | } | 197 | } |
188 | 198 | ||
189 | @Override | 199 | @Override |
190 | public void onDownloadFailed(String msg) { | 200 | public void onDownloadFailed(String msg) { |
191 | dialog.dismiss(); | 201 | dialog.dismiss(); |
192 | Looper.prepare(); | 202 | Looper.prepare(); |
193 | showToast("下载失败。"); | 203 | showToast("下载失败。"); |
194 | Looper.loop(); | 204 | Looper.loop(); |
195 | } | 205 | } |
196 | }); | 206 | }); |
197 | } | 207 | } |
198 | 208 | ||
199 | public void installApk(String path) { | 209 | public void installApk(String path) { |
200 | //开启扫码界面 | 210 | //开启扫码界面 |
201 | Intent intentUpdate = new Intent("android.intent.action.VIEW"); | 211 | Intent intentUpdate = new Intent("android.intent.action.VIEW"); |
202 | intentUpdate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 212 | intentUpdate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
203 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //对Android N及以上的版本做判断 | 213 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //对Android N及以上的版本做判断 |
204 | Uri apkUriN = FileProvider.getUriForFile(MainActivity.this, | 214 | Uri apkUriN = FileProvider.getUriForFile(MainActivity.this, |
205 | getApplicationContext().getPackageName() + ".fileprovider", new File(path)); | 215 | getApplicationContext().getPackageName() + ".fileprovider", new File(path)); |
206 | intentUpdate.addCategory("android.intent.category.DEFAULT"); | 216 | intentUpdate.addCategory("android.intent.category.DEFAULT"); |
207 | intentUpdate.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //天假Flag 表示我们需要什么权限 | 217 | intentUpdate.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //天假Flag 表示我们需要什么权限 |
208 | intentUpdate.setDataAndType(apkUriN, "application/vnd.android.package-archive"); | 218 | intentUpdate.setDataAndType(apkUriN, "application/vnd.android.package-archive"); |
209 | } else { | 219 | } else { |
210 | Uri apkUri = Uri.fromFile(new File(path)); | 220 | Uri apkUri = Uri.fromFile(new File(path)); |
211 | intentUpdate.setDataAndType(apkUri, "application/vnd.android.package-archive"); | 221 | intentUpdate.setDataAndType(apkUri, "application/vnd.android.package-archive"); |
212 | } | 222 | } |
213 | startActivity(intentUpdate); | 223 | startActivity(intentUpdate); |
214 | } | 224 | } |
215 | 225 | ||
216 | public void checkUpdate() { | 226 | public void checkUpdate() { |
217 | NetWorks.checkUpdate(BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID, new Callback<ResponseResult<UpdateBean>>() { | 227 | NetWorks.checkUpdate(BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID, new Callback<ResponseResult<UpdateBean>>() { |
218 | @Override | 228 | @Override |
219 | public void onResponse(Call<ResponseResult<UpdateBean>> call, Response<ResponseResult<UpdateBean>> response) { | 229 | public void onResponse(Call<ResponseResult<UpdateBean>> call, Response<ResponseResult<UpdateBean>> response) { |
220 | if (response.body() != null && response.body().getCode() == 200) { | 230 | if (response.body() != null && response.body().getCode() == 200) { |
221 | if (response.body().getData() != null) { | 231 | if (response.body().getData() != null) { |
222 | String msg = response.body().getData().getExplain(); | 232 | String msg = response.body().getData().getExplain(); |
223 | String url = response.body().getData().getUrl(); | 233 | String url = response.body().getData().getUrl(); |
224 | int versionCode = response.body().getData().getVersion(); | 234 | int versionCode = response.body().getData().getVersion(); |
225 | showUpdateDialog(msg, url, versionCode); | 235 | showUpdateDialog(msg, url, versionCode); |
226 | } | 236 | } |
227 | } | 237 | } |
228 | } | 238 | } |
229 | 239 | ||
230 | @Override | 240 | @Override |
231 | public void onFailure(Call<ResponseResult<UpdateBean>> call, Throwable t) { | 241 | public void onFailure(Call<ResponseResult<UpdateBean>> call, Throwable t) { |
232 | } | 242 | } |
233 | }); | 243 | }); |
234 | } | 244 | } |
235 | 245 | ||
236 | public void showUpdateDialog(String msg, String url, int versionCode) { | 246 | public void showUpdateDialog(String msg, String url, int versionCode) { |
237 | TipDialog tipDialog = new TipDialog(this, "检测到新版本", msg, "升级", "取消", new TipDialog.TipDialogInterface() { | 247 | TipDialog tipDialog = new TipDialog(this, "检测到新版本", msg, "升级", "取消", new TipDialog.TipDialogInterface() { |
238 | @Override | 248 | @Override |
239 | public void onConfirm(Dialog dialog) { | 249 | public void onConfirm(Dialog dialog) { |
240 | if (!XXPermissions.isGranted(MainActivity.this, Permission.MANAGE_EXTERNAL_STORAGE)) { | 250 | if (!XXPermissions.isGranted(MainActivity.this, Permission.MANAGE_EXTERNAL_STORAGE)) { |
241 | XXPermissions.with(MainActivity.this) | 251 | XXPermissions.with(MainActivity.this) |
242 | // 申请多个权限 | 252 | // 申请多个权限 |
243 | .permission(Permission.MANAGE_EXTERNAL_STORAGE) | 253 | .permission(Permission.MANAGE_EXTERNAL_STORAGE) |
244 | .request(new OnPermissionCallback() { | 254 | .request(new OnPermissionCallback() { |
245 | @Override | 255 | @Override |
246 | public void onGranted(List<String> permissions, boolean all) { | 256 | public void onGranted(List<String> permissions, boolean all) { |
247 | if (all) { | 257 | if (all) { |
248 | //开启扫码界面 | 258 | //开启扫码界面 |
249 | downloadApk(url, versionCode); | 259 | downloadApk(url, versionCode); |
250 | } else { | 260 | } else { |
251 | Toast.makeText(MainActivity.this, "需要权限", Toast.LENGTH_SHORT).show(); | 261 | Toast.makeText(MainActivity.this, "需要权限", Toast.LENGTH_SHORT).show(); |
252 | } | 262 | } |
253 | } | 263 | } |
254 | 264 | ||
255 | @Override | 265 | @Override |
256 | public void onDenied(List<String> permissions, boolean never) { | 266 | public void onDenied(List<String> permissions, boolean never) { |
257 | XXPermissions.startPermissionActivity(MainActivity.this, permissions); | 267 | XXPermissions.startPermissionActivity(MainActivity.this, permissions); |
258 | } | 268 | } |
259 | }); | 269 | }); |
260 | } else { | 270 | } else { |
261 | downloadApk(url, versionCode); | 271 | downloadApk(url, versionCode); |
262 | } | 272 | } |
263 | 273 | ||
264 | } | 274 | } |
265 | 275 | ||
266 | @Override | 276 | @Override |
267 | public void onCancel(Dialog dialog) { | 277 | public void onCancel(Dialog dialog) { |
268 | dialog.dismiss(); | 278 | dialog.dismiss(); |
269 | } | 279 | } |
270 | }); | 280 | }); |
271 | tipDialog.show(); | 281 | tipDialog.show(); |
272 | } | 282 | } |
273 | } | 283 | } |
app/src/main/java/com/hjx/parent/TeacherChooseActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.content.Intent; | ||
4 | import android.text.TextUtils; | ||
5 | import android.view.View; | ||
6 | import android.widget.ImageView; | ||
7 | |||
8 | import androidx.annotation.NonNull; | ||
9 | import androidx.recyclerview.widget.LinearLayoutManager; | ||
10 | import androidx.recyclerview.widget.RecyclerView; | ||
11 | |||
12 | import com.bumptech.glide.Glide; | ||
13 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | ||
14 | import com.bumptech.glide.request.RequestOptions; | ||
15 | import com.chad.library.adapter.base.BaseQuickAdapter; | ||
16 | import com.chad.library.adapter.base.BaseViewHolder; | ||
17 | import com.google.gson.Gson; | ||
18 | import com.hjx.parent.bean.StudentBean; | ||
19 | import com.prws.common.base.BaseActivity; | ||
20 | import com.prws.common.base.BasePresenter; | ||
21 | import com.prws.common.net.NetWorks; | ||
22 | import com.prws.common.utils.LogUtil; | ||
23 | import com.prws.common.utils.ScreenUtils; | ||
24 | import com.prws.common.utils.SharedPreferencesUtil; | ||
25 | |||
26 | import org.json.JSONArray; | ||
27 | import org.json.JSONObject; | ||
28 | |||
29 | import java.util.ArrayList; | ||
30 | |||
31 | import butterknife.BindView; | ||
32 | import butterknife.OnClick; | ||
33 | import io.reactivex.Observer; | ||
34 | import io.reactivex.disposables.Disposable; | ||
35 | import okhttp3.ResponseBody; | ||
36 | |||
37 | public class TeacherChooseActivity extends BaseActivity { | ||
38 | @BindView(R.id.recycle) | ||
39 | RecyclerView recycle; | ||
40 | private int select = 0; | ||
41 | |||
42 | @Override | ||
43 | protected int layoutResId() { | ||
44 | return R.layout.choose_activity; | ||
45 | } | ||
46 | |||
47 | @Override | ||
48 | public Object getContract() { | ||
49 | return null; | ||
50 | } | ||
51 | |||
52 | @Override | ||
53 | public BasePresenter getPresenter() { | ||
54 | return null; | ||
55 | } | ||
56 | |||
57 | @Override | ||
58 | protected void initView() { | ||
59 | |||
60 | } | ||
61 | |||
62 | @Override | ||
63 | protected void initListener() { | ||
64 | |||
65 | } | ||
66 | |||
67 | @Override | ||
68 | protected void initData() { | ||
69 | |||
70 | } | ||
71 | |||
72 | @Override | ||
73 | public void onNetChanged(int netWorkState) { | ||
74 | |||
75 | } | ||
76 | |||
77 | @Override | ||
78 | protected void onResume() { | ||
79 | super.onResume(); | ||
80 | loadChildList(); | ||
81 | } | ||
82 | |||
83 | ArrayList<StudentBean> alist = new ArrayList<>(); | ||
84 | |||
85 | public void loadChildList() { | ||
86 | NetWorks.listStudent(new Observer<ResponseBody>() { | ||
87 | @Override | ||
88 | public void onSubscribe(Disposable d) { | ||
89 | |||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public void onNext(ResponseBody responseBody) { | ||
94 | try { | ||
95 | String str = responseBody.string().toString(); | ||
96 | LogUtil.e("TAG", "----" + str); | ||
97 | JSONObject jo = new JSONObject(str); | ||
98 | boolean isSucceed = jo.getBoolean("success"); | ||
99 | if (isSucceed) { | ||
100 | JSONArray jarr = jo.getJSONArray("data"); | ||
101 | alist.clear(); | ||
102 | for (int i = 0; i < jarr.length(); i++) { | ||
103 | JSONObject jo2 = jarr.getJSONObject(i); | ||
104 | Gson gson = new Gson(); | ||
105 | StudentBean sb = gson.fromJson(jo2.toString(), StudentBean.class); | ||
106 | alist.add(sb); | ||
107 | } | ||
108 | loadList(); | ||
109 | } else { | ||
110 | |||
111 | } | ||
112 | } catch (Exception e) { | ||
113 | e.printStackTrace(); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public void onError(Throwable e) { | ||
119 | |||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public void onComplete() { | ||
124 | |||
125 | } | ||
126 | }); | ||
127 | } | ||
128 | |||
129 | public void loadList() { | ||
130 | String student = (String) SharedPreferencesUtil.getData("student", ""); | ||
131 | try { | ||
132 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); | ||
133 | for (int i = 0; i < alist.size(); i++) { | ||
134 | if (studentBean.getStuId().equals(alist.get(i).getStuId())) { | ||
135 | select = i; | ||
136 | break; | ||
137 | } | ||
138 | } | ||
139 | } catch (Exception e) { | ||
140 | |||
141 | } | ||
142 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_child_choose, alist) { | ||
143 | @Override | ||
144 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | ||
145 | |||
146 | } | ||
147 | |||
148 | @Override | ||
149 | protected void convert(@NonNull BaseViewHolder item, Object o) { | ||
150 | StudentBean studentBean = alist.get(item.getAdapterPosition()); | ||
151 | item.setText(R.id.tv_name, studentBean.getStuName()); | ||
152 | item.setBackgroundRes(R.id.rl_child, select == item.getAdapterPosition() ? R.drawable.bg_solid_white_10_or : R.drawable.bg_solid_white_10); | ||
153 | item.setImageResource(R.id.iv_select, select == item.getAdapterPosition() ? R.mipmap.gx : R.mipmap.wsyq); | ||
154 | item.setVisible(R.id.rl_add, false); | ||
155 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | ||
156 | item.setImageResource(R.id.iv_avatar, studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | ||
157 | } else { | ||
158 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(TeacherChooseActivity.this, 45)); | ||
159 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | ||
160 | Glide.with(TeacherChooseActivity.this).load(studentBean.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_avatar)); | ||
161 | } | ||
162 | item.setVisible(R.id.iv_vip, !"虚拟".equals(studentBean.getTeacherIdentity())); | ||
163 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | ||
164 | @Override | ||
165 | public void onClick(View view) { | ||
166 | select = item.getAdapterPosition(); | ||
167 | notifyDataSetChanged(); | ||
168 | } | ||
169 | }); | ||
170 | } | ||
171 | }; | ||
172 | recycle.setLayoutManager(new LinearLayoutManager(TeacherChooseActivity.this, LinearLayoutManager.VERTICAL, false)); | ||
173 | recycle.setAdapter(adapter); | ||
174 | } | ||
175 | |||
176 | @OnClick(R.id.tv_confirm) | ||
177 | public void confirm(View view) { | ||
178 | if (alist.size() > 0 && alist.size() - 1 >= select && alist.get(select) != null) { | ||
179 | StudentBean studentBean = alist.get(select); | ||
180 | if (studentBean.getStuId() != null) { | ||
181 | if (getIntent().getBooleanExtra("needBack", false)) { | ||
182 | SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); | ||
183 | } else { | ||
184 | Intent intent = new Intent(TeacherChooseActivity.this, TeacherMainActivity.class); | ||
185 | SharedPreferencesUtil.putData("student", new Gson().toJson(studentBean)); | ||
186 | startActivity(intent); | ||
187 | } | ||
188 | finish(); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 |
app/src/main/java/com/hjx/parent/TeacherMainActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.app.Dialog; | ||
4 | import android.app.ProgressDialog; | ||
5 | import android.content.Intent; | ||
6 | import android.graphics.Color; | ||
7 | import android.net.Uri; | ||
8 | import android.os.Build; | ||
9 | import android.os.Looper; | ||
10 | import android.widget.ImageView; | ||
11 | import android.widget.TextView; | ||
12 | import android.widget.Toast; | ||
13 | |||
14 | import androidx.constraintlayout.widget.ConstraintLayout; | ||
15 | import androidx.core.content.FileProvider; | ||
16 | |||
17 | import com.google.gson.JsonObject; | ||
18 | import com.hjq.permissions.OnPermissionCallback; | ||
19 | import com.hjq.permissions.Permission; | ||
20 | import com.hjq.permissions.XXPermissions; | ||
21 | import com.hjx.parent.dialog.TipDialog; | ||
22 | import com.hjx.parent.fragment.ErrorFragment; | ||
23 | import com.hjx.parent.fragment.HomeFragment; | ||
24 | import com.hjx.parent.fragment.MeFragment; | ||
25 | import com.hjx.parent.fragment.TeacherFragment; | ||
26 | import com.prws.common.base.BaseActivity; | ||
27 | import com.prws.common.base.BasePresenter; | ||
28 | import com.prws.common.bean.GradeAndSubject; | ||
29 | import com.prws.common.bean.ResponseResult; | ||
30 | import com.prws.common.bean.UpdateBean; | ||
31 | import com.prws.common.net.NetWorks; | ||
32 | import com.prws.common.utils.DownloadUtil; | ||
33 | import com.prws.common.utils.SharedPreferencesUtil; | ||
34 | |||
35 | import java.io.File; | ||
36 | import java.util.List; | ||
37 | |||
38 | import io.reactivex.Observer; | ||
39 | import io.reactivex.disposables.Disposable; | ||
40 | import retrofit2.Call; | ||
41 | import retrofit2.Callback; | ||
42 | import retrofit2.Response; | ||
43 | |||
44 | public class TeacherMainActivity extends BaseActivity { | ||
45 | |||
46 | @Override | ||
47 | protected int layoutResId() { | ||
48 | return R.layout.activity_main; | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | public Object getContract() { | ||
53 | return null; | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | public BasePresenter getPresenter() { | ||
58 | return null; | ||
59 | } | ||
60 | |||
61 | |||
62 | ErrorFragment errorFragment; | ||
63 | TeacherFragment meFragment; | ||
64 | ConstraintLayout cl_home; | ||
65 | ConstraintLayout cl_me; | ||
66 | ImageView iv_3, iv_4; | ||
67 | TextView tv_1, tv_4; | ||
68 | |||
69 | @Override | ||
70 | protected void initView() { | ||
71 | blackBar(); | ||
72 | showFragment(getErrorFragment(), R.id.rl_content); | ||
73 | cl_home = findViewById(R.id.cl_home); | ||
74 | cl_me = findViewById(R.id.cl_me); | ||
75 | iv_3 = findViewById(R.id.iv_3); | ||
76 | iv_4 = findViewById(R.id.iv_4); | ||
77 | tv_1 = findViewById(R.id.tv_1); | ||
78 | tv_4 = findViewById(R.id.tv_4); | ||
79 | iv_3.setBackgroundResource(R.mipmap.hoss); | ||
80 | tv_1.setTextColor(Color.parseColor("#FE5E09")); | ||
81 | NetWorks.getBaiduToken(new Observer<JsonObject>() { | ||
82 | @Override | ||
83 | public void onSubscribe(Disposable d) { | ||
84 | |||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public void onNext(JsonObject jsonObject) { | ||
89 | SharedPreferencesUtil.putData("baiduToken", jsonObject.get("access_token").getAsString()); | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public void onError(Throwable e) { | ||
94 | |||
95 | } | ||
96 | |||
97 | @Override | ||
98 | public void onComplete() { | ||
99 | |||
100 | } | ||
101 | }); | ||
102 | NetWorks.listGradeAndSubject(new Observer<ResponseResult<List<GradeAndSubject>>>() { | ||
103 | @Override | ||
104 | public void onSubscribe(Disposable d) { | ||
105 | |||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public void onNext(ResponseResult<List<GradeAndSubject>> listResponseResult) { | ||
110 | App.getInstance().setGradeAndSubjects(listResponseResult.getData()); | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public void onError(Throwable e) { | ||
115 | e.toString(); | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public void onComplete() { | ||
120 | |||
121 | } | ||
122 | }); | ||
123 | checkUpdate(); | ||
124 | } | ||
125 | |||
126 | public ErrorFragment getErrorFragment() { | ||
127 | if (errorFragment == null) | ||
128 | errorFragment = new ErrorFragment(); | ||
129 | return errorFragment; | ||
130 | } | ||
131 | |||
132 | public TeacherFragment getMeFragment() { | ||
133 | if (meFragment == null) | ||
134 | meFragment = new TeacherFragment(); | ||
135 | return meFragment; | ||
136 | } | ||
137 | |||
138 | |||
139 | @Override | ||
140 | protected void initListener() { | ||
141 | cl_home.setOnClickListener(view -> { | ||
142 | showFragment(getErrorFragment(), R.id.rl_content); | ||
143 | iv_3.setBackgroundResource(R.mipmap.hoss); | ||
144 | tv_1.setTextColor(Color.parseColor("#1C90F3")); | ||
145 | iv_4.setBackgroundResource(R.mipmap.wmus); | ||
146 | tv_4.setTextColor(Color.parseColor("#333333")); | ||
147 | }); | ||
148 | |||
149 | cl_me.setOnClickListener(view -> { | ||
150 | showFragment(getMeFragment(), R.id.rl_content); | ||
151 | iv_3.setBackgroundResource(R.mipmap.hous); | ||
152 | tv_1.setTextColor(Color.parseColor("#333333")); | ||
153 | iv_4.setBackgroundResource(R.mipmap.wmss); | ||
154 | tv_4.setTextColor(Color.parseColor("#1C90F3")); | ||
155 | }); | ||
156 | } | ||
157 | |||
158 | @Override | ||
159 | protected void initData() { | ||
160 | |||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public void onNetChanged(int netWorkState) { | ||
165 | |||
166 | } | ||
167 | |||
168 | public void downloadApk(String url, int versionCode) { | ||
169 | String filepath = getExternalFilesDir("apk").getPath() + "/" + versionCode + ".apk"; | ||
170 | ProgressDialog dialog = new ProgressDialog(this); | ||
171 | dialog.setTitle("版本更新"); | ||
172 | dialog.setMessage("正在下载新版本,请稍后"); | ||
173 | dialog.setMax(100); | ||
174 | dialog.setProgress(0); | ||
175 | dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | ||
176 | dialog.show(); | ||
177 | DownloadUtil.download(url, filepath, new DownloadUtil.OnDownloadListener() { | ||
178 | @Override | ||
179 | public void onDownloadSuccess(String path) { | ||
180 | dialog.setProgress(100); | ||
181 | dialog.dismiss(); | ||
182 | installApk(filepath); | ||
183 | } | ||
184 | |||
185 | @Override | ||
186 | public void onDownloading(int progress) { | ||
187 | dialog.setProgress(progress); | ||
188 | } | ||
189 | |||
190 | @Override | ||
191 | public void onDownloadFailed(String msg) { | ||
192 | dialog.dismiss(); | ||
193 | Looper.prepare(); | ||
194 | showToast("下载失败。"); | ||
195 | Looper.loop(); | ||
196 | } | ||
197 | }); | ||
198 | } | ||
199 | |||
200 | public void installApk(String path) { | ||
201 | //开启扫码界面 | ||
202 | Intent intentUpdate = new Intent("android.intent.action.VIEW"); | ||
203 | intentUpdate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
204 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //对Android N及以上的版本做判断 | ||
205 | Uri apkUriN = FileProvider.getUriForFile(TeacherMainActivity.this, | ||
206 | getApplicationContext().getPackageName() + ".fileprovider", new File(path)); | ||
207 | intentUpdate.addCategory("android.intent.category.DEFAULT"); | ||
208 | intentUpdate.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //天假Flag 表示我们需要什么权限 | ||
209 | intentUpdate.setDataAndType(apkUriN, "application/vnd.android.package-archive"); | ||
210 | } else { | ||
211 | Uri apkUri = Uri.fromFile(new File(path)); | ||
212 | intentUpdate.setDataAndType(apkUri, "application/vnd.android.package-archive"); | ||
213 | } | ||
214 | startActivity(intentUpdate); | ||
215 | } | ||
216 | |||
217 | public void checkUpdate() { | ||
218 | NetWorks.checkUpdate(BuildConfig.VERSION_CODE, BuildConfig.APPLICATION_ID, new Callback<ResponseResult<UpdateBean>>() { | ||
219 | @Override | ||
220 | public void onResponse(Call<ResponseResult<UpdateBean>> call, Response<ResponseResult<UpdateBean>> response) { | ||
221 | if (response.body() != null && response.body().getCode() == 200) { | ||
222 | if (response.body().getData() != null) { | ||
223 | String msg = response.body().getData().getExplain(); | ||
224 | String url = response.body().getData().getUrl(); | ||
225 | int versionCode = response.body().getData().getVersion(); | ||
226 | showUpdateDialog(msg, url, versionCode); | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | @Override | ||
232 | public void onFailure(Call<ResponseResult<UpdateBean>> call, Throwable t) { | ||
233 | } | ||
234 | }); | ||
235 | } | ||
236 | |||
237 | public void showUpdateDialog(String msg, String url, int versionCode) { | ||
238 | TipDialog tipDialog = new TipDialog(this, "检测到新版本", msg, "升级", "取消", new TipDialog.TipDialogInterface() { | ||
239 | @Override | ||
240 | public void onConfirm(Dialog dialog) { | ||
241 | if (!XXPermissions.isGranted(TeacherMainActivity.this, Permission.MANAGE_EXTERNAL_STORAGE)) { | ||
242 | XXPermissions.with(TeacherMainActivity.this) | ||
243 | // 申请多个权限 | ||
244 | .permission(Permission.MANAGE_EXTERNAL_STORAGE) | ||
245 | .request(new OnPermissionCallback() { | ||
246 | @Override | ||
247 | public void onGranted(List<String> permissions, boolean all) { | ||
248 | if (all) { | ||
249 | //开启扫码界面 | ||
250 | downloadApk(url, versionCode); | ||
251 | } else { | ||
252 | Toast.makeText(TeacherMainActivity.this, "需要权限", Toast.LENGTH_SHORT).show(); | ||
253 | } | ||
254 | } | ||
255 | |||
256 | @Override | ||
257 | public void onDenied(List<String> permissions, boolean never) { | ||
258 | XXPermissions.startPermissionActivity(TeacherMainActivity.this, permissions); | ||
259 | } | ||
260 | }); | ||
261 | } else { | ||
262 | downloadApk(url, versionCode); | ||
263 | } | ||
264 | |||
265 | } | ||
266 | |||
267 | @Override | ||
268 | public void onCancel(Dialog dialog) { | ||
269 | dialog.dismiss(); | ||
270 | } | ||
271 | }); | ||
272 | tipDialog.show(); | ||
273 | } | ||
274 | } |
app/src/main/java/com/hjx/parent/dialog/ErrorInputDialog.java
1 | package com.hjx.parent.dialog; | 1 | package com.hjx.parent.dialog; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Color; | 6 | import android.graphics.Color; |
7 | import android.graphics.drawable.Drawable; | 7 | import android.graphics.drawable.Drawable; |
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.view.Gravity; | 9 | import android.view.Gravity; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.Window; | 11 | import android.view.Window; |
12 | import android.view.WindowManager; | 12 | import android.view.WindowManager; |
13 | import android.widget.AdapterView; | 13 | import android.widget.AdapterView; |
14 | import android.widget.ArrayAdapter; | 14 | import android.widget.ArrayAdapter; |
15 | import android.widget.CompoundButton; | 15 | import android.widget.CompoundButton; |
16 | import android.widget.RadioButton; | 16 | import android.widget.RadioButton; |
17 | import android.widget.RadioGroup; | 17 | import android.widget.RadioGroup; |
18 | 18 | ||
19 | import androidx.annotation.NonNull; | 19 | import androidx.annotation.NonNull; |
20 | import androidx.recyclerview.widget.LinearLayoutManager; | 20 | import androidx.recyclerview.widget.LinearLayoutManager; |
21 | import androidx.recyclerview.widget.RecyclerView; | 21 | import androidx.recyclerview.widget.RecyclerView; |
22 | 22 | ||
23 | import com.bumptech.glide.Glide; | 23 | import com.bumptech.glide.Glide; |
24 | import com.chad.library.adapter.base.BaseQuickAdapter; | 24 | import com.chad.library.adapter.base.BaseQuickAdapter; |
25 | import com.chad.library.adapter.base.BaseViewHolder; | 25 | import com.chad.library.adapter.base.BaseViewHolder; |
26 | import com.google.gson.Gson; | 26 | import com.google.gson.Gson; |
27 | import com.hjx.parent.AddSuccessActivity; | 27 | import com.hjx.parent.AddSuccessActivity; |
28 | import com.hjx.parent.App; | 28 | import com.hjx.parent.App; |
29 | import com.hjx.parent.ImageActivity; | 29 | import com.hjx.parent.ImageActivity; |
30 | import com.hjx.parent.R; | 30 | import com.hjx.parent.R; |
31 | import com.hjx.parent.bean.StudentBean; | 31 | import com.hjx.parent.bean.StudentBean; |
32 | import com.hjx.parent.databinding.DialogAddErrorBinding; | 32 | import com.hjx.parent.databinding.DialogAddErrorBinding; |
33 | import com.prws.common.bean.Grade; | 33 | import com.prws.common.bean.Grade; |
34 | import com.prws.common.bean.GradeAndSubject; | 34 | import com.prws.common.bean.GradeAndSubject; |
35 | import com.prws.common.bean.ResponseResult; | 35 | import com.prws.common.bean.ResponseResult; |
36 | import com.prws.common.bean.Subject; | 36 | import com.prws.common.bean.Subject; |
37 | import com.prws.common.bean.TopicBean; | 37 | import com.prws.common.bean.TopicBean; |
38 | import com.prws.common.net.NetWorks; | 38 | import com.prws.common.net.NetWorks; |
39 | import com.prws.common.utils.CommonUtil; | 39 | import com.prws.common.utils.CommonUtil; |
40 | import com.prws.common.utils.LogUtil; | ||
40 | import com.prws.common.utils.SharedPreferencesUtil; | 41 | import com.prws.common.utils.SharedPreferencesUtil; |
41 | import com.prws.common.utils.StringUtils; | 42 | import com.prws.common.utils.StringUtils; |
42 | 43 | ||
44 | import org.json.JSONArray; | ||
45 | import org.json.JSONObject; | ||
46 | |||
43 | import java.util.ArrayList; | 47 | import java.util.ArrayList; |
44 | import java.util.HashMap; | 48 | import java.util.HashMap; |
45 | import java.util.List; | 49 | import java.util.List; |
46 | import java.util.Map; | 50 | import java.util.Map; |
47 | 51 | ||
48 | import io.reactivex.Observer; | 52 | import io.reactivex.Observer; |
49 | import io.reactivex.disposables.Disposable; | 53 | import io.reactivex.disposables.Disposable; |
54 | import okhttp3.ResponseBody; | ||
50 | 55 | ||
51 | public class ErrorInputDialog extends Dialog { | 56 | public class ErrorInputDialog extends Dialog { |
52 | private ImageActivity context; | 57 | private ImageActivity context; |
53 | private DialogAddErrorBinding binding; | 58 | private DialogAddErrorBinding binding; |
54 | private List<TopicBean> list; | 59 | private List<TopicBean> list; |
55 | private int select = 0; | 60 | private int select = 0; |
56 | private Grade grade; | 61 | private Grade grade; |
57 | private Subject subject; | 62 | private Subject subject; |
58 | private int reason; | 63 | private int reason; |
59 | private int type = 0; | 64 | private int type = 0; |
60 | BaseQuickAdapter adapter; | 65 | BaseQuickAdapter adapter; |
61 | 66 | ||
62 | public ErrorInputDialog(@NonNull ImageActivity context, List<TopicBean> list) { | 67 | public ErrorInputDialog(@NonNull ImageActivity context, List<TopicBean> list) { |
63 | super(context, R.style.MyAlertDialog); | 68 | super(context, R.style.MyAlertDialog); |
64 | this.context = context; | 69 | this.context = context; |
65 | this.list = list; | 70 | this.list = list; |
66 | } | 71 | } |
67 | 72 | ||
68 | @Override | 73 | @Override |
69 | protected void onCreate(Bundle savedInstanceState) { | 74 | protected void onCreate(Bundle savedInstanceState) { |
70 | super.onCreate(savedInstanceState); | 75 | super.onCreate(savedInstanceState); |
71 | binding = DialogAddErrorBinding.inflate(getLayoutInflater()); | 76 | binding = DialogAddErrorBinding.inflate(getLayoutInflater()); |
72 | setContentView(binding.getRoot()); | 77 | setContentView(binding.getRoot()); |
73 | Window dialogWindow = getWindow(); | 78 | Window dialogWindow = getWindow(); |
74 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); | 79 | WindowManager.LayoutParams lp = dialogWindow.getAttributes(); |
75 | lp.width = CommonUtil.getScreenWidth(getContext()); | 80 | lp.width = CommonUtil.getScreenWidth(getContext()); |
76 | dialogWindow.setGravity(Gravity.BOTTOM); | 81 | dialogWindow.setGravity(Gravity.BOTTOM); |
77 | dialogWindow.setAttributes(lp); | 82 | dialogWindow.setAttributes(lp); |
78 | adapter = new BaseQuickAdapter(R.layout.item_topic, list) { | 83 | adapter = new BaseQuickAdapter(R.layout.item_topic, list) { |
79 | @Override | 84 | @Override |
80 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 85 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
81 | int position = item.getAdapterPosition(); | 86 | int position = item.getAdapterPosition(); |
82 | item.setText(R.id.tv_name, context.getString(R.string.num_topic, StringUtils.intToChinese(position + 1))); | 87 | item.setText(R.id.tv_name, context.getString(R.string.num_topic, StringUtils.intToChinese(position + 1))); |
83 | if (list.get(position).isFinish()) { | 88 | if (list.get(position).isFinish()) { |
84 | item.setGone(R.id.iv_click, true); | 89 | item.setGone(R.id.iv_click, true); |
85 | item.setBackgroundRes(R.id.tv_name, R.drawable.topic_finish_bg); | 90 | item.setBackgroundRes(R.id.tv_name, R.drawable.topic_finish_bg); |
86 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); | 91 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); |
87 | } else if (select == position) { | 92 | } else if (select == position) { |
88 | item.setGone(R.id.iv_click, false); | 93 | item.setGone(R.id.iv_click, false); |
89 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_select_topic_bg); | 94 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_select_topic_bg); |
90 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); | 95 | item.setTextColor(R.id.tv_name, Color.parseColor("#1C90F3")); |
91 | } else { | 96 | } else { |
92 | item.setGone(R.id.iv_click, false); | 97 | item.setGone(R.id.iv_click, false); |
93 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_topic_bg); | 98 | item.setBackgroundRes(R.id.tv_name, R.drawable.button_topic_bg); |
94 | item.setTextColor(R.id.tv_name, Color.parseColor("#999999")); | 99 | item.setTextColor(R.id.tv_name, Color.parseColor("#999999")); |
95 | } | 100 | } |
96 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 101 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
97 | @Override | 102 | @Override |
98 | public void onClick(View v) { | 103 | public void onClick(View v) { |
99 | select = position; | 104 | select = position; |
100 | loadError(); | 105 | loadError(); |
101 | notifyDataSetChanged(); | 106 | notifyDataSetChanged(); |
102 | } | 107 | } |
103 | }); | 108 | }); |
104 | } | 109 | } |
105 | 110 | ||
106 | @Override | 111 | @Override |
107 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 112 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
108 | 113 | ||
109 | } | 114 | } |
110 | }; | 115 | }; |
111 | binding.listItem.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); | 116 | binding.listItem.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); |
112 | binding.listItem.setAdapter(adapter); | 117 | binding.listItem.setAdapter(adapter); |
113 | List<String> grades = new ArrayList<>(); | 118 | List<String> grades = new ArrayList<>(); |
114 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { | 119 | for (GradeAndSubject grade : App.getInstance().getGradeAndSubjects()) { |
115 | grades.add(grade.getGrade().getGrade()); | 120 | grades.add(grade.getGrade().getGrade()); |
116 | } | 121 | } |
117 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); | 122 | ArrayAdapter<String> gradeAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, grades); |
118 | binding.spinnerGrade.setAdapter(gradeAdapter); | 123 | binding.spinnerGrade.setAdapter(gradeAdapter); |
119 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 124 | binding.spinnerGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
120 | @Override | 125 | @Override |
121 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 126 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
122 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); | 127 | grade = App.getInstance().getGradeAndSubjects().get(position).getGrade(); |
123 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); | 128 | refreshSubject(App.getInstance().getGradeAndSubjects().get(position).getSubjects()); |
124 | } | 129 | } |
125 | 130 | ||
126 | @Override | 131 | @Override |
127 | public void onNothingSelected(AdapterView<?> parent) { | 132 | public void onNothingSelected(AdapterView<?> parent) { |
128 | 133 | ||
129 | } | 134 | } |
130 | }); | 135 | }); |
131 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); | 136 | ArrayAdapter<String> reasonAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, context.getResources().getStringArray(R.array.error_reason)); |
132 | binding.spinnerReason.setAdapter(reasonAdapter); | 137 | binding.spinnerReason.setAdapter(reasonAdapter); |
133 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 138 | binding.spinnerReason.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
134 | @Override | 139 | @Override |
135 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 140 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
136 | reason = position; | 141 | reason = position; |
137 | } | 142 | } |
138 | 143 | ||
139 | @Override | 144 | @Override |
140 | public void onNothingSelected(AdapterView<?> parent) { | 145 | public void onNothingSelected(AdapterView<?> parent) { |
141 | 146 | ||
142 | } | 147 | } |
143 | }); | 148 | }); |
144 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(type); | 149 | RadioButton typeButton = (RadioButton) binding.typeRadio.getChildAt(type); |
145 | typeButton.setChecked(true); | 150 | typeButton.setChecked(true); |
146 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 151 | binding.typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
147 | @Override | 152 | @Override |
148 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 153 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
149 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 154 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
150 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; | 155 | type = getContext().getString(R.string.topic_type_in).equals(rcheck.getText().toString()) ? 0 : 1; |
151 | list.get(select).setType(type); | 156 | list.get(select).setType(type); |
152 | } | 157 | } |
153 | }); | 158 | }); |
154 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 159 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
155 | @Override | 160 | @Override |
156 | public void onClick(View v) { | 161 | public void onClick(View v) { |
157 | dismiss(); | 162 | dismiss(); |
158 | } | 163 | } |
159 | }); | 164 | }); |
160 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | 165 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
161 | @Override | 166 | @Override |
162 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | 167 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
163 | if (isChecked) { | 168 | if (isChecked) { |
164 | binding.addTopic.setText("全部加入错题本"); | 169 | binding.addTopic.setText("全部加入错题本"); |
165 | } else { | 170 | } else { |
166 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); | 171 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); |
167 | } | 172 | } |
168 | } | 173 | } |
169 | }); | 174 | }); |
170 | binding.addTopic.setOnClickListener(new View.OnClickListener() { | 175 | binding.addTopic.setOnClickListener(new View.OnClickListener() { |
171 | @Override | 176 | @Override |
172 | public void onClick(View v) { | 177 | public void onClick(View v) { |
173 | if (binding.checkbox.isChecked()) { | 178 | if (binding.checkbox.isChecked()) { |
174 | for (TopicBean topicBean : list) { | 179 | for (TopicBean topicBean : list) { |
175 | addTopic(topicBean); | 180 | addTopic(topicBean); |
176 | } | 181 | } |
177 | } else { | 182 | } else { |
178 | addTopic(list.get(select)); | 183 | addTopic(list.get(select)); |
179 | } | 184 | } |
180 | } | 185 | } |
181 | }); | 186 | }); |
182 | loadError(); | 187 | loadError(); |
183 | } | 188 | } |
184 | 189 | ||
190 | |||
185 | private void refreshSubject(List<Subject> subjects) { | 191 | private void refreshSubject(List<Subject> subjects) { |
186 | List<String> s = new ArrayList<>(); | 192 | List<String> s = new ArrayList<>(); |
187 | for (Subject subject : subjects) { | 193 | for (Subject subject : subjects) { |
188 | s.add(subject.getSubject()); | 194 | s.add(subject.getSubject()); |
189 | } | 195 | } |
190 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); | 196 | ArrayAdapter<String> subjectAdapter = new ArrayAdapter<>(context, R.layout.item_for_custom_spinner, s); |
191 | binding.spinnerSubject.setAdapter(subjectAdapter); | 197 | binding.spinnerSubject.setAdapter(subjectAdapter); |
192 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | 198 | binding.spinnerSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { |
193 | @Override | 199 | @Override |
194 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | 200 | public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
195 | subject = subjects.get(position); | 201 | subject = subjects.get(position); |
196 | } | 202 | } |
197 | 203 | ||
198 | @Override | 204 | @Override |
199 | public void onNothingSelected(AdapterView<?> parent) { | 205 | public void onNothingSelected(AdapterView<?> parent) { |
200 | 206 | ||
201 | } | 207 | } |
202 | }); | 208 | }); |
203 | } | 209 | } |
204 | 210 | ||
205 | private void loadError() { | 211 | private void loadError() { |
206 | TopicBean bean = list.get(select); | 212 | TopicBean bean = list.get(select); |
207 | Glide.with(getContext()).load(bean.getPath()).override(CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(getContext(), 40), CommonUtil.dpToPx(getContext(), 90)).fitCenter().into(binding.ivTopic); | 213 | Glide.with(getContext()).load(bean.getPath()).override(CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(getContext(), 40), CommonUtil.dpToPx(getContext(), 90)).fitCenter().into(binding.ivTopic); |
208 | if (!binding.checkbox.isChecked()) { | 214 | if (!binding.checkbox.isChecked()) { |
209 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); | 215 | binding.addTopic.setText("第" + StringUtils.intToChinese(select + 1) + "题加入错题本"); |
210 | } | 216 | } |
211 | } | 217 | } |
212 | 218 | ||
213 | private void addTopic(TopicBean bean) { | 219 | private void addTopic(TopicBean bean) { |
214 | if (!bean.isFinish()) { | 220 | if (!bean.isFinish()) { |
215 | bean.setId(String.valueOf(System.currentTimeMillis())); | 221 | bean.setId(String.valueOf(System.currentTimeMillis())); |
216 | bean.setDate(String.valueOf(System.currentTimeMillis())); | 222 | bean.setDate(String.valueOf(System.currentTimeMillis())); |
217 | bean.setGrade(grade.getGrade()); | 223 | bean.setGrade(grade.getGrade()); |
218 | bean.setType(type); | 224 | bean.setType(type); |
219 | bean.setSubject(subject.getSubject()); | 225 | bean.setSubject(subject.getSubject()); |
220 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 226 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
221 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); | 227 | StudentBean studentBean = new Gson().fromJson(student, StudentBean.class); |
222 | Map<String, String> param = new HashMap<>(); | 228 | Map<String, String> param = new HashMap<>(); |
223 | param.put("bookId", bean.getId()); | 229 | param.put("bookId", bean.getId()); |
224 | param.put("stuId", studentBean.getStuId()); | 230 | param.put("stuId", studentBean.getStuId()); |
225 | param.put("errorReason", String.valueOf(reason)); | 231 | param.put("errorReason", String.valueOf(reason)); |
226 | param.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); | 232 | param.put("title", grade.getGrade() + "-" + subject.getSubject() + "-" + (type == 0 ? "课内" : "课外") + "错题"); |
227 | param.put("subject", bean.getSubject()); | 233 | param.put("subject", bean.getSubject()); |
228 | param.put("grade", bean.getGrade()); | 234 | param.put("grade", bean.getGrade()); |
229 | param.put("type", String.valueOf(bean.getType())); | 235 | param.put("type", String.valueOf(bean.getType())); |
230 | param.put("teacherFlag", "0"); | 236 | param.put("teacherFlag", "0"); |
231 | param.put("controlFlag", "1"); | 237 | param.put("controlFlag", "1"); |
232 | NetWorks.addError(bean.getPath(), param, new Observer<ResponseResult>() { | 238 | NetWorks.addError(bean.getPath(), param, new Observer<ResponseResult>() { |
233 | @Override | 239 | @Override |
234 | public void onSubscribe(Disposable d) { | 240 | public void onSubscribe(Disposable d) { |
235 | 241 | ||
236 | } | 242 | } |
237 | 243 | ||
238 | @Override | 244 | @Override |
239 | public void onNext(ResponseResult responseResult) { | 245 | public void onNext(ResponseResult responseResult) { |
240 | if (responseResult.getCode() == 200) { | 246 | if (responseResult.getCode() == 200) { |
241 | bean.setFinish(true); | 247 | bean.setFinish(true); |
242 | boolean isAllAdd = true; | 248 | boolean isAllAdd = true; |
243 | for (int i = 0; i < list.size(); i++) { | 249 | for (int i = 0; i < list.size(); i++) { |
244 | if (!list.get(i).isFinish()) { | 250 | if (!list.get(i).isFinish()) { |
245 | select = i; | 251 | select = i; |
246 | adapter.notifyDataSetChanged(); | 252 | adapter.notifyDataSetChanged(); |
247 | isAllAdd = false; | 253 | isAllAdd = false; |
248 | loadError(); | 254 | loadError(); |
249 | break; | 255 | break; |
250 | } | 256 | } |
251 | } | 257 | } |
252 | if (isAllAdd) { | 258 | if (isAllAdd) { |
253 | dismiss(); | 259 | dismiss(); |
254 | Intent intent = new Intent(context, AddSuccessActivity.class); | 260 | Intent intent = new Intent(context, AddSuccessActivity.class); |
255 | context.startActivity(intent); | 261 | context.startActivity(intent); |
256 | context.finish(); | 262 | context.finish(); |
257 | } | 263 | } |
258 | } | 264 | } |
259 | } | 265 | } |
260 | 266 | ||
261 | @Override | 267 | @Override |
262 | public void onError(Throwable e) { | 268 | public void onError(Throwable e) { |
263 | 269 | ||
264 | } | 270 | } |
265 | 271 | ||
266 | @Override | 272 | @Override |
267 | public void onComplete() { | 273 | public void onComplete() { |
268 | 274 | ||
269 | } | 275 | } |
270 | }); | 276 | }); |
271 | } | 277 | } |
272 | } | 278 | } |
273 | } | 279 | } |
274 | 280 |
app/src/main/java/com/hjx/parent/fragment/BaseBindingFragment.java
File was created | 1 | package com.hjx.parent.fragment; | |
2 | |||
3 | import android.os.Bundle; | ||
4 | import android.view.LayoutInflater; | ||
5 | import android.view.View; | ||
6 | import android.view.ViewGroup; | ||
7 | |||
8 | import androidx.annotation.NonNull; | ||
9 | import androidx.annotation.Nullable; | ||
10 | import androidx.fragment.app.Fragment; | ||
11 | import androidx.viewbinding.ViewBinding; | ||
12 | |||
13 | public abstract class BaseBindingFragment<T extends ViewBinding> extends Fragment { | ||
14 | |||
15 | private T binding; | ||
16 | |||
17 | @Nullable | ||
18 | @Override | ||
19 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
20 | // 调用onCreateViewBinding方法获取binding | ||
21 | binding = onCreateViewBinding(inflater, container); | ||
22 | return binding.getRoot(); | ||
23 | } | ||
24 | |||
25 | @Override | ||
26 | public void onDestroyView() { | ||
27 | super.onDestroyView(); | ||
28 | // 引用置空处理 | ||
29 | binding = null; | ||
30 | } | ||
31 | |||
32 | // 子类使用该方法来使用binding | ||
33 | public T getBinding() { | ||
34 | return binding; | ||
35 | } | ||
36 | |||
37 | // 由子类去重写 | ||
38 | protected abstract T onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent); | ||
39 | } |
app/src/main/java/com/hjx/parent/fragment/ErrorFragment.java
File was created | 1 | package com.hjx.parent.fragment; | |
2 | |||
3 | import static android.app.Activity.RESULT_OK; | ||
4 | |||
5 | import android.content.Intent; | ||
6 | import android.graphics.Bitmap; | ||
7 | import android.graphics.BitmapFactory; | ||
8 | import android.net.Uri; | ||
9 | import android.os.Bundle; | ||
10 | import android.provider.MediaStore; | ||
11 | import android.text.TextUtils; | ||
12 | import android.util.Log; | ||
13 | import android.view.LayoutInflater; | ||
14 | import android.view.View; | ||
15 | import android.view.ViewGroup; | ||
16 | import android.widget.ImageView; | ||
17 | import android.widget.LinearLayout; | ||
18 | import android.widget.Toast; | ||
19 | |||
20 | import androidx.annotation.NonNull; | ||
21 | import androidx.annotation.Nullable; | ||
22 | import androidx.core.content.FileProvider; | ||
23 | import androidx.recyclerview.widget.LinearLayoutManager; | ||
24 | import androidx.recyclerview.widget.RecyclerView; | ||
25 | |||
26 | import com.bumptech.glide.Glide; | ||
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | ||
28 | import com.bumptech.glide.request.RequestOptions; | ||
29 | import com.chad.library.adapter.base.BaseQuickAdapter; | ||
30 | import com.chad.library.adapter.base.BaseViewHolder; | ||
31 | import com.google.gson.Gson; | ||
32 | import com.hjq.permissions.OnPermissionCallback; | ||
33 | import com.hjq.permissions.Permission; | ||
34 | import com.hjq.permissions.XXPermissions; | ||
35 | import com.hjx.parent.ChooseActivity; | ||
36 | import com.hjx.parent.ErrorBookActivity; | ||
37 | import com.hjx.parent.ErrorListActivity; | ||
38 | import com.hjx.parent.ImageActivity; | ||
39 | import com.hjx.parent.R; | ||
40 | import com.hjx.parent.TeacherChooseActivity; | ||
41 | import com.hjx.parent.adapter.ErrorAdapter; | ||
42 | import com.hjx.parent.bean.StudentBean; | ||
43 | import com.hjx.parent.databinding.ActivityErrorBookBinding; | ||
44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | ||
45 | import com.prws.common.bean.PageInfo; | ||
46 | import com.prws.common.bean.ResponseResult; | ||
47 | import com.prws.common.bean.TopicBean; | ||
48 | import com.prws.common.net.NetWorks; | ||
49 | import com.prws.common.utils.BitmapUtils; | ||
50 | import com.prws.common.utils.CommonUtil; | ||
51 | import com.prws.common.utils.ScreenUtils; | ||
52 | import com.prws.common.utils.SharedPreferencesUtil; | ||
53 | import com.prws.common.utils.dialog.MyButtomDialog; | ||
54 | import com.zhangteng.imagepicker.bean.ImageInfo; | ||
55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | ||
56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | ||
57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | ||
58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | ||
59 | import com.zhangteng.utils.IHandlerCallBack; | ||
60 | |||
61 | import java.io.File; | ||
62 | import java.util.ArrayList; | ||
63 | import java.util.Arrays; | ||
64 | import java.util.HashMap; | ||
65 | import java.util.List; | ||
66 | import java.util.Map; | ||
67 | |||
68 | import io.reactivex.Observer; | ||
69 | import io.reactivex.disposables.Disposable; | ||
70 | |||
71 | public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> { | ||
72 | StudentBean studentBean; | ||
73 | private int subject; | ||
74 | private ErrorAdapter adapter; | ||
75 | private int REQUEST_CODE_IMAGE = 123; | ||
76 | private String filePath; | ||
77 | |||
78 | @Override | ||
79 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | ||
80 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | ||
81 | } | ||
82 | |||
83 | @Override | ||
84 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
85 | super.onViewCreated(view, savedInstanceState); | ||
86 | String student = (String) SharedPreferencesUtil.getData("student", ""); | ||
87 | try { | ||
88 | studentBean = new Gson().fromJson(student, StudentBean.class); | ||
89 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | ||
90 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | ||
91 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | ||
92 | getBinding().ivStudent.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | ||
93 | } else { | ||
94 | Glide.with(getContext()).load(studentBean.getPhoto()).apply(options).into(getBinding().ivStudent); | ||
95 | } | ||
96 | getBinding().tvName.setText(studentBean.getStuName()); | ||
97 | } catch (Exception e) { | ||
98 | |||
99 | } | ||
100 | getBinding().rlTakePhoto.post(new Runnable() { | ||
101 | @Override | ||
102 | public void run() { | ||
103 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getBinding().rlTakePhoto.getLayoutParams(); | ||
104 | layoutParams.width = CommonUtil.getScreenWidth(getContext()); | ||
105 | layoutParams.height = CommonUtil.getScreenWidth(getContext()) * 20 / 37; | ||
106 | getBinding().rlTakePhoto.setLayoutParams(layoutParams); | ||
107 | } | ||
108 | }); | ||
109 | getBinding().tvChoose.setOnClickListener(new View.OnClickListener() { | ||
110 | @Override | ||
111 | public void onClick(View v) { | ||
112 | startActivity(new Intent(getContext(), TeacherChooseActivity.class)); | ||
113 | getActivity().finish(); | ||
114 | } | ||
115 | }); | ||
116 | getBinding().rlTakePhoto.setOnClickListener(new View.OnClickListener() { | ||
117 | @Override | ||
118 | public void onClick(View v) { | ||
119 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | ||
120 | XXPermissions.with(getContext()) | ||
121 | // 申请多个权限 | ||
122 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | ||
123 | @Override | ||
124 | public void onGranted(List<String> permissions, boolean all) { | ||
125 | if (all) { | ||
126 | //开启扫码界面 | ||
127 | showButtonDialog(); | ||
128 | } else { | ||
129 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | @Override | ||
134 | public void onDenied(List<String> permissions, boolean never) { | ||
135 | XXPermissions.startPermissionActivity(getContext(), permissions); | ||
136 | } | ||
137 | }); | ||
138 | } else { | ||
139 | showButtonDialog(); | ||
140 | } | ||
141 | |||
142 | } | ||
143 | }); | ||
144 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | ||
145 | @Override | ||
146 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | ||
147 | |||
148 | } | ||
149 | |||
150 | @Override | ||
151 | protected void convert(@NonNull BaseViewHolder item, Object o) { | ||
152 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | ||
153 | switch (item.getAdapterPosition()) { | ||
154 | case 0: | ||
155 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | ||
156 | break; | ||
157 | case 1: | ||
158 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | ||
159 | break; | ||
160 | case 2: | ||
161 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | ||
162 | break; | ||
163 | case 3: | ||
164 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | ||
165 | break; | ||
166 | case 4: | ||
167 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | ||
168 | break; | ||
169 | } | ||
170 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | ||
171 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | ||
172 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | ||
173 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | ||
174 | @Override | ||
175 | public void onClick(View v) { | ||
176 | if (subject != item.getAdapterPosition()) { | ||
177 | subject = item.getAdapterPosition(); | ||
178 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | ||
179 | } | ||
180 | } | ||
181 | }); | ||
182 | } | ||
183 | }; | ||
184 | getBinding().recycleSubject.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | ||
185 | getBinding().recycleSubject.setAdapter(adapter); | ||
186 | subject = 0; | ||
187 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | ||
188 | getBinding().llAll.setOnClickListener(new View.OnClickListener() { | ||
189 | @Override | ||
190 | public void onClick(View v) { | ||
191 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | ||
192 | startActivity(intent); | ||
193 | } | ||
194 | }); | ||
195 | } | ||
196 | |||
197 | private void showButtonDialog() { | ||
198 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | ||
199 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | ||
200 | dialog.setContentView(bottomView); | ||
201 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | ||
202 | @Override | ||
203 | public void onClick(View view) { | ||
204 | dialog.dismiss(); | ||
205 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | ||
206 | //确保有相机来处理Intent | ||
207 | filePath = getActivity().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | ||
208 | File photoFile = new File(filePath); | ||
209 | if (photoFile != null) { | ||
210 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | ||
211 | Uri photoUri = FileProvider.getUriForFile(getActivity(), "com.hjx.parent.fileprovider", photoFile); | ||
212 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | ||
213 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | ||
214 | startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | ||
215 | } | ||
216 | } | ||
217 | }); | ||
218 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | ||
219 | @Override | ||
220 | public void onClick(View view) { | ||
221 | dialog.dismiss(); | ||
222 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | ||
223 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | ||
224 | .multiSelect(true) //是否多选 | ||
225 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | ||
226 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | ||
227 | .maxImageSelectable(9) //图片可选择数 | ||
228 | .maxHeight(1920) //图片最大高度 | ||
229 | .maxWidth(1920) //图片最大宽度 | ||
230 | .maxImageSize(10) //图片最大大小Mb | ||
231 | .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(); | ||
232 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | ||
233 | |||
234 | } | ||
235 | }); | ||
236 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | ||
237 | @Override | ||
238 | public void onClick(View view) { | ||
239 | dialog.dismiss(); | ||
240 | } | ||
241 | }); | ||
242 | dialog.show(); | ||
243 | } | ||
244 | |||
245 | private void getError(String subject) { | ||
246 | if (studentBean != null) { | ||
247 | Map map = new HashMap(); | ||
248 | map.put("subject", subject); | ||
249 | map.put("stuId", studentBean.getStuId()); | ||
250 | map.put("pageSize", 5); | ||
251 | map.put("pageNum", 1); | ||
252 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | ||
253 | @Override | ||
254 | public void onSubscribe(Disposable d) { | ||
255 | |||
256 | } | ||
257 | |||
258 | @Override | ||
259 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | ||
260 | if (result.getData() != null && result.getCode() == 200) { | ||
261 | List<TopicBean> topicBeans = result.getData().getList(); | ||
262 | loadError(topicBeans); | ||
263 | } | ||
264 | } | ||
265 | |||
266 | @Override | ||
267 | public void onError(Throwable e) { | ||
268 | e.toString(); | ||
269 | } | ||
270 | |||
271 | @Override | ||
272 | public void onComplete() { | ||
273 | |||
274 | } | ||
275 | }); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | private void loadError(List<TopicBean> list) { | ||
280 | if (list.size() > 0) { | ||
281 | getBinding().recycleError.setVisibility(View.VISIBLE); | ||
282 | getBinding().llEmpty.setVisibility(View.GONE); | ||
283 | if (adapter != null) { | ||
284 | adapter.refresh(list); | ||
285 | } else { | ||
286 | adapter = new ErrorAdapter(getActivity(), list, false); | ||
287 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false)); | ||
288 | getBinding().recycleError.setAdapter(adapter); | ||
289 | } | ||
290 | } else { | ||
291 | getBinding().recycleError.setVisibility(View.GONE); | ||
292 | getBinding().llEmpty.setVisibility(View.VISIBLE); | ||
293 | } | ||
294 | } | ||
295 | |||
296 | @Override | ||
297 | public void onResume() { | ||
298 | super.onResume(); | ||
299 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | ||
300 | } | ||
301 | |||
302 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | ||
303 | private String TAG = "---ImagePicker---"; | ||
304 | List<ImageInfo> photoList = new ArrayList<>(); | ||
305 | |||
306 | @Override | ||
307 | public void onStart() { | ||
308 | Log.i(TAG, "onStart: 开启"); | ||
309 | } | ||
310 | |||
311 | @Override | ||
312 | public void onSuccess(List<ImageInfo> photoList) { | ||
313 | this.photoList = photoList; | ||
314 | Log.i(TAG, "onSuccess: 返回数据"); | ||
315 | } | ||
316 | |||
317 | @Override | ||
318 | public void onCancel() { | ||
319 | Log.i(TAG, "onCancel: 取消"); | ||
320 | } | ||
321 | |||
322 | @Override | ||
323 | public void onFinish(List<ImageInfo> selectImage) { | ||
324 | if (selectImage.size() == photoList.size()) { | ||
325 | List<String> strings = new ArrayList<>(); | ||
326 | Intent intent = new Intent(getActivity(), ImageActivity.class); | ||
327 | for (ImageInfo imageInfo : selectImage) { | ||
328 | strings.add(imageInfo.getPath()); | ||
329 | } | ||
330 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | ||
331 | startActivity(intent); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | @Override | ||
336 | public void onError() { | ||
337 | Log.i(TAG, "onError: 出错"); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | @Override | ||
342 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | ||
343 | super.onActivityResult(requestCode, resultCode, data); | ||
344 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | ||
345 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | ||
346 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | ||
347 | CommonUtil.saveBitmapToUri(b, path); | ||
348 | List<String> strings = new ArrayList<>(); | ||
349 | Intent intent = new Intent(getContext(), ImageActivity.class); | ||
350 | strings.add(path); | ||
351 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | ||
352 | startActivity(intent); | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 |
app/src/main/java/com/hjx/parent/fragment/HomeFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.text.TextUtils; | 5 | import android.text.TextUtils; |
6 | import android.view.LayoutInflater; | 6 | import android.view.LayoutInflater; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.widget.ImageView; | 8 | import android.widget.ImageView; |
9 | import android.widget.LinearLayout; | 9 | import android.widget.LinearLayout; |
10 | import android.widget.TextView; | 10 | import android.widget.TextView; |
11 | import android.widget.Toast; | 11 | import android.widget.Toast; |
12 | 12 | ||
13 | import androidx.annotation.NonNull; | 13 | import androidx.annotation.NonNull; |
14 | import androidx.annotation.Nullable; | 14 | import androidx.annotation.Nullable; |
15 | import androidx.recyclerview.widget.LinearLayoutManager; | 15 | import androidx.recyclerview.widget.LinearLayoutManager; |
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.load.resource.bitmap.RoundedCorners; | 19 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
20 | import com.bumptech.glide.request.RequestOptions; | 20 | import com.bumptech.glide.request.RequestOptions; |
21 | import com.chad.library.adapter.base.BaseQuickAdapter; | 21 | import com.chad.library.adapter.base.BaseQuickAdapter; |
22 | import com.chad.library.adapter.base.BaseViewHolder; | 22 | import com.chad.library.adapter.base.BaseViewHolder; |
23 | import com.google.gson.Gson; | 23 | import com.google.gson.Gson; |
24 | import com.hjq.permissions.OnPermissionCallback; | 24 | import com.hjq.permissions.OnPermissionCallback; |
25 | import com.hjq.permissions.Permission; | 25 | import com.hjq.permissions.Permission; |
26 | import com.hjq.permissions.XXPermissions; | 26 | import com.hjq.permissions.XXPermissions; |
27 | import com.hjx.parent.ChooseActivity; | 27 | import com.hjx.parent.ChooseActivity; |
28 | import com.hjx.parent.ErrorBookActivity; | 28 | import com.hjx.parent.ErrorBookActivity; |
29 | import com.hjx.parent.QRActivity; | 29 | import com.hjx.parent.QRActivity; |
30 | import com.hjx.parent.R; | 30 | import com.hjx.parent.R; |
31 | import com.hjx.parent.bean.StudentBean; | 31 | import com.hjx.parent.bean.StudentBean; |
32 | import com.prws.common.base.BaseFragment; | 32 | import com.prws.common.base.BaseFragment; |
33 | import com.prws.common.bean.ResponseResult; | 33 | import com.prws.common.bean.ResponseResult; |
34 | import com.prws.common.bean.ScheduleBean; | 34 | import com.prws.common.bean.ScheduleBean; |
35 | import com.prws.common.bean.Video; | 35 | import com.prws.common.bean.Video; |
36 | import com.prws.common.net.NetWorks; | 36 | import com.prws.common.net.NetWorks; |
37 | import com.prws.common.utils.ScreenUtils; | 37 | import com.prws.common.utils.ScreenUtils; |
38 | import com.prws.common.utils.SharedPreferencesUtil; | 38 | import com.prws.common.utils.SharedPreferencesUtil; |
39 | import com.uuzuche.lib_zxing.activity.CaptureActivity; | 39 | import com.uuzuche.lib_zxing.activity.CaptureActivity; |
40 | import com.uuzuche.lib_zxing.activity.CodeUtils; | 40 | import com.uuzuche.lib_zxing.activity.CodeUtils; |
41 | 41 | ||
42 | import java.text.SimpleDateFormat; | 42 | import java.text.SimpleDateFormat; |
43 | import java.util.ArrayList; | 43 | import java.util.ArrayList; |
44 | import java.util.List; | 44 | import java.util.List; |
45 | 45 | ||
46 | import butterknife.BindView; | 46 | import butterknife.BindView; |
47 | import butterknife.OnClick; | 47 | import butterknife.OnClick; |
48 | import io.reactivex.Observer; | 48 | import io.reactivex.Observer; |
49 | import io.reactivex.disposables.Disposable; | 49 | import io.reactivex.disposables.Disposable; |
50 | 50 | ||
51 | public class HomeFragment extends BaseFragment { | 51 | public class HomeFragment extends BaseFragment { |
52 | @Override | 52 | @Override |
53 | protected int getLayoutRes() { | 53 | protected int getLayoutRes() { |
54 | return R.layout.fragment_home; | 54 | return R.layout.fragment_home; |
55 | } | 55 | } |
56 | 56 | ||
57 | ImageView iv_sapmiao; | 57 | ImageView iv_sapmiao; |
58 | TextView tv_name; | 58 | TextView tv_name; |
59 | StudentBean studentBean; | 59 | StudentBean studentBean; |
60 | ImageView iv_2; | 60 | ImageView iv_2; |
61 | @BindView(R.id.recycle) | 61 | @BindView(R.id.recycle) |
62 | RecyclerView recyclerView; | 62 | RecyclerView recyclerView; |
63 | @BindView(R.id.tv_empty) | 63 | @BindView(R.id.tv_empty) |
64 | TextView tv_empty; | 64 | TextView tv_empty; |
65 | @BindView(R.id.iv_empty) | 65 | @BindView(R.id.iv_empty) |
66 | ImageView iv_empty; | 66 | ImageView iv_empty; |
67 | 67 | ||
68 | @Override | 68 | @Override |
69 | protected void initDatas() { | 69 | protected void initDatas() { |
70 | super.initDatas(); | 70 | super.initDatas(); |
71 | iv_2 = mRootView.findViewById(R.id.iv_2); | 71 | iv_2 = mRootView.findViewById(R.id.iv_2); |
72 | iv_sapmiao = mRootView.findViewById(R.id.iv_sapmiao); | 72 | iv_sapmiao = mRootView.findViewById(R.id.iv_sapmiao); |
73 | tv_name = mRootView.findViewById(R.id.tv_name); | 73 | tv_name = mRootView.findViewById(R.id.tv_name); |
74 | iv_sapmiao.setOnClickListener(view -> { | 74 | iv_sapmiao.setOnClickListener(view -> { |
75 | if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)) { | 75 | if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)) { |
76 | XXPermissions.with(getActivity()) | 76 | XXPermissions.with(getActivity()) |
77 | // 申请多个权限 | 77 | // 申请多个权限 |
78 | .permission(Permission.CAMERA) | 78 | .permission(Permission.CAMERA) |
79 | .request(new OnPermissionCallback() { | 79 | .request(new OnPermissionCallback() { |
80 | @Override | 80 | @Override |
81 | public void onGranted(List<String> permissions, boolean all) { | 81 | public void onGranted(List<String> permissions, boolean all) { |
82 | if (all) { | 82 | if (all) { |
83 | //开启扫码界面 | 83 | //开启扫码界面 |
84 | startQRView(); | 84 | startQRView(); |
85 | 85 | ||
86 | 86 | ||
87 | } else { | 87 | } else { |
88 | Toast.makeText(getActivity(), "需要相机权限", Toast.LENGTH_SHORT).show(); | 88 | Toast.makeText(getActivity(), "需要相机权限", Toast.LENGTH_SHORT).show(); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | @Override | 92 | @Override |
93 | public void onDenied(List<String> permissions, boolean never) { | 93 | public void onDenied(List<String> permissions, boolean never) { |
94 | XXPermissions.startPermissionActivity(getActivity(), permissions); | 94 | XXPermissions.startPermissionActivity(getActivity(), permissions); |
95 | } | 95 | } |
96 | }); | 96 | }); |
97 | } else { | 97 | } else { |
98 | startQRView(); | 98 | startQRView(); |
99 | } | 99 | } |
100 | 100 | ||
101 | }); | 101 | }); |
102 | } | 102 | } |
103 | 103 | ||
104 | @OnClick(R.id.ll_error) | 104 | @OnClick(R.id.ll_error) |
105 | public void goError(View view) { | 105 | public void goError(View view) { |
106 | Intent intent = new Intent(getActivity(), ErrorBookActivity.class); | 106 | Intent intent = new Intent(getActivity(), ErrorBookActivity.class); |
107 | startActivity(intent); | 107 | startActivity(intent); |
108 | } | 108 | } |
109 | 109 | ||
110 | @Override | 110 | @Override |
111 | public void onResume() { | 111 | public void onResume() { |
112 | super.onResume(); | 112 | super.onResume(); |
113 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 113 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
114 | try { | 114 | try { |
115 | studentBean = new Gson().fromJson(student, StudentBean.class); | 115 | studentBean = new Gson().fromJson(student, StudentBean.class); |
116 | tv_name.setText(studentBean.getNickName()); | 116 | tv_name.setText(studentBean.getNickName()); |
117 | if (TextUtils.isEmpty(studentBean.getPhoto())) { | 117 | if (TextUtils.isEmpty(studentBean.getPhoto())) { |
118 | iv_2.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | 118 | iv_2.setImageResource(studentBean.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); |
119 | } else { | 119 | } else { |
120 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 20)); | 120 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 30)); |
121 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 121 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
122 | Glide.with(getActivity()).load(studentBean.getPhoto()).apply(options).into(iv_2); | 122 | Glide.with(getActivity()).load(studentBean.getPhoto()).apply(options).into(iv_2); |
123 | } | 123 | } |
124 | getWeekPlan(studentBean.getStuId()); | 124 | getWeekPlan(studentBean.getStuId()); |
125 | } catch (Exception e) { | 125 | } catch (Exception e) { |
126 | 126 | ||
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | public void getWeekPlan(String id) { | 130 | public void getWeekPlan(String id) { |
131 | NetWorks.getWeekPlan(id, new Observer<ResponseResult<ScheduleBean>>() { | 131 | NetWorks.getWeekPlan(id, new Observer<ResponseResult<ScheduleBean>>() { |
132 | @Override | 132 | @Override |
133 | public void onSubscribe(Disposable d) { | 133 | public void onSubscribe(Disposable d) { |
134 | 134 | ||
135 | } | 135 | } |
136 | 136 | ||
137 | @Override | 137 | @Override |
138 | public void onNext(ResponseResult<ScheduleBean> result) { | 138 | public void onNext(ResponseResult<ScheduleBean> result) { |
139 | if (result != null && result.getCode() == 200) { | 139 | if (result != null && result.getCode() == 200) { |
140 | showWeekPlan(result.getData().getList()); | 140 | showWeekPlan(result.getData().getList()); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | @Override | 144 | @Override |
145 | public void onError(Throwable e) { | 145 | public void onError(Throwable e) { |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | @Override | 149 | @Override |
150 | public void onComplete() { | 150 | public void onComplete() { |
151 | 151 | ||
152 | } | 152 | } |
153 | }); | 153 | }); |
154 | } | 154 | } |
155 | 155 | ||
156 | public void startQRView() { | 156 | public void startQRView() { |
157 | startActivityForResult(new Intent(getActivity(), QRActivity.class), 101); | 157 | startActivityForResult(new Intent(getActivity(), QRActivity.class), 101); |
158 | } | 158 | } |
159 | 159 | ||
160 | @Override | 160 | @Override |
161 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 161 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
162 | super.onActivityResult(requestCode, resultCode, data); | 162 | super.onActivityResult(requestCode, resultCode, data); |
163 | if (requestCode == 101) { | 163 | if (requestCode == 101) { |
164 | if (null != data) { | 164 | if (null != data) { |
165 | Bundle bundle = data.getExtras(); | 165 | Bundle bundle = data.getExtras(); |
166 | if (bundle == null) { | 166 | if (bundle == null) { |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { | 169 | if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { |
170 | String result = bundle.getString(CodeUtils.RESULT_STRING); | 170 | String result = bundle.getString(CodeUtils.RESULT_STRING); |
171 | Toast.makeText(getActivity(), "解析结果:" + result, Toast.LENGTH_LONG).show(); | 171 | Toast.makeText(getActivity(), "解析结果:" + result, Toast.LENGTH_LONG).show(); |
172 | } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) { | 172 | } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) { |
173 | Toast.makeText(getActivity(), "解析二维码失败", Toast.LENGTH_LONG).show(); | 173 | Toast.makeText(getActivity(), "解析二维码失败", Toast.LENGTH_LONG).show(); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | @OnClick({R.id.iv_2, R.id.tv_name}) | 179 | @OnClick({R.id.iv_3, R.id.tv_name}) |
180 | public void choose(View view) { | 180 | public void choose(View view) { |
181 | Intent intent = new Intent(getActivity(), ChooseActivity.class); | 181 | Intent intent = new Intent(getActivity(), ChooseActivity.class); |
182 | startActivity(intent); | 182 | startActivity(intent); |
183 | } | 183 | } |
184 | 184 | ||
185 | @OnClick(R.id.iv_1) | 185 | @OnClick(R.id.iv_1) |
186 | public void exit(View view) { | 186 | public void exit(View view) { |
187 | getActivity().finish(); | 187 | getActivity().finish(); |
188 | } | 188 | } |
189 | 189 | ||
190 | private void showWeekPlan(List<Video> list) { | 190 | private void showWeekPlan(List<Video> list) { |
191 | iv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); | 191 | iv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); |
192 | tv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); | 192 | tv_empty.setVisibility(list.size() > 0 ? View.GONE : View.VISIBLE); |
193 | List<Schedule> schedules = new ArrayList<>(); | 193 | List<Schedule> schedules = new ArrayList<>(); |
194 | for (int i = 0; i < list.size(); i++) { | 194 | for (int i = 0; i < list.size(); i++) { |
195 | String date = new SimpleDateFormat("yyyy.MM.dd").format(list.get(i).getStudyTime()); | 195 | String date = new SimpleDateFormat("yyyy.MM.dd").format(list.get(i).getStudyTime()); |
196 | if (schedules.size() > 0 && schedules.get(schedules.size() - 1).getDate().equals(date)) { | 196 | if (schedules.size() > 0 && schedules.get(schedules.size() - 1).getDate().equals(date)) { |
197 | schedules.get(schedules.size() - 1).getStrings().add(list.get(i).getSectionChildName()); | 197 | schedules.get(schedules.size() - 1).getStrings().add(list.get(i).getSectionChildName()); |
198 | } else { | 198 | } else { |
199 | List<String> stringList = new ArrayList<>(); | 199 | List<String> stringList = new ArrayList<>(); |
200 | Schedule schedule = new Schedule(); | 200 | Schedule schedule = new Schedule(); |
201 | schedule.setDate(date); | 201 | schedule.setDate(date); |
202 | stringList.add(list.get(i).getSectionChildName()); | 202 | stringList.add(list.get(i).getSectionChildName()); |
203 | schedule.setStrings(stringList); | 203 | schedule.setStrings(stringList); |
204 | schedules.add(schedule); | 204 | schedules.add(schedule); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_schedule, schedules) { | 207 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_schedule, schedules) { |
208 | @Override | 208 | @Override |
209 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 209 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | @Override | 213 | @Override |
214 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 214 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
215 | Schedule schedule = schedules.get(item.getAdapterPosition()); | 215 | Schedule schedule = schedules.get(item.getAdapterPosition()); |
216 | item.setText(R.id.tv_date, schedule.getDate()); | 216 | item.setText(R.id.tv_date, schedule.getDate()); |
217 | LinearLayout layout = item.getView(R.id.ll_schedule); | 217 | LinearLayout layout = item.getView(R.id.ll_schedule); |
218 | for (int i = 0; i < schedule.getStrings().size(); i++) { | 218 | for (int i = 0; i < schedule.getStrings().size(); i++) { |
219 | View view = LayoutInflater.from(getContext()).inflate(R.layout.item_video, null); | 219 | View view = LayoutInflater.from(getContext()).inflate(R.layout.item_video, null); |
220 | TextView textView = view.findViewById(R.id.tv_name); | 220 | TextView textView = view.findViewById(R.id.tv_name); |
221 | textView.setText(schedule.getStrings().get(i)); | 221 | textView.setText(schedule.getStrings().get(i)); |
222 | layout.addView(view); | 222 | layout.addView(view); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | }; | 225 | }; |
226 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false)); | 226 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false)); |
227 | recyclerView.setAdapter(adapter); | 227 | recyclerView.setAdapter(adapter); |
228 | } | 228 | } |
229 | 229 | ||
230 | class Schedule { | 230 | class Schedule { |
231 | String date; | 231 | String date; |
232 | List<String> strings; | 232 | List<String> strings; |
233 | 233 | ||
234 | public void setDate(String date) { | 234 | public void setDate(String date) { |
235 | this.date = date; | 235 | this.date = date; |
236 | } | 236 | } |
237 | 237 | ||
238 | public void setStrings(List<String> strings) { | 238 | public void setStrings(List<String> strings) { |
239 | this.strings = strings; | 239 | this.strings = strings; |
240 | } | 240 | } |
241 | 241 | ||
242 | public String getDate() { | 242 | public String getDate() { |
243 | return date; | 243 | return date; |
244 | } | 244 | } |
245 | 245 | ||
246 | public List<String> getStrings() { | 246 | public List<String> getStrings() { |
247 | return strings; | 247 | return strings; |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 |
app/src/main/java/com/hjx/parent/fragment/TeacherFragment.java
File was created | 1 | package com.hjx.parent.fragment; | |
2 | |||
3 | import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; | ||
4 | import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; | ||
5 | |||
6 | import android.app.AlertDialog; | ||
7 | import android.content.DialogInterface; | ||
8 | import android.content.Intent; | ||
9 | import android.graphics.drawable.Drawable; | ||
10 | import android.os.Bundle; | ||
11 | import android.text.TextUtils; | ||
12 | import android.view.LayoutInflater; | ||
13 | import android.view.MotionEvent; | ||
14 | import android.view.View; | ||
15 | import android.view.ViewGroup; | ||
16 | import android.webkit.WebSettings; | ||
17 | import android.webkit.WebView; | ||
18 | import android.widget.ImageView; | ||
19 | import android.widget.LinearLayout; | ||
20 | |||
21 | import androidx.annotation.NonNull; | ||
22 | import androidx.annotation.Nullable; | ||
23 | import androidx.recyclerview.widget.LinearLayoutManager; | ||
24 | import androidx.recyclerview.widget.RecyclerView; | ||
25 | |||
26 | import com.bumptech.glide.Glide; | ||
27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | ||
28 | import com.bumptech.glide.request.RequestOptions; | ||
29 | import com.bumptech.glide.request.target.SimpleTarget; | ||
30 | import com.bumptech.glide.request.transition.Transition; | ||
31 | import com.chad.library.adapter.base.BaseQuickAdapter; | ||
32 | import com.chad.library.adapter.base.BaseViewHolder; | ||
33 | import com.google.gson.Gson; | ||
34 | import com.hjx.parent.AccountActivity; | ||
35 | import com.hjx.parent.ErrorDetailActivity; | ||
36 | import com.hjx.parent.LoginActivity; | ||
37 | import com.hjx.parent.R; | ||
38 | import com.hjx.parent.TeacherChooseActivity; | ||
39 | import com.hjx.parent.bean.StudentBean; | ||
40 | import com.hjx.parent.databinding.FragmentTeacherBinding; | ||
41 | import com.prws.common.bean.Record; | ||
42 | import com.prws.common.net.NetWorks; | ||
43 | import com.prws.common.utils.CommonUtil; | ||
44 | import com.prws.common.utils.LogUtil; | ||
45 | import com.prws.common.utils.ScreenUtils; | ||
46 | import com.prws.common.utils.SharedPreferencesUtil; | ||
47 | import com.prws.common.utils.StringUtils; | ||
48 | |||
49 | import org.json.JSONArray; | ||
50 | import org.json.JSONObject; | ||
51 | |||
52 | import java.text.SimpleDateFormat; | ||
53 | import java.util.ArrayList; | ||
54 | import java.util.logging.SimpleFormatter; | ||
55 | |||
56 | import io.reactivex.Observer; | ||
57 | import io.reactivex.disposables.Disposable; | ||
58 | import okhttp3.ResponseBody; | ||
59 | |||
60 | public class TeacherFragment extends BaseBindingFragment<FragmentTeacherBinding> { | ||
61 | ArrayList<Record> alist = new ArrayList<>(); | ||
62 | |||
63 | @Override | ||
64 | protected FragmentTeacherBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | ||
65 | return FragmentTeacherBinding.inflate(inflater, parent, false); | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
70 | super.onViewCreated(view, savedInstanceState); | ||
71 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | ||
72 | if (!TextUtils.isEmpty(photo)) { | ||
73 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | ||
74 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | ||
75 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivTeacher); | ||
76 | } | ||
77 | String name = (String) SharedPreferencesUtil.getData("name", ""); | ||
78 | getBinding().tvTeacher.setText(name); | ||
79 | getBinding().tvAnswerName.setText("亲爱的" + name + "老师"); | ||
80 | getBinding().logout.setOnClickListener(new View.OnClickListener() { | ||
81 | @Override | ||
82 | public void onClick(View v) { | ||
83 | logout(); | ||
84 | } | ||
85 | }); | ||
86 | NetWorks.listRecord(new Observer<ResponseBody>() { | ||
87 | @Override | ||
88 | public void onSubscribe(Disposable d) { | ||
89 | |||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public void onNext(ResponseBody responseBody) { | ||
94 | try { | ||
95 | String str = responseBody.string().toString(); | ||
96 | LogUtil.e("TAG", "----" + str); | ||
97 | JSONObject jo = new JSONObject(str); | ||
98 | boolean isSucceed = jo.getBoolean("success"); | ||
99 | if (isSucceed) { | ||
100 | JSONArray jarr = jo.getJSONArray("data"); | ||
101 | if (jarr.length() > 0) { | ||
102 | getBinding().tvNum.setText("您有" + jarr.length() + "个题目需要答疑"); | ||
103 | alist.clear(); | ||
104 | for (int i = 0; i < jarr.length(); i++) { | ||
105 | JSONObject jo2 = jarr.getJSONObject(i); | ||
106 | Gson gson = new Gson(); | ||
107 | Record sb = gson.fromJson(jo2.toString(), Record.class); | ||
108 | alist.add(sb); | ||
109 | } | ||
110 | loadList(); | ||
111 | } else { | ||
112 | getBinding().tvNum.setText("您暂时没有题目需要答疑"); | ||
113 | } | ||
114 | } else { | ||
115 | |||
116 | } | ||
117 | } catch (Exception e) { | ||
118 | e.printStackTrace(); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public void onError(Throwable e) { | ||
124 | |||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public void onComplete() { | ||
129 | |||
130 | } | ||
131 | }); | ||
132 | |||
133 | } | ||
134 | |||
135 | private void loadList() { | ||
136 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_record, alist) { | ||
137 | @Override | ||
138 | protected void convert(@NonNull BaseViewHolder item, Object o) { | ||
139 | Record record = alist.get(item.getAdapterPosition()); | ||
140 | item.setText(R.id.tv_name, record.getStuName()); | ||
141 | item.setText(R.id.tv_date, "提问时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(record.getAskTime())); | ||
142 | if (TextUtils.isEmpty(record.getPhoto())) { | ||
143 | item.setImageResource(R.id.iv_student, record.getGender() == 0 ? R.mipmap.ic_avatar_male : R.mipmap.ic_avatar_female); | ||
144 | } else { | ||
145 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | ||
146 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | ||
147 | Glide.with(getContext()).load(record.getPhoto()).apply(options).into((ImageView) item.getView(R.id.iv_student)); | ||
148 | } | ||
149 | if (TextUtils.isEmpty(record.getContent())) { | ||
150 | item.setGone(R.id.iv_topic, true); | ||
151 | item.setGone(R.id.webview, false); | ||
152 | int maxWidth = CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 60); | ||
153 | Glide.with(getContext()).load(record.getQuestionUrl()).into(new SimpleTarget<Drawable>() { | ||
154 | @Override | ||
155 | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { | ||
156 | int width = resource.getIntrinsicWidth(); | ||
157 | int height = resource.getIntrinsicHeight(); | ||
158 | int newHeight = maxWidth * height / width; | ||
159 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) item.getView(R.id.iv_topic).getLayoutParams(); | ||
160 | layoutParams.width = maxWidth; | ||
161 | layoutParams.height = newHeight; | ||
162 | item.getView(R.id.iv_topic).setLayoutParams(layoutParams); | ||
163 | ((ImageView) item.getView(R.id.iv_topic)).setImageDrawable(resource); | ||
164 | } | ||
165 | }); | ||
166 | } else { | ||
167 | item.setGone(R.id.iv_topic, false); | ||
168 | item.setGone(R.id.webview, true); | ||
169 | WebView webView = item.getView(R.id.webview); | ||
170 | String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/style.css\" type=\"text/css\">"; | ||
171 | StringBuilder sb = new StringBuilder(4096); | ||
172 | if (!TextUtils.isEmpty(record.getLabel())) { | ||
173 | sb.append(record.getLabel()); | ||
174 | } | ||
175 | sb.append(record.getContent()); | ||
176 | if (record.getOptions() != null && record.getOptionsList().size() > 0) { | ||
177 | sb.append("<div class='pt1'>"); | ||
178 | sb.append(StringUtils.OptionsHtml(record.getOptionsList(), null)); | ||
179 | sb.append("</div>"); | ||
180 | } | ||
181 | String body = "<html><header>" + linkCss + "</header>" + sb.toString() + "</body></html>"; | ||
182 | webView.loadDataWithBaseURL(linkCss, body, "text/html", "UTF-8", null); | ||
183 | webView.setVisibility(View.VISIBLE); | ||
184 | webView.setOnTouchListener(new View.OnTouchListener() { | ||
185 | @Override | ||
186 | public boolean onTouch(View v, MotionEvent event) { | ||
187 | return true; | ||
188 | } | ||
189 | }); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | @Override | ||
194 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | ||
195 | |||
196 | } | ||
197 | }; | ||
198 | getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); | ||
199 | getBinding().recycleError.setAdapter(adapter); | ||
200 | } | ||
201 | |||
202 | public void logout() { | ||
203 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); | ||
204 | builder.setTitle("温馨提示"); | ||
205 | builder.setMessage("是否退出登录?"); | ||
206 | builder.setCancelable(false); | ||
207 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { | ||
208 | @Override | ||
209 | public void onClick(DialogInterface dialogInterface, int i) { | ||
210 | dialogInterface.dismiss(); | ||
211 | } | ||
212 | }); | ||
213 | builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { | ||
214 | @Override | ||
215 | public void onClick(DialogInterface dialogInterface, int i) { | ||
216 | SharedPreferencesUtil.clear(getContext()); | ||
217 | restartApp(); | ||
218 | } | ||
219 | }); | ||
220 | builder.show(); | ||
221 | } | ||
222 | |||
223 | private void restartApp() { | ||
224 | //重启app,这一步一定要加上,如果不重启app,可能打开新的页面显示的语言会不正确 | ||
225 | Intent intent = new Intent(getContext(), LoginActivity.class); | ||
226 | intent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); | ||
227 | startActivity(intent); | ||
228 | android.os.Process.killProcess(android.os.Process.myPid()); | ||
229 | System.exit(0); | ||
230 | } | ||
231 | |||
232 | } | ||
233 |
app/src/main/res/drawable/bg_home.png
160 KB
app/src/main/res/drawable/bg_item_schedule.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#E8F4FE" /> | ||
6 | |||
7 | <corners android:radius="5dp" /> | ||
8 | |||
9 | </shape> |
app/src/main/res/drawable/bg_solid_white_30.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#FFFFFF" /> | ||
6 | |||
7 | <corners | ||
8 | android:radius="30dp" /> | ||
9 | |||
10 | </shape> |
app/src/main/res/drawable/bg_student.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | <gradient | ||
5 | android:angle="90" | ||
6 | android:endColor="#E7F4FF" | ||
7 | android:startColor="#FFFFFF" /> | ||
8 | <corners | ||
9 | android:topLeftRadius="11dp" | ||
10 | android:topRightRadius="11dp" /> | ||
11 | </shape> |
app/src/main/res/drawable/bg_teacher.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | <gradient | ||
5 | android:angle="90" | ||
6 | android:centerColor="#F8F8F8" | ||
7 | android:endColor="#CDE6FB" | ||
8 | android:startColor="#F8F8F8" /> | ||
9 | |||
10 | </shape> |
app/src/main/res/drawable/bg_teacher_answer.png
65.2 KB
app/src/main/res/drawable/ic_filter_black.png
178 Bytes
app/src/main/res/layout/activity_error_list.xml
1 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | xmlns:xxx="http://schemas.android.com/apk/res-auto" | 2 | xmlns:xxx="http://schemas.android.com/apk/res-auto" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | android:background="#F8F8F8" | 5 | android:background="#F8F8F8" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | <RelativeLayout | 8 | <RelativeLayout |
9 | android:id="@+id/rl_top" | 9 | android:id="@+id/rl_top" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="40dp" | 11 | android:layout_height="40dp" |
12 | android:background="@color/white"> | 12 | android:background="@color/white"> |
13 | 13 | ||
14 | <TextView | 14 | <TextView |
15 | android:id="@+id/tv_title" | 15 | android:id="@+id/tv_title" |
16 | android:layout_width="wrap_content" | 16 | android:layout_width="wrap_content" |
17 | android:layout_height="wrap_content" | 17 | android:layout_height="wrap_content" |
18 | android:layout_centerInParent="true" | 18 | android:layout_centerInParent="true" |
19 | android:text="错题本" | 19 | android:text="错题本" |
20 | android:textColor="#333333" | 20 | android:textColor="#333333" |
21 | android:textSize="18sp" /> | 21 | android:textSize="18sp" /> |
22 | |||
23 | <ImageView | ||
24 | android:layout_width="30dp" | ||
25 | android:id="@+id/iv_change" | ||
26 | android:src="@mipmap/ic_change" | ||
27 | android:padding="5dp" | ||
28 | android:layout_toRightOf="@+id/tv_title" | ||
29 | android:layout_centerVertical="true" | ||
30 | android:layout_height="30dp"/> | ||
22 | 31 | ||
23 | <CheckBox | 32 | <CheckBox |
24 | android:id="@+id/checkbox" | 33 | android:id="@+id/checkbox" |
25 | android:layout_width="wrap_content" | 34 | android:layout_width="wrap_content" |
26 | android:layout_height="wrap_content" | 35 | android:layout_height="wrap_content" |
27 | android:layout_centerVertical="true" | 36 | android:layout_centerVertical="true" |
28 | android:layout_marginLeft="15dp" | 37 | android:layout_marginLeft="15dp" |
29 | android:button="@drawable/selectall_selector" | 38 | android:button="@drawable/selectall_selector" |
30 | android:checked="false" | 39 | android:checked="false" |
31 | android:paddingLeft="8dp" | 40 | android:paddingLeft="8dp" |
32 | android:text="全选" | 41 | android:text="全选" |
33 | android:textColor="@color/text_title" | 42 | android:textColor="@color/text_title" |
34 | android:visibility="gone" /> | 43 | android:visibility="gone" /> |
35 | 44 | ||
36 | <ImageView | 45 | <ImageView |
37 | android:id="@+id/iv_back" | 46 | android:id="@+id/iv_back" |
38 | android:layout_width="30dp" | 47 | android:layout_width="30dp" |
39 | android:layout_height="36dp" | 48 | android:layout_height="36dp" |
40 | android:layout_centerVertical="true" | 49 | android:layout_centerVertical="true" |
41 | android:layout_marginLeft="5dp" | 50 | android:layout_marginLeft="5dp" |
42 | android:padding="10dp" | 51 | android:padding="10dp" |
43 | android:src="@mipmap/icon_back" /> | 52 | android:src="@mipmap/icon_back" /> |
44 | 53 | ||
45 | <TextView | 54 | <TextView |
46 | android:id="@+id/tv_edit" | 55 | android:id="@+id/tv_edit" |
47 | android:layout_width="wrap_content" | 56 | android:layout_width="wrap_content" |
48 | android:layout_height="wrap_content" | 57 | android:layout_height="wrap_content" |
49 | android:layout_alignParentRight="true" | 58 | android:layout_alignParentRight="true" |
50 | android:layout_centerVertical="true" | 59 | android:layout_centerVertical="true" |
51 | android:layout_marginRight="15dp" | 60 | android:layout_marginRight="15dp" |
52 | android:text="编辑" | 61 | android:text="编辑" |
53 | android:textColor="@color/text_title" | 62 | android:textColor="@color/text_title" |
54 | android:visibility="visible" /> | 63 | android:visibility="visible" /> |
55 | </RelativeLayout> | 64 | </RelativeLayout> |
56 | 65 | ||
57 | <LinearLayout | 66 | <LinearLayout |
58 | android:id="@+id/ll_filter" | 67 | android:id="@+id/ll_filter" |
59 | android:layout_width="match_parent" | 68 | android:layout_width="match_parent" |
60 | android:layout_height="40dp" | 69 | android:layout_height="40dp" |
61 | android:layout_below="@+id/rl_top" | 70 | android:layout_below="@+id/rl_top" |
62 | android:background="@color/white"> | 71 | android:background="@color/white"> |
63 | 72 | ||
64 | <RelativeLayout | 73 | <RelativeLayout |
65 | android:layout_width="0dp" | 74 | android:layout_width="0dp" |
66 | android:layout_height="40dp" | 75 | android:layout_height="40dp" |
67 | android:layout_weight="1"> | 76 | android:layout_weight="1"> |
68 | 77 | ||
69 | <TextView | 78 | <TextView |
70 | android:id="@+id/tv_filter_subject" | 79 | android:id="@+id/tv_filter_subject" |
71 | android:layout_width="wrap_content" | 80 | android:layout_width="wrap_content" |
72 | android:layout_height="40dp" | 81 | android:layout_height="40dp" |
73 | android:layout_centerVertical="true" | 82 | android:layout_centerVertical="true" |
74 | android:layout_marginLeft="15dp" | 83 | android:layout_marginLeft="15dp" |
75 | android:drawableRight="@drawable/ic_filter_gray" | 84 | android:drawableRight="@drawable/ic_filter_gray" |
76 | android:drawablePadding="5dp" | 85 | android:drawablePadding="5dp" |
77 | android:gravity="center_vertical" | 86 | android:gravity="center_vertical" |
78 | android:text="学科" | 87 | android:text="学科" |
79 | android:textColor="@color/text_title" | 88 | android:textColor="@color/text_title" |
80 | android:textSize="14sp" /> | 89 | android:textSize="14sp" /> |
81 | 90 | ||
82 | </RelativeLayout> | 91 | </RelativeLayout> |
83 | 92 | ||
84 | <RelativeLayout | 93 | <RelativeLayout |
85 | android:layout_width="0dp" | 94 | android:layout_width="0dp" |
86 | android:layout_height="40dp" | 95 | android:layout_height="40dp" |
87 | android:layout_weight="1"> | 96 | android:layout_weight="1"> |
88 | 97 | ||
89 | <TextView | 98 | <TextView |
90 | android:id="@+id/tv_filter_grade" | 99 | android:id="@+id/tv_filter_grade" |
91 | android:layout_width="wrap_content" | 100 | android:layout_width="wrap_content" |
92 | android:layout_height="40dp" | 101 | android:layout_height="40dp" |
93 | android:layout_centerVertical="true" | 102 | android:layout_centerVertical="true" |
94 | android:drawableRight="@drawable/ic_filter_gray" | 103 | android:drawableRight="@drawable/ic_filter_gray" |
95 | android:drawablePadding="5dp" | 104 | android:drawablePadding="5dp" |
96 | android:gravity="center_vertical" | 105 | android:gravity="center_vertical" |
97 | android:text="年级学期" | 106 | android:text="年级学期" |
98 | android:textColor="@color/text_title" | 107 | android:textColor="@color/text_title" |
99 | android:textSize="14sp" /> | 108 | android:textSize="14sp" /> |
100 | </RelativeLayout> | 109 | </RelativeLayout> |
101 | 110 | ||
102 | <RelativeLayout | 111 | <RelativeLayout |
103 | android:layout_width="0dp" | 112 | android:layout_width="0dp" |
104 | android:layout_height="40dp" | 113 | android:layout_height="40dp" |
105 | android:layout_weight="1"> | 114 | android:layout_weight="1"> |
106 | 115 | ||
107 | <TextView | 116 | <TextView |
108 | android:id="@+id/tv_filter_manage" | 117 | android:id="@+id/tv_filter_manage" |
109 | android:layout_width="wrap_content" | 118 | android:layout_width="wrap_content" |
110 | android:layout_height="40dp" | 119 | android:layout_height="40dp" |
111 | android:layout_centerVertical="true" | 120 | android:layout_centerVertical="true" |
112 | android:layout_marginLeft="10dp" | 121 | android:layout_marginLeft="10dp" |
113 | android:drawableRight="@drawable/ic_filter_gray" | 122 | android:drawableRight="@drawable/ic_filter_gray" |
114 | android:drawablePadding="5dp" | 123 | android:drawablePadding="5dp" |
115 | android:gravity="center_vertical" | 124 | android:gravity="center_vertical" |
116 | android:text="掌握情况" | 125 | android:text="掌握情况" |
117 | android:textColor="@color/text_title" | 126 | android:textColor="@color/text_title" |
118 | android:textSize="14sp" /> | 127 | android:textSize="14sp" /> |
119 | </RelativeLayout> | 128 | </RelativeLayout> |
120 | 129 | ||
121 | <RelativeLayout | 130 | <RelativeLayout |
122 | android:layout_width="0dp" | 131 | android:layout_width="0dp" |
123 | android:layout_height="40dp" | 132 | android:layout_height="40dp" |
124 | android:layout_weight="1"> | 133 | android:layout_weight="1"> |
125 | 134 | ||
126 | <TextView | 135 | <TextView |
127 | android:id="@+id/tv_filter_more" | 136 | android:id="@+id/tv_filter_more" |
128 | android:layout_width="wrap_content" | 137 | android:layout_width="wrap_content" |
129 | android:layout_height="40dp" | 138 | android:layout_height="40dp" |
130 | android:layout_alignParentRight="true" | 139 | android:layout_alignParentRight="true" |
131 | android:layout_centerVertical="true" | 140 | android:layout_centerVertical="true" |
132 | android:layout_marginRight="15dp" | 141 | android:layout_marginRight="15dp" |
133 | android:drawableRight="@drawable/ic_filter_gray" | 142 | android:drawableRight="@drawable/ic_filter_gray" |
134 | android:drawablePadding="5dp" | 143 | android:drawablePadding="5dp" |
135 | android:gravity="center_vertical" | 144 | android:gravity="center_vertical" |
136 | android:text="更多筛选" | 145 | android:text="更多筛选" |
137 | android:textColor="@color/text_title" | 146 | android:textColor="@color/text_title" |
138 | android:textSize="14sp" /> | 147 | android:textSize="14sp" /> |
139 | </RelativeLayout> | 148 | </RelativeLayout> |
140 | 149 | ||
141 | </LinearLayout> | 150 | </LinearLayout> |
142 | 151 | ||
143 | <androidx.recyclerview.widget.RecyclerView | 152 | <androidx.recyclerview.widget.RecyclerView |
144 | android:id="@+id/recycle" | 153 | android:id="@+id/recycle" |
145 | android:layout_width="match_parent" | 154 | android:layout_width="match_parent" |
146 | android:layout_height="match_parent" | 155 | android:layout_height="match_parent" |
147 | android:layout_above="@+id/rl_bottom" | 156 | android:layout_above="@+id/rl_bottom" |
148 | android:layout_below="@+id/ll_filter" | 157 | android:layout_below="@+id/ll_filter" |
149 | android:layout_marginTop="15dp" /> | 158 | android:layout_marginTop="15dp" /> |
150 | 159 | ||
151 | <LinearLayout | 160 | <LinearLayout |
152 | android:id="@+id/ll_filter_common" | 161 | android:id="@+id/ll_filter_common" |
153 | android:layout_width="match_parent" | 162 | android:layout_width="match_parent" |
154 | android:layout_height="wrap_content" | 163 | android:layout_height="wrap_content" |
155 | android:layout_below="@+id/ll_filter" | 164 | android:layout_below="@+id/ll_filter" |
156 | android:background="@drawable/bg_solid_white_10_bottom" | 165 | android:background="@drawable/bg_solid_white_10_bottom" |
157 | android:visibility="visible"> | 166 | android:visibility="visible"> |
158 | 167 | ||
159 | <androidx.recyclerview.widget.RecyclerView | 168 | <androidx.recyclerview.widget.RecyclerView |
160 | android:id="@+id/recycle_filter" | 169 | android:id="@+id/recycle_filter" |
161 | android:layout_width="match_parent" | 170 | android:layout_width="match_parent" |
162 | android:layout_height="wrap_content" | 171 | android:layout_height="wrap_content" |
163 | android:layout_marginLeft="15dp" | 172 | android:layout_marginLeft="15dp" |
164 | android:layout_marginTop="15dp" | 173 | android:layout_marginTop="15dp" |
165 | android:visibility="gone" /> | 174 | android:visibility="gone" /> |
166 | </LinearLayout> | 175 | </LinearLayout> |
167 | 176 | ||
168 | <LinearLayout | 177 | <LinearLayout |
169 | android:id="@+id/ll_filter_more" | 178 | android:id="@+id/ll_filter_more" |
170 | android:layout_width="match_parent" | 179 | android:layout_width="match_parent" |
171 | android:layout_height="wrap_content" | 180 | android:layout_height="wrap_content" |
172 | android:layout_below="@+id/ll_filter" | 181 | android:layout_below="@+id/ll_filter" |
173 | android:background="@drawable/bg_solid_white_10_bottom" | 182 | android:background="@drawable/bg_solid_white_10_bottom" |
174 | android:orientation="vertical" | 183 | android:orientation="vertical" |
175 | android:visibility="gone"> | 184 | android:visibility="gone"> |
176 | 185 | ||
177 | <TextView | 186 | <TextView |
178 | android:layout_width="wrap_content" | 187 | android:layout_width="wrap_content" |
179 | android:layout_height="wrap_content" | 188 | android:layout_height="wrap_content" |
180 | android:layout_marginLeft="15dp" | 189 | android:layout_marginLeft="15dp" |
181 | android:layout_marginTop="15dp" | 190 | android:layout_marginTop="15dp" |
182 | android:text="来源" | 191 | android:text="来源" |
183 | android:textColor="@color/text_title" | 192 | android:textColor="@color/text_title" |
184 | android:textSize="14sp" | 193 | android:textSize="14sp" |
185 | android:textStyle="bold" /> | 194 | android:textStyle="bold" /> |
186 | 195 | ||
187 | <RadioGroup | 196 | <RadioGroup |
188 | android:id="@+id/group_type" | 197 | android:id="@+id/group_type" |
189 | android:layout_width="match_parent" | 198 | android:layout_width="match_parent" |
190 | android:layout_height="30dp" | 199 | android:layout_height="30dp" |
191 | android:layout_marginLeft="15dp" | 200 | android:layout_marginLeft="15dp" |
192 | android:layout_marginTop="15dp" | 201 | android:layout_marginTop="15dp" |
193 | android:layout_marginRight="15dp" | 202 | android:layout_marginRight="15dp" |
194 | android:orientation="horizontal"> | 203 | android:orientation="horizontal"> |
195 | 204 | ||
196 | <RadioButton | 205 | <RadioButton |
197 | android:layout_width="0dp" | 206 | android:layout_width="0dp" |
198 | android:layout_height="match_parent" | 207 | android:layout_height="match_parent" |
199 | android:layout_marginRight="15dp" | 208 | android:layout_marginRight="15dp" |
200 | android:layout_weight="1" | 209 | android:layout_weight="1" |
201 | android:background="@drawable/filter_button_selector" | 210 | android:background="@drawable/filter_button_selector" |
202 | android:button="@null" | 211 | android:button="@null" |
203 | android:gravity="center" | 212 | android:gravity="center" |
204 | android:text="课内" | 213 | android:text="课内" |
205 | android:textColor="@drawable/radio_text_selector" | 214 | android:textColor="@drawable/radio_text_selector" |
206 | android:textSize="14sp" /> | 215 | android:textSize="14sp" /> |
207 | 216 | ||
208 | <RadioButton | 217 | <RadioButton |
209 | android:layout_width="0dp" | 218 | android:layout_width="0dp" |
210 | android:layout_height="match_parent" | 219 | android:layout_height="match_parent" |
211 | android:layout_marginRight="15dp" | 220 | android:layout_marginRight="15dp" |
212 | android:layout_weight="1" | 221 | android:layout_weight="1" |
213 | android:background="@drawable/filter_button_selector" | 222 | android:background="@drawable/filter_button_selector" |
214 | android:button="@null" | 223 | android:button="@null" |
215 | android:gravity="center" | 224 | android:gravity="center" |
216 | android:text="课外" | 225 | android:text="课外" |
217 | android:textColor="@drawable/radio_text_selector" | 226 | android:textColor="@drawable/radio_text_selector" |
218 | android:textSize="14sp" /> | 227 | android:textSize="14sp" /> |
219 | 228 | ||
220 | <RadioButton | 229 | <RadioButton |
221 | android:layout_width="0dp" | 230 | android:layout_width="0dp" |
222 | android:layout_height="match_parent" | 231 | android:layout_height="match_parent" |
223 | android:layout_marginRight="15dp" | 232 | android:layout_marginRight="15dp" |
224 | android:layout_weight="1" | 233 | android:layout_weight="1" |
225 | android:background="@drawable/filter_button_selector" | 234 | android:background="@drawable/filter_button_selector" |
226 | android:button="@null" | 235 | android:button="@null" |
227 | android:gravity="center" | 236 | android:gravity="center" |
228 | android:text="全部" | 237 | android:text="全部" |
229 | android:textColor="@drawable/radio_text_selector" | 238 | android:textColor="@drawable/radio_text_selector" |
230 | android:textSize="14sp" /> | 239 | android:textSize="14sp" /> |
231 | 240 | ||
232 | <View | 241 | <View |
233 | android:layout_width="0dp" | 242 | android:layout_width="0dp" |
234 | android:layout_height="match_parent" | 243 | android:layout_height="match_parent" |
235 | android:layout_weight="1" /> | 244 | android:layout_weight="1" /> |
236 | </RadioGroup> | 245 | </RadioGroup> |
237 | 246 | ||
238 | <TextView | 247 | <TextView |
239 | android:layout_width="wrap_content" | 248 | android:layout_width="wrap_content" |
240 | android:layout_height="wrap_content" | 249 | android:layout_height="wrap_content" |
241 | android:layout_marginLeft="15dp" | 250 | android:layout_marginLeft="15dp" |
242 | android:layout_marginTop="15dp" | 251 | android:layout_marginTop="15dp" |
243 | android:text="录入时间" | 252 | android:text="录入时间" |
244 | android:textColor="@color/text_title" | 253 | android:textColor="@color/text_title" |
245 | android:textSize="14sp" | 254 | android:textSize="14sp" |
246 | android:textStyle="bold" /> | 255 | android:textStyle="bold" /> |
247 | 256 | ||
248 | <RadioGroup | 257 | <RadioGroup |
249 | android:id="@+id/group_time" | 258 | android:id="@+id/group_time" |
250 | android:layout_width="match_parent" | 259 | android:layout_width="match_parent" |
251 | android:layout_height="30dp" | 260 | android:layout_height="30dp" |
252 | android:layout_marginLeft="15dp" | 261 | android:layout_marginLeft="15dp" |
253 | android:layout_marginTop="15dp" | 262 | android:layout_marginTop="15dp" |
254 | android:layout_marginRight="15dp" | 263 | android:layout_marginRight="15dp" |
255 | android:layout_marginBottom="15dp" | 264 | android:layout_marginBottom="15dp" |
256 | android:orientation="horizontal"> | 265 | android:orientation="horizontal"> |
257 | 266 | ||
258 | <RadioButton | 267 | <RadioButton |
259 | android:layout_width="0dp" | 268 | android:layout_width="0dp" |
260 | android:layout_height="match_parent" | 269 | android:layout_height="match_parent" |
261 | android:layout_marginRight="15dp" | 270 | android:layout_marginRight="15dp" |
262 | android:layout_weight="1" | 271 | android:layout_weight="1" |
263 | android:background="@drawable/filter_button_selector" | 272 | android:background="@drawable/filter_button_selector" |
264 | android:button="@null" | 273 | android:button="@null" |
265 | android:gravity="center" | 274 | android:gravity="center" |
266 | android:text="一周内" | 275 | android:text="一周内" |
267 | android:textColor="@drawable/radio_text_selector" | 276 | android:textColor="@drawable/radio_text_selector" |
268 | android:textSize="14sp" /> | 277 | android:textSize="14sp" /> |
269 | 278 | ||
270 | <RadioButton | 279 | <RadioButton |
271 | android:layout_width="0dp" | 280 | android:layout_width="0dp" |
272 | android:layout_height="match_parent" | 281 | android:layout_height="match_parent" |
273 | android:layout_marginRight="15dp" | 282 | android:layout_marginRight="15dp" |
274 | android:layout_weight="1" | 283 | android:layout_weight="1" |
275 | android:background="@drawable/filter_button_selector" | 284 | android:background="@drawable/filter_button_selector" |
276 | android:button="@null" | 285 | android:button="@null" |
277 | android:gravity="center" | 286 | android:gravity="center" |
278 | android:text="一个月内" | 287 | android:text="一个月内" |
279 | android:textColor="@drawable/radio_text_selector" | 288 | android:textColor="@drawable/radio_text_selector" |
280 | android:textSize="14sp" /> | 289 | android:textSize="14sp" /> |
281 | 290 | ||
282 | <RadioButton | 291 | <RadioButton |
283 | android:layout_width="0dp" | 292 | android:layout_width="0dp" |
284 | android:layout_height="match_parent" | 293 | android:layout_height="match_parent" |
285 | android:layout_marginRight="15dp" | 294 | android:layout_marginRight="15dp" |
286 | android:layout_weight="1" | 295 | android:layout_weight="1" |
287 | android:background="@drawable/filter_button_selector" | 296 | android:background="@drawable/filter_button_selector" |
288 | android:button="@null" | 297 | android:button="@null" |
289 | android:gravity="center" | 298 | android:gravity="center" |
290 | android:text="三个月内" | 299 | android:text="三个月内" |
291 | android:textColor="@drawable/radio_text_selector" | 300 | android:textColor="@drawable/radio_text_selector" |
292 | android:textSize="14sp" /> | 301 | android:textSize="14sp" /> |
293 | 302 | ||
294 | <RadioButton | 303 | <RadioButton |
295 | android:layout_width="0dp" | 304 | android:layout_width="0dp" |
296 | android:layout_height="match_parent" | 305 | android:layout_height="match_parent" |
297 | android:layout_marginRight="15dp" | 306 | android:layout_marginRight="15dp" |
298 | android:layout_weight="1" | 307 | android:layout_weight="1" |
299 | android:background="@drawable/filter_button_selector" | 308 | android:background="@drawable/filter_button_selector" |
300 | android:button="@null" | 309 | android:button="@null" |
301 | android:gravity="center" | 310 | android:gravity="center" |
302 | android:text="全部" | 311 | android:text="全部" |
303 | android:textColor="@drawable/radio_text_selector" | 312 | android:textColor="@drawable/radio_text_selector" |
304 | android:textSize="14sp" /> | 313 | android:textSize="14sp" /> |
305 | </RadioGroup> | 314 | </RadioGroup> |
306 | </LinearLayout> | 315 | </LinearLayout> |
307 | 316 | ||
308 | 317 | ||
309 | <LinearLayout | 318 | <LinearLayout |
310 | android:id="@+id/ll_empty" | 319 | android:id="@+id/ll_empty" |
311 | android:layout_width="wrap_content" | 320 | android:layout_width="wrap_content" |
312 | android:layout_height="wrap_content" | 321 | android:layout_height="wrap_content" |
313 | android:layout_above="@+id/rl_bottom" | 322 | android:layout_above="@+id/rl_bottom" |
314 | android:layout_below="@+id/ll_filter" | 323 | android:layout_below="@+id/ll_filter" |
315 | android:layout_centerHorizontal="true" | 324 | android:layout_centerHorizontal="true" |
316 | android:layout_marginTop="150dp" | 325 | android:layout_marginTop="150dp" |
317 | android:orientation="vertical" | 326 | android:orientation="vertical" |
318 | android:visibility="gone"> | 327 | android:visibility="gone"> |
319 | 328 | ||
320 | <ImageView | 329 | <ImageView |
321 | android:layout_width="155dp" | 330 | android:layout_width="155dp" |
322 | android:layout_height="130dp" | 331 | android:layout_height="130dp" |
323 | android:src="@mipmap/ic_empty" /> | 332 | android:src="@mipmap/ic_empty" /> |
324 | 333 | ||
325 | <TextView | 334 | <TextView |
326 | android:layout_width="wrap_content" | 335 | android:layout_width="wrap_content" |
327 | android:layout_height="wrap_content" | 336 | android:layout_height="wrap_content" |
328 | android:layout_gravity="center_horizontal" | 337 | android:layout_gravity="center_horizontal" |
329 | android:text="暂无错题~" /> | 338 | android:text="暂无错题~" /> |
330 | </LinearLayout> | 339 | </LinearLayout> |
331 | 340 | ||
332 | <RelativeLayout | 341 | <RelativeLayout |
333 | android:id="@+id/rl_bottom" | 342 | android:id="@+id/rl_bottom" |
334 | android:layout_width="match_parent" | 343 | android:layout_width="match_parent" |
335 | android:layout_height="70dp" | 344 | android:layout_height="70dp" |
336 | android:layout_alignParentBottom="true" | 345 | android:layout_alignParentBottom="true" |
337 | android:background="@color/white"> | 346 | android:background="@color/white"> |
338 | 347 | ||
339 | <TextView | 348 | <TextView |
340 | android:id="@+id/tv_add" | 349 | android:id="@+id/tv_add" |
341 | android:layout_width="280dp" | 350 | android:layout_width="280dp" |
342 | android:layout_height="40dp" | 351 | android:layout_height="40dp" |
343 | android:layout_centerInParent="true" | 352 | android:layout_centerInParent="true" |
344 | android:background="@drawable/bg_soild_blue_5" | 353 | android:background="@drawable/bg_soild_blue_5" |
345 | android:gravity="center" | 354 | android:gravity="center" |
346 | android:text="录入错题" | 355 | android:text="录入错题" |
347 | android:textColor="@color/white" | 356 | android:textColor="@color/white" |
348 | android:textSize="18sp" /> | 357 | android:textSize="18sp" /> |
349 | 358 | ||
350 | <LinearLayout | 359 | <LinearLayout |
351 | android:id="@+id/ll_delete" | 360 | android:id="@+id/ll_delete" |
352 | android:layout_width="wrap_content" | 361 | android:layout_width="wrap_content" |
353 | android:layout_height="wrap_content" | 362 | android:layout_height="wrap_content" |
354 | android:layout_centerVertical="true" | 363 | android:layout_centerVertical="true" |
355 | android:layout_marginLeft="15dp" | 364 | android:layout_marginLeft="15dp" |
356 | android:orientation="vertical" | 365 | android:orientation="vertical" |
357 | android:visibility="gone"> | 366 | android:visibility="gone"> |
358 | 367 | ||
359 | <ImageView | 368 | <ImageView |
360 | android:layout_width="25dp" | 369 | android:layout_width="25dp" |
361 | android:layout_height="25dp" | 370 | android:layout_height="25dp" |
362 | android:layout_gravity="center_horizontal" | 371 | android:layout_gravity="center_horizontal" |
363 | android:src="@mipmap/ic_delete" /> | 372 | android:src="@mipmap/ic_delete" /> |
364 | 373 | ||
365 | <TextView | 374 | <TextView |
366 | android:layout_width="wrap_content" | 375 | android:layout_width="wrap_content" |
367 | android:layout_height="wrap_content" | 376 | android:layout_height="wrap_content" |
368 | android:layout_gravity="center_horizontal" | 377 | android:layout_gravity="center_horizontal" |
369 | android:layout_marginTop="5dp" | 378 | android:layout_marginTop="5dp" |
370 | android:text="删除" | 379 | android:text="删除" |
371 | android:textSize="11sp" /> | 380 | android:textSize="11sp" /> |
372 | </LinearLayout> | 381 | </LinearLayout> |
373 | 382 | ||
374 | <TextView | 383 | <TextView |
375 | android:id="@+id/tv_save" | 384 | android:id="@+id/tv_save" |
376 | android:layout_width="280dp" | 385 | android:layout_width="280dp" |
377 | android:layout_height="40dp" | 386 | android:layout_height="40dp" |
378 | android:layout_alignParentRight="true" | 387 | android:layout_alignParentRight="true" |
379 | android:layout_centerVertical="true" | 388 | android:layout_centerVertical="true" |
380 | android:layout_marginRight="15dp" | 389 | android:layout_marginRight="15dp" |
381 | android:background="@drawable/bg_soild_blue_5" | 390 | android:background="@drawable/bg_soild_blue_5" |
382 | android:gravity="center" | 391 | android:gravity="center" |
383 | android:text="批量修改标签" | 392 | android:text="批量修改标签" |
384 | android:textColor="@color/white" | 393 | android:textColor="@color/white" |
385 | android:textSize="18sp" | 394 | android:textSize="18sp" |
386 | android:visibility="gone" /> | 395 | android:visibility="gone" /> |
387 | </RelativeLayout> | 396 | </RelativeLayout> |
388 | </RelativeLayout> | 397 | </RelativeLayout> |
app/src/main/res/layout/activity_main.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | xmlns:tools="http://schemas.android.com/tools" | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
7 | android:background="#F4F6F8" | 7 | android:background="#F4F6F8" |
8 | tools:context=".MainActivity"> | 8 | tools:context=".MainActivity"> |
9 | 9 | ||
10 | <FrameLayout | 10 | <FrameLayout |
11 | android:id="@+id/rl_content" | 11 | android:id="@+id/rl_content" |
12 | android:layout_width="match_parent" | 12 | android:layout_width="match_parent" |
13 | android:layout_height="0dp" | 13 | android:layout_height="0dp" |
14 | app:layout_constraintLeft_toLeftOf="parent" | ||
15 | app:layout_constraintTop_toTopOf="parent" | ||
16 | app:layout_constraintBottom_toTopOf="@id/cl_1" | 14 | app:layout_constraintBottom_toTopOf="@id/cl_1" |
17 | /> | 15 | app:layout_constraintLeft_toLeftOf="parent" |
16 | app:layout_constraintTop_toTopOf="parent" /> | ||
18 | 17 | ||
19 | 18 | ||
20 | <androidx.constraintlayout.widget.ConstraintLayout | 19 | <androidx.constraintlayout.widget.ConstraintLayout |
21 | android:id="@+id/cl_1" | 20 | android:id="@+id/cl_1" |
22 | android:layout_width="match_parent" | 21 | android:layout_width="match_parent" |
23 | android:layout_height="50dp" | 22 | android:layout_height="50dp" |
24 | app:layout_constraintBottom_toBottomOf="parent" | ||
25 | android:background="@drawable/bg_solid_white_20" | 23 | android:background="@drawable/bg_solid_white_20" |
26 | > | 24 | app:layout_constraintBottom_toBottomOf="parent"> |
27 | 25 | ||
28 | <View | 26 | <View |
29 | android:id="@+id/view_5" | 27 | android:id="@+id/view_5" |
30 | android:layout_width="1dp" | 28 | android:layout_width="1dp" |
31 | android:layout_height="1dp" | 29 | android:layout_height="1dp" |
32 | app:layout_constraintLeft_toLeftOf="parent" | ||
33 | app:layout_constraintRight_toRightOf="parent" | ||
34 | app:layout_constraintBottom_toBottomOf="parent" | 30 | app:layout_constraintBottom_toBottomOf="parent" |
35 | /> | 31 | app:layout_constraintLeft_toLeftOf="parent" |
32 | app:layout_constraintRight_toRightOf="parent" /> | ||
36 | 33 | ||
37 | <androidx.constraintlayout.widget.ConstraintLayout | 34 | <androidx.constraintlayout.widget.ConstraintLayout |
38 | android:id="@+id/cl_home" | 35 | android:id="@+id/cl_home" |
39 | android:layout_width="0dp" | 36 | android:layout_width="0dp" |
40 | android:layout_height="0dp" | 37 | android:layout_height="0dp" |
41 | app:layout_constraintLeft_toLeftOf="parent" | ||
42 | app:layout_constraintBottom_toBottomOf="parent" | 38 | app:layout_constraintBottom_toBottomOf="parent" |
43 | app:layout_constraintTop_toTopOf="@id/cl_1" | 39 | app:layout_constraintLeft_toLeftOf="parent" |
44 | app:layout_constraintRight_toRightOf="@id/view_5" | 40 | app:layout_constraintRight_toRightOf="@id/view_5" |
45 | > | 41 | app:layout_constraintTop_toTopOf="@id/cl_1"> |
42 | |||
46 | <ImageView | 43 | <ImageView |
47 | android:id="@+id/iv_3" | 44 | android:id="@+id/iv_3" |
48 | android:layout_width="27dp" | 45 | android:layout_width="27dp" |
49 | android:layout_height="24dp" | 46 | android:layout_height="24dp" |
50 | app:layout_constraintLeft_toLeftOf="parent" | ||
51 | app:layout_constraintRight_toRightOf="parent" | ||
52 | app:layout_constraintTop_toTopOf="parent" | ||
53 | android:layout_marginTop="5dp" | 47 | android:layout_marginTop="5dp" |
54 | android:background="@mipmap/hous" | 48 | android:background="@mipmap/hous" |
55 | /> | 49 | app:layout_constraintLeft_toLeftOf="parent" |
50 | app:layout_constraintRight_toRightOf="parent" | ||
51 | app:layout_constraintTop_toTopOf="parent" /> | ||
56 | 52 | ||
57 | <TextView | 53 | <TextView |
58 | android:id="@+id/tv_1" | 54 | android:id="@+id/tv_1" |
59 | android:layout_width="wrap_content" | 55 | android:layout_width="wrap_content" |
60 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
61 | app:layout_constraintLeft_toLeftOf="parent" | ||
62 | app:layout_constraintRight_toRightOf="parent" | ||
63 | app:layout_constraintTop_toBottomOf="@id/iv_3" | ||
64 | android:layout_marginTop="5dp" | 57 | android:layout_marginTop="5dp" |
65 | android:textSize="11dp" | ||
66 | android:textColor="@drawable/select_t_1" | ||
67 | android:text="首页" | 58 | android:text="首页" |
68 | /> | 59 | android:textColor="@drawable/select_t_1" |
60 | android:textSize="11dp" | ||
61 | app:layout_constraintLeft_toLeftOf="parent" | ||
62 | app:layout_constraintRight_toRightOf="parent" | ||
63 | app:layout_constraintTop_toBottomOf="@id/iv_3" /> | ||
69 | 64 | ||
70 | 65 | ||
71 | </androidx.constraintlayout.widget.ConstraintLayout> | 66 | </androidx.constraintlayout.widget.ConstraintLayout> |
67 | |||
72 | <androidx.constraintlayout.widget.ConstraintLayout | 68 | <androidx.constraintlayout.widget.ConstraintLayout |
73 | android:id="@+id/cl_me" | 69 | android:id="@+id/cl_me" |
74 | android:layout_width="0dp" | 70 | android:layout_width="0dp" |
75 | android:layout_height="0dp" | 71 | android:layout_height="0dp" |
76 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
77 | app:layout_constraintBottom_toBottomOf="parent" | 72 | app:layout_constraintBottom_toBottomOf="parent" |
78 | app:layout_constraintTop_toTopOf="@id/cl_1" | 73 | app:layout_constraintLeft_toLeftOf="@id/view_5" |
79 | app:layout_constraintRight_toRightOf="parent" | 74 | app:layout_constraintRight_toRightOf="parent" |
80 | > | 75 | app:layout_constraintTop_toTopOf="@id/cl_1"> |
76 | |||
81 | <ImageView | 77 | <ImageView |
82 | android:id="@+id/iv_4" | 78 | android:id="@+id/iv_4" |
83 | android:layout_width="22dp" | 79 | android:layout_width="22dp" |
84 | android:layout_height="25dp" | 80 | android:layout_height="25dp" |
85 | app:layout_constraintLeft_toLeftOf="parent" | ||
86 | app:layout_constraintRight_toRightOf="parent" | ||
87 | app:layout_constraintTop_toTopOf="parent" | ||
88 | android:layout_marginTop="5dp" | 81 | android:layout_marginTop="5dp" |
89 | android:background="@mipmap/wmus" | 82 | android:background="@mipmap/wmus" |
90 | /> | 83 | app:layout_constraintLeft_toLeftOf="parent" |
84 | app:layout_constraintRight_toRightOf="parent" | ||
85 | app:layout_constraintTop_toTopOf="parent" /> | ||
91 | 86 | ||
92 | <TextView | 87 | <TextView |
93 | android:id="@+id/tv_4" | 88 | android:id="@+id/tv_4" |
94 | android:layout_width="wrap_content" | 89 | android:layout_width="wrap_content" |
95 | android:layout_height="wrap_content" | 90 | android:layout_height="wrap_content" |
96 | app:layout_constraintLeft_toLeftOf="parent" | ||
97 | app:layout_constraintRight_toRightOf="parent" | ||
98 | app:layout_constraintTop_toBottomOf="@id/iv_4" |
app/src/main/res/layout/dialog_add_error.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="wrap_content" | 3 | android:layout_height="wrap_content" |
4 | android:background="@drawable/bg_solid_white_10_top" | 4 | android:background="@drawable/bg_solid_white_10_top" |
5 | android:orientation="vertical"> | 5 | android:orientation="vertical"> |
6 | 6 | ||
7 | <RelativeLayout | 7 | <RelativeLayout |
8 | android:layout_width="match_parent" | 8 | android:layout_width="match_parent" |
9 | android:layout_height="50dp"> | 9 | android:layout_height="50dp"> |
10 | 10 | ||
11 | <TextView | 11 | <TextView |
12 | android:layout_width="wrap_content" | 12 | android:layout_width="wrap_content" |
13 | android:layout_height="wrap_content" | 13 | android:layout_height="wrap_content" |
14 | android:layout_centerInParent="true" | 14 | android:layout_centerInParent="true" |
15 | android:text="加入错题本" | 15 | android:text="加入错题本" |
16 | android:textColor="@color/text_title" | 16 | android:textColor="@color/text_title" |
17 | android:textSize="17sp" | 17 | android:textSize="17sp" |
18 | android:textStyle="bold" /> | 18 | android:textStyle="bold" /> |
19 | 19 | ||
20 | <ImageView | 20 | <ImageView |
21 | android:id="@+id/iv_back" | 21 | android:id="@+id/iv_back" |
22 | android:layout_width="35dp" | 22 | android:layout_width="35dp" |
23 | android:layout_height="35dp" | 23 | android:layout_height="35dp" |
24 | android:layout_alignParentRight="true" | 24 | android:layout_alignParentRight="true" |
25 | android:layout_centerVertical="true" | 25 | android:layout_centerVertical="true" |
26 | android:layout_marginRight="10dp" | 26 | android:layout_marginRight="10dp" |
27 | android:padding="10dp" | 27 | android:padding="10dp" |
28 | android:src="@mipmap/ic_close" /> | 28 | android:src="@mipmap/ic_close" /> |
29 | </RelativeLayout> | 29 | </RelativeLayout> |
30 | 30 | ||
31 | <androidx.recyclerview.widget.RecyclerView | 31 | <androidx.recyclerview.widget.RecyclerView |
32 | android:id="@+id/list_item" | 32 | android:id="@+id/list_item" |
33 | android:layout_width="match_parent" | 33 | android:layout_width="match_parent" |
34 | android:layout_height="30dp" | 34 | android:layout_height="30dp" |
35 | android:layout_marginLeft="20dp" | 35 | android:layout_marginLeft="20dp" |
36 | android:layout_marginTop="10dp" | 36 | android:layout_marginTop="10dp" |
37 | android:layout_marginRight="20dp" /> | 37 | android:layout_marginRight="20dp" /> |
38 | 38 | ||
39 | <RelativeLayout | 39 | <RelativeLayout |
40 | android:layout_width="match_parent" | 40 | android:layout_width="match_parent" |
41 | android:layout_height="90dp" | 41 | android:layout_height="90dp" |
42 | android:layout_marginLeft="20dp" | 42 | android:layout_marginLeft="20dp" |
43 | android:layout_marginTop="20dp" | 43 | android:layout_marginTop="20dp" |
44 | android:layout_marginRight="20dp"> | 44 | android:layout_marginRight="20dp"> |
45 | 45 | ||
46 | <RelativeLayout | 46 | <RelativeLayout |
47 | android:layout_width="match_parent" | 47 | android:layout_width="match_parent" |
48 | android:layout_height="match_parent" | 48 | android:layout_height="match_parent" |
49 | android:background="#F5F5F5"> | 49 | android:background="#F5F5F5"> |
50 | 50 | ||
51 | <ImageView | 51 | <ImageView |
52 | android:id="@+id/iv_topic" | 52 | android:id="@+id/iv_topic" |
53 | android:layout_width="wrap_content" | 53 | android:layout_width="wrap_content" |
54 | android:layout_height="wrap_content" | 54 | android:layout_height="wrap_content" |
55 | android:layout_centerVertical="true" /> | 55 | android:layout_centerVertical="true" /> |
56 | </RelativeLayout> | 56 | </RelativeLayout> |
57 | </RelativeLayout> | 57 | </RelativeLayout> |
58 | 58 | ||
59 | <TextView | 59 | <TextView |
60 | android:layout_width="wrap_content" | 60 | android:layout_width="wrap_content" |
61 | android:layout_height="wrap_content" | 61 | android:layout_height="wrap_content" |
62 | android:layout_centerVertical="true" | 62 | android:layout_centerVertical="true" |
63 | android:layout_marginLeft="20dp" | 63 | android:layout_marginLeft="20dp" |
64 | android:layout_marginTop="20dp" | 64 | android:layout_marginTop="20dp" |
65 | android:text="年级学期" | 65 | android:text="年级学期" |
66 | android:textColor="@color/text_title" | 66 | android:textColor="@color/text_title" |
67 | android:textSize="15sp" | 67 | android:textSize="15sp" |
68 | android:textStyle="bold" /> | 68 | android:textStyle="bold" /> |
69 | 69 | ||
70 | <androidx.appcompat.widget.AppCompatSpinner | 70 | <androidx.appcompat.widget.AppCompatSpinner |
71 | android:id="@+id/spinner_grade" | 71 | android:id="@+id/spinner_grade" |
72 | style="@style/customSpinnerStyle" | 72 | style="@style/customSpinnerStyle" |
73 | android:layout_width="match_parent" | 73 | android:layout_width="match_parent" |
74 | android:layout_height="40dp" | 74 | android:layout_height="40dp" |
75 | android:layout_centerHorizontal="true" | 75 | android:layout_centerHorizontal="true" |
76 | android:layout_marginLeft="20dp" | 76 | android:layout_marginLeft="20dp" |
77 | android:layout_marginTop="10dp" | 77 | android:layout_marginTop="10dp" |
78 | android:layout_marginRight="20dp" | 78 | android:layout_marginRight="20dp" |
79 | android:background="@drawable/selector_for_custom_spinner" | 79 | android:background="@drawable/selector_for_custom_spinner" |
80 | android:entries="@array/filter_subject" | 80 | android:entries="@array/filter_subject" |
81 | android:popupBackground="@drawable/shape_for_custom_spinner" | 81 | android:popupBackground="@drawable/shape_for_custom_spinner" |
82 | android:scrollbars="none" /> | 82 | android:scrollbars="none" /> |
83 | 83 | ||
84 | <TextView | 84 | <TextView |
85 | android:layout_width="wrap_content" | 85 | android:layout_width="wrap_content" |
86 | android:layout_height="wrap_content" | 86 | android:layout_height="wrap_content" |
87 | android:layout_centerVertical="true" | 87 | android:layout_centerVertical="true" |
88 | android:layout_marginLeft="20dp" | 88 | android:layout_marginLeft="20dp" |
89 | android:layout_marginTop="20dp" | 89 | android:layout_marginTop="20dp" |
90 | android:text="科目" | 90 | android:text="科目" |
91 | android:textColor="@color/text_title" | 91 | android:textColor="@color/text_title" |
92 | android:textSize="15sp" | 92 | android:textSize="15sp" |
93 | android:textStyle="bold" /> | 93 | android:textStyle="bold" /> |
94 | 94 | ||
95 | <androidx.appcompat.widget.AppCompatSpinner | 95 | <androidx.appcompat.widget.AppCompatSpinner |
96 | android:id="@+id/spinner_subject" | 96 | android:id="@+id/spinner_subject" |
97 | style="@style/customSpinnerStyle" | 97 | style="@style/customSpinnerStyle" |
98 | android:layout_width="match_parent" | 98 | android:layout_width="match_parent" |
99 | android:layout_height="40dp" | 99 | android:layout_height="40dp" |
100 | android:layout_centerHorizontal="true" | 100 | android:layout_centerHorizontal="true" |
101 | android:layout_marginLeft="20dp" | 101 | android:layout_marginLeft="20dp" |
102 | android:layout_marginTop="10dp" | 102 | android:layout_marginTop="10dp" |
103 | android:layout_marginRight="20dp" | 103 | android:layout_marginRight="20dp" |
104 | android:background="@drawable/selector_for_custom_spinner" | 104 | android:background="@drawable/selector_for_custom_spinner" |
105 | android:entries="@array/filter_subject" | 105 | android:entries="@array/filter_subject" |
106 | android:popupBackground="@drawable/shape_for_custom_spinner" | 106 | android:popupBackground="@drawable/shape_for_custom_spinner" |
107 | android:scrollbars="none" /> | 107 | android:scrollbars="none" /> |
108 | 108 | ||
109 | <TextView | 109 | <TextView |
110 | android:layout_width="wrap_content" | 110 | android:layout_width="wrap_content" |
111 | android:layout_height="wrap_content" | 111 | android:layout_height="wrap_content" |
112 | android:layout_centerVertical="true" | 112 | android:layout_centerVertical="true" |
113 | android:layout_marginLeft="20dp" | 113 | android:layout_marginLeft="20dp" |
114 | android:layout_marginTop="20dp" | 114 | android:layout_marginTop="20dp" |
115 | android:text="错误原因" | 115 | android:text="错误原因" |
116 | android:textColor="@color/text_title" | 116 | android:textColor="@color/text_title" |
117 | android:textSize="15sp" | 117 | android:textSize="15sp" |
118 | android:textStyle="bold" /> | 118 | android:textStyle="bold" /> |
119 | 119 | ||
120 | <androidx.appcompat.widget.AppCompatSpinner | 120 | <androidx.appcompat.widget.AppCompatSpinner |
121 | android:id="@+id/spinner_reason" | 121 | android:id="@+id/spinner_reason" |
122 | style="@style/customSpinnerStyle" | 122 | style="@style/customSpinnerStyle" |
123 | android:layout_width="match_parent" | 123 | android:layout_width="match_parent" |
124 | android:layout_height="40dp" | 124 | android:layout_height="40dp" |
125 | android:layout_centerHorizontal="true" | 125 | android:layout_centerHorizontal="true" |
126 | android:layout_marginLeft="20dp" | 126 | android:layout_marginLeft="20dp" |
127 | android:layout_marginTop="10dp" | 127 | android:layout_marginTop="10dp" |
128 | android:layout_marginRight="20dp" | 128 | android:layout_marginRight="20dp" |
129 | android:background="@drawable/selector_for_custom_spinner" | 129 | android:background="@drawable/selector_for_custom_spinner" |
130 | android:entries="@array/filter_subject" | 130 | android:entries="@array/filter_subject" |
131 | android:popupBackground="@drawable/shape_for_custom_spinner" | 131 | android:popupBackground="@drawable/shape_for_custom_spinner" |
132 | android:scrollbars="none" /> | 132 | android:scrollbars="none" /> |
133 | 133 | ||
134 | <TextView | 134 | <TextView |
135 | android:id="@+id/tv_student" | ||
136 | android:layout_width="wrap_content" | ||
137 | android:layout_height="wrap_content" | ||
138 | android:layout_centerVertical="true" | ||
139 | android:layout_marginLeft="20dp" | ||
140 | android:layout_marginTop="20dp" | ||
141 | android:text="学生" | ||
142 | android:textColor="@color/text_title" | ||
143 | android:visibility="gone" | ||
144 | android:textSize="15sp" | ||
145 | android:textStyle="bold" /> | ||
146 | |||
147 | <androidx.appcompat.widget.AppCompatSpinner | ||
148 | android:id="@+id/spinner_student" | ||
149 | style="@style/customSpinnerStyle" | ||
150 | android:layout_width="match_parent" | ||
151 | android:layout_height="40dp" | ||
152 | android:layout_centerHorizontal="true" | ||
153 | android:layout_marginLeft="20dp" | ||
154 | android:layout_marginTop="10dp" | ||
155 | android:layout_marginRight="20dp" | ||
156 | android:visibility="gone" | ||
157 | android:background="@drawable/selector_for_custom_spinner" | ||
158 | android:entries="@array/filter_subject" | ||
159 | android:popupBackground="@drawable/shape_for_custom_spinner" | ||
160 | android:scrollbars="none" /> | ||
161 | |||
162 | <TextView | ||
135 | android:layout_width="wrap_content" | 163 | android:layout_width="wrap_content" |
136 | android:layout_height="wrap_content" | 164 | android:layout_height="wrap_content" |
137 | android:layout_centerVertical="true" | 165 | android:layout_centerVertical="true" |
138 | android:layout_marginLeft="20dp" | 166 | android:layout_marginLeft="20dp" |
139 | android:layout_marginTop="20dp" | 167 | android:layout_marginTop="20dp" |
140 | android:text="来源" | 168 | android:text="来源" |
141 | android:textColor="@color/text_title" | 169 | android:textColor="@color/text_title" |
142 | android:textSize="15sp" | 170 | android:textSize="15sp" |
143 | android:textStyle="bold" /> | 171 | android:textStyle="bold" /> |
144 | 172 | ||
145 | <RadioGroup | 173 | <RadioGroup |
146 | android:id="@+id/type_radio" | 174 | android:id="@+id/type_radio" |
147 | android:layout_width="match_parent" | 175 | android:layout_width="match_parent" |
148 | android:layout_height="40dp" | 176 | android:layout_height="40dp" |
149 | android:layout_marginLeft="20dp" | 177 | android:layout_marginLeft="20dp" |
150 | android:layout_marginTop="10dp" | 178 | android:layout_marginTop="10dp" |
151 | android:orientation="horizontal"> | 179 | android:orientation="horizontal"> |
152 | 180 | ||
153 | <RadioButton | 181 | <RadioButton |
154 | android:layout_width="65dp" | 182 | android:layout_width="65dp" |
155 | android:layout_height="match_parent" | 183 | android:layout_height="match_parent" |
156 | android:layout_marginRight="20dp" | 184 | android:layout_marginRight="20dp" |
157 | android:background="@drawable/radio_button_selector" | 185 | android:background="@drawable/radio_button_selector" |
158 | android:button="@null" | 186 | android:button="@null" |
159 | android:gravity="center" | 187 | android:gravity="center" |
160 | android:text="课内" | 188 | android:text="课内" |
161 | android:textColor="@drawable/radio_text_selector" | 189 | android:textColor="@drawable/radio_text_selector" |
162 | android:textSize="14sp" /> | 190 | android:textSize="14sp" /> |
163 | 191 | ||
164 | <RadioButton | 192 | <RadioButton |
165 | android:layout_width="65dp" | 193 | android:layout_width="65dp" |
166 | android:layout_height="match_parent" | 194 | android:layout_height="match_parent" |
167 | android:layout_marginRight="20dp" | 195 | android:layout_marginRight="20dp" |
168 | android:background="@drawable/radio_button_selector" | 196 | android:background="@drawable/radio_button_selector" |
169 | android:button="@null" | 197 | android:button="@null" |
170 | android:gravity="center" | 198 | android:gravity="center" |
171 | android:text="课外" | 199 | android:text="课外" |
172 | android:textColor="@drawable/radio_text_selector" | 200 | android:textColor="@drawable/radio_text_selector" |
173 | android:textSize="14sp" /> | 201 | android:textSize="14sp" /> |
174 | </RadioGroup> | 202 | </RadioGroup> |
175 | 203 | ||
176 | 204 | ||
177 | <RelativeLayout | 205 | <RelativeLayout |
178 | android:layout_width="match_parent" | 206 | android:layout_width="match_parent" |
179 | android:layout_height="40dp" | 207 | android:layout_height="40dp" |
180 | android:layout_marginLeft="20dp" | 208 | android:layout_marginLeft="20dp" |
181 | android:layout_marginTop="20dp" | 209 | android:layout_marginTop="20dp" |
182 | android:layout_marginRight="20dp" | 210 | android:layout_marginRight="20dp" |
183 | android:layout_marginBottom="15dp"> | 211 | android:layout_marginBottom="15dp"> |
184 | 212 | ||
185 | <TextView | 213 | <TextView |
186 | android:id="@+id/add_topic" | 214 | android:id="@+id/add_topic" |
187 | android:layout_width="250dp" | 215 | android:layout_width="250dp" |
188 | android:layout_height="match_parent" | 216 | android:layout_height="match_parent" |
189 | android:layout_alignParentRight="true" | 217 | android:layout_alignParentRight="true" |
190 | android:background="@drawable/bg_soild_blue_5" | 218 | android:background="@drawable/bg_soild_blue_5" |
191 | android:gravity="center" | 219 | android:gravity="center" |
192 | android:textColor="@color/white" | 220 | android:textColor="@color/white" |
193 | android:textSize="17sp" /> | 221 | android:textSize="17sp" /> |
194 | 222 | ||
195 | <CheckBox | 223 | <CheckBox |
196 | android:id="@+id/checkbox" | 224 | android:id="@+id/checkbox" |
197 | android:layout_width="wrap_content" | 225 | android:layout_width="wrap_content" |
198 | android:layout_height="30dp" | 226 | android:layout_height="30dp" |
199 | android:layout_centerVertical="true" | 227 | android:layout_centerVertical="true" |
200 | android:button="@drawable/checkbox_selector" | 228 | android:button="@drawable/checkbox_selector" |
201 | android:text="批量设置" | 229 | android:text="批量设置" |
202 | android:paddingLeft="8dp" | 230 | android:paddingLeft="8dp" |
203 | android:textColor="@color/text_title" | 231 | android:textColor="@color/text_title" |
204 | android:textSize="14sp" /> | 232 | android:textSize="14sp" /> |
205 | 233 | ||
206 | </RelativeLayout> | 234 | </RelativeLayout> |
207 | </LinearLayout> | 235 | </LinearLayout> |
208 | 236 | ||
209 | 237 |
app/src/main/res/layout/fragment_error_book.xml
File was created | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:layout_width="match_parent" | ||
3 | android:layout_height="match_parent" | ||
4 | android:orientation="vertical"> | ||
5 | |||
6 | <RelativeLayout | ||
7 | android:layout_width="match_parent" | ||
8 | android:layout_height="40dp" | ||
9 | android:layout_marginTop="20dp"> | ||
10 | |||
11 | <ImageView | ||
12 | android:id="@+id/iv_student" | ||
13 | android:layout_width="35dp" | ||
14 | android:layout_height="35dp" | ||
15 | android:layout_centerVertical="true" | ||
16 | android:layout_marginLeft="15dp" /> | ||
17 | |||
18 | <TextView | ||
19 | android:id="@+id/tv_name" | ||
20 | android:layout_width="wrap_content" | ||
21 | android:layout_height="wrap_content" | ||
22 | android:layout_centerVertical="true" | ||
23 | android:layout_marginLeft="10dp" | ||
24 | android:layout_toRightOf="@+id/iv_student" | ||
25 | android:textColor="#333333" | ||
26 | android:textSize="16sp" /> | ||
27 | |||
28 | <TextView | ||
29 | android:id="@+id/tv_choose" | ||
30 | android:layout_width="wrap_content" | ||
31 | android:layout_height="wrap_content" | ||
32 | android:layout_alignParentRight="true" | ||
33 | android:layout_centerVertical="true" | ||
34 | android:layout_marginRight="15dp" | ||
35 | android:drawableRight="@drawable/ic_filter_black" | ||
36 | android:drawablePadding="5dp" | ||
37 | android:text="选择学生" | ||
38 | android:textColor="#333333" | ||
39 | android:textSize="14sp" /> | ||
40 | |||
41 | </RelativeLayout> | ||
42 | |||
43 | <RelativeLayout | ||
44 | android:id="@+id/rl_take_photo" | ||
45 | android:layout_width="match_parent" | ||
46 | android:layout_height="200dp" | ||
47 | android:background="@mipmap/ic_take_photo"> | ||
48 | |||
49 | <TextView | ||
50 | android:layout_width="wrap_content" | ||
51 | android:layout_height="wrap_content" | ||
52 | android:layout_alignParentRight="true" | ||
53 | android:layout_centerVertical="true" | ||
54 | android:layout_marginRight="70dp" | ||
55 | android:text="录入错题" | ||
56 | android:textColor="#EDF6FF" | ||
57 | android:textSize="22sp" | ||
58 | android:textStyle="bold" /> | ||
59 | </RelativeLayout> | ||
60 | |||
61 | <RelativeLayout | ||
62 | android:layout_width="match_parent" | ||
63 | android:layout_height="25dp"> | ||
64 | |||
65 | <TextView | ||
66 | android:layout_width="wrap_content" | ||
67 | android:layout_height="wrap_content" | ||
68 | android:layout_marginLeft="15dp" | ||
69 | android:text="最近录入错题" | ||
70 | android:textColor="#333333" | ||
71 | android:textSize="16sp" | ||
72 | android:textStyle="bold" /> | ||
73 | |||
74 | <LinearLayout | ||
75 | android:id="@+id/ll_all" | ||
76 | android:layout_width="wrap_content" | ||
77 | android:layout_height="wrap_content" | ||
78 | android:layout_alignParentRight="true" | ||
79 | android:layout_centerVertical="true" | ||
80 | android:layout_marginRight="15dp"> | ||
81 | |||
82 | <TextView | ||
83 | android:layout_width="wrap_content" | ||
84 | android:layout_height="wrap_content" | ||
85 | android:layout_gravity="center_vertical" | ||
86 | android:text="查看全部" | ||
87 | android:textColor="#666666" | ||
88 | android:textSize="12sp" /> | ||
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 | |||
99 | <androidx.recyclerview.widget.RecyclerView | ||
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 | |||
107 | <RelativeLayout | ||
108 | android:layout_width="match_parent" | ||
109 | android:layout_height="match_parent"> | ||
110 | |||
111 | <androidx.recyclerview.widget.RecyclerView | ||
112 | android:id="@+id/recycle_error" | ||
113 | android:layout_width="match_parent" | ||
114 | android:layout_height="wrap_content" | ||
115 | android:layout_marginTop="15dp" /> | ||
116 | |||
117 | <LinearLayout | ||
118 | android:id="@+id/ll_empty" | ||
119 | android:layout_width="wrap_content" | ||
120 | android:layout_height="wrap_content" | ||
121 | android:layout_centerHorizontal="true" | ||
122 | android:layout_marginTop="30dp" | ||
123 | android:orientation="vertical" | ||
124 | android:visibility="gone"> | ||
125 | |||
126 | <ImageView | ||
127 | android:layout_width="155dp" | ||
128 | android:layout_height="130dp" | ||
129 | android:src="@mipmap/ic_empty" /> | ||
130 | |||
131 | <TextView | ||
132 | android:layout_width="wrap_content" | ||
133 | android:layout_height="wrap_content" | ||
134 | android:layout_gravity="center_horizontal" | ||
135 | android:text="暂无错题~" /> | ||
136 | </LinearLayout> | ||
137 | </RelativeLayout> | ||
138 | |||
139 | |||
140 | </LinearLayout> |
app/src/main/res/layout/fragment_home.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
6 | android:background="#F4F6F8"> | 6 | android:background="#F4F6F8"> |
7 | 7 | ||
8 | <View | 8 | <View |
9 | android:id="@+id/view_1" | 9 | android:id="@+id/view_1" |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="44dp" | 11 | android:layout_height="170dp" |
12 | android:background="@android:color/white" | 12 | android:background="@drawable/bg_home" |
13 | app:layout_constraintTop_toTopOf="parent" /> | ||
14 | |||
15 | <TextView | ||
16 | android:id="@+id/tv_title" | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:layout_marginTop="35dp" | ||
20 | android:text="首页" | ||
21 | android:textColor="@color/white" | ||
22 | android:textSize="20sp" | ||
23 | android:textStyle="bold" | ||
24 | app:layout_constraintLeft_toLeftOf="parent" | ||
25 | app:layout_constraintRight_toRightOf="parent" | ||
13 | app:layout_constraintTop_toTopOf="parent" /> | 26 | app:layout_constraintTop_toTopOf="parent" /> |
14 | 27 | ||
15 | <ImageView | 28 | <ImageView |
16 | android:id="@+id/iv_1" | 29 | android:id="@+id/iv_1" |
17 | android:layout_width="10dp" | 30 | android:layout_width="10dp" |
18 | android:layout_height="16dp" | 31 | android:layout_height="16dp" |
19 | android:layout_marginLeft="15dp" | 32 | android:layout_marginLeft="15dp" |
20 | android:background="@mipmap/icon_back" | 33 | android:background="@mipmap/icon_back" |
34 | android:visibility="gone" | ||
21 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 35 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
22 | app:layout_constraintLeft_toLeftOf="parent" | 36 | app:layout_constraintLeft_toLeftOf="parent" |
23 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 37 | app:layout_constraintTop_toTopOf="@id/view_1" /> |
24 | 38 | ||
25 | <ImageView | 39 | <ImageView |
26 | android:id="@+id/iv_2" | 40 | android:id="@+id/iv_2" |
27 | android:layout_width="31dp" | 41 | android:layout_width="55dp" |
28 | android:layout_height="31dp" | 42 | android:layout_height="55dp" |
29 | android:layout_marginLeft="35dp" | 43 | android:layout_marginLeft="25dp" |
30 | android:background="@mipmap/txz" | 44 | android:background="@drawable/bg_solid_white_30" |
45 | android:padding="1dp" | ||
46 | android:src="@mipmap/txz" | ||
31 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 47 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
32 | app:layout_constraintLeft_toLeftOf="parent" | 48 | app:layout_constraintLeft_toLeftOf="parent" |
33 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 49 | app:layout_constraintTop_toBottomOf="@id/tv_title" /> |
34 | 50 | ||
35 | <TextView | 51 | <TextView |
36 | android:id="@+id/tv_name" | 52 | android:id="@+id/tv_name" |
37 | android:layout_width="wrap_content" | 53 | android:layout_width="wrap_content" |
38 | android:layout_height="wrap_content" | 54 | android:layout_height="wrap_content" |
39 | android:layout_marginLeft="6.5dp" | 55 | android:layout_marginLeft="20dp" |
40 | android:textColor="#333333" | 56 | android:textColor="@color/white" |
41 | android:textSize="15dp" | 57 | android:textSize="18sp" |
42 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 58 | app:layout_constraintBottom_toBottomOf="@id/iv_2" |
43 | app:layout_constraintLeft_toRightOf="@id/iv_2" | 59 | app:layout_constraintLeft_toRightOf="@id/iv_2" |
44 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 60 | app:layout_constraintTop_toTopOf="@id/iv_2" /> |
45 | 61 | ||
46 | <ImageView | 62 | <ImageView |
47 | android:id="@+id/iv_3" | 63 | android:id="@+id/iv_3" |
48 | android:layout_width="8dp" | 64 | android:layout_width="35dp" |
49 | android:layout_height="5dp" | 65 | android:layout_height="35dp" |
50 | android:layout_marginLeft="5dp" | 66 | android:padding="5dp" |
51 | android:background="@mipmap/xxan" | 67 | android:src="@mipmap/xxan" |
52 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 68 | app:layout_constraintBottom_toBottomOf="@id/iv_2" |
53 | app:layout_constraintLeft_toRightOf="@id/tv_name" | 69 | app:layout_constraintLeft_toRightOf="@id/tv_name" |
54 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 70 | app:layout_constraintTop_toTopOf="@id/iv_2" /> |
55 | 71 | ||
56 | <ImageView | 72 | <ImageView |
57 | android:id="@+id/iv_sapmiao" | 73 | android:id="@+id/iv_sapmiao" |
58 | android:layout_width="match_parent" | 74 | android:layout_width="35dp" |
59 | android:layout_height="167dp" | 75 | android:layout_height="35dp" |
60 | android:layout_marginLeft="15dp" | 76 | android:layout_marginRight="20dp" |
61 | android:layout_marginTop="60dp" | 77 | android:padding="5dp" |
62 | android:layout_marginRight="15dp" | 78 | android:src="@mipmap/ssss" |
63 | android:background="@mipmap/ssss" | 79 | app:layout_constraintBottom_toBottomOf="@id/iv_2" |
64 | app:layout_constraintLeft_toLeftOf="parent" | ||
65 | app:layout_constraintRight_toRightOf="parent" | 80 | app:layout_constraintRight_toRightOf="parent" |
66 | app:layout_constraintTop_toTopOf="parent" /> | 81 | app:layout_constraintTop_toTopOf="@id/iv_2" /> |
67 | 82 | ||
68 | 83 | ||
69 | <LinearLayout | 84 | <LinearLayout |
70 | android:id="@+id/view_2" | 85 | android:id="@+id/view_2" |
71 | android:layout_width="match_parent" | 86 | android:layout_width="match_parent" |
72 | android:layout_height="100dp" | 87 | android:layout_height="130dp" |
73 | android:layout_marginLeft="15dp" | 88 | android:layout_marginTop="160dp" |
74 | android:layout_marginTop="240dp" | 89 | android:background="@drawable/bg_student" |
75 | android:layout_marginRight="15dp" | ||
76 | android:background="@drawable/bg_solid_white_10" | ||
77 | android:orientation="horizontal" | 90 | android:orientation="horizontal" |
78 | app:layout_constraintLeft_toLeftOf="parent" | 91 | app:layout_constraintLeft_toLeftOf="parent" |
79 | app:layout_constraintRight_toRightOf="parent" | 92 | app:layout_constraintRight_toRightOf="parent" |
80 | app:layout_constraintTop_toTopOf="parent"> | 93 | app:layout_constraintTop_toTopOf="parent"> |
81 | 94 | ||
82 | <LinearLayout | 95 | <LinearLayout |
83 | android:layout_width="0dp" | 96 | android:layout_width="0dp" |
84 | android:layout_height="wrap_content" | 97 | android:layout_height="wrap_content" |
98 | android:layout_gravity="center_vertical" | ||
85 | android:layout_weight="1" | 99 | android:layout_weight="1" |
86 | android:orientation="vertical"> | 100 | android:orientation="vertical"> |
87 | 101 | ||
88 | <ImageView | 102 | <ImageView |
89 | android:id="@+id/iv_21" | 103 | android:id="@+id/iv_21" |
90 | android:layout_width="50dp" | 104 | android:layout_width="50dp" |
91 | android:layout_height="50dp" | 105 | android:layout_height="50dp" |
92 | android:layout_gravity="center_horizontal" | 106 | android:layout_gravity="center_horizontal" |
93 | android:layout_marginTop="15dp" | 107 | android:layout_marginTop="15dp" |
94 | android:background="@mipmap/yyxz" /> | 108 | android:background="@mipmap/yyxz" /> |
95 | 109 | ||
96 | <TextView | 110 | <TextView |
97 | android:layout_width="wrap_content" | 111 | android:layout_width="wrap_content" |
98 | android:layout_height="wrap_content" | 112 | android:layout_height="wrap_content" |
99 | android:layout_gravity="center_horizontal" | 113 | android:layout_gravity="center_horizontal" |
100 | android:layout_marginTop="8dp" | 114 | android:layout_marginTop="10dp" |
101 | android:text="应用管理" | 115 | android:text="应用管理" |
102 | android:textColor="#333333" | 116 | android:textColor="#333333" |
103 | android:textSize="13dp" | 117 | android:textSize="14sp" |
104 | app:layout_constraintLeft_toLeftOf="@id/iv_21" | 118 | app:layout_constraintLeft_toLeftOf="@id/iv_21" |
105 | app:layout_constraintRight_toRightOf="@id/iv_21" | 119 | app:layout_constraintRight_toRightOf="@id/iv_21" |
106 | app:layout_constraintTop_toBottomOf="@id/iv_21" /> | 120 | app:layout_constraintTop_toBottomOf="@id/iv_21" /> |
107 | </LinearLayout> | 121 | </LinearLayout> |
108 | 122 | ||
109 | <LinearLayout | 123 | <LinearLayout |
110 | android:layout_width="0dp" | ||
111 | android:id="@+id/ll_error" | 124 | android:id="@+id/ll_error" |
125 | android:layout_width="0dp" | ||
112 | android:layout_height="wrap_content" | 126 | android:layout_height="wrap_content" |
127 | android:layout_gravity="center_vertical" | ||
113 | android:layout_weight="1" | 128 | android:layout_weight="1" |
114 | android:orientation="vertical"> | 129 | android:orientation="vertical"> |
115 | 130 | ||
116 | <ImageView | 131 | <ImageView |
117 | android:id="@+id/iv_22" | 132 | android:id="@+id/iv_22" |
118 | android:layout_width="50dp" | 133 | android:layout_width="50dp" |
119 | android:layout_height="50dp" | 134 | android:layout_height="50dp" |
120 | android:layout_gravity="center_horizontal" | 135 | android:layout_gravity="center_horizontal" |
121 | android:layout_marginTop="15dp" | 136 | android:layout_marginTop="15dp" |
122 | android:background="@mipmap/xxxt" | 137 | android:background="@mipmap/xxxt" |
123 | app:layout_constraintLeft_toLeftOf="@id/view_2" | 138 | app:layout_constraintLeft_toLeftOf="@id/view_2" |
124 | app:layout_constraintTop_toTopOf="@id/view_2" /> | 139 | app:layout_constraintTop_toTopOf="@id/view_2" /> |
125 | 140 | ||
126 | <TextView | 141 | <TextView |
127 | android:layout_width="wrap_content" | 142 | android:layout_width="wrap_content" |
128 | android:layout_height="wrap_content" | 143 | android:layout_height="wrap_content" |
129 | android:layout_gravity="center_horizontal" | 144 | android:layout_gravity="center_horizontal" |
130 | android:layout_marginTop="8dp" | 145 | android:layout_marginTop="10dp" |
131 | android:text="小星错题" | 146 | android:text="小星错题" |
132 | android:textColor="#333333" | 147 | android:textColor="#333333" |
133 | android:textSize="13dp" | 148 | android:textSize="14sp" |
134 | app:layout_constraintLeft_toLeftOf="@id/iv_22" | 149 | app:layout_constraintLeft_toLeftOf="@id/iv_22" |
135 | app:layout_constraintRight_toRightOf="@id/iv_22" | 150 | app:layout_constraintRight_toRightOf="@id/iv_22" |
136 | app:layout_constraintTop_toBottomOf="@id/iv_22" /> | 151 | app:layout_constraintTop_toBottomOf="@id/iv_22" /> |
137 | </LinearLayout> | 152 | </LinearLayout> |
138 | 153 | ||
139 | <LinearLayout | ||
140 | android:layout_width="0dp" | ||
141 | android:layout_height="wrap_content" | ||
142 | android:layout_weight="1" | ||
143 | android:orientation="vertical"> | ||
144 | |||
145 | <ImageView | ||
146 | android:id="@+id/iv_23" | ||
147 | android:layout_width="50dp" | ||
148 | android:layout_height="50dp" | ||
149 | android:layout_gravity="center_horizontal" | ||
150 | android:layout_marginTop="15dp" | ||
151 | android:background="@mipmap/ffsj" | ||
152 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
153 | app:layout_constraintTop_toTopOf="@id/view_2" /> | ||
154 | |||
155 | <TextView | ||
156 | android:layout_width="wrap_content" | ||
157 | android:layout_height="wrap_content" | ||
158 | android:layout_gravity="center_horizontal" | ||
159 | android:layout_marginTop="8dp" | ||
160 | android:text="分发试卷" | ||
161 | android:textColor="#333333" | ||
162 | android:textSize="13dp" | ||
163 | app:layout_constraintLeft_toLeftOf="@id/iv_23" | ||
164 | app:layout_constraintRight_toRightOf="@id/iv_23" | ||
165 | app:layout_constraintTop_toBottomOf="@id/iv_23" /> | ||
166 | </LinearLayout> | ||
167 | 154 | ||
168 | <LinearLayout | 155 | <LinearLayout |
169 | android:layout_width="0dp" | 156 | android:layout_width="0dp" |
170 | android:layout_height="wrap_content" | 157 | android:layout_height="wrap_content" |
158 | android:layout_gravity="center_vertical" | ||
171 | android:layout_weight="1" | 159 | android:layout_weight="1" |
172 | android:orientation="vertical"> | 160 | android:orientation="vertical"> |
173 | 161 | ||
174 | <ImageView | 162 | <ImageView |
175 | android:id="@+id/iv_24" | 163 | android:id="@+id/iv_24" |
176 | android:layout_width="50dp" | 164 | android:layout_width="50dp" |
177 | android:layout_height="50dp" | 165 | android:layout_height="50dp" |
178 | android:layout_gravity="center_horizontal" | 166 | android:layout_gravity="center_horizontal" |
179 | android:layout_marginTop="15dp" | 167 | android:layout_marginTop="15dp" |
180 | android:background="@mipmap/sbgl" | 168 | android:background="@mipmap/sbgl" |
181 | app:layout_constraintLeft_toLeftOf="@id/view_2" | 169 | app:layout_constraintLeft_toLeftOf="@id/view_2" |
182 | app:layout_constraintTop_toTopOf="@id/view_2" /> | 170 | app:layout_constraintTop_toTopOf="@id/view_2" /> |
183 | 171 | ||
184 | <TextView | 172 | <TextView |
185 | android:layout_width="wrap_content" | 173 | android:layout_width="wrap_content" |
186 | android:layout_height="wrap_content" | 174 | android:layout_height="wrap_content" |
187 | android:layout_gravity="center_horizontal" | 175 | android:layout_gravity="center_horizontal" |
188 | android:layout_marginTop="8dp" | 176 | android:layout_marginTop="10dp" |
189 | android:text="设备管理" | 177 | android:text="设备管理" |
190 | android:textColor="#333333" | 178 | android:textColor="#333333" |
191 | android:textSize="13dp" | 179 | android:textSize="14sp" |
192 | app:layout_constraintLeft_toLeftOf="@id/iv_24" | 180 | app:layout_constraintLeft_toLeftOf="@id/iv_24" |
193 | app:layout_constraintRight_toRightOf="@id/iv_24" | 181 | app:layout_constraintRight_toRightOf="@id/iv_24" |
194 | app:layout_constraintTop_toBottomOf="@id/iv_24" /> | 182 | app:layout_constraintTop_toBottomOf="@id/iv_24" /> |
195 | </LinearLayout> | 183 | </LinearLayout> |
196 | </LinearLayout> | 184 | </LinearLayout> |
197 | 185 | ||
198 | <RelativeLayout | 186 | <RelativeLayout |
199 | android:id="@+id/view_3" | 187 | android:id="@+id/view_3" |
200 | android:layout_width="match_parent" | 188 | android:layout_width="match_parent" |
201 | android:layout_height="match_parent" | 189 | android:layout_height="match_parent" |
202 | android:layout_marginLeft="15dp" | 190 | android:layout_marginTop="305dp" |
203 | android:layout_marginTop="357dp" | ||
204 | android:layout_marginRight="15dp" | ||
205 | android:layout_marginBottom="20dp" | 191 | android:layout_marginBottom="20dp" |
206 | android:background="@drawable/bg_solid_white_10" | 192 | android:background="@color/white" |
207 | android:orientation="vertical" | 193 | android:orientation="vertical" |
208 | app:layout_constraintLeft_toLeftOf="parent" | 194 | app:layout_constraintLeft_toLeftOf="parent" |
209 | app:layout_constraintRight_toRightOf="parent" | 195 | app:layout_constraintRight_toRightOf="parent" |
210 | app:layout_constraintTop_toTopOf="parent"> | 196 | app:layout_constraintTop_toBottomOf="@+id/view_2"> |
211 | 197 | ||
212 | <RelativeLayout | 198 | <LinearLayout |
213 | android:id="@+id/rl_schedule" | 199 | android:id="@+id/rl_schedule" |
214 | android:layout_width="match_parent" | 200 | android:layout_width="wrap_content" |
215 | android:layout_height="wrap_content" | 201 | android:layout_height="wrap_content" |
202 | android:layout_centerHorizontal="true" | ||
216 | android:layout_marginTop="15dp" | 203 | android:layout_marginTop="15dp" |
217 | android:layout_marginRight="10dp"> | 204 | android:layout_marginRight="10dp" |
205 | android:orientation="horizontal"> | ||
206 | |||
207 | <ImageView | ||
208 | android:layout_width="25dp" | ||
209 | android:layout_height="22dp" | ||
210 | android:layout_centerVertical="true" | ||
211 | android:layout_gravity="center_vertical" | ||
212 | android:layout_marginRight="5dp" | ||
213 | android:layout_toLeftOf="@+id/tv_31" | ||
214 | android:src="@mipmap/ic_schedule" /> | ||
218 | 215 | ||
219 | <TextView | 216 | <TextView |
220 | android:id="@+id/tv_31" | 217 | android:id="@+id/tv_31" |
221 | android:layout_width="wrap_content" | 218 | android:layout_width="wrap_content" |
222 | android:layout_height="wrap_content" | 219 | android:layout_height="wrap_content" |
223 | android:layout_centerHorizontal="true" | 220 | android:layout_gravity="center_vertical" |
224 | android:text="本周学习计划" | 221 | android:text="本周学习计划" |
225 | android:textColor="#333333" | 222 | android:textColor="#333333" |
226 | android:textSize="15dp" /> | 223 | android:textSize="19sp" |
224 | android:textStyle="bold" /> | ||
227 | 225 | ||
228 | 226 | ||
229 | <View | 227 | </LinearLayout> |
230 | android:layout_width="25dp" | ||
231 | android:layout_height="1dp" | ||
232 | android:layout_centerVertical="true" | ||
233 | android:layout_marginRight="10dp" | ||
234 | android:layout_toLeftOf="@+id/tv_31" | ||
235 | android:background="#EEEEEE" /> | ||
236 | |||
237 | <View | ||
238 | android:layout_width="25dp" | ||
239 | android:layout_height="1dp" | ||
240 | android:layout_centerVertical="true" | ||
241 | android:layout_marginLeft="10dp" | ||
242 | android:layout_toRightOf="@+id/tv_31" | ||
243 | android:background="#EEEEEE" /> | ||
244 | </RelativeLayout> | ||
245 | 228 |
app/src/main/res/layout/fragment_me.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
6 | android:background="#F4F6F8"> | 6 | android:background="@drawable/bg_teacher"> |
7 | 7 | ||
8 | <androidx.constraintlayout.widget.Group | 8 | <androidx.constraintlayout.widget.Group |
9 | android:id="@+id/group_1" | 9 | android:id="@+id/group_1" |
10 | android:layout_width="wrap_content" | 10 | android:layout_width="wrap_content" |
11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
12 | android:visibility="visible" /> | 12 | android:visibility="visible" /> |
13 | 13 | ||
14 | <View | 14 | <View |
15 | android:id="@+id/view_1" | 15 | android:id="@+id/view_1" |
16 | android:layout_width="match_parent" | 16 | android:layout_width="match_parent" |
17 | android:layout_height="44dp" | 17 | android:layout_height="44dp" |
18 | android:background="@android:color/white" | 18 | android:layout_marginTop="20dp" |
19 | app:layout_constraintTop_toTopOf="parent" /> | 19 | app:layout_constraintTop_toTopOf="parent" /> |
20 | 20 | ||
21 | <TextView | 21 | <TextView |
22 | android:layout_width="wrap_content" | 22 | android:layout_width="wrap_content" |
23 | android:layout_height="wrap_content" | 23 | android:layout_height="wrap_content" |
24 | android:text="个人中心" | 24 | android:text="个人中心" |
25 | android:textColor="#333333" | 25 | android:textColor="#333333" |
26 | android:textSize="18dp" | 26 | android:textSize="18dp" |
27 | android:textStyle="bold" | ||
27 | app:layout_constraintBottom_toBottomOf="@id/view_1" | 28 | app:layout_constraintBottom_toBottomOf="@id/view_1" |
28 | app:layout_constraintLeft_toLeftOf="@id/view_1" | 29 | app:layout_constraintLeft_toLeftOf="@id/view_1" |
29 | app:layout_constraintRight_toRightOf="@id/view_1" | 30 | app:layout_constraintRight_toRightOf="@id/view_1" |
30 | app:layout_constraintTop_toTopOf="@id/view_1" /> | 31 | app:layout_constraintTop_toTopOf="@id/view_1" /> |
31 | 32 | ||
32 | 33 | ||
33 | <ImageView | 34 | <ImageView |
34 | android:id="@+id/iv_toux" | 35 | android:id="@+id/iv_toux" |
35 | android:layout_width="57dp" | 36 | android:layout_width="60dp" |
36 | android:layout_height="57dp" | 37 | android:layout_height="60dp" |
37 | android:layout_marginLeft="15dp" | 38 | android:layout_marginLeft="15dp" |
38 | android:layout_marginTop="63dp" | 39 | android:layout_marginTop="25dp" |
39 | android:background="@mipmap/ic_parent_avatar" | 40 | android:background="@drawable/bg_solid_white_30" |
41 | android:padding="1dp" | ||
42 | android:src="@mipmap/ic_parent_avatar" | ||
40 | app:layout_constraintLeft_toLeftOf="parent" | 43 | app:layout_constraintLeft_toLeftOf="parent" |
41 | app:layout_constraintTop_toTopOf="parent" /> | 44 | app:layout_constraintTop_toBottomOf="@+id/view_1" /> |
42 | 45 | ||
43 | <TextView | 46 | <TextView |
44 | android:id="@+id/tv_name" | 47 | android:id="@+id/tv_name" |
45 | android:layout_width="wrap_content" | 48 | android:layout_width="wrap_content" |
46 | android:layout_height="wrap_content" | 49 | android:layout_height="wrap_content" |
47 | android:layout_marginLeft="88dp" | 50 | android:layout_marginLeft="20dp" |
48 | android:layout_marginTop="72dp" | ||
49 | android:text="名字" | 51 | android:text="名字" |
50 | android:textColor="#333333" | 52 | android:textColor="#333333" |
51 | android:textSize="20dp" | 53 | android:textSize="18sp" |
52 | app:layout_constraintLeft_toLeftOf="parent" | 54 | app:layout_constraintBottom_toBottomOf="@+id/iv_toux" |
53 | app:layout_constraintTop_toTopOf="parent" /> | 55 | app:layout_constraintLeft_toRightOf="@+id/iv_toux" |
56 | app:layout_constraintTop_toTopOf="@+id/iv_toux" /> | ||
54 | 57 | ||
55 | <TextView | 58 | <TextView |
56 | android:id="@+id/tv_phone" | 59 | android:id="@+id/tv_phone" |
57 | android:layout_width="wrap_content" | 60 | android:layout_width="wrap_content" |
58 | android:layout_height="wrap_content" | 61 | android:layout_height="wrap_content" |
59 | android:layout_marginLeft="88dp" | 62 | android:layout_marginLeft="88dp" |
60 | android:layout_marginTop="98dp" | 63 | android:layout_marginTop="98dp" |
61 | android:text="1231223123" | 64 | android:text="1231223123" |
62 | android:textColor="#999999" | 65 | android:textColor="#999999" |
63 | android:textSize="17dp" | 66 | android:textSize="17dp" |
64 | android:visibility="gone" | 67 | android:visibility="gone" |
65 | app:layout_constraintLeft_toLeftOf="parent" | 68 | app:layout_constraintLeft_toLeftOf="parent" |
66 | app:layout_constraintTop_toTopOf="parent" /> | 69 | app:layout_constraintTop_toTopOf="parent" /> |
67 | 70 | ||
68 | 71 | ||
69 | <LinearLayout | 72 | <LinearLayout |
70 | android:id="@+id/view_2" | 73 | android:id="@+id/view_2" |
71 | android:layout_width="match_parent" | 74 | android:layout_width="match_parent" |
72 | android:layout_height="140dp" | 75 | android:layout_height="160dp" |
73 | android:layout_marginLeft="15dp" | 76 | android:layout_marginLeft="15dp" |
74 | android:layout_marginTop="140dp" | 77 | android:layout_marginTop="20dp" |
75 | android:layout_marginRight="15dp" | 78 | android:layout_marginRight="15dp" |
76 | android:background="@drawable/bg_solid_white_10" | 79 | android:background="@drawable/bg_soild_blue_25" |
77 | android:orientation="vertical" | 80 | android:orientation="vertical" |
78 | app:layout_constraintLeft_toLeftOf="parent" | 81 | app:layout_constraintLeft_toLeftOf="parent" |
79 | app:layout_constraintRight_toRightOf="parent" | 82 | app:layout_constraintRight_toRightOf="parent" |
80 | app:layout_constraintTop_toTopOf="parent"> | 83 | app:layout_constraintTop_toBottomOf="@+id/iv_toux"> |
81 | 84 | ||
82 | <TextView | 85 | <TextView |
83 | android:id="@+id/tv_title" | 86 | android:id="@+id/tv_title" |
84 | android:layout_width="wrap_content" | 87 | android:layout_width="wrap_content" |
85 | android:layout_height="wrap_content" | 88 | android:layout_height="wrap_content" |
86 | android:layout_marginLeft="15dp" | 89 | android:layout_marginLeft="15dp" |
87 | android:layout_marginTop="15dp" | 90 | android:layout_marginTop="15dp" |
91 | android:layout_marginBottom="10dp" | ||
88 | android:text="学生" | 92 | android:text="学生" |
89 | android:textColor="#333333" | 93 | android:textColor="@color/white" |
90 | android:textSize="16dp" /> | 94 | android:textSize="18sp" |
95 | android:textStyle="bold" /> | ||
91 | 96 | ||
92 | <androidx.recyclerview.widget.RecyclerView | 97 | <androidx.recyclerview.widget.RecyclerView |
93 | android:id="@+id/recycle" | 98 | android:id="@+id/recycle" |
94 | android:layout_width="match_parent" | 99 | android:layout_width="match_parent" |
95 | android:layout_height="match_parent" | 100 | android:layout_height="match_parent" |
96 | android:layout_marginLeft="15dp" | 101 | android:layout_marginLeft="15dp" |
97 | android:layout_marginRight="15dp" /> | 102 | android:layout_marginRight="15dp" |
103 | android:layout_marginBottom="15dp" /> | ||
98 | </LinearLayout> | 104 | </LinearLayout> |
99 | 105 | ||
100 | <View | 106 | <View |
101 | android:id="@+id/view_3" | 107 | android:id="@+id/view_3" |
102 | android:layout_width="match_parent" | 108 | android:layout_width="match_parent" |
103 | android:layout_height="45dp" | 109 | android:layout_height="50dp" |
104 | android:layout_marginLeft="15dp" | 110 | android:layout_marginLeft="15dp" |
105 | android:layout_marginTop="15dp" | 111 | android:layout_marginTop="15dp" |
106 | android:layout_marginRight="15dp" | 112 | android:layout_marginRight="15dp" |
107 | android:background="@drawable/bg_solid_white_10_top" | 113 | android:background="@drawable/bg_solid_white_10_top" |
108 | app:layout_constraintLeft_toLeftOf="parent" | 114 | app:layout_constraintLeft_toLeftOf="parent" |
109 | app:layout_constraintRight_toRightOf="parent" | 115 | app:layout_constraintRight_toRightOf="parent" |
110 | app:layout_constraintTop_toBottomOf="@id/view_2" | 116 | app:layout_constraintTop_toBottomOf="@id/view_2" |
111 | app:layout_goneMarginTop="241dp" /> | 117 | app:layout_goneMarginTop="241dp" /> |
112 | 118 | ||
113 | <ImageView | 119 | <ImageView |
114 | android:layout_width="6.8dp" | 120 | android:layout_width="8dp" |
115 | android:layout_height="12dp" | 121 | android:layout_height="14dp" |
116 | android:layout_marginRight="15dp" | 122 | android:layout_marginRight="15dp" |
117 | android:background="@mipmap/ycaj" | 123 | android:background="@mipmap/ycaj" |
118 | app:layout_constraintBottom_toBottomOf="@id/view_3" | 124 | app:layout_constraintBottom_toBottomOf="@id/view_3" |
119 | app:layout_constraintRight_toRightOf="@id/view_3" | 125 | app:layout_constraintRight_toRightOf="@id/view_3" |
120 | app:layout_constraintTop_toTopOf="@id/view_3" /> | 126 | app:layout_constraintTop_toTopOf="@id/view_3" /> |
121 | 127 | ||
122 | <ImageView | 128 | <ImageView |
123 | android:layout_width="14dp" | 129 | android:layout_width="14dp" |
124 | android:layout_height="14dp" | 130 | android:layout_height="14dp" |
125 | android:layout_marginLeft="15dp" | 131 | android:layout_marginLeft="15dp" |
126 | android:background="@mipmap/szz" | 132 | android:background="@mipmap/szz" |
127 | app:layout_constraintBottom_toBottomOf="@id/view_3" | 133 | app:layout_constraintBottom_toBottomOf="@id/view_3" |
128 | app:layout_constraintLeft_toLeftOf="@id/view_3" | 134 | app:layout_constraintLeft_toLeftOf="@id/view_3" |
129 | app:layout_constraintTop_toTopOf="@id/view_3" /> | 135 | app:layout_constraintTop_toTopOf="@id/view_3" /> |
130 | 136 | ||
131 | <TextView | 137 | <TextView |
132 | android:layout_width="wrap_content" | 138 | android:layout_width="wrap_content" |
133 | android:layout_height="wrap_content" | 139 | android:layout_height="wrap_content" |
134 | android:layout_marginLeft="40dp" | 140 | android:layout_marginLeft="40dp" |
135 | android:text="账户设置" | 141 | android:text="账户设置" |
136 | android:textColor="#333333" | 142 | android:textColor="#333333" |
137 | android:textSize="15dp" | 143 | android:textSize="16sp" |
138 | app:layout_constraintBottom_toBottomOf="@id/view_3" | 144 | app:layout_constraintBottom_toBottomOf="@id/view_3" |
139 | app:layout_constraintLeft_toLeftOf="@id/view_3" | 145 | app:layout_constraintLeft_toLeftOf="@id/view_3" |
140 | app:layout_constraintTop_toTopOf="@id/view_3" /> | 146 | app:layout_constraintTop_toTopOf="@id/view_3" /> |
141 | 147 | ||
142 | <View | 148 | <View |
143 | android:id="@+id/view_4" | 149 | android:id="@+id/view_4" |
144 | android:layout_width="match_parent" | 150 | android:layout_width="match_parent" |
145 | android:layout_height="45dp" | 151 | android:layout_height="50dp" |
146 | android:layout_marginLeft="15dp" | 152 | android:layout_marginLeft="15dp" |
147 | android:layout_marginRight="15dp" | 153 | android:layout_marginRight="15dp" |
148 | android:background="@android:color/white" | 154 | android:background="@android:color/white" |
149 | app:layout_constraintLeft_toLeftOf="parent" | 155 | app:layout_constraintLeft_toLeftOf="parent" |
150 | app:layout_constraintRight_toRightOf="parent" | 156 | app:layout_constraintRight_toRightOf="parent" |
151 | app:layout_constraintTop_toBottomOf="@id/view_3" /> | 157 | app:layout_constraintTop_toBottomOf="@id/view_3" /> |
152 | 158 | ||
153 | <ImageView | 159 | <ImageView |
154 | android:layout_width="6.8dp" | 160 | android:layout_width="8dp" |
155 | android:layout_height="12dp" | 161 | android:layout_height="14dp" |
156 | android:layout_marginRight="15dp" | 162 | android:layout_marginRight="15dp" |
157 | android:background="@mipmap/ycaj" | 163 | android:background="@mipmap/ycaj" |
158 | app:layout_constraintBottom_toBottomOf="@id/view_4" | 164 | app:layout_constraintBottom_toBottomOf="@id/view_4" |
159 | app:layout_constraintRight_toRightOf="@id/view_4" | 165 | app:layout_constraintRight_toRightOf="@id/view_4" |
160 | app:layout_constraintTop_toTopOf="@id/view_4" /> | 166 | app:layout_constraintTop_toTopOf="@id/view_4" /> |
161 | 167 | ||
162 | <ImageView | 168 | <ImageView |
163 | android:layout_width="14dp" | 169 | android:layout_width="14dp" |
164 | android:layout_height="14dp" | 170 | android:layout_height="14dp" |
165 | android:layout_marginLeft="15dp" | 171 | android:layout_marginLeft="15dp" |
166 | android:background="@mipmap/yincs" | 172 | android:background="@mipmap/yincs" |
167 | app:layout_constraintBottom_toBottomOf="@id/view_4" | 173 | app:layout_constraintBottom_toBottomOf="@id/view_4" |
168 | app:layout_constraintLeft_toLeftOf="@id/view_4" | 174 | app:layout_constraintLeft_toLeftOf="@id/view_4" |
169 | app:layout_constraintTop_toTopOf="@id/view_4" /> | 175 | app:layout_constraintTop_toTopOf="@id/view_4" /> |
170 | 176 | ||
171 | <TextView | 177 | <TextView |
172 | android:layout_width="wrap_content" | 178 | android:layout_width="wrap_content" |
173 | android:layout_height="wrap_content" | 179 | android:layout_height="wrap_content" |
174 | android:layout_marginLeft="40dp" | 180 | android:layout_marginLeft="40dp" |
175 | android:text="隐私政策" | 181 | android:text="隐私政策" |
176 | android:textColor="#333333" | 182 | android:textColor="#333333" |
177 | android:textSize="15dp" | 183 | android:textSize="16sp" |
178 | app:layout_constraintBottom_toBottomOf="@id/view_4" | 184 | app:layout_constraintBottom_toBottomOf="@id/view_4" |
179 | app:layout_constraintLeft_toLeftOf="@id/view_4" | 185 | app:layout_constraintLeft_toLeftOf="@id/view_4" |
180 | app:layout_constraintTop_toTopOf="@id/view_4" /> | 186 | app:layout_constraintTop_toTopOf="@id/view_4" /> |
181 | 187 | ||
182 | <View | 188 | <View |
183 | android:id="@+id/view_5" | 189 | android:id="@+id/view_5" |
184 | android:layout_width="match_parent" | 190 | android:layout_width="match_parent" |
185 | android:layout_height="45dp" | 191 | android:layout_height="50dp" |
186 | android:layout_marginLeft="15dp" | 192 | android:layout_marginLeft="15dp" |
187 | android:layout_marginRight="15dp" | 193 | android:layout_marginRight="15dp" |
188 | android:background="@android:color/white" | 194 | android:background="@android:color/white" |
189 | app:layout_constraintLeft_toLeftOf="parent" | 195 | app:layout_constraintLeft_toLeftOf="parent" |
190 | app:layout_constraintRight_toRightOf="parent" | 196 | app:layout_constraintRight_toRightOf="parent" |
191 | app:layout_constraintTop_toBottomOf="@id/view_4" /> | 197 | app:layout_constraintTop_toBottomOf="@id/view_4" /> |
192 | 198 | ||
193 | <ImageView | 199 | <ImageView |
194 | android:layout_width="6.8dp" | 200 | android:layout_width="8dp" |
195 | android:layout_height="12dp" | 201 | android:layout_height="14dp" |
196 | android:layout_marginRight="15dp" | 202 | android:layout_marginRight="15dp" |
197 | android:background="@mipmap/ycaj" | 203 | android:background="@mipmap/ycaj" |
198 | app:layout_constraintBottom_toBottomOf="@id/view_5" | 204 | app:layout_constraintBottom_toBottomOf="@id/view_5" |
199 | app:layout_constraintRight_toRightOf="@id/view_5" | 205 | app:layout_constraintRight_toRightOf="@id/view_5" |
200 | app:layout_constraintTop_toTopOf="@id/view_5" /> | 206 | app:layout_constraintTop_toTopOf="@id/view_5" /> |
201 | 207 | ||
202 | <ImageView | 208 | <ImageView |
203 | android:layout_width="14dp" | 209 | android:layout_width="14dp" |
204 | android:layout_height="14dp" | 210 | android:layout_height="14dp" |
205 | android:layout_marginLeft="15dp" | 211 | android:layout_marginLeft="15dp" |
206 | android:background="@mipmap/gywmm" | 212 | android:background="@mipmap/gywmm" |
207 | app:layout_constraintBottom_toBottomOf="@id/view_5" | 213 | app:layout_constraintBottom_toBottomOf="@id/view_5" |
208 | app:layout_constraintLeft_toLeftOf="@id/view_5" | 214 | app:layout_constraintLeft_toLeftOf="@id/view_5" |
209 | app:layout_constraintTop_toTopOf="@id/view_5" /> | 215 | app:layout_constraintTop_toTopOf="@id/view_5" /> |
210 | 216 | ||
211 | <TextView | 217 | <TextView |
212 | android:layout_width="wrap_content" | 218 | android:layout_width="wrap_content" |
213 | android:layout_height="wrap_content" | 219 | android:layout_height="wrap_content" |
214 | android:layout_marginLeft="40dp" | 220 | android:layout_marginLeft="40dp" |
215 | android:text="关于我们" | 221 | android:text="关于我们" |
216 | android:textColor="#333333" | 222 | android:textColor="#333333" |
217 | android:textSize="15dp" | 223 | android:textSize="16sp" |
218 | app:layout_constraintBottom_toBottomOf="@id/view_5" | 224 | app:layout_constraintBottom_toBottomOf="@id/view_5" |
219 | app:layout_constraintLeft_toLeftOf="@id/view_5" | 225 | app:layout_constraintLeft_toLeftOf="@id/view_5" |
220 | app:layout_constraintTop_toTopOf="@id/view_5" /> | 226 | app:layout_constraintTop_toTopOf="@id/view_5" /> |
221 | 227 | ||
222 | <View | 228 | <View |
223 | android:id="@+id/view_6" | 229 | android:id="@+id/view_6" |
224 | android:layout_width="match_parent" | 230 | android:layout_width="match_parent" |
225 | android:layout_height="45dp" | 231 | android:layout_height="50dp" |
226 | android:layout_marginLeft="15dp" | 232 | android:layout_marginLeft="15dp" |
227 | android:layout_marginRight="15dp" | 233 | android:layout_marginRight="15dp" |
228 | android:background="@drawable/bg_solid_white_10_bottom" | 234 | android:background="@drawable/bg_solid_white_10_bottom" |
229 | app:layout_constraintLeft_toLeftOf="parent" | 235 | app:layout_constraintLeft_toLeftOf="parent" |
230 | app:layout_constraintRight_toRightOf="parent" | 236 | app:layout_constraintRight_toRightOf="parent" |
231 | app:layout_constraintTop_toBottomOf="@id/view_5" /> | 237 | app:layout_constraintTop_toBottomOf="@id/view_5" /> |
232 | 238 | ||
233 | <ImageView | 239 | <ImageView |
234 | android:layout_width="14dp" | 240 | android:layout_width="14dp" |
235 | android:layout_height="14dp" | 241 | android:layout_height="14dp" |
236 | android:layout_marginLeft="15dp" | 242 | android:layout_marginLeft="15dp" |
237 | android:background="@mipmap/banb" | 243 | android:background="@mipmap/banb" |
238 | app:layout_constraintBottom_toBottomOf="@id/view_6" | 244 | app:layout_constraintBottom_toBottomOf="@id/view_6" |
239 | app:layout_constraintLeft_toLeftOf="@id/view_6" | 245 | app:layout_constraintLeft_toLeftOf="@id/view_6" |
240 | app:layout_constraintTop_toTopOf="@id/view_6" /> | 246 | app:layout_constraintTop_toTopOf="@id/view_6" /> |
241 | 247 | ||
242 | <TextView | 248 | <TextView |
243 | android:layout_width="wrap_content" | 249 | android:layout_width="wrap_content" |
244 | android:layout_height="wrap_content" | 250 | android:layout_height="wrap_content" |
245 | android:layout_marginLeft="40dp" | 251 | android:layout_marginLeft="40dp" |
246 | android:text="当前版本" | 252 | android:text="当前版本" |
247 | android:textColor="#333333" | 253 | android:textColor="#333333" |
248 | android:textSize="15dp" | 254 | android:textSize="16sp" |
249 | app:layout_constraintBottom_toBottomOf="@id/view_6" | 255 | app:layout_constraintBottom_toBottomOf="@id/view_6" |
250 | app:layout_constraintLeft_toLeftOf="@id/view_6" | 256 | app:layout_constraintLeft_toLeftOf="@id/view_6" |
251 | app:layout_constraintTop_toTopOf="@id/view_6" /> | 257 | app:layout_constraintTop_toTopOf="@id/view_6" /> |
252 | 258 | ||
253 | <TextView | 259 | <TextView |
254 | android:layout_width="wrap_content" | 260 | android:layout_width="wrap_content" |
255 | android:layout_height="wrap_content" | 261 | android:layout_height="wrap_content" |
256 | android:layout_marginRight="15dp" | 262 | android:layout_marginRight="15dp" |
257 | android:text="V1.0" | 263 | android:text="V1.0" |
258 | android:textColor="#333333" | 264 | android:textColor="#333333" |
259 | android:textSize="15dp" | 265 | android:textSize="15dp" |
260 | app:layout_constraintBottom_toBottomOf="@id/view_6" | 266 | app:layout_constraintBottom_toBottomOf="@id/view_6" |
261 | app:layout_constraintRight_toRightOf="@id/view_6" | 267 | app:layout_constraintRight_toRightOf="@id/view_6" |
262 | app:layout_constraintTop_toTopOf="@id/view_6" /> | 268 | app:layout_constraintTop_toTopOf="@id/view_6" /> |
263 | 269 |
app/src/main/res/layout/fragment_teacher.xml
File was created | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:layout_width="match_parent" | ||
3 | android:layout_height="match_parent" | ||
4 | android:background="@drawable/bg_teacher" | ||
5 | android:orientation="vertical"> | ||
6 | |||
7 | <RelativeLayout | ||
8 | android:layout_width="match_parent" | ||
9 | android:layout_height="40dp" | ||
10 | android:layout_marginTop="20dp"> | ||
11 | |||
12 | <TextView | ||
13 | android:layout_width="wrap_content" | ||
14 | android:layout_height="wrap_content" | ||
15 | android:layout_centerInParent="true" | ||
16 | android:text="个人中心" | ||
17 | android:textColor="#333333" | ||
18 | android:textSize="19sp" /> | ||
19 | |||
20 | </RelativeLayout> | ||
21 | |||
22 | <RelativeLayout | ||
23 | android:layout_width="match_parent" | ||
24 | android:layout_height="65dp"> | ||
25 | |||
26 | <ImageView | ||
27 | android:id="@+id/iv_teacher" | ||
28 | android:layout_width="65dp" | ||
29 | android:layout_height="65dp" | ||
30 | android:layout_marginLeft="25dp" | ||
31 | android:src="@mipmap/ic_teacher" /> | ||
32 | |||
33 | <TextView | ||
34 | android:id="@+id/tv_teacher" | ||
35 | android:layout_width="wrap_content" | ||
36 | android:layout_height="wrap_content" | ||
37 | android:layout_centerVertical="true" | ||
38 | android:layout_marginLeft="15dp" | ||
39 | android:layout_toRightOf="@+id/iv_teacher" | ||
40 | android:textColor="#333333" | ||
41 | android:textSize="18sp" /> | ||
42 | </RelativeLayout> | ||
43 | |||
44 | <RelativeLayout | ||
45 | android:layout_width="match_parent" | ||
46 | android:layout_height="90dp" | ||
47 | android:layout_marginLeft="5dp" | ||
48 | android:layout_marginRight="5dp" | ||
49 | android:background="@drawable/bg_teacher_answer"> | ||
50 | |||
51 | <LinearLayout | ||
52 | android:layout_width="wrap_content" | ||
53 | android:layout_height="wrap_content" | ||
54 | android:layout_centerVertical="true" | ||
55 | android:layout_marginLeft="25dp" | ||
56 | android:orientation="vertical"> | ||
57 | |||
58 | <TextView | ||
59 | android:id="@+id/tv_answer_name" | ||
60 | android:layout_width="wrap_content" | ||
61 | android:layout_height="wrap_content" | ||
62 | android:textColor="@color/white" | ||
63 | android:textSize="14sp" /> | ||
64 | |||
65 | <TextView | ||
66 | android:id="@+id/tv_num" | ||
67 | android:layout_width="wrap_content" | ||
68 | android:layout_height="wrap_content" | ||
69 | android:layout_marginTop="5dp" | ||
70 | android:textColor="@color/white" | ||
71 | android:textSize="12sp" /> | ||
72 | |||
73 | |||
74 | </LinearLayout> | ||
75 | |||
76 | <ImageView | ||
77 | android:layout_width="70dp" | ||
78 | android:layout_height="60dp" | ||
79 | android:layout_alignParentRight="true" | ||
80 | android:layout_centerVertical="true" | ||
81 | android:layout_marginRight="35dp" | ||
82 | android:src="@mipmap/ic_book" /> | ||
83 | </RelativeLayout> | ||
84 | |||
85 | <RelativeLayout | ||
86 | android:layout_width="match_parent" | ||
87 | android:layout_height="match_parent"> | ||
88 | |||
89 | <androidx.recyclerview.widget.RecyclerView | ||
90 | android:id="@+id/recycle_error" | ||
91 | android:layout_width="match_parent" | ||
92 | android:layout_height="match_parent" | ||
93 | android:layout_above="@+id/logout" | ||
94 | android:layout_marginTop="15dp" | ||
95 | android:layout_marginBottom="30dp" /> | ||
96 | |||
97 | <Button | ||
98 | android:id="@+id/logout" | ||
99 | android:layout_width="250dp" | ||
100 | android:layout_height="40dp" | ||
101 | android:layout_alignParentBottom="true" | ||
102 | android:layout_centerHorizontal="true" | ||
103 | android:layout_marginBottom="30dp" | ||
104 | android:background="@drawable/bg_soild_blue_5" | ||
105 | android:text="退出登录" | ||
106 | android:textColor="@color/white" | ||
107 | android:textSize="18sp" /> | ||
108 | </RelativeLayout> | ||
109 | |||
110 | |||
111 | </LinearLayout> |
app/src/main/res/layout/item_child.xml
1 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="75dp" | 2 | android:layout_width="75dp" |
3 | android:layout_height="wrap_content" | 3 | android:layout_height="wrap_content" |
4 | android:layout_marginLeft="15dp" | 4 | android:layout_marginLeft="15dp" |
5 | android:layout_marginRight="15dp" | 5 | android:layout_marginRight="15dp" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | <ImageView | 8 | <ImageView |
9 | android:id="@+id/iv_avatar" | 9 | android:id="@+id/iv_avatar" |
10 | android:layout_width="56dp" | 10 | android:layout_width="60dp" |
11 | android:layout_height="56dp" | 11 | android:layout_height="60dp" |
12 | android:layout_centerHorizontal="true" | 12 | android:layout_centerHorizontal="true" |
13 | android:layout_marginTop="8dp" | 13 | android:layout_marginTop="8dp" |
14 | android:background="@mipmap/tjxss" /> | 14 | android:padding="1dp" |
15 | android:background="@drawable/bg_solid_white_30" | ||
16 | android:src="@mipmap/tjxss" /> | ||
15 | 17 | ||
16 | <ImageView | 18 | <ImageView |
17 | android:id="@+id/iv_vip" | 19 | android:id="@+id/iv_vip" |
18 | android:layout_width="20dp" | 20 | android:layout_width="20dp" |
19 | android:layout_height="18dp" | 21 | android:layout_height="18dp" |
20 | android:layout_alignRight="@+id/iv_avatar" | 22 | android:layout_alignRight="@+id/iv_avatar" |
21 | android:src="@mipmap/ic_vip" /> | 23 | android:src="@mipmap/ic_vip" /> |
22 | 24 | ||
23 | <TextView | 25 | <TextView |
24 | android:id="@+id/tv_name" | 26 | android:id="@+id/tv_name" |
25 | android:layout_width="wrap_content" | 27 | android:layout_width="wrap_content" |
26 | android:layout_height="wrap_content" | 28 | android:layout_height="wrap_content" |
27 | android:layout_below="@+id/iv_avatar" | 29 | android:layout_below="@+id/iv_avatar" |
28 | android:layout_centerHorizontal="true" | 30 | android:layout_centerHorizontal="true" |
29 | android:layout_marginTop="10dp" | 31 | android:layout_marginTop="10dp" |
30 | android:ellipsize="end" | 32 | android:ellipsize="end" |
31 | android:singleLine="true" | 33 | android:singleLine="true" |
32 | android:text="添加学生" | 34 | android:text="添加学生" |
33 | android:textColor="#000000" | 35 | android:textColor="@color/white" |
34 | android:textSize="13dp" /> | 36 | android:textSize="14dp" /> |
35 | </RelativeLayout> | 37 | </RelativeLayout> |
36 | 38 | ||
37 | 39 |
app/src/main/res/layout/item_record.xml
File was created | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | xmlns:tools="http://schemas.android.com/tools" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="wrap_content" | ||
5 | android:layout_marginTop="15dp" | ||
6 | android:background="@drawable/bg_item_video_10" | ||
7 | android:orientation="vertical"> | ||
8 | |||
9 | <RelativeLayout | ||
10 | android:layout_width="match_parent" | ||
11 | android:layout_height="35dp" | ||
12 | android:layout_marginTop="10dp"> | ||
13 | |||
14 | <ImageView | ||
15 | android:id="@+id/iv_student" | ||
16 | android:layout_width="35dp" | ||
17 | android:layout_height="35dp" | ||
18 | android:layout_marginLeft="15dp" /> | ||
19 | |||
20 | <TextView | ||
21 | android:id="@+id/tv_name" | ||
22 | android:layout_width="wrap_content" | ||
23 | android:layout_height="wrap_content" | ||
24 | android:layout_centerVertical="true" | ||
25 | android:layout_marginLeft="10dp" | ||
26 | android:layout_toRightOf="@+id/iv_student" | ||
27 | android:textColor="#333333" | ||
28 | android:textSize="14sp" /> | ||
29 | |||
30 | <TextView | ||
31 | android:id="@+id/tv_date" | ||
32 | android:layout_width="wrap_content" | ||
33 | android:layout_height="wrap_content" | ||
34 | android:layout_alignParentRight="true" | ||
35 | android:layout_centerVertical="true" | ||
36 | android:layout_marginRight="15dp" | ||
37 | android:textColor="#666666" | ||
38 | android:textSize="12sp" /> | ||
39 | </RelativeLayout> | ||
40 | |||
41 | <LinearLayout | ||
42 | android:layout_width="match_parent" | ||
43 | android:layout_height="wrap_content" | ||
44 | android:orientation="vertical"> | ||
45 | |||
46 | <WebView | ||
47 | android:id="@+id/webview" | ||
48 | android:layout_width="match_parent" | ||
49 | android:layout_height="wrap_content" | ||
50 | android:layout_marginLeft="15dp" | ||
51 | android:layout_marginTop="10dp" | ||
52 | android:layout_marginRight="15dp" | ||
53 | android:scrollbars="none" | ||
54 | tools:ignore="WebViewLayout" /> | ||
55 | |||
56 | <ImageView | ||
57 | android:id="@+id/iv_topic" | ||
58 | android:layout_width="match_parent" | ||
59 | android:layout_height="wrap_content" | ||
60 | android:layout_marginLeft="15dp" | ||
61 | android:layout_marginTop="15dp" | ||
62 | android:layout_marginRight="15dp" | ||
63 | android:layout_marginBottom="15dp" /> | ||
64 | |||
65 | </LinearLayout> | ||
66 | </LinearLayout> |
app/src/main/res/layout/item_schedule.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="wrap_content" | 3 | android:layout_height="wrap_content" |
4 | android:layout_marginLeft="15dp" | 4 | android:layout_marginLeft="15dp" |
5 | android:layout_marginTop="15dp" | 5 | android:layout_marginTop="15dp" |
6 | android:layout_marginRight="15dp" | 6 | android:layout_marginRight="15dp" |
7 | android:orientation="vertical"> | 7 | android:orientation="vertical"> |
8 | 8 | ||
9 | <LinearLayout | 9 | <LinearLayout |
10 | android:layout_width="wrap_content" | 10 | android:layout_width="wrap_content" |
11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
12 | android:orientation="horizontal"> | 12 | android:orientation="horizontal"> |
13 | 13 | ||
14 | <View | 14 | <View |
15 | android:layout_width="1dp" | 15 | android:layout_width="1dp" |
16 | android:layout_height="15dp" | 16 | android:layout_height="15dp" |
17 | android:layout_gravity="center_vertical" | 17 | android:layout_gravity="center_vertical" |
18 | android:background="#FE5E09" /> | 18 | android:background="#1C90F3" /> |
19 | 19 | ||
20 | <TextView | 20 | <TextView |
21 | android:id="@+id/tv_date" | 21 | android:id="@+id/tv_date" |
22 | android:layout_width="wrap_content" | 22 | android:layout_width="wrap_content" |
23 | android:layout_height="wrap_content" | 23 | android:layout_height="wrap_content" |
24 | android:layout_gravity="center_vertical" | 24 | android:layout_gravity="center_vertical" |
25 | android:layout_marginLeft="10dp" | 25 | android:layout_marginLeft="10dp" |
26 | android:textColor="#333333" | 26 | android:textColor="#333333" |
27 | android:textSize="13sp" /> | 27 | android:textSize="15sp" /> |
28 | </LinearLayout> | 28 | </LinearLayout> |
29 | 29 | ||
30 | <LinearLayout | 30 | <LinearLayout |
31 | android:id="@+id/ll_schedule" | 31 | android:id="@+id/ll_schedule" |
32 | android:layout_width="match_parent" | 32 | android:layout_width="match_parent" |
33 | android:layout_height="wrap_content" | 33 | android:layout_height="wrap_content" |
34 | android:orientation="vertical" /> | 34 | android:orientation="vertical" /> |
35 | </LinearLayout> | 35 | </LinearLayout> |
app/src/main/res/layout/item_video.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="wrap_content"> | 3 | android:layout_height="wrap_content"> |
4 | 4 | ||
5 | <TextView | 5 | <TextView |
6 | android:id="@+id/tv_name" | 6 | android:id="@+id/tv_name" |
7 | android:layout_width="match_parent" | 7 | android:layout_width="match_parent" |
8 | android:layout_height="35dp" | 8 | android:layout_height="40dp" |
9 | android:layout_marginTop="15dp" | 9 | android:layout_marginTop="15dp" |
10 | android:background="@drawable/bg_item_video_10" | 10 | android:background="@drawable/bg_item_schedule" |
11 | android:gravity="center" | 11 | android:gravity="center" |
12 | android:singleLine="true" | 12 | android:singleLine="true" |
13 | android:textColor="#333333" | 13 | android:textColor="#333333" |
14 | android:textSize="13sp" /> | 14 | android:textSize="14sp" /> |
15 | </LinearLayout> | 15 | </LinearLayout> |
app/src/main/res/mipmap-hdpi/hoss.png
app/src/main/res/mipmap-hdpi/hous.png
app/src/main/res/mipmap-hdpi/ic_change.png
2.1 KB
app/src/main/res/mipmap-hdpi/ic_schedule.png
2.65 KB
app/src/main/res/mipmap-hdpi/sbgl.png
app/src/main/res/mipmap-hdpi/ssss.png
app/src/main/res/mipmap-hdpi/tjxss.png
app/src/main/res/mipmap-hdpi/wmss.png
app/src/main/res/mipmap-hdpi/wmus.png
app/src/main/res/mipmap-hdpi/xxan.png
app/src/main/res/mipmap-hdpi/xxxt.png
app/src/main/res/mipmap-hdpi/ycaj.png
app/src/main/res/mipmap-hdpi/yyxz.png
app/src/main/res/mipmap-xxhdpi/ic_book.png
53.5 KB
app/src/main/res/mipmap-xxhdpi/ic_teacher.png
54.8 KB
libs/common/src/main/java/com/prws/common/base/BaseActivity.java
1 | package com.prws.common.base; | 1 | package com.prws.common.base; |
2 | 2 | ||
3 | 3 | ||
4 | import android.app.Activity; | 4 | import android.app.Activity; |
5 | import android.app.AlertDialog; | 5 | import android.app.AlertDialog; |
6 | import android.content.Context; | 6 | import android.content.Context; |
7 | import android.content.DialogInterface; | 7 | import android.content.DialogInterface; |
8 | import android.content.Intent; | 8 | import android.content.Intent; |
9 | import android.graphics.Color; | 9 | import android.graphics.Color; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.os.IBinder; | 11 | import android.os.IBinder; |
12 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
13 | import android.util.Log; | 13 | import android.util.Log; |
14 | import android.view.MotionEvent; | 14 | import android.view.MotionEvent; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | import android.view.Window; | 16 | import android.view.Window; |
17 | import android.view.WindowManager; | 17 | import android.view.WindowManager; |
18 | import android.view.inputmethod.InputMethodManager; | 18 | import android.view.inputmethod.InputMethodManager; |
19 | import android.widget.EditText; | 19 | import android.widget.EditText; |
20 | import android.widget.Toast; | 20 | import android.widget.Toast; |
21 | 21 | ||
22 | import androidx.annotation.IdRes; | 22 | import androidx.annotation.IdRes; |
23 | import androidx.annotation.Nullable; | 23 | import androidx.annotation.Nullable; |
24 | import androidx.appcompat.app.AppCompatActivity; | 24 | import androidx.appcompat.app.AppCompatActivity; |
25 | import androidx.fragment.app.Fragment; | 25 | import androidx.fragment.app.Fragment; |
26 | import androidx.fragment.app.FragmentTransaction; | 26 | import androidx.fragment.app.FragmentTransaction; |
27 | import androidx.lifecycle.Lifecycle; | 27 | import androidx.lifecycle.Lifecycle; |
28 | 28 | ||
29 | import com.developer.wang.utils.PermissionUtils; | 29 | import com.developer.wang.utils.PermissionUtils; |
30 | import com.prws.common.R; | 30 | import com.prws.common.R; |
31 | import com.prws.common.net.INetEvent; | 31 | import com.prws.common.net.INetEvent; |
32 | import com.prws.common.utils.LogUtil; | 32 | import com.prws.common.utils.LogUtil; |
33 | import com.prws.common.utils.ScreenUtils; | 33 | import com.prws.common.utils.ScreenUtils; |
34 | import com.prws.common.utils.SharedPreferencesUtil; | 34 | import com.prws.common.utils.SharedPreferencesUtil; |
35 | import com.prws.common.view.LoadingView; | 35 | import com.prws.common.view.LoadingView; |
36 | 36 | ||
37 | import org.simple.eventbus.EventBus; | 37 | import org.simple.eventbus.EventBus; |
38 | 38 | ||
39 | import java.util.ArrayList; | 39 | import java.util.ArrayList; |
40 | import java.util.List; | 40 | import java.util.List; |
41 | 41 | ||
42 | import butterknife.ButterKnife; | 42 | import butterknife.ButterKnife; |
43 | import io.reactivex.disposables.CompositeDisposable; | 43 | import io.reactivex.disposables.CompositeDisposable; |
44 | import io.reactivex.disposables.Disposable; | 44 | import io.reactivex.disposables.Disposable; |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
48 | * @author 描述:BaseActivity | 48 | * @author 描述:BaseActivity |
49 | */ | 49 | */ |
50 | public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity implements INetEvent, BaseView { | 50 | public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity implements INetEvent, BaseView { |
51 | 51 | ||
52 | 52 | ||
53 | private LoadingView loading; | 53 | private LoadingView loading; |
54 | 54 | ||
55 | public static INetEvent mINetEvent; | 55 | public static INetEvent mINetEvent; |
56 | protected final String TAG = getClass().getSimpleName(); | 56 | protected final String TAG = getClass().getSimpleName(); |
57 | private CompositeDisposable mCompositeDisposable; | 57 | private CompositeDisposable mCompositeDisposable; |
58 | protected P p; | 58 | protected P p; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * 获取布局文件 | 61 | * 获取布局文件 |
62 | * | 62 | * |
63 | * @return | 63 | * @return |
64 | */ | 64 | */ |
65 | protected abstract int layoutResId(); | 65 | protected abstract int layoutResId(); |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * 让P层做相应需求 | 68 | * 让P层做相应需求 |
69 | */ | 69 | */ |
70 | public abstract CONTRACT getContract(); | 70 | public abstract CONTRACT getContract(); |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * 子类获取具体契约 | 73 | * 子类获取具体契约 |
74 | */ | 74 | */ |
75 | public abstract P getPresenter(); | 75 | public abstract P getPresenter(); |
76 | 76 | ||
77 | @Override | 77 | @Override |
78 | protected void onCreate(@Nullable Bundle savedInstanceState) { | 78 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
79 | super.onCreate(savedInstanceState); | 79 | super.onCreate(savedInstanceState); |
80 | setNetEvent(); | 80 | setNetEvent(); |
81 | initPresenter(); | 81 | initPresenter(); |
82 | showWhiteStatus(); | 82 | showWhiteStatus(); |
83 | setContentView(layoutResId()); | 83 | setContentView(layoutResId()); |
84 | ButterKnife.bind(this); | 84 | ButterKnife.bind(this); |
85 | registerEventBus(); | 85 | registerEventBus(); |
86 | initView(); | 86 | initView(); |
87 | initListener(); | 87 | initListener(); |
88 | initData(); | 88 | initData(); |
89 | 89 | ||
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | public void showWhiteStatus() { | 93 | public void showWhiteStatus() { |
94 | Window window = getWindow(); | 94 | Window window = getWindow(); |
95 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | 95 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
96 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | 96 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
97 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | 97 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
98 | window.setStatusBarColor(Color.TRANSPARENT); | 98 | window.setStatusBarColor(Color.TRANSPARENT); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | public void fullScreen(){ | ||
103 | Window window = getWindow(); | ||
104 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | ||
105 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | ||
106 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); | ||
107 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | ||
108 | window.setStatusBarColor(Color.TRANSPARENT); | ||
109 | } | ||
110 | |||
111 | protected void blackBar() { | ||
112 | Window window = getWindow(); | ||
113 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); | ||
114 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | ||
115 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | ||
116 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | ||
117 | window.setStatusBarColor(Color.TRANSPARENT); | ||
118 | } | ||
119 | |||
102 | @Override | 120 | @Override |
103 | protected void onResume() { | 121 | protected void onResume() { |
104 | super.onResume(); | 122 | super.onResume(); |
105 | } | 123 | } |
106 | 124 | ||
107 | protected abstract void initView(); | 125 | protected abstract void initView(); |
108 | 126 | ||
109 | protected abstract void initListener(); | 127 | protected abstract void initListener(); |
110 | 128 | ||
111 | protected abstract void initData(); | 129 | protected abstract void initData(); |
112 | 130 | ||
113 | 131 | ||
114 | private void setNetEvent() { | 132 | private void setNetEvent() { |
115 | mINetEvent = this; | 133 | mINetEvent = this; |
116 | } | 134 | } |
117 | 135 | ||
118 | private void initPresenter() { | 136 | private void initPresenter() { |
119 | p = getPresenter(); | 137 | p = getPresenter(); |
120 | if (p != null) | 138 | if (p != null) |
121 | p.bindView(this); | 139 | p.bindView(this); |
122 | } | 140 | } |
123 | 141 | ||
124 | 142 | ||
125 | public void showDialog(String title, String message, String confirm, String cancel, DialogInterface.OnClickListener cancelListener, DialogInterface.OnClickListener listener) { | 143 | public void showDialog(String title, String message, String confirm, String cancel, DialogInterface.OnClickListener cancelListener, DialogInterface.OnClickListener listener) { |
126 | AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); | 144 | AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); |
127 | builder.setTitle(title); | 145 | builder.setTitle(title); |
128 | builder.setMessage(message); | 146 | builder.setMessage(message); |
129 | builder.setCancelable(false); | 147 | builder.setCancelable(false); |
130 | if (!TextUtils.isEmpty(cancel)) { | 148 | if (!TextUtils.isEmpty(cancel)) { |
131 | builder.setNegativeButton(cancel, cancelListener); | 149 | builder.setNegativeButton(cancel, cancelListener); |
132 | } | 150 | } |
133 | builder.setPositiveButton(confirm, listener); | 151 | builder.setPositiveButton(confirm, listener); |
134 | builder.show(); | 152 | builder.show(); |
135 | } | 153 | } |
136 | 154 | ||
137 | private void setWindow() { | 155 | private void setWindow() { |
138 | Window window = getWindow(); | 156 | Window window = getWindow(); |
139 | WindowManager.LayoutParams params = window.getAttributes(); | 157 | WindowManager.LayoutParams params = window.getAttributes(); |
140 | params.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN | 158 | params.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN |
141 | ; | 159 | ; |
142 | window.setAttributes(params); | 160 | window.setAttributes(params); |
143 | } | 161 | } |
144 | 162 | ||
145 | 163 | ||
146 | private void addNavigationBar() { | 164 | private void addNavigationBar() { |
147 | //判断是否有浮窗权限 | 165 | //判断是否有浮窗权限 |
148 | if (PermissionUtils.requestWindowManager(this)) { | 166 | if (PermissionUtils.requestWindowManager(this)) { |
149 | //开启浮窗 | 167 | //开启浮窗 |
150 | // openFloatWindow(); | 168 | // openFloatWindow(); |
151 | } else { | 169 | } else { |
152 | showAlertDialogOfFloatWindow(); | 170 | showAlertDialogOfFloatWindow(); |
153 | } | 171 | } |
154 | } | 172 | } |
155 | 173 | ||
156 | // public void openFloatWindow() { | 174 | // public void openFloatWindow() { |
157 | // if (FloatWindow.get("navigation") == null) { | 175 | // if (FloatWindow.get("navigation") == null) { |
158 | // NavigationBarView navigationBarView = new NavigationBarView(this); | 176 | // NavigationBarView navigationBarView = new NavigationBarView(this); |
159 | // FloatWindow.with(CommonApplication.getAppContext()) | 177 | // FloatWindow.with(CommonApplication.getAppContext()) |
160 | // .setView(navigationBarView) | 178 | // .setView(navigationBarView) |
161 | // .setWidth(Screen.width, 1) | 179 | // .setWidth(Screen.width, 1) |
162 | // .setHeight(WindowManager.LayoutParams.WRAP_CONTENT) | 180 | // .setHeight(WindowManager.LayoutParams.WRAP_CONTENT) |
163 | // .setX(0) | 181 | // .setX(0) |
164 | // .setY(0) | 182 | // .setY(0) |
165 | // .setMoveType(MoveType.inactive) | 183 | // .setMoveType(MoveType.inactive) |
166 | // .setDesktopShow(false) | 184 | // .setDesktopShow(false) |
167 | // .setTag("navigation") | 185 | // .setTag("navigation") |
168 | // .build(); | 186 | // .build(); |
169 | // } | 187 | // } |
170 | // if (!FloatWindow.get("navigation").isShowing()) | 188 | // if (!FloatWindow.get("navigation").isShowing()) |
171 | // FloatWindow.get("navigation").show(); | 189 | // FloatWindow.get("navigation").show(); |
172 | // | 190 | // |
173 | // } | 191 | // } |
174 | 192 | ||
175 | 193 | ||
176 | public void showAlertDialogOfFloatWindow() { | 194 | public void showAlertDialogOfFloatWindow() { |
177 | //弹窗提示用户开启权限 | 195 | //弹窗提示用户开启权限 |
178 | // new AlertDialog(this).builder().setTitle(getString(R.string.need_permission)) | 196 | // new AlertDialog(this).builder().setTitle(getString(R.string.need_permission)) |
179 | // .setMsg(getString(R.string.need_permission_window)) | 197 | // .setMsg(getString(R.string.need_permission_window)) |
180 | // .setPositiveButton(getString(R.string.open), new View.OnClickListener() { | 198 | // .setPositiveButton(getString(R.string.open), new View.OnClickListener() { |
181 | // @Override | 199 | // @Override |
182 | // public void onClick(View v) { | 200 | // public void onClick(View v) { |
183 | // Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); | 201 | // Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); |
184 | // intent.setData(Uri.parse("package:" + getPackageName())); | 202 | // intent.setData(Uri.parse("package:" + getPackageName())); |
185 | // startActivity(intent); | 203 | // startActivity(intent); |
186 | // } | 204 | // } |
187 | // }).setNegativeButton(getString(R.string.cancel), new View.OnClickListener() { | 205 | // }).setNegativeButton(getString(R.string.cancel), new View.OnClickListener() { |
188 | // @Override | 206 | // @Override |
189 | // public void onClick(View v) { | 207 | // public void onClick(View v) { |
190 | // } | 208 | // } |
191 | // }).show(); | 209 | // }).show(); |
192 | LogUtil.toast("请开启浮窗权限"); | 210 | LogUtil.toast("请开启浮窗权限"); |
193 | } | 211 | } |
194 | 212 | ||
195 | 213 | ||
196 | public void showLoading(String title) { | 214 | public void showLoading(String title) { |
197 | synchronized (this) { | 215 | synchronized (this) { |
198 | if (loading != null || !isLiving(this)) return; | 216 | if (loading != null || !isLiving(this)) return; |
199 | runOnUiThread(() -> { | 217 | runOnUiThread(() -> { |
200 | loading = new LoadingView(this, R.style.CustomDialog, title); | 218 | loading = new LoadingView(this, R.style.CustomDialog, title); |
201 | loading.show(); | 219 | loading.show(); |
202 | ScreenUtils.hideBottomUIMenu(this); | 220 | ScreenUtils.hideBottomUIMenu(this); |
203 | ScreenUtils.hideDialogBottomUIMenu(loading); | 221 | ScreenUtils.hideDialogBottomUIMenu(loading); |
204 | }); | 222 | }); |
205 | } | 223 | } |
206 | } | 224 | } |
207 | 225 | ||
208 | 226 | ||
209 | public void setCanAble(boolean canAble) { | 227 | public void setCanAble(boolean canAble) { |
210 | if (loading != null) | 228 | if (loading != null) |
211 | loading.setCancelable(canAble); | 229 | loading.setCancelable(canAble); |
212 | 230 | ||
213 | } | 231 | } |
214 | 232 | ||
215 | public boolean isShowLoading() { | 233 | public boolean isShowLoading() { |
216 | if (loading == null) return false; | 234 | if (loading == null) return false; |
217 | return loading.isShowing(); | 235 | return loading.isShowing(); |
218 | } | 236 | } |
219 | 237 | ||
220 | public void dismissLoading() { | 238 | public void dismissLoading() { |
221 | runOnUiThread(() -> { | 239 | runOnUiThread(() -> { |
222 | if (loading == null || loading.isShowing() == false || !isLiving(this)) { | 240 | if (loading == null || loading.isShowing() == false || !isLiving(this)) { |
223 | Log.w(TAG, "loading == null" + | 241 | Log.w(TAG, "loading == null" + |
224 | " || loading.isShowing() == false >> return;"); | 242 | " || loading.isShowing() == false >> return;"); |
225 | return; | 243 | return; |
226 | } | 244 | } |
227 | loading.dismiss(); | 245 | loading.dismiss(); |
228 | loading = null; | 246 | loading = null; |
229 | 247 | ||
230 | }); | 248 | }); |
231 | } | 249 | } |
232 | 250 | ||
233 | 251 | ||
234 | private static boolean isLiving(Activity activity) { | 252 | private static boolean isLiving(Activity activity) { |
235 | 253 | ||
236 | if (activity == null) { | 254 | if (activity == null) { |
237 | Log.d("wisely", "activity == null"); | 255 | Log.d("wisely", "activity == null"); |
238 | return false; | 256 | return false; |
239 | } | 257 | } |
240 | 258 | ||
241 | if (activity.isFinishing()) { | 259 | if (activity.isFinishing()) { |
242 | Log.d("wisely", "activity is finishing"); | 260 | Log.d("wisely", "activity is finishing"); |
243 | return false; | 261 | return false; |
244 | } | 262 | } |
245 | 263 | ||
246 | return true; | 264 | return true; |
247 | } | 265 | } |
248 | 266 | ||
249 | 267 | ||
250 | /** | 268 | /** |
251 | * 是否需要弹窗提示更新 | 269 | * 是否需要弹窗提示更新 |
252 | */ | 270 | */ |
253 | protected void isNeedGetVersionUpdate() { | 271 | protected void isNeedGetVersionUpdate() { |
254 | // View view = findViewById(R.id.view_loading); | 272 | // View view = findViewById(R.id.view_loading); |
255 | //如果显示正在下载的页面,则不弹出更新弹窗 | 273 | //如果显示正在下载的页面,则不弹出更新弹窗 |
256 | // if (null == view || view.getVisibility() == View.VISIBLE) return; | 274 | // if (null == view || view.getVisibility() == View.VISIBLE) return; |
257 | // UpdateUtils.getVersion(this); | 275 | // UpdateUtils.getVersion(this); |
258 | } | 276 | } |
259 | 277 | ||
260 | 278 | ||
261 | /** | 279 | /** |
262 | * 全局检测网络广播的回调 处理网络变化 | 280 | * 全局检测网络广播的回调 处理网络变化 |
263 | * 注:在程序第一次启动的时候,没网并不会回调,需要自己在启动页面,或者主页自己再判断一次 | 281 | * 注:在程序第一次启动的时候,没网并不会回调,需要自己在启动页面,或者主页自己再判断一次 |
264 | * | 282 | * |
265 | * @param netWorkState 网络状态 -1:没网络 0:移动网络 1:WiFi网络 | 283 | * @param netWorkState 网络状态 -1:没网络 0:移动网络 1:WiFi网络 |
266 | */ | 284 | */ |
267 | public abstract void onNetChanged(int netWorkState); | 285 | public abstract void onNetChanged(int netWorkState); |
268 | 286 | ||
269 | @Override | 287 | @Override |
270 | public void onNetChange(int netWorkState) { | 288 | public void onNetChange(int netWorkState) { |
271 | onNetChanged(netWorkState); | 289 | onNetChanged(netWorkState); |
272 | } | 290 | } |
273 | 291 | ||
274 | @Override | 292 | @Override |
275 | protected void onDestroy() { | 293 | protected void onDestroy() { |
276 | super.onDestroy(); | 294 | super.onDestroy(); |
277 | unSubscribe(); | 295 | unSubscribe(); |
278 | cleanFragment(); | 296 | cleanFragment(); |
279 | unregisterEventBus(); | 297 | unregisterEventBus(); |
280 | if (p != null) { | 298 | if (p != null) { |
281 | p.onBindView(); | 299 | p.onBindView(); |
282 | p.cancelAllRequest(); | 300 | p.cancelAllRequest(); |
283 | } | 301 | } |
284 | } | 302 | } |
285 | 303 | ||
286 | @Override | 304 | @Override |
287 | protected void onPause() { | 305 | protected void onPause() { |
288 | super.onPause(); | 306 | super.onPause(); |
289 | 307 | ||
290 | } | 308 | } |
291 | 309 | ||
292 | private void registerEventBus() { | 310 | private void registerEventBus() { |
293 | EventBus.getDefault().register(this); | 311 | EventBus.getDefault().register(this); |
294 | } | 312 | } |
295 | 313 | ||
296 | private void unregisterEventBus() { | 314 | private void unregisterEventBus() { |
297 | EventBus.getDefault().unregister(this); | 315 | EventBus.getDefault().unregister(this); |
298 | } | 316 | } |
299 | 317 | ||
300 | public void showErrorToast() { | 318 | public void showErrorToast() { |
301 | // LogUtil.toast(MainApplication.getAppContext(), getString(R.string.service_error)); | 319 | // LogUtil.toast(MainApplication.getAppContext(), getString(R.string.service_error)); |
302 | } | 320 | } |
303 | 321 | ||
304 | public void showToast(String s) { | 322 | public void showToast(String s) { |
305 | Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show(); | 323 | Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show(); |
306 | } | 324 | } |
307 | 325 | ||
308 | private void unSubscribe() { | 326 | private void unSubscribe() { |
309 | if (mCompositeDisposable != null) { | 327 | if (mCompositeDisposable != null) { |
310 | mCompositeDisposable.clear(); | 328 | mCompositeDisposable.clear(); |
311 | } | 329 | } |
312 | } | 330 | } |
313 | 331 | ||
314 | protected void addSubscribe(Disposable disposable) { | 332 | protected void addSubscribe(Disposable disposable) { |
315 | if (mCompositeDisposable == null) { | 333 | if (mCompositeDisposable == null) { |
316 | mCompositeDisposable = new CompositeDisposable(); | 334 | mCompositeDisposable = new CompositeDisposable(); |
317 | } | 335 | } |
318 | mCompositeDisposable.add(disposable); | 336 | mCompositeDisposable.add(disposable); |
319 | } | 337 | } |
320 | 338 | ||
321 | protected void startActivity(Class clazz) { | 339 | protected void startActivity(Class clazz) { |
322 | startActivity(new Intent(this, clazz)); | 340 | startActivity(new Intent(this, clazz)); |
323 | } | 341 | } |
324 | 342 | ||
325 | /******************** 处理fragment *******************************/ | 343 | /******************** 处理fragment *******************************/ |
326 | List<Fragment> fragmentList = new ArrayList<>(); | 344 | List<Fragment> fragmentList = new ArrayList<>(); |
327 | 345 | ||
328 | protected void showFragment(Fragment fragment, @IdRes int id) { | 346 | protected void showFragment(Fragment fragment, @IdRes int id) { |
329 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | 347 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); |
330 | 348 | ||
331 | if (!fragmentList.contains(fragment)) { | 349 | if (!fragmentList.contains(fragment)) { |
332 | fragmentList.add(fragment); | 350 | fragmentList.add(fragment); |
333 | fragmentTransaction.add(id, fragment, fragment.getClass().getSimpleName()).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); | 351 | fragmentTransaction.add(id, fragment, fragment.getClass().getSimpleName()).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); |
334 | } | 352 | } |
335 | 353 | ||
336 | fragmentTransaction.show(fragment).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); | 354 | fragmentTransaction.show(fragment).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); |
337 | 355 | ||
338 | for (Fragment fragment1 : fragmentList) { | 356 | for (Fragment fragment1 : fragmentList) { |
339 | if (fragment1 != fragment) { | 357 | if (fragment1 != fragment) { |
340 | fragmentTransaction.hide(fragment1).setMaxLifecycle(fragment1, Lifecycle.State.STARTED); | 358 | fragmentTransaction.hide(fragment1).setMaxLifecycle(fragment1, Lifecycle.State.STARTED); |
341 | } | 359 | } |
342 | } | 360 | } |
343 | 361 | ||
344 | fragmentTransaction.commitAllowingStateLoss(); | 362 | fragmentTransaction.commitAllowingStateLoss(); |
345 | 363 | ||
346 | } | 364 | } |
347 | 365 | ||
348 | protected void cleanFragment() { | 366 | protected void cleanFragment() { |
349 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | 367 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); |
350 | if (fragmentList.size() > 0) { | 368 | if (fragmentList.size() > 0) { |
351 | for (Fragment fragment : fragmentList) { | 369 | for (Fragment fragment : fragmentList) { |
352 | fragmentTransaction.remove(fragment); | 370 | fragmentTransaction.remove(fragment); |
353 | } | 371 | } |
354 | try { | 372 | try { |
355 | fragmentTransaction.commitNowAllowingStateLoss(); | 373 | fragmentTransaction.commitNowAllowingStateLoss(); |
356 | } catch (Exception e) { | 374 | } catch (Exception e) { |
357 | e.printStackTrace(); | 375 | e.printStackTrace(); |
358 | } | 376 | } |
359 | } | 377 | } |
360 | fragmentList.clear(); | 378 | fragmentList.clear(); |
361 | } | 379 | } |
362 | 380 | ||
363 | //************************* 用于隐藏键盘 ***************************************// | 381 | //************************* 用于隐藏键盘 ***************************************// |
364 | @Override | 382 | @Override |
365 | public boolean dispatchTouchEvent(MotionEvent ev) { | 383 | public boolean dispatchTouchEvent(MotionEvent ev) { |
366 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { | 384 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { |
367 | 385 | ||
368 | View v = getCurrentFocus(); | 386 | View v = getCurrentFocus(); |
369 | if (isShouldHideInput(v, ev)) { | 387 | if (isShouldHideInput(v, ev)) { |
370 | hideSoftInput(v.getWindowToken()); | 388 | hideSoftInput(v.getWindowToken()); |
371 | } | 389 | } |
372 | } | 390 | } |
373 | return super.dispatchTouchEvent(ev); | 391 | return super.dispatchTouchEvent(ev); |
374 | } | 392 | } |
375 | 393 | ||
376 | private boolean isShouldHideInput(View v, MotionEvent event) { | 394 | private boolean isShouldHideInput(View v, MotionEvent event) { |
377 | if (v != null && (v instanceof EditText)) { | 395 | if (v != null && (v instanceof EditText)) { |
378 | int[] l = {0, 0}; | 396 | int[] l = {0, 0}; |
379 | v.getLocationInWindow(l); | 397 | v.getLocationInWindow(l); |
380 | int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left | 398 | int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left |
381 | + v.getWidth(); | 399 | + v.getWidth(); |
382 | if (event.getX() > left && event.getX() < right | 400 | if (event.getX() > left && event.getX() < right |
383 | && event.getY() > top && event.getY() < bottom) { | 401 | && event.getY() > top && event.getY() < bottom) { |
384 | // 点击EditText的事件,忽略它。 | 402 | // 点击EditText的事件,忽略它。 |
385 | return false; | 403 | return false; |
386 | } else { | 404 | } else { |
387 | return true; | 405 | return true; |
388 | } | 406 | } |
389 | } | 407 | } |
390 | 408 | ||
391 | return false; | 409 | return false; |
392 | } | 410 | } |
393 | 411 | ||
394 | /** | 412 | /** |
395 | * 多种隐藏软件盘方法的其中一种 | 413 | * 多种隐藏软件盘方法的其中一种 |
396 | * | 414 | * |
397 | * @param token | 415 | * @param token |
398 | */ | 416 | */ |
399 | private void hideSoftInput(IBinder token) { | 417 | private void hideSoftInput(IBinder token) { |
400 | LogUtil.i(TAG, "隐藏键盘"); | 418 | LogUtil.i(TAG, "隐藏键盘"); |
401 | if (token != null) { | 419 | if (token != null) { |
402 | InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | 420 | InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
403 | im.hideSoftInputFromWindow(token, | 421 | im.hideSoftInputFromWindow(token, |
404 | InputMethodManager.HIDE_NOT_ALWAYS); | 422 | InputMethodManager.HIDE_NOT_ALWAYS); |
405 | } | 423 | } |
406 | } | 424 | } |
407 | 425 | ||
408 | //************************* 用于隐藏键盘 end***************************************// | 426 | //************************* 用于隐藏键盘 end***************************************// |
409 | 427 | ||
410 | 428 | ||
411 | } | 429 | } |
412 | 430 |
libs/common/src/main/java/com/prws/common/bean/Record.java
File was created | 1 | package com.prws.common.bean; | |
2 | |||
3 | import com.google.gson.annotations.SerializedName; | ||
4 | |||
5 | import java.util.Date; | ||
6 | import java.util.List; | ||
7 | |||
8 | public class Record { | ||
9 | |||
10 | @SerializedName("subject") | ||
11 | private String subject; | ||
12 | @SerializedName("sid") | ||
13 | private String sid; | ||
14 | @SerializedName("degree") | ||
15 | private Double degree; | ||
16 | @SerializedName("cate") | ||
17 | private Integer cate; | ||
18 | @SerializedName("cateName") | ||
19 | private String cateName; | ||
20 | @SerializedName("label") | ||
21 | private String label; | ||
22 | @SerializedName("content") | ||
23 | private String content; | ||
24 | @SerializedName("options") | ||
25 | private String options; | ||
26 | @SerializedName("optionsList") | ||
27 | private List<String> optionsList; | ||
28 | @SerializedName("points") | ||
29 | private String points; | ||
30 | @SerializedName("pointsList") | ||
31 | private List<KeyValue> pointsList; | ||
32 | @SerializedName("topics") | ||
33 | private String topics; | ||
34 | @SerializedName("topicsList") | ||
35 | private List<KeyValue> topicsList; | ||
36 | @SerializedName("analyse") | ||
37 | private String analyse; | ||
38 | @SerializedName("method") | ||
39 | private String method; | ||
40 | @SerializedName("discuss") | ||
41 | private String discuss; | ||
42 | @SerializedName("answers") | ||
43 | private String answers; | ||
44 | @SerializedName("answersList") | ||
45 | private List<String> answersList; | ||
46 | @SerializedName("displayAnswer") | ||
47 | private String displayAnswer; | ||
48 | @SerializedName("askId") | ||
49 | private Integer askId; | ||
50 | @SerializedName("stuId") | ||
51 | private String stuId; | ||
52 | @SerializedName("stuName") | ||
53 | private String stuName; | ||
54 | @SerializedName("photo") | ||
55 | private String photo; | ||
56 | @SerializedName("questionUrl") | ||
57 | private String questionUrl; | ||
58 | @SerializedName("askTime") | ||
59 | private Date askTime; | ||
60 | private int gender; | ||
61 | |||
62 | public static class KeyValue { | ||
63 | @SerializedName("Key") | ||
64 | private String key; | ||
65 | @SerializedName("Value") | ||
66 | private String value; | ||
67 | |||
68 | public void setKey(String key) { | ||
69 | this.key = key; | ||
70 | } | ||
71 | |||
72 | public void setValue(String value) { | ||
73 | this.value = value; | ||
74 | } | ||
75 | |||
76 | public String getKey() { | ||
77 | return key; | ||
78 | } | ||
79 | |||
80 | public String getValue() { | ||
81 | return value; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | public void setGender(int gender) { | ||
86 | this.gender = gender; | ||
87 | } | ||
88 | |||
89 | public int getGender() { | ||
90 | return gender; | ||
91 | } | ||
92 | |||
93 | public void setSubject(String subject) { | ||
94 | this.subject = subject; | ||
95 | } | ||
96 | |||
97 | public void setSid(String sid) { | ||
98 | this.sid = sid; | ||
99 | } | ||
100 | |||
101 | public void setDegree(Double degree) { | ||
102 | this.degree = degree; | ||
103 | } | ||
104 | |||
105 | public void setCate(Integer cate) { | ||
106 | this.cate = cate; | ||
107 | } | ||
108 | |||
109 | public void setCateName(String cateName) { | ||
110 | this.cateName = cateName; | ||
111 | } | ||
112 | |||
113 | public void setLabel(String label) { | ||
114 | this.label = label; | ||
115 | } | ||
116 | |||
117 | public void setContent(String content) { | ||
118 | this.content = content; | ||
119 | } | ||
120 | |||
121 | public void setOptions(String options) { | ||
122 | this.options = options; | ||
123 | } | ||
124 | |||
125 | public void setOptionsList(List<String> optionsList) { | ||
126 | this.optionsList = optionsList; | ||
127 | } | ||
128 | |||
129 | public void setPoints(String points) { | ||
130 | this.points = points; | ||
131 | } | ||
132 | |||
133 | public void setPointsList(List<KeyValue> pointsList) { | ||
134 | this.pointsList = pointsList; | ||
135 | } | ||
136 | |||
137 | public void setTopics(String topics) { | ||
138 | this.topics = topics; | ||
139 | } | ||
140 | |||
141 | public void setTopicsList(List<KeyValue> topicsList) { | ||
142 | this.topicsList = topicsList; | ||
143 | } | ||
144 | |||
145 | public void setAnalyse(String analyse) { | ||
146 | this.analyse = analyse; | ||
147 | } | ||
148 | |||
149 | public void setMethod(String method) { | ||
150 | this.method = method; | ||
151 | } | ||
152 | |||
153 | public void setDiscuss(String discuss) { | ||
154 | this.discuss = discuss; | ||
155 | } | ||
156 | |||
157 | public void setAnswers(String answers) { | ||
158 | this.answers = answers; | ||
159 | } | ||
160 | |||
161 | public void setAnswersList(List<String> answersList) { | ||
162 | this.answersList = answersList; | ||
163 | } | ||
164 | |||
165 | public void setDisplayAnswer(String displayAnswer) { | ||
166 | this.displayAnswer = displayAnswer; | ||
167 | } | ||
168 | |||
169 | public void setAskId(Integer askId) { | ||
170 | this.askId = askId; | ||
171 | } | ||
172 | |||
173 | public void setStuId(String stuId) { | ||
174 | this.stuId = stuId; | ||
175 | } | ||
176 | |||
177 | public void setStuName(String stuName) { | ||
178 | this.stuName = stuName; | ||
179 | } | ||
180 | |||
181 | public void setPhoto(String photo) { | ||
182 | this.photo = photo; | ||
183 | } | ||
184 | |||
185 | public void setQuestionUrl(String questionUrl) { | ||
186 | this.questionUrl = questionUrl; | ||
187 | } | ||
188 | |||
189 | public void setAskTime(Date askTime) { | ||
190 | this.askTime = askTime; | ||
191 | } | ||
192 | |||
193 | public String getSubject() { | ||
194 | return subject; | ||
195 | } | ||
196 | |||
197 | public String getSid() { | ||
198 | return sid; | ||
199 | } | ||
200 | |||
201 | public Double getDegree() { | ||
202 | return degree; | ||
203 | } | ||
204 | |||
205 | public Integer getCate() { | ||
206 | return cate; | ||
207 | } | ||
208 | |||
209 | public String getCateName() { | ||
210 | return cateName; | ||
211 | } | ||
212 | |||
213 | public String getLabel() { | ||
214 | return label; | ||
215 | } | ||
216 | |||
217 | public String getContent() { | ||
218 | return content; | ||
219 | } | ||
220 | |||
221 | public String getOptions() { | ||
222 | return options; | ||
223 | } | ||
224 | |||
225 | public List<String> getOptionsList() { | ||
226 | return optionsList; | ||
227 | } | ||
228 | |||
229 | public String getPoints() { | ||
230 | return points; | ||
231 | } | ||
232 | |||
233 | public List<KeyValue> getPointsList() { | ||
234 | return pointsList; | ||
235 | } | ||
236 | |||
237 | public String getTopics() { | ||
238 | return topics; | ||
239 | } | ||
240 | |||
241 | public List<KeyValue> getTopicsList() { | ||
242 | return topicsList; | ||
243 | } | ||
244 | |||
245 | public String getAnalyse() { | ||
246 | return analyse; | ||
247 | } | ||
248 | |||
249 | public String getMethod() { | ||
250 | return method; | ||
251 | } | ||
252 | |||
253 | public String getDiscuss() { | ||
254 | return discuss; | ||
255 | } | ||
256 | |||
257 | public String getAnswers() { | ||
258 | return answers; | ||
259 | } | ||
260 | |||
261 | public List<String> getAnswersList() { | ||
262 | return answersList; | ||
263 | } | ||
264 | |||
265 | public String getDisplayAnswer() { | ||
266 | return displayAnswer; | ||
267 | } | ||
268 | |||
269 | public Integer getAskId() { | ||
270 | return askId; | ||
271 | } | ||
272 | |||
273 | public String getStuId() { | ||
274 | return stuId; | ||
275 | } | ||
276 | |||
277 | public String getStuName() { | ||
278 | return stuName; | ||
279 | } | ||
280 | |||
281 | public String getPhoto() { | ||
282 | return photo; | ||
283 | } | ||
284 | |||
285 | public String getQuestionUrl() { | ||
286 | return questionUrl; | ||
287 | } | ||
288 | |||
289 | public Date getAskTime() { | ||
290 | return askTime; | ||
291 | } | ||
292 | } | ||
293 |
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; | 7 | import com.prws.common.bean.BaseEntity; |
8 | import com.prws.common.bean.CutPicBean; | 8 | import com.prws.common.bean.CutPicBean; |
9 | import com.prws.common.bean.GradeAndSubject; | 9 | import com.prws.common.bean.GradeAndSubject; |
10 | import com.prws.common.bean.PageInfo; | 10 | import com.prws.common.bean.PageInfo; |
11 | import com.prws.common.bean.ResponseResult; | 11 | import com.prws.common.bean.ResponseResult; |
12 | import com.prws.common.bean.ScheduleBean; | 12 | import com.prws.common.bean.ScheduleBean; |
13 | import com.prws.common.bean.Teacher; | 13 | import com.prws.common.bean.Teacher; |
14 | import com.prws.common.bean.TopicBean; | 14 | import com.prws.common.bean.TopicBean; |
15 | import com.prws.common.bean.UpdateBean; | 15 | import com.prws.common.bean.UpdateBean; |
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.android.schedulers.AndroidSchedulers; | 25 | import io.reactivex.android.schedulers.AndroidSchedulers; |
26 | import io.reactivex.schedulers.Schedulers; | 26 | import io.reactivex.schedulers.Schedulers; |
27 | import okhttp3.MediaType; | 27 | import okhttp3.MediaType; |
28 | import okhttp3.MultipartBody; | 28 | import okhttp3.MultipartBody; |
29 | import okhttp3.RequestBody; | 29 | import okhttp3.RequestBody; |
30 | import okhttp3.ResponseBody; | 30 | import okhttp3.ResponseBody; |
31 | import retrofit2.Call; | 31 | import retrofit2.Call; |
32 | import retrofit2.Callback; | 32 | import retrofit2.Callback; |
33 | import retrofit2.http.Body; | 33 | import retrofit2.http.Body; |
34 | import retrofit2.http.DELETE; | 34 | import retrofit2.http.DELETE; |
35 | import retrofit2.http.FieldMap; | 35 | import retrofit2.http.FieldMap; |
36 | import retrofit2.http.FormUrlEncoded; | 36 | import retrofit2.http.FormUrlEncoded; |
37 | import retrofit2.http.GET; | 37 | import retrofit2.http.GET; |
38 | import retrofit2.http.Header; | 38 | import retrofit2.http.Header; |
39 | import retrofit2.http.HeaderMap; | 39 | import retrofit2.http.HeaderMap; |
40 | import retrofit2.http.Headers; | 40 | import retrofit2.http.Headers; |
41 | import retrofit2.http.Multipart; | 41 | import retrofit2.http.Multipart; |
42 | import retrofit2.http.POST; | 42 | import retrofit2.http.POST; |
43 | import retrofit2.http.PUT; | 43 | import retrofit2.http.PUT; |
44 | import retrofit2.http.Part; | 44 | import retrofit2.http.Part; |
45 | import retrofit2.http.PartMap; | 45 | import retrofit2.http.PartMap; |
46 | import retrofit2.http.Path; | 46 | import retrofit2.http.Path; |
47 | import retrofit2.http.Query; | 47 | import retrofit2.http.Query; |
48 | import retrofit2.http.QueryMap; | 48 | import retrofit2.http.QueryMap; |
49 | import retrofit2.http.Streaming; | 49 | import retrofit2.http.Streaming; |
50 | import retrofit2.http.Url; | 50 | import retrofit2.http.Url; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * 类名称:NetWorks | 53 | * 类名称:NetWorks |
54 | * 创建人: | 54 | * 创建人: |
55 | * <p> | 55 | * <p> |
56 | * 类描述:网络请求的操作类 | 56 | * 类描述:网络请求的操作类 |
57 | */ | 57 | */ |
58 | public class NetWorks extends RetrofitUtils { | 58 | public class NetWorks extends RetrofitUtils { |
59 | //服务器路径 | 59 | //服务器路径 |
60 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); | 60 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); |
61 | 61 | ||
62 | //设缓存有效期为1天 | 62 | //设缓存有效期为1天 |
63 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | 63 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; |
64 | //查询缓存的Cache-Control设置,使用缓存 | 64 | //查询缓存的Cache-Control设置,使用缓存 |
65 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | 65 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; |
66 | //查询网络的Cache-Control设置。不使用缓存 | 66 | //查询网络的Cache-Control设置。不使用缓存 |
67 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | 67 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
68 | 68 | ||
69 | 69 | ||
70 | private interface NetService { | 70 | private interface NetService { |
71 | 71 | ||
72 | 72 | ||
73 | @GET("/api/v1/user/logout") | 73 | @GET("/api/v1/user/logout") |
74 | Observable<ResponseBody> logout(); | 74 | Observable<ResponseBody> logout(); |
75 | 75 | ||
76 | @Multipart | 76 | @Multipart |
77 | @POST("/api/v1/user/upLoadAvatar") | 77 | @POST("/api/v1/user/upLoadAvatar") |
78 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); | 78 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); |
79 | 79 | ||
80 | 80 | ||
81 | @Headers("Content-Type: application/json") | 81 | @Headers("Content-Type: application/json") |
82 | @POST("/api/v1/user/editUser") | 82 | @POST("/api/v1/user/editUser") |
83 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); | 83 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); |
84 | 84 | ||
85 | @Headers("Content-Type: application/json") | 85 | @Headers("Content-Type: application/json") |
86 | @POST("/api/v1/user/changePassword") | 86 | @POST("/api/v1/user/changePassword") |
87 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); | 87 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); |
88 | 88 | ||
89 | 89 | ||
90 | @GET("/api/v1/user/searchById") | 90 | @GET("/api/v1/user/searchById") |
91 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); | 91 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); |
92 | 92 | ||
93 | 93 | ||
94 | @Headers("Content-Type: application/json") | 94 | @Headers("Content-Type: application/json") |
95 | @POST("/api/v1/auth/login") | 95 | @POST("/api/v1/auth/login") |
96 | Observable<ResponseBody> login(@Body RequestBody body); | 96 | Observable<ResponseBody> login(@Body RequestBody body); |
97 | 97 | ||
98 | @GET("/api/v1/resource/listGradeAndSubject") | 98 | @GET("/api/v1/resource/listGradeAndSubject") |
99 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); | 99 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); |
100 | 100 | ||
101 | 101 | ||
102 | @GET("/api/v1/manager/generalQrCode") | 102 | @GET("/api/v1/manager/generalQrCode") |
103 | Observable<ResponseBody> generalQrCode(); | 103 | Observable<ResponseBody> generalQrCode(); |
104 | 104 | ||
105 | @GET("/api/v1/parent/scanAndLogin?") | 105 | @GET("/api/v1/parent/scanAndLogin?") |
106 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code); | 106 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code); |
107 | 107 | ||
108 | @GET("/api/v1/parent/getChildrenList") | 108 | @GET("/api/v1/parent/getChildrenList") |
109 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); | 109 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); |
110 | 110 | ||
111 | 111 | ||
112 | @Headers("Content-Type: application/json") | 112 | @Headers("Content-Type: application/json") |
113 | @POST("/api/v1/parent/registerParent") | 113 | @POST("/api/v1/parent/registerParent") |
114 | Observable<ResponseBody> registerParent(@Body RequestBody body); | 114 | Observable<ResponseBody> registerParent(@Body RequestBody body); |
115 | 115 | ||
116 | 116 | ||
117 | @GET("/api/v1/parent/listChildren") | 117 | @GET("/api/v1/parent/listChildren") |
118 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); | 118 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); |
119 | 119 | ||
120 | 120 | ||
121 | @Headers("Content-Type: application/json") | 121 | @Headers("Content-Type: application/json") |
122 | @POST("/api/v1/parent/registerStudent") | 122 | @POST("/api/v1/parent/registerStudent") |
123 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); | 123 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); |
124 | 124 | ||
125 | @Headers("Content-Type: application/json") | 125 | @Headers("Content-Type: application/json") |
126 | @POST("/api/v1/parent/bindTeacher") | 126 | @POST("/api/v1/parent/bindTeacher") |
127 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); | 127 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); |
128 | 128 | ||
129 | @Multipart | 129 | @Multipart |
130 | @POST("/api/v1/user/upLoadAvatar") | 130 | @POST("/api/v1/user/upLoadAvatar") |
131 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); | 131 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); |
132 | 132 | ||
133 | 133 | ||
134 | @Multipart | 134 | @Multipart |
135 | @POST("/api/v1/student/editStudentAvatar") | 135 | @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); | 136 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
137 | 137 | ||
138 | @Headers("Content-Type: application/json") | 138 | @Headers("Content-Type: application/json") |
139 | @POST("/api/v1/parent/editChild") | 139 | @POST("/api/v1/parent/editChild") |
140 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); | 140 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); |
141 | 141 | ||
142 | @GET("/api/v1/student/getStudyPlanForThisWeek") | 142 | @GET("/api/v1/student/getStudyPlanForThisWeek") |
143 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); | 143 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); |
144 | 144 | ||
145 | @GET("api/v1/parent/searchTeacher") | 145 | @GET("api/v1/parent/searchTeacher") |
146 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); | 146 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); |
147 | 147 | ||
148 | @POST("api/v1/question/listErrorBook") | 148 | @POST("api/v1/question/listErrorBook") |
149 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); | 149 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); |
150 | 150 | ||
151 | @POST | 151 | @POST |
152 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); | 152 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); |
153 | 153 | ||
154 | @POST | 154 | @POST |
155 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); | 155 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); |
156 | 156 | ||
157 | @POST | 157 | @POST |
158 | Observable<JsonObject> getBaiduToken(@Url String url); | 158 | Observable<JsonObject> getBaiduToken(@Url String url); |
159 | 159 | ||
160 | @Multipart | 160 | @Multipart |
161 | @POST("api/v1/pad/addErrorBook") | 161 | @POST("api/v1/pad/addErrorBook") |
162 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 162 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
163 | 163 | ||
164 | @POST("api/v1/pad/deleteStuErrorBook") | 164 | @POST("api/v1/pad/deleteStuErrorBook") |
165 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); | 165 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); |
166 | 166 | ||
167 | @PUT("api/v1/pad/updateStuErrorBookInfo") | 167 | @PUT("api/v1/pad/updateStuErrorBookInfo") |
168 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); | 168 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); |
169 | 169 | ||
170 | @POST("api/v1/question/editErrorBook") | 170 | @POST("api/v1/question/editErrorBook") |
171 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); | 171 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); |
172 | 172 | ||
173 | @GET("api/v1/resource/checkUpdate") | 173 | @GET("api/v1/resource/checkUpdate") |
174 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); | 174 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); |
175 | 175 | ||
176 | @GET("api/v1/teacher/getStudentList") | ||
177 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); | ||
178 | |||
179 | @GET("api/v1/answer/listRecordForTeacher") | ||
180 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); | ||
176 | } | 181 | } |
177 | 182 | ||
178 | 183 | ||
179 | public static String getHeader() { | 184 | public static String getHeader() { |
180 | return (String) SharedPreferencesUtil.getData("token", ""); | 185 | return (String) SharedPreferencesUtil.getData("token", ""); |
181 | } | 186 | } |
182 | 187 | ||
183 | public static String getBaiduToken() { | 188 | public static String getBaiduToken() { |
184 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); | 189 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); |
185 | } | 190 | } |
186 | 191 | ||
187 | 192 | ||
188 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { | 193 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { |
189 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); | 194 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); |
190 | } | 195 | } |
191 | 196 | ||
192 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { | 197 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { |
193 | File file = new File(path); | 198 | File file = new File(path); |
194 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 199 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
195 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 200 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
196 | Map<String, Object> map = new HashMap<>(); | 201 | Map<String, Object> map = new HashMap<>(); |
197 | map.put("condition", param); | 202 | map.put("condition", param); |
198 | setSubscribe(service_url.addError(part, map), observer); | 203 | setSubscribe(service_url.addError(part, map), observer); |
199 | } | 204 | } |
200 | 205 | ||
201 | 206 | ||
202 | public static void cut(String base64, Observer<CutPicBean> observer) { | 207 | public static void cut(String base64, Observer<CutPicBean> observer) { |
203 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 208 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
204 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); | 209 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); |
205 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); | 210 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); |
206 | } | 211 | } |
207 | 212 | ||
208 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | 213 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { |
209 | setSubscribe(service_url.editError(getHeader(), map), observer); | 214 | setSubscribe(service_url.editError(getHeader(), map), observer); |
210 | } | 215 | } |
211 | 216 | ||
212 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { | 217 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { |
213 | setSubscribe(service_url.updateError(getHeader(), map), observer); | 218 | setSubscribe(service_url.updateError(getHeader(), map), observer); |
214 | } | 219 | } |
215 | 220 | ||
216 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { | 221 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { |
217 | setSubscribe(service_url.deleteError(getHeader(), map), observer); | 222 | setSubscribe(service_url.deleteError(getHeader(), map), observer); |
218 | } | 223 | } |
219 | 224 | ||
220 | public static void getBaiduToken(Observer<JsonObject> observer) { | 225 | public static void getBaiduToken(Observer<JsonObject> observer) { |
221 | 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); | 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); |
222 | } | 227 | } |
223 | 228 | ||
224 | public static void removeWriting(String base64, Observer<JsonObject> observer) { | 229 | public static void removeWriting(String base64, Observer<JsonObject> observer) { |
225 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 230 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
226 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | 231 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); |
227 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); | 232 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); |
228 | } | 233 | } |
229 | 234 | ||
230 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | 235 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { |
231 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); | 236 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); |
232 | } | 237 | } |
233 | 238 | ||
234 | public static void logout(Observer<ResponseBody> observer) { | 239 | public static void logout(Observer<ResponseBody> observer) { |
235 | setSubscribe(service_url.logout(), observer); | 240 | setSubscribe(service_url.logout(), observer); |
236 | } | 241 | } |
237 | 242 | ||
238 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { | 243 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { |
239 | setSubscribe(service_url.editStudent(getHeader(), body), observable); | 244 | setSubscribe(service_url.editStudent(getHeader(), body), observable); |
240 | } | 245 | } |
241 | 246 | ||
242 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { | 247 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { |
243 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); | 248 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); |
244 | } | 249 | } |
245 | 250 | ||
246 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { | 251 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { |
247 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 252 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
248 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 253 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
249 | Map<String, Object> map = new HashMap<>(); | 254 | Map<String, Object> map = new HashMap<>(); |
250 | map.put("stuId", stuId); | 255 | map.put("stuId", stuId); |
251 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); | 256 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); |
252 | } | 257 | } |
253 | 258 | ||
254 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { | 259 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { |
255 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 260 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
256 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 261 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
257 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); | 262 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); |
258 | } | 263 | } |
259 | 264 | ||
260 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | 265 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { |
261 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); | 266 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); |
262 | } | 267 | } |
263 | 268 | ||
264 | 269 | ||
265 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { | 270 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { |
266 | setSubscribe(service_url.editUser(getHeader(), body), observer); | 271 | setSubscribe(service_url.editUser(getHeader(), body), observer); |
267 | } | 272 | } |
268 | 273 | ||
269 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { | 274 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { |
270 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | 275 | setSubscribe(service_url.changePassword(getHeader(), body), observer); |
271 | } | 276 | } |
272 | 277 | ||
273 | 278 | ||
274 | public static void searchById(String userId, Observer<ResponseBody> observer) { | 279 | public static void searchById(String userId, Observer<ResponseBody> observer) { |
275 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | 280 | setSubscribe(service_url.searchById(getHeader(), userId), observer); |
276 | } | 281 | } |
277 | 282 | ||
278 | 283 | ||
279 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | 284 | public static void login(RequestBody body, Observer<ResponseBody> observer) { |
280 | setSubscribe(service_url.login(body), observer); | 285 | setSubscribe(service_url.login(body), observer); |
281 | } | 286 | } |
282 | 287 | ||
283 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { | 288 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { |
284 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | 289 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); |
285 | } | 290 | } |
286 | 291 | ||
287 | 292 | ||
288 | public static void scanAndLogin(String code, Observer<ResponseBody> observer) { | 293 | public static void scanAndLogin(String code, Observer<ResponseBody> observer) { |
289 | setSubscribe(service_url.scanAndLogin(getHeader(), code), observer); | 294 | setSubscribe(service_url.scanAndLogin(getHeader(), code), observer); |
290 | } | 295 | } |
291 | 296 | ||
292 | public static void getChildrenList(Observer<ResponseBody> observer) { | 297 | public static void getChildrenList(Observer<ResponseBody> observer) { |
293 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | 298 | setSubscribe(service_url.getChildrenList(getHeader()), observer); |
294 | } | 299 | } |
295 | 300 | ||
296 | 301 | ||
297 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { | 302 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { |
298 | setSubscribe(service_url.registerParent(body), observer); | 303 | setSubscribe(service_url.registerParent(body), observer); |
299 | } | 304 | } |
300 | 305 | ||
301 | 306 | ||
302 | public static void listChildren(Observer<ResponseBody> observer) { | 307 | public static void listChildren(Observer<ResponseBody> observer) { |
303 | setSubscribe(service_url.listChildren(getHeader()), observer); | 308 | setSubscribe(service_url.listChildren(getHeader()), observer); |
304 | } | 309 | } |
305 | 310 | ||
311 | public static void listStudent(Observer<ResponseBody> observer) { | ||
312 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | ||
313 | } | ||
314 | |||
315 | public static void listRecord(Observer<ResponseBody> observer) { | ||
316 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | ||
317 | } | ||
318 | |||
306 | 319 | ||
307 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { | 320 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { |
308 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | 321 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); |
309 | } | 322 | } |
310 | 323 | ||
311 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { | 324 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { |
312 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | 325 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); |
313 | } | 326 | } |
314 | 327 | ||
315 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { | 328 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { |
316 | setSubscribe(service_url.getError(getHeader(), map), observer); | 329 | setSubscribe(service_url.getError(getHeader(), map), observer); |
317 | } | 330 | } |
318 | 331 | ||
319 | 332 | ||
320 | public static RequestBody getMapRequestBody(Map map) { | 333 | public static RequestBody getMapRequestBody(Map map) { |
321 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | 334 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); |
322 | } | 335 | } |
323 | 336 | ||
324 | 337 | ||
325 | public static RequestBody getArrayRequestBody(List list) { | 338 | public static RequestBody getArrayRequestBody(List list) { |
326 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | 339 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); |
327 | } | 340 | } |
328 | 341 | ||
329 | public static RequestBody getFileRequestBody(File file) { | 342 | public static RequestBody getFileRequestBody(File file) { |
330 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | 343 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); |
331 | } | 344 | } |
332 | 345 | ||
333 | public static RequestBody getFileRequestBody(byte[] bytes) { | 346 | public static RequestBody getFileRequestBody(byte[] bytes) { |
334 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | 347 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); |
335 | } | 348 | } |
336 | 349 | ||
337 | public static RequestBody getObjectRequestBody(Object obj) { | 350 | public static RequestBody getObjectRequestBody(Object obj) { |
338 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | 351 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); |
339 | } | 352 | } |
340 | 353 | ||
341 | public static RequestBody getStringRequestBody(String str) { | 354 | public static RequestBody getStringRequestBody(String str) { |
342 | return RequestBody.create(MediaType.parse("text/plain"), str); | 355 | return RequestBody.create(MediaType.parse("text/plain"), str); |
343 | } | 356 | } |
344 | 357 | ||
345 | 358 | ||
346 | /** | 359 | /** |
347 | * 插入观察者 | 360 | * 插入观察者 |
348 | * | 361 | * |
349 | * @param observable | 362 | * @param observable |
350 | * @param observer | 363 | * @param observer |
351 | * @param <T> | 364 | * @param <T> |
352 | */ | 365 | */ |
353 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | 366 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { |
354 | observable.subscribeOn(Schedulers.io())//子线程访问网络 | 367 | observable.subscribeOn(Schedulers.io())//子线程访问网络 |
355 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 | 368 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 |
356 | .subscribe(observer); | 369 | .subscribe(observer); |
357 | } | 370 | } |
358 | 371 | ||
359 | } | 372 | } |
360 | 373 |