Commit 7f42ea4db659d7a0993cfb0f0be92e248084af8d
1 parent
a516c951d2
Exists in
master
题目详情, 选择错题
Showing
15 changed files
with
492 additions
and
3 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 | 30 | <uses-permission |
31 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" | 31 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" |
32 | tools:ignore="ScopedStorage" /> | 32 | tools:ignore="ScopedStorage" /> |
33 | 33 | ||
34 | <application | 34 | <application |
35 | android:name=".App" | 35 | android:name=".App" |
36 | android:allowBackup="true" | 36 | android:allowBackup="true" |
37 | android:icon="@mipmap/icon" | 37 | android:icon="@mipmap/icon" |
38 | android:label="@string/app_name" | 38 | android:label="@string/app_name" |
39 | android:networkSecurityConfig="@xml/network_security_config" | 39 | android:networkSecurityConfig="@xml/network_security_config" |
40 | android:supportsRtl="true" | 40 | android:supportsRtl="true" |
41 | android:theme="@style/Theme.AppCompat.Light.NoActionBar"> | 41 | android:theme="@style/Theme.AppCompat.Light.NoActionBar"> |
42 | <activity | 42 | <activity |
43 | android:name=".LoginActivity" | 43 | android:name=".LoginActivity" |
44 | android:exported="true" | 44 | android:exported="true" |
45 | android:screenOrientation="portrait" | 45 | android:screenOrientation="portrait" |
46 | android:theme="@style/ThemeSplash"> | 46 | android:theme="@style/ThemeSplash"> |
47 | <intent-filter> | 47 | <intent-filter> |
48 | <action android:name="android.intent.action.MAIN" /> | 48 | <action android:name="android.intent.action.MAIN" /> |
49 | <category android:name="android.intent.category.LAUNCHER" /> | 49 | <category android:name="android.intent.category.LAUNCHER" /> |
50 | </intent-filter> | 50 | </intent-filter> |
51 | </activity> | 51 | </activity> |
52 | <activity | 52 | <activity |
53 | android:name=".MainActivity" | 53 | android:name=".MainActivity" |
54 | android:launchMode="singleTask" | 54 | android:launchMode="singleTask" |
55 | android:screenOrientation="portrait" | 55 | android:screenOrientation="portrait" |
56 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 56 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
57 | <activity | 57 | <activity |
58 | android:name=".RegisterActivity" | 58 | android:name=".RegisterActivity" |
59 | android:screenOrientation="portrait" | 59 | android:screenOrientation="portrait" |
60 | android:theme="@style/ThemeSplash" /> | 60 | android:theme="@style/ThemeSplash" /> |
61 | <activity | 61 | <activity |
62 | android:name=".UserActivity" | 62 | android:name=".UserActivity" |
63 | android:screenOrientation="portrait" | 63 | android:screenOrientation="portrait" |
64 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 64 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
65 | <activity | 65 | <activity |
66 | android:name=".YinsiActivity" | 66 | android:name=".YinsiActivity" |
67 | android:screenOrientation="portrait" | 67 | android:screenOrientation="portrait" |
68 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 68 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
69 | <activity | 69 | <activity |
70 | android:name=".QRActivity" | 70 | android:name=".QRActivity" |
71 | android:screenOrientation="portrait" | 71 | android:screenOrientation="portrait" |
72 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 72 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
73 | <activity | 73 | <activity |
74 | android:name=".AddStudentActivity" | 74 | android:name=".AddStudentActivity" |
75 | android:screenOrientation="portrait" | 75 | android:screenOrientation="portrait" |
76 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 76 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
77 | <activity | 77 | <activity |
78 | android:name=".NickActivity" | 78 | android:name=".NickActivity" |
79 | android:screenOrientation="portrait" | 79 | android:screenOrientation="portrait" |
80 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 80 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
81 | <activity | 81 | <activity |
82 | android:name=".SexActivity" | 82 | android:name=".SexActivity" |
83 | android:screenOrientation="portrait" | 83 | android:screenOrientation="portrait" |
84 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 84 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
85 | <activity | 85 | <activity |
86 | android:name=".NianActivity" | 86 | android:name=".NianActivity" |
87 | android:screenOrientation="portrait" | 87 | android:screenOrientation="portrait" |
88 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 88 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
89 | <activity | 89 | <activity |
90 | android:name=".ShenActivity" | 90 | android:name=".ShenActivity" |
91 | android:screenOrientation="portrait" | 91 | android:screenOrientation="portrait" |
92 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 92 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
93 | <activity | 93 | <activity |
94 | android:name=".UserAgreementActivity" | 94 | android:name=".UserAgreementActivity" |
95 | android:screenOrientation="portrait" | 95 | android:screenOrientation="portrait" |
96 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 96 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
97 | <activity | 97 | <activity |
98 | android:name=".AccountActivity" | 98 | android:name=".AccountActivity" |
99 | android:screenOrientation="portrait" | 99 | android:screenOrientation="portrait" |
100 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 100 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
101 | 101 | ||
102 | <activity | 102 | <activity |
103 | android:name=".ChangePwdActivity" | 103 | android:name=".ChangePwdActivity" |
104 | android:screenOrientation="portrait" | 104 | android:screenOrientation="portrait" |
105 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 105 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
106 | <activity | 106 | <activity |
107 | android:name=".EditStudentActivity" | 107 | android:name=".EditStudentActivity" |
108 | android:screenOrientation="portrait" | 108 | android:screenOrientation="portrait" |
109 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 109 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
110 | <activity | 110 | <activity |
111 | android:name=".ChooseActivity" | 111 | android:name=".ChooseActivity" |
112 | android:screenOrientation="portrait" | 112 | android:screenOrientation="portrait" |
113 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 113 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
114 | <activity | 114 | <activity |
115 | android:name=".AddTeacherActivity" | 115 | android:name=".AddTeacherActivity" |
116 | android:screenOrientation="portrait" | 116 | android:screenOrientation="portrait" |
117 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 117 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
118 | <activity | 118 | <activity |
119 | android:name=".ErrorBookActivity" | 119 | android:name=".ErrorBookActivity" |
120 | android:screenOrientation="portrait" | 120 | android:screenOrientation="portrait" |
121 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 121 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
122 | <activity | 122 | <activity |
123 | android:name=".ImageActivity" | 123 | android:name=".ImageActivity" |
124 | android:screenOrientation="portrait" | 124 | android:screenOrientation="portrait" |
125 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 125 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
126 | <activity | 126 | <activity |
127 | android:name=".ImageEditActivity" | 127 | android:name=".ImageEditActivity" |
128 | android:screenOrientation="portrait" | 128 | android:screenOrientation="portrait" |
129 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 129 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
130 | <activity | 130 | <activity |
131 | android:name=".ImageSelectActivity" | 131 | android:name=".ImageSelectActivity" |
132 | android:screenOrientation="portrait" | 132 | android:screenOrientation="portrait" |
133 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 133 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
134 | <activity | 134 | <activity |
135 | android:name=".AddSuccessActivity" | 135 | android:name=".AddSuccessActivity" |
136 | android:screenOrientation="portrait" | 136 | android:screenOrientation="portrait" |
137 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 137 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
138 | <activity | 138 | <activity |
139 | android:name=".ErrorListActivity" | 139 | android:name=".ErrorListActivity" |
140 | android:screenOrientation="portrait" | 140 | android:screenOrientation="portrait" |
141 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 141 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
142 | <activity | 142 | <activity |
143 | android:name=".ErrorDetailActivity" | 143 | android:name=".ErrorDetailActivity" |
144 | android:screenOrientation="portrait" | 144 | android:screenOrientation="portrait" |
145 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 145 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
146 | <activity | 146 | <activity |
147 | android:name=".TeacherChooseActivity" | 147 | android:name=".TeacherChooseActivity" |
148 | android:screenOrientation="portrait" | 148 | android:screenOrientation="portrait" |
149 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 149 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
150 | <activity | 150 | <activity |
151 | android:name=".TeacherMainActivity" | 151 | android:name=".TeacherMainActivity" |
152 | android:screenOrientation="portrait" | 152 | android:screenOrientation="portrait" |
153 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | 153 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
154 | <activity android:name=".StuHomeworkActivity" /> | 154 | <activity android:name=".StuHomeworkActivity" /> |
155 | <activity android:name=".HomeworkDetailActivity" /> | ||
156 | <activity android:name=".HomeworkSelectActivity" /> | ||
155 | 157 | ||
156 | <provider | 158 | <provider |
157 | android:name="androidx.core.content.FileProvider" | 159 | android:name="androidx.core.content.FileProvider" |
158 | android:authorities="com.hjx.parent.fileprovider" | 160 | android:authorities="com.hjx.parent.fileprovider" |
159 | android:exported="false" | 161 | android:exported="false" |
160 | android:grantUriPermissions="true" | 162 | android:grantUriPermissions="true" |
161 | tools:replace="android:authorities"> | 163 | tools:replace="android:authorities"> |
162 | <meta-data | 164 | <meta-data |
163 | android:name="android.support.FILE_PROVIDER_PATHS" | 165 | android:name="android.support.FILE_PROVIDER_PATHS" |
164 | android:resource="@xml/file_provider_paths" | 166 | android:resource="@xml/file_provider_paths" |
165 | tools:replace="android:resource" /> | 167 | tools:replace="android:resource" /> |
166 | </provider> | 168 | </provider> |
167 | </application> | 169 | </application> |
168 | 170 | ||
169 | </manifest> | 171 | </manifest> |
app/src/main/java/com/hjx/parent/HomeworkDetailActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.annotation.SuppressLint; | ||
4 | import android.content.Intent; | ||
5 | import android.os.Bundle; | ||
6 | import android.widget.ImageView; | ||
7 | import android.widget.TextView; | ||
8 | |||
9 | import androidx.annotation.NonNull; | ||
10 | |||
11 | import com.bumptech.glide.Glide; | ||
12 | import com.chad.library.adapter.base.BaseQuickAdapter; | ||
13 | import com.chad.library.adapter.base.BaseViewHolder; | ||
14 | import com.google.gson.Gson; | ||
15 | import com.hjx.parent.databinding.ActivityHomeworkDetailBinding; | ||
16 | import com.hjx.parent.rx.BaseRxActivity; | ||
17 | import com.prws.common.bean.ResponseResult; | ||
18 | import com.prws.common.bean.homework.HomeWork; | ||
19 | import com.prws.common.bean.homework.HomeworkList; | ||
20 | import com.prws.common.net.NetWorks; | ||
21 | |||
22 | import java.util.ArrayList; | ||
23 | |||
24 | public class HomeworkDetailActivity extends BaseRxActivity<ActivityHomeworkDetailBinding> { | ||
25 | |||
26 | private HomeworkList mData; | ||
27 | |||
28 | private Adapter mAdapter = new Adapter(); | ||
29 | |||
30 | @Override | ||
31 | public void initView(Bundle savedInstanceState) { | ||
32 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | ||
33 | String json = getIntent().getStringExtra("data"); | ||
34 | mData = new Gson().fromJson(json, HomeworkList.class); | ||
35 | binding.tvTitle.setText(mData.getName()); | ||
36 | |||
37 | binding.recyclerView.setAdapter(mAdapter); | ||
38 | getDetail(); | ||
39 | |||
40 | binding.btnFeedback.setOnClickListener(v -> { | ||
41 | Intent intent = new Intent(this, HomeworkSelectActivity.class); | ||
42 | intent.putExtra("data", mData); | ||
43 | intent.putExtra("list", new ArrayList<>(mAdapter.getData())); | ||
44 | startActivity(intent); | ||
45 | }); | ||
46 | } | ||
47 | |||
48 | @SuppressLint("CheckResult") | ||
49 | private void getDetail() { | ||
50 | NetWorks.service_url.getHomeworkDetail(NetWorks.getHeader(), mData.getId()) | ||
51 | .compose(transformSingle()) | ||
52 | .map(ResponseResult::getData) | ||
53 | .subscribe((list, th) -> { | ||
54 | if (th != null) th.printStackTrace(); | ||
55 | mAdapter.setNewData(list); | ||
56 | }); | ||
57 | } | ||
58 | |||
59 | @Override | ||
60 | protected ActivityHomeworkDetailBinding getViewBinding() { | ||
61 | return ActivityHomeworkDetailBinding.inflate(getLayoutInflater()); | ||
62 | } | ||
63 | |||
64 | static class Adapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | ||
65 | |||
66 | public Adapter() { | ||
67 | super(R.layout.item_homework_detail); | ||
68 | } | ||
69 | |||
70 | @SuppressLint("SetTextI18n") | ||
71 | @Override | ||
72 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | ||
73 | TextView tvNumber = holder.getView(R.id.tvNumber); | ||
74 | ImageView imageView = holder.getView(R.id.ivTopic); | ||
75 | int number = getData().indexOf(homeWork) + 1; | ||
76 | tvNumber.setText("第" + number + "题"); | ||
77 | Glide.with(mContext).load(homeWork.url).into(imageView); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 |
app/src/main/java/com/hjx/parent/HomeworkSelectActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.annotation.SuppressLint; | ||
4 | import android.content.res.ColorStateList; | ||
5 | import android.os.Bundle; | ||
6 | import android.view.View; | ||
7 | import android.widget.CheckBox; | ||
8 | import android.widget.ImageView; | ||
9 | import android.widget.TextView; | ||
10 | |||
11 | import androidx.annotation.NonNull; | ||
12 | import androidx.lifecycle.MutableLiveData; | ||
13 | |||
14 | import com.bumptech.glide.Glide; | ||
15 | import com.chad.library.adapter.base.BaseQuickAdapter; | ||
16 | import com.chad.library.adapter.base.BaseViewHolder; | ||
17 | import com.hjx.parent.databinding.ActivityHomeworkSelectBinding; | ||
18 | import com.hjx.parent.function.Function1; | ||
19 | import com.hjx.parent.rx.BaseRxActivity; | ||
20 | import com.prws.common.bean.homework.HomeWork; | ||
21 | import com.prws.common.bean.homework.HomeworkList; | ||
22 | |||
23 | import java.util.ArrayList; | ||
24 | |||
25 | public class HomeworkSelectActivity extends BaseRxActivity<ActivityHomeworkSelectBinding> { | ||
26 | |||
27 | private HomeworkList mData; | ||
28 | private ArrayList<HomeWork> mList; | ||
29 | private Adapter mAdapter = new Adapter(); | ||
30 | |||
31 | MutableLiveData<Integer> selectNum = new MutableLiveData<>(0); | ||
32 | |||
33 | @SuppressLint("NotifyDataSetChanged") | ||
34 | @SuppressWarnings("unchecked,ConstantConditions") | ||
35 | @Override | ||
36 | public void initView(Bundle savedInstanceState) { | ||
37 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | ||
38 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); | ||
39 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); | ||
40 | |||
41 | mAdapter.setNewData(mList); | ||
42 | binding.recyclerView.setAdapter(mAdapter); | ||
43 | |||
44 | mAdapter.selectCall = i -> selectNum.setValue(selectNum.getValue() + i); | ||
45 | selectNum.observe(this, i -> { | ||
46 | binding.tvNumber.setText(String.valueOf(i)); | ||
47 | if (i == 0) { | ||
48 | binding.btnConfirm.setText("作业全对"); | ||
49 | binding.btnConfirm.setBackgroundTintList(ColorStateList.valueOf(0xFF4ABC78)); | ||
50 | } else { | ||
51 | binding.btnConfirm.setText("下一步"); | ||
52 | binding.btnConfirm.setBackgroundTintList(ColorStateList.valueOf(0xFF1C90F3)); | ||
53 | } | ||
54 | binding.chkAll.setChecked(i == mList.size() && i != 0); | ||
55 | }); | ||
56 | |||
57 | binding.chkAll.setOnClickListener(v -> { | ||
58 | if (mList.size() == 0) return; | ||
59 | boolean b = binding.chkAll.isChecked(); | ||
60 | for (HomeWork item: mList) { | ||
61 | item.check = b; | ||
62 | } | ||
63 | selectNum.setValue(b ? mList.size() : 0); | ||
64 | mAdapter.notifyDataSetChanged(); | ||
65 | }); | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | protected ActivityHomeworkSelectBinding getViewBinding() { | ||
70 | return ActivityHomeworkSelectBinding.inflate(getLayoutInflater()); | ||
71 | } | ||
72 | |||
73 | |||
74 | static class Adapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | ||
75 | public Adapter() { | ||
76 | super(R.layout.item_homework_detail); | ||
77 | } | ||
78 | public Function1<Integer> selectCall; | ||
79 | |||
80 | @SuppressLint("SetTextI18n") | ||
81 | @Override | ||
82 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | ||
83 | TextView tvNumber = holder.getView(R.id.tvNumber); | ||
84 | ImageView imageView = holder.getView(R.id.ivTopic); | ||
85 | int number = getData().indexOf(homeWork) + 1; | ||
86 | tvNumber.setText("第" + number + "题"); | ||
87 | Glide.with(mContext).load(homeWork.url).into(imageView); | ||
88 | |||
89 | CheckBox checkBox = holder.getView(R.id.checkbox); | ||
90 | checkBox.setVisibility(View.VISIBLE); | ||
91 | checkBox.setOnCheckedChangeListener(null); | ||
92 | checkBox.setChecked(homeWork.check); | ||
93 | |||
94 | holder.itemView.setOnClickListener(v -> checkBox.performClick()); | ||
95 | checkBox.setOnCheckedChangeListener((v, b) -> { | ||
96 | homeWork.check = b; | ||
97 | if (selectCall != null) { | ||
98 | selectCall.invoke(b ? 1 : -1); | ||
99 | } | ||
100 | }); | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 |
app/src/main/java/com/hjx/parent/adapter/HomeworkListAdapter.java
1 | package com.hjx.parent.adapter; | 1 | package com.hjx.parent.adapter; |
2 | 2 | ||
3 | import android.content.Intent; | ||
3 | import android.view.View; | 4 | import android.view.View; |
4 | import android.widget.TextView; | 5 | import android.widget.TextView; |
5 | 6 | ||
6 | import androidx.annotation.NonNull; | 7 | import androidx.annotation.NonNull; |
7 | 8 | ||
8 | import com.chad.library.adapter.base.BaseQuickAdapter; | 9 | import com.chad.library.adapter.base.BaseQuickAdapter; |
9 | import com.chad.library.adapter.base.BaseViewHolder; | 10 | import com.chad.library.adapter.base.BaseViewHolder; |
11 | import com.google.gson.Gson; | ||
12 | import com.hjx.parent.HomeworkDetailActivity; | ||
10 | import com.hjx.parent.R; | 13 | import com.hjx.parent.R; |
11 | import com.hjx.parent.function.Function0; | 14 | import com.hjx.parent.function.Function0; |
12 | import com.hjx.parent.function.Function1; | 15 | import com.hjx.parent.function.Function1; |
13 | import com.prws.common.bean.homework.HomeworkList; | 16 | import com.prws.common.bean.homework.HomeworkList; |
14 | 17 | ||
15 | public class HomeworkListAdapter extends BaseQuickAdapter<HomeworkList, BaseViewHolder> { | 18 | public class HomeworkListAdapter extends BaseQuickAdapter<HomeworkList, BaseViewHolder> { |
16 | 19 | ||
17 | public Function1<HomeworkList> deleteCall; | 20 | public Function1<HomeworkList> deleteCall; |
18 | 21 | ||
19 | public HomeworkListAdapter() { | 22 | public HomeworkListAdapter() { |
20 | super(R.layout.item_homework_list); | 23 | super(R.layout.item_homework_list); |
21 | } | 24 | } |
22 | 25 | ||
23 | @Override | 26 | @Override |
24 | protected void convert(@NonNull BaseViewHolder helper, HomeworkList homework) { | 27 | protected void convert(@NonNull BaseViewHolder helper, HomeworkList homework) { |
25 | helper.setGone(R.id.tvFlag, homework.getRight() != null); | 28 | helper.setGone(R.id.tvFlag, homework.getRight() != null); |
26 | helper.setText(R.id.tvName, homework.getName()); | 29 | helper.setText(R.id.tvName, homework.getName()); |
27 | helper.setText(R.id.tvGrade, homework.getGrade() + "-" + homework.getTerm()); | 30 | helper.setText(R.id.tvGrade, homework.getGrade() + "-" + homework.getTerm()); |
28 | int subjectImg; | 31 | int subjectImg; |
29 | switch (homework.getSubject()) { | 32 | switch (homework.getSubject()) { |
30 | case "语文": | 33 | case "语文": |
31 | subjectImg = R.drawable.ic_chinese; | 34 | subjectImg = R.drawable.ic_chinese; |
32 | break; | 35 | break; |
33 | case "英语": | 36 | case "英语": |
34 | subjectImg = R.drawable.ic_english; | 37 | subjectImg = R.drawable.ic_english; |
35 | break; | 38 | break; |
36 | case "物理": | 39 | case "物理": |
37 | subjectImg = R.drawable.ic_physics; | 40 | subjectImg = R.drawable.ic_physics; |
38 | break; | 41 | break; |
39 | case "化学": | 42 | case "化学": |
40 | subjectImg = R.drawable.ic_chemistry; | 43 | subjectImg = R.drawable.ic_chemistry; |
41 | break; | 44 | break; |
42 | case "数学": | 45 | case "数学": |
43 | default: | 46 | default: |
44 | subjectImg = R.drawable.ic_math; | 47 | subjectImg = R.drawable.ic_math; |
45 | } | 48 | } |
46 | helper.setImageResource(R.id.ivSubject, subjectImg); | 49 | helper.setImageResource(R.id.ivSubject, subjectImg); |
47 | 50 | ||
48 | TextView tvDate = helper.getView(R.id.tvDate); | 51 | TextView tvDate = helper.getView(R.id.tvDate); |
49 | int index = getData().indexOf(homework); | 52 | int index = getData().indexOf(homework); |
50 | if (index == 0) { | 53 | if (index == 0) { |
51 | tvDate.setVisibility(View.VISIBLE); | 54 | tvDate.setVisibility(View.VISIBLE); |
52 | } else if (!homework.getFormatTime().equals(getData().get(index - 1).getFormatTime())) { | 55 | } else if (!homework.getFormatTime().equals(getData().get(index - 1).getFormatTime())) { |
53 | tvDate.setVisibility(View.VISIBLE); | 56 | tvDate.setVisibility(View.VISIBLE); |
54 | } else { | 57 | } else { |
55 | tvDate.setVisibility(View.GONE); | 58 | tvDate.setVisibility(View.GONE); |
56 | } | 59 | } |
57 | tvDate.setText(homework.getFormatTime()); | 60 | tvDate.setText(homework.getFormatTime()); |
58 | 61 | ||
59 | View btnDelete = helper.getView(R.id.btnDelete); | 62 | View btnDelete = helper.getView(R.id.btnDelete); |
60 | btnDelete.setOnClickListener(v -> { | 63 | btnDelete.setOnClickListener(v -> { |
61 | if (deleteCall != null) deleteCall.invoke(homework); | 64 | if (deleteCall != null) deleteCall.invoke(homework); |
62 | }); | 65 | }); |
63 | 66 | ||
64 | View btnDetail = helper.getView(R.id.btnDetail); | 67 | View btnDetail = helper.getView(R.id.btnDetail); |
65 | btnDetail.setOnClickListener(v -> { | 68 | btnDetail.setOnClickListener(v -> { |
66 | // TODO | 69 | Intent intent = new Intent(mContext, HomeworkDetailActivity.class); |
70 | intent.putExtra("data", new Gson().toJson(homework)); | ||
71 | mContext.startActivity(intent); | ||
67 | }); | 72 | }); |
68 | } | 73 | } |
69 | } | 74 | } |
70 | 75 |
app/src/main/java/com/hjx/parent/rx/ILifecycleActivity.java
1 | package com.hjx.parent.rx; | 1 | package com.hjx.parent.rx; |
2 | 2 | ||
3 | import com.trello.rxlifecycle2.android.ActivityEvent; | 3 | import com.trello.rxlifecycle2.android.ActivityEvent; |
4 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 4 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
5 | 5 | ||
6 | import io.reactivex.Observable; | 6 | import io.reactivex.Observable; |
7 | import io.reactivex.ObservableSource; | ||
8 | import io.reactivex.ObservableTransformer; | ||
7 | import io.reactivex.Observer; | 9 | import io.reactivex.Observer; |
8 | import io.reactivex.Single; | 10 | import io.reactivex.Single; |
9 | import io.reactivex.SingleObserver; | 11 | import io.reactivex.SingleObserver; |
12 | import io.reactivex.SingleTransformer; | ||
10 | import io.reactivex.android.schedulers.AndroidSchedulers; | 13 | import io.reactivex.android.schedulers.AndroidSchedulers; |
11 | import io.reactivex.disposables.Disposable; | 14 | import io.reactivex.disposables.Disposable; |
12 | import io.reactivex.functions.Consumer; | 15 | import io.reactivex.functions.Consumer; |
13 | import io.reactivex.schedulers.Schedulers; | 16 | import io.reactivex.schedulers.Schedulers; |
14 | import retrofit2.Call; | 17 | import retrofit2.Call; |
15 | 18 | ||
16 | // 抽象 | 19 | // 抽象 |
17 | public interface ILifecycleActivity { | 20 | public interface ILifecycleActivity { |
18 | Observable<ActivityEvent> getRxLifecycle(); | 21 | Observable<ActivityEvent> getRxLifecycle(); |
19 | 22 | ||
20 | default <T> Single<T> getSingleResult(Call<T> call) { | 23 | default <T> Single<T> getSingleResult(Call<T> call) { |
21 | return Single.just(call) | 24 | return Single.just(call) |
22 | .map(t -> t.execute().body()) | 25 | .map(t -> t.execute().body()) |
23 | .subscribeOn(Schedulers.io()) | 26 | .subscribeOn(Schedulers.io()) |
24 | .observeOn(AndroidSchedulers.mainThread()) | 27 | .observeOn(AndroidSchedulers.mainThread()) |
25 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())); | 28 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())); |
26 | } | 29 | } |
27 | 30 | ||
28 | default <T> void subscribeSingle(Single<T> single, SingleObserver<T> observer) { | 31 | default <T> void subscribeSingle(Single<T> single, SingleObserver<T> observer) { |
29 | single.subscribeOn(Schedulers.io()) | 32 | single.subscribeOn(Schedulers.io()) |
30 | .observeOn(AndroidSchedulers.mainThread()) | 33 | .observeOn(AndroidSchedulers.mainThread()) |
31 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | 34 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) |
32 | .subscribe(observer); | 35 | .subscribe(observer); |
33 | } | 36 | } |
34 | 37 | ||
35 | default <T> void subscribeRx(Observable<T> observable, Observer<T> observer) { | 38 | default <T> void subscribeRx(Observable<T> observable, Observer<T> observer) { |
36 | observable.subscribeOn(Schedulers.io()) | 39 | observable.subscribeOn(Schedulers.io()) |
37 | .observeOn(AndroidSchedulers.mainThread()) | 40 | .observeOn(AndroidSchedulers.mainThread()) |
38 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | 41 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) |
39 | .subscribe(observer); | 42 | .subscribe(observer); |
40 | } | 43 | } |
41 | 44 | ||
42 | default <T> Disposable subscribeRx(Observable<T> observable, Consumer<T> onNext) { | 45 | default <T> Disposable subscribeRx(Observable<T> observable, Consumer<T> onNext) { |
43 | return observable.subscribeOn(Schedulers.io()) | 46 | return observable.subscribeOn(Schedulers.io()) |
44 | .observeOn(AndroidSchedulers.mainThread()) | 47 | .observeOn(AndroidSchedulers.mainThread()) |
45 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | 48 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) |
46 | .subscribe(onNext); | 49 | .subscribe(onNext); |
47 | } | 50 | } |
51 | |||
52 | default <T> ObservableTransformer<T, T> transform() { | ||
53 | return upstream -> upstream.subscribeOn(Schedulers.io()) | ||
54 | .observeOn(AndroidSchedulers.mainThread()) | ||
55 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())); | ||
56 | } | ||
57 | |||
58 | default <T> SingleTransformer<T, T> transformSingle() { | ||
59 | return upstream -> upstream.subscribeOn(Schedulers.io()) | ||
60 | .observeOn(AndroidSchedulers.mainThread()) | ||
61 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())); | ||
62 | } | ||
63 | |||
48 | } | 64 | } |
49 | 65 |
app/src/main/res/drawable/chk_circle.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item android:drawable="@drawable/svg_select_circle_on" android:state_checked="true"/> | ||
4 | <item android:drawable="@drawable/svg_select_circle_off"/> | ||
5 | </selector> |
app/src/main/res/drawable/svg_homework_edit.xml
File was created | 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:width="34dp" | ||
3 | android:height="34dp" | ||
4 | android:viewportWidth="34" | ||
5 | android:viewportHeight="34"> | ||
6 | <path | ||
7 | android:pathData="M8,0L26,0C30.418,0 34,3.582 34,8L34,26C34,30.418 30.418,34 26,34L8,34C3.582,34 0,30.418 0,26L0,8C0,3.582 3.582,0 8,0Z" | ||
8 | android:fillColor="#1C90F3" | ||
9 | android:fillType="evenOdd"/> | ||
10 | <path | ||
11 | android:pathData="M4,9L15,9C16.105,9 17,9.895 17,11C17,12.105 16.105,13 15,13L4,13C2.895,13 2,12.105 2,11C2,9.895 2.895,9 4,9Z" | ||
12 | android:fillColor="#FFFFFF" | ||
13 | android:fillType="evenOdd"/> | ||
14 | <path | ||
15 | android:pathData="M4,18L9,18C10.105,18 11,18.895 11,20C11,21.105 10.105,22 9,22L4,22C2.895,22 2,21.105 2,20C2,18.895 2.895,18 4,18Z" | ||
16 | android:fillColor="#FFFFFF" | ||
17 | android:fillType="evenOdd"/> | ||
18 | <path | ||
19 | android:pathData="M27.058,5.276L32.959,10.334L16.942,28.881L11.041,29.724L11.041,23.823L27.058,5.276Z" | ||
20 | android:fillColor="#FFFFFF" | ||
21 | android:fillType="evenOdd"/> | ||
22 | </vector> | ||
23 |
app/src/main/res/drawable/svg_select_circle_off.xml
File was created | 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:width="15dp" | ||
3 | android:height="15dp" | ||
4 | android:viewportWidth="33" | ||
5 | android:viewportHeight="33"> | ||
6 | <path | ||
7 | android:pathData="M16,1C24.284,1 31,7.716 31,16C31,24.284 24.284,31 16,31C7.716,31 1,24.284 1,16C1,7.716 7.716,1 16,1Z" | ||
8 | android:strokeLineJoin="miter" | ||
9 | android:strokeWidth="2" | ||
10 | android:fillColor="#00000000" | ||
11 | android:fillType="evenOdd" | ||
12 | android:strokeColor="#CCCCCC" | ||
13 | android:strokeLineCap="butt"/> | ||
14 | </vector> | ||
15 |
app/src/main/res/drawable/svg_select_circle_on.xml
File was created | 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | android:width="15dp" | ||
3 | android:height="15dp" | ||
4 | android:viewportWidth="33.5" | ||
5 | android:viewportHeight="33.5"> | ||
6 | <path | ||
7 | android:pathData="M16,1C24.284,1 31,7.716 31,16C31,24.284 24.284,31 16,31C7.716,31 1,24.284 1,16C1,7.716 7.716,1 16,1Z" | ||
8 | android:strokeLineJoin="miter" | ||
9 | android:strokeWidth="2" | ||
10 | android:fillColor="#00000000" | ||
11 | android:fillType="evenOdd" | ||
12 | android:strokeColor="#FF4837" | ||
13 | android:strokeLineCap="butt"/> | ||
14 | <path | ||
15 | android:pathData="M24.543,11.008L24.545,11.009L24.538,11.018C24.521,11.051 24.505,11.09 24.487,11.119C24.418,11.226 24.324,11.348 24.211,11.477L16.298,22.577C15.44,23.982 14.527,23.904 13.74,23.098L7.691,16.84" | ||
16 | android:strokeLineJoin="miter" | ||
17 | android:strokeWidth="3" | ||
18 | android:fillColor="#00000000" | ||
19 | android:fillType="evenOdd" | ||
20 | android:strokeColor="#FF4837" | ||
21 | android:strokeLineCap="round"/> | ||
22 | </vector> | ||
23 |
app/src/main/res/layout/activity_homework_detail.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <LinearLayout | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
5 | xmlns:tools="http://schemas.android.com/tools" | ||
6 | android:orientation="vertical" | ||
7 | android:layout_width="match_parent" | ||
8 | android:layout_height="match_parent" | ||
9 | tools:ignore="HardcodedText"> | ||
10 | |||
11 | <androidx.appcompat.widget.Toolbar | ||
12 | android:id="@+id/toolbar" | ||
13 | app:navigationIcon="@drawable/svg_back" | ||
14 | app:contentInsetStartWithNavigation="14dp" | ||
15 | android:paddingStart="-8dp" | ||
16 | android:paddingEnd="-8dp" | ||
17 | android:background="@color/white" | ||
18 | android:layout_width="match_parent" | ||
19 | android:layout_height="40dp"> | ||
20 | <TextView | ||
21 | android:id="@+id/tvTitle" | ||
22 | tools:text="作业名称" | ||
23 | android:textSize="18sp" | ||
24 | android:textColor="#333" | ||
25 | android:textStyle="bold" | ||
26 | android:layout_width="wrap_content" | ||
27 | android:layout_height="wrap_content"/> | ||
28 | <TextView | ||
29 | android:id="@+id/btnFeedback" | ||
30 | android:text="反馈作业" | ||
31 | android:textSize="13sp" | ||
32 | android:textColor="#1C90F3" | ||
33 | android:textStyle="bold" | ||
34 | android:layout_gravity="end|center_vertical" | ||
35 | android:layout_marginEnd="24dp" | ||
36 | android:layout_width="wrap_content" | ||
37 | android:layout_height="wrap_content"/> | ||
38 | </androidx.appcompat.widget.Toolbar> | ||
39 | |||
40 | <androidx.recyclerview.widget.RecyclerView | ||
41 | android:id="@+id/recyclerView" | ||
42 | android:orientation="vertical" | ||
43 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
44 | android:layout_width="match_parent" | ||
45 | android:layout_height="match_parent"/> | ||
46 | |||
47 | </LinearLayout> |
app/src/main/res/layout/activity_homework_select.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <LinearLayout | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
5 | xmlns:tools="http://schemas.android.com/tools" | ||
6 | android:orientation="vertical" | ||
7 | android:layout_width="match_parent" | ||
8 | android:layout_height="match_parent" | ||
9 | tools:ignore="HardcodedText"> | ||
10 | |||
11 | <androidx.appcompat.widget.Toolbar | ||
12 | android:id="@+id/toolbar" | ||
13 | app:navigationIcon="@drawable/svg_back" | ||
14 | app:contentInsetStartWithNavigation="14dp" | ||
15 | android:paddingStart="-8dp" | ||
16 | android:paddingEnd="-8dp" | ||
17 | android:background="@color/white" | ||
18 | android:layout_width="match_parent" | ||
19 | android:layout_height="40dp"> | ||
20 | <TextView | ||
21 | android:text="第一步:选择错题" | ||
22 | android:textSize="18sp" | ||
23 | android:textColor="#333" | ||
24 | android:textStyle="bold" | ||
25 | android:layout_gravity="center" | ||
26 | android:layout_width="wrap_content" | ||
27 | android:layout_height="wrap_content"/> | ||
28 | </androidx.appcompat.widget.Toolbar> | ||
29 | |||
30 | <LinearLayout | ||
31 | android:orientation="horizontal" | ||
32 | android:layout_marginHorizontal="16dp" | ||
33 | android:layout_marginTop="16dp" | ||
34 | android:layout_marginBottom="8dp" | ||
35 | android:layout_width="match_parent" | ||
36 | android:layout_height="wrap_content"> | ||
37 | <CheckBox | ||
38 | android:id="@+id/chkAll" | ||
39 | android:text="全选" | ||
40 | android:textSize="13sp" | ||
41 | android:textColor="#333" | ||
42 | android:button="@drawable/chk_circle" | ||
43 | android:gravity="center_vertical" | ||
44 | android:paddingStart="8dp" | ||
45 | android:paddingEnd="0dp" | ||
46 | android:layout_width="wrap_content" | ||
47 | android:layout_height="wrap_content"/> | ||
48 | <Space style="@style/empty_space"/> | ||
49 | <TextView | ||
50 | android:text="已选择 " | ||
51 | android:textSize="13sp" | ||
52 | android:textColor="#333" | ||
53 | android:layout_width="wrap_content" | ||
54 | android:layout_height="wrap_content"/> | ||
55 | <TextView | ||
56 | android:id="@+id/tvNumber" | ||
57 | android:text="0" | ||
58 | android:textSize="13sp" | ||
59 | android:textColor="#1C90F3" | ||
60 | android:layout_width="wrap_content" | ||
61 | android:layout_height="wrap_content"/> | ||
62 | <TextView | ||
63 | android:text=" 道错题" | ||
64 | android:textSize="13sp" | ||
65 | android:textColor="#333" | ||
66 | android:layout_width="wrap_content" | ||
67 | android:layout_height="wrap_content"/> | ||
68 | </LinearLayout> | ||
69 | |||
70 | <androidx.recyclerview.widget.RecyclerView | ||
71 | android:id="@+id/recyclerView" | ||
72 | android:orientation="vertical" | ||
73 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
74 | android:layout_width="match_parent" | ||
75 | android:layout_height="0px" | ||
76 | android:layout_weight="1"/> | ||
77 | |||
78 | <FrameLayout | ||
79 | android:background="@color/white" | ||
80 | android:paddingTop="8dp" | ||
81 | android:paddingBottom="16dp" | ||
82 | android:layout_width="match_parent" | ||
83 | android:layout_height="wrap_content"> | ||
84 | <TextView | ||
85 | android:id="@+id/btnConfirm" | ||
86 | android:text="作业全对" | ||
87 | android:textSize="16sp" | ||
88 | android:textColor="@color/white" | ||
89 | android:gravity="center" | ||
90 | android:layout_gravity="center" | ||
91 | android:background="@drawable/shape_radius_5" | ||
92 | android:backgroundTint="#4ABC78" | ||
93 | android:layout_width="265dp" | ||
94 | android:layout_height="36dp"/> | ||
95 | </FrameLayout> | ||
96 | </LinearLayout> |
app/src/main/res/layout/item_homework_detail.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <LinearLayout | ||
3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | xmlns:tools="http://schemas.android.com/tools" | ||
5 | android:orientation="vertical" | ||
6 | android:background="@drawable/shape_radius_10" | ||
7 | android:backgroundTint="@color/white" | ||
8 | android:paddingVertical="14dp" | ||
9 | android:layout_marginHorizontal="16dp" | ||
10 | android:layout_marginVertical="8dp" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="wrap_content" | ||
13 | tools:ignore="SmallSp"> | ||
14 | |||
15 | <LinearLayout | ||
16 | android:orientation="horizontal" | ||
17 | android:gravity="center_vertical" | ||
18 | android:layout_marginStart="16dp" | ||
19 | android:layout_width="match_parent" | ||
20 | android:layout_height="wrap_content"> | ||
21 | <CheckBox | ||
22 | android:id="@+id/checkbox" | ||
23 | android:visibility="gone" | ||
24 | tools:visibility="visible" | ||
25 | android:button="@drawable/chk_circle" | ||
26 | android:layout_marginEnd="5dp" | ||
27 | android:layout_width="16dp" | ||
28 | android:layout_height="16dp"/> | ||
29 | <TextView | ||
30 | android:id="@+id/tvNumber" | ||
31 | tools:text="第1题" | ||
32 | android:textSize="9sp" | ||
33 | android:textColor="#333" | ||
34 | android:paddingHorizontal="7dp" | ||
35 | android:paddingVertical="3dp" | ||
36 | android:background="@drawable/shape_radius_5" | ||
37 | android:backgroundTint="#F2F2F2" | ||
38 | android:layout_width="wrap_content" | ||
39 | android:layout_height="wrap_content" /> | ||
40 | </LinearLayout> | ||
41 | |||
42 | <ImageView | ||
43 | android:id="@+id/ivTopic" | ||
44 | android:adjustViewBounds="true" | ||
45 | android:layout_marginStart="10dp" | ||
46 | android:layout_marginEnd="4dp" | ||
47 | android:layout_marginTop="14dp" | ||
48 | android:layout_width="match_parent" | ||
49 | android:layout_height="wrap_content" | ||
50 | android:importantForAccessibility="no" /> | ||
51 | </LinearLayout> |
libs/common/src/main/java/com/prws/common/bean/homework/HomeWork.java
File was created | 1 | package com.prws.common.bean.homework; | |
2 | |||
3 | import com.google.gson.annotations.SerializedName; | ||
4 | |||
5 | import java.io.Serializable; | ||
6 | |||
7 | public class HomeWork implements Serializable { | ||
8 | |||
9 | @SerializedName(value = "homeworkId", alternate = "id") | ||
10 | public Integer homeworkId; | ||
11 | public String brief; | ||
12 | public String url; | ||
13 | public String analyseUrl; | ||
14 | public String analyseVideoUrl; | ||
15 | public Integer correction; | ||
16 | public String answer; | ||
17 | public String points; | ||
18 | |||
19 | public boolean check = false; | ||
20 | |||
21 | } | ||
22 |
libs/common/src/main/java/com/prws/common/bean/homework/HomeworkList.java
1 | package com.prws.common.bean.homework; | 1 | package com.prws.common.bean.homework; |
2 | 2 | ||
3 | import com.google.gson.annotations.SerializedName; | 3 | import com.google.gson.annotations.SerializedName; |
4 | 4 | ||
5 | import java.io.Serializable; | ||
5 | import java.text.SimpleDateFormat; | 6 | import java.text.SimpleDateFormat; |
6 | import java.util.Date; | 7 | import java.util.Date; |
7 | import java.util.Locale; | 8 | import java.util.Locale; |
8 | 9 | ||
9 | public class HomeworkList implements Comparable<HomeworkList> { | 10 | public class HomeworkList implements Comparable<HomeworkList>, Serializable { |
10 | 11 | ||
11 | @SerializedName(value = "homeworkId", alternate = "id") | 12 | @SerializedName(value = "homeworkId", alternate = "id") |
12 | private String homeworkId; | 13 | private String homeworkId; |
13 | @SerializedName(value = "name", alternate = "homeworkName") | 14 | @SerializedName(value = "name", alternate = "homeworkName") |
14 | private String name; | 15 | private String name; |
15 | @SerializedName("grade") | 16 | @SerializedName("grade") |
16 | private String grade; | 17 | private String grade; |
17 | @SerializedName("term") | 18 | @SerializedName("term") |
18 | private String term; | 19 | private String term; |
19 | @SerializedName("subject") | 20 | @SerializedName("subject") |
20 | private String subject; | 21 | private String subject; |
21 | private int completeFlag; | 22 | private int completeFlag; |
22 | 23 | ||
23 | private Integer total; | 24 | private Integer total; |
24 | private Integer right; | 25 | private Integer right; |
25 | 26 | ||
26 | public Date uploadTime; | 27 | public Date uploadTime; |
27 | 28 | ||
28 | public Integer getTotal() { | 29 | public Integer getTotal() { |
29 | return total; | 30 | return total; |
30 | } | 31 | } |
31 | 32 | ||
32 | public Integer getRight() { | 33 | public Integer getRight() { |
33 | return right; | 34 | return right; |
34 | } | 35 | } |
35 | 36 | ||
36 | public void setRight(Integer right) { | 37 | public void setRight(Integer right) { |
37 | this.right = right; | 38 | this.right = right; |
38 | } | 39 | } |
39 | 40 | ||
40 | public void setTotal(Integer total) { | 41 | public void setTotal(Integer total) { |
41 | this.total = total; | 42 | this.total = total; |
42 | } | 43 | } |
43 | 44 | ||
44 | public void setId(String id) { | 45 | public void setId(String id) { |
45 | this.homeworkId = id; | 46 | this.homeworkId = id; |
46 | } | 47 | } |
47 | 48 | ||
48 | public void setName(String name) { | 49 | public void setName(String name) { |
49 | this.name = name; | 50 | this.name = name; |
50 | } | 51 | } |
51 | 52 | ||
52 | public void setGrade(String grade) { | 53 | public void setGrade(String grade) { |
53 | this.grade = grade; | 54 | this.grade = grade; |
54 | } | 55 | } |
55 | 56 | ||
56 | public void setTerm(String term) { | 57 | public void setTerm(String term) { |
57 | this.term = term; | 58 | this.term = term; |
58 | } | 59 | } |
59 | 60 | ||
60 | public void setSubject(String subject) { | 61 | public void setSubject(String subject) { |
61 | this.subject = subject; | 62 | this.subject = subject; |
62 | } | 63 | } |
63 | 64 | ||
64 | public void setCompleteFlag(int completeFlag) { | 65 | public void setCompleteFlag(int completeFlag) { |
65 | this.completeFlag = completeFlag; | 66 | this.completeFlag = completeFlag; |
66 | } | 67 | } |
67 | 68 | ||
68 | public String getId() { | 69 | public String getId() { |
69 | return homeworkId; | 70 | return homeworkId; |
70 | } | 71 | } |
71 | 72 | ||
72 | public String getName() { | 73 | public String getName() { |
73 | return name; | 74 | return name; |
74 | } | 75 | } |
75 | 76 | ||
76 | public String getGrade() { | 77 | public String getGrade() { |
77 | return grade; | 78 | return grade; |
78 | } | 79 | } |
79 | 80 | ||
80 | public String getTerm() { | 81 | public String getTerm() { |
81 | return term; | 82 | return term; |
82 | } | 83 | } |
83 | 84 | ||
84 | public String getSubject() { | 85 | public String getSubject() { |
85 | return subject; | 86 | return subject; |
86 | } | 87 | } |
87 | 88 | ||
88 | public int getCompleteFlag() { | 89 | public int getCompleteFlag() { |
89 | return completeFlag; | 90 | return completeFlag; |
90 | } | 91 | } |
91 | 92 | ||
92 | @Override | 93 | @Override |
93 | public int compareTo(HomeworkList other) { | 94 | public int compareTo(HomeworkList other) { |
94 | long time1 = this.uploadTime == null ? 0 : this.uploadTime.getTime(); | 95 | long time1 = this.uploadTime == null ? 0 : this.uploadTime.getTime(); |
95 | long time2 = other.uploadTime == null ? 0 : other.uploadTime.getTime(); | 96 | long time2 = other.uploadTime == null ? 0 : other.uploadTime.getTime(); |
96 | return (int) (time2 - time1); | 97 | return (int) (time2 - time1); |
97 | } | 98 | } |
98 | 99 | ||
99 | private String time; | 100 | private String time; |
100 | private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); | ||
101 | public String getFormatTime() { | 101 | public String getFormatTime() { |
102 | if (uploadTime == null) return ""; | 102 | if (uploadTime == null) return ""; |
103 | if (time != null) return time; | 103 | if (time != null) return time; |
104 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); | ||
104 | time = format.format(uploadTime); | 105 | time = format.format(uploadTime); |
105 | return time; | 106 | return time; |
106 | } | 107 | } |
107 | } | 108 | } |
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.CutPicBean; | 7 | import com.prws.common.bean.CutPicBean; |
8 | import com.prws.common.bean.GradeAndSubject; | 8 | import com.prws.common.bean.GradeAndSubject; |
9 | import com.prws.common.bean.PageInfo; | 9 | import com.prws.common.bean.PageInfo; |
10 | import com.prws.common.bean.ResponseResult; | 10 | import com.prws.common.bean.ResponseResult; |
11 | import com.prws.common.bean.ScheduleBean; | 11 | import com.prws.common.bean.ScheduleBean; |
12 | import com.prws.common.bean.Student; | 12 | import com.prws.common.bean.Student; |
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.bean.baidu.BaiduInput; | 16 | import com.prws.common.bean.baidu.BaiduInput; |
17 | import com.prws.common.bean.homework.HomeWork; | ||
17 | import com.prws.common.bean.homework.HomeworkList; | 18 | import com.prws.common.bean.homework.HomeworkList; |
18 | import com.prws.common.utils.BitmapUtils; | 19 | import com.prws.common.utils.BitmapUtils; |
19 | import com.prws.common.utils.SharedPreferencesUtil; | 20 | import com.prws.common.utils.SharedPreferencesUtil; |
20 | 21 | ||
21 | import java.io.File; | 22 | import java.io.File; |
22 | import java.util.HashMap; | 23 | import java.util.HashMap; |
23 | import java.util.List; | 24 | import java.util.List; |
24 | import java.util.Map; | 25 | import java.util.Map; |
25 | 26 | ||
26 | import io.reactivex.Observable; | 27 | import io.reactivex.Observable; |
27 | import io.reactivex.Observer; | 28 | import io.reactivex.Observer; |
28 | import io.reactivex.Single; | 29 | import io.reactivex.Single; |
29 | import io.reactivex.android.schedulers.AndroidSchedulers; | 30 | import io.reactivex.android.schedulers.AndroidSchedulers; |
30 | import io.reactivex.schedulers.Schedulers; | 31 | import io.reactivex.schedulers.Schedulers; |
31 | import okhttp3.MediaType; | 32 | import okhttp3.MediaType; |
32 | import okhttp3.MultipartBody; | 33 | import okhttp3.MultipartBody; |
33 | import okhttp3.RequestBody; | 34 | import okhttp3.RequestBody; |
34 | import okhttp3.ResponseBody; | 35 | import okhttp3.ResponseBody; |
35 | import retrofit2.Call; | 36 | import retrofit2.Call; |
36 | import retrofit2.Callback; | 37 | import retrofit2.Callback; |
37 | import retrofit2.http.Body; | 38 | import retrofit2.http.Body; |
38 | import retrofit2.http.GET; | 39 | import retrofit2.http.GET; |
39 | import retrofit2.http.Header; | 40 | import retrofit2.http.Header; |
40 | import retrofit2.http.Headers; | 41 | import retrofit2.http.Headers; |
41 | import retrofit2.http.Multipart; | 42 | import retrofit2.http.Multipart; |
42 | import retrofit2.http.POST; | 43 | import retrofit2.http.POST; |
43 | import retrofit2.http.PUT; | 44 | import retrofit2.http.PUT; |
44 | import retrofit2.http.Part; | 45 | import retrofit2.http.Part; |
45 | import retrofit2.http.PartMap; | 46 | import retrofit2.http.PartMap; |
46 | import retrofit2.http.Query; | 47 | import retrofit2.http.Query; |
47 | import retrofit2.http.Url; | 48 | import retrofit2.http.Url; |
48 | 49 | ||
49 | /** | 50 | /** |
50 | * 类名称:NetWorks | 51 | * 类名称:NetWorks |
51 | * 创建人: | 52 | * 创建人: |
52 | * <p> | 53 | * <p> |
53 | * 类描述:网络请求的操作类 | 54 | * 类描述:网络请求的操作类 |
54 | */ | 55 | */ |
55 | public class NetWorks extends RetrofitUtils { | 56 | public class NetWorks extends RetrofitUtils { |
56 | //服务器路径 | 57 | //服务器路径 |
57 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); | 58 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); |
58 | 59 | ||
59 | //设缓存有效期为1天 | 60 | //设缓存有效期为1天 |
60 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | 61 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; |
61 | //查询缓存的Cache-Control设置,使用缓存 | 62 | //查询缓存的Cache-Control设置,使用缓存 |
62 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | 63 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; |
63 | //查询网络的Cache-Control设置。不使用缓存 | 64 | //查询网络的Cache-Control设置。不使用缓存 |
64 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | 65 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
65 | 66 | ||
66 | 67 | ||
67 | public interface NetService { | 68 | public interface NetService { |
68 | 69 | ||
69 | 70 | ||
70 | @GET("/api/v1/user/logout") | 71 | @GET("/api/v1/user/logout") |
71 | Observable<ResponseBody> logout(); | 72 | Observable<ResponseBody> logout(); |
72 | 73 | ||
73 | @Multipart | 74 | @Multipart |
74 | @POST("/api/v1/user/upLoadAvatar") | 75 | @POST("/api/v1/user/upLoadAvatar") |
75 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); | 76 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); |
76 | 77 | ||
77 | 78 | ||
78 | @Headers("Content-Type: application/json") | 79 | @Headers("Content-Type: application/json") |
79 | @POST("/api/v1/user/editUser") | 80 | @POST("/api/v1/user/editUser") |
80 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); | 81 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); |
81 | 82 | ||
82 | @Headers("Content-Type: application/json") | 83 | @Headers("Content-Type: application/json") |
83 | @POST("/api/v1/user/changePassword") | 84 | @POST("/api/v1/user/changePassword") |
84 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); | 85 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); |
85 | 86 | ||
86 | 87 | ||
87 | @GET("/api/v1/user/searchById") | 88 | @GET("/api/v1/user/searchById") |
88 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); | 89 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); |
89 | 90 | ||
90 | 91 | ||
91 | @Headers("Content-Type: application/json") | 92 | @Headers("Content-Type: application/json") |
92 | @POST("/api/v1/auth/login") | 93 | @POST("/api/v1/auth/login") |
93 | Observable<ResponseBody> login(@Body RequestBody body); | 94 | Observable<ResponseBody> login(@Body RequestBody body); |
94 | 95 | ||
95 | @GET("/api/v1/resource/listGradeAndSubject") | 96 | @GET("/api/v1/resource/listGradeAndSubject") |
96 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); | 97 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); |
97 | 98 | ||
98 | 99 | ||
99 | @GET("/api/v1/manager/generalQrCode") | 100 | @GET("/api/v1/manager/generalQrCode") |
100 | Observable<ResponseBody> generalQrCode(); | 101 | Observable<ResponseBody> generalQrCode(); |
101 | 102 | ||
102 | @GET("/api/v1/parent/scanAndLogin?") | 103 | @GET("/api/v1/parent/scanAndLogin?") |
103 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); | 104 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); |
104 | 105 | ||
105 | @GET("/api/v1/parent/getChildrenList") | 106 | @GET("/api/v1/parent/getChildrenList") |
106 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); | 107 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); |
107 | 108 | ||
108 | 109 | ||
109 | @Headers("Content-Type: application/json") | 110 | @Headers("Content-Type: application/json") |
110 | @POST("/api/v1/parent/registerParent") | 111 | @POST("/api/v1/parent/registerParent") |
111 | Observable<ResponseBody> registerParent(@Body RequestBody body); | 112 | Observable<ResponseBody> registerParent(@Body RequestBody body); |
112 | 113 | ||
113 | 114 | ||
114 | @GET("/api/v1/parent/listChildren") | 115 | @GET("/api/v1/parent/listChildren") |
115 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); | 116 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); |
116 | 117 | ||
117 | 118 | ||
118 | @Headers("Content-Type: application/json") | 119 | @Headers("Content-Type: application/json") |
119 | @POST("/api/v1/parent/registerStudent") | 120 | @POST("/api/v1/parent/registerStudent") |
120 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); | 121 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); |
121 | 122 | ||
122 | @Headers("Content-Type: application/json") | 123 | @Headers("Content-Type: application/json") |
123 | @POST("/api/v1/parent/bindTeacher") | 124 | @POST("/api/v1/parent/bindTeacher") |
124 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); | 125 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); |
125 | 126 | ||
126 | @Multipart | 127 | @Multipart |
127 | @POST("/api/v1/user/upLoadAvatar") | 128 | @POST("/api/v1/user/upLoadAvatar") |
128 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); | 129 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); |
129 | 130 | ||
130 | 131 | ||
131 | @Multipart | 132 | @Multipart |
132 | @POST("/api/v1/student/editStudentAvatar") | 133 | @POST("/api/v1/student/editStudentAvatar") |
133 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 134 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
134 | 135 | ||
135 | @Headers("Content-Type: application/json") | 136 | @Headers("Content-Type: application/json") |
136 | @POST("/api/v1/parent/editChild") | 137 | @POST("/api/v1/parent/editChild") |
137 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); | 138 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); |
138 | 139 | ||
139 | @GET("/api/v1/student/getStudyPlanForThisWeek") | 140 | @GET("/api/v1/student/getStudyPlanForThisWeek") |
140 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); | 141 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); |
141 | 142 | ||
142 | @GET("api/v1/parent/searchTeacher") | 143 | @GET("api/v1/parent/searchTeacher") |
143 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); | 144 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); |
144 | 145 | ||
145 | @POST("api/v1/question/listErrorBook") | 146 | @POST("api/v1/question/listErrorBook") |
146 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); | 147 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); |
147 | 148 | ||
148 | @POST | 149 | @POST |
149 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); | 150 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); |
150 | 151 | ||
151 | @POST | 152 | @POST |
152 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); | 153 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); |
153 | 154 | ||
154 | @POST | 155 | @POST |
155 | Observable<JsonObject> getBaiduToken(@Url String url); | 156 | Observable<JsonObject> getBaiduToken(@Url String url); |
156 | 157 | ||
157 | @Multipart | 158 | @Multipart |
158 | @POST("api/v1/pad/addErrorBook") | 159 | @POST("api/v1/pad/addErrorBook") |
159 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 160 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
160 | 161 | ||
161 | @POST("api/v1/pad/deleteStuErrorBook") | 162 | @POST("api/v1/pad/deleteStuErrorBook") |
162 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); | 163 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); |
163 | 164 | ||
164 | @PUT("api/v1/pad/updateStuErrorBookInfo") | 165 | @PUT("api/v1/pad/updateStuErrorBookInfo") |
165 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); | 166 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); |
166 | 167 | ||
167 | @POST("api/v1/question/editErrorBook") | 168 | @POST("api/v1/question/editErrorBook") |
168 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); | 169 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); |
169 | 170 | ||
170 | @GET("api/v1/resource/checkUpdate") | 171 | @GET("api/v1/resource/checkUpdate") |
171 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); | 172 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); |
172 | 173 | ||
173 | @GET("api/v1/teacher/getStudentList") | 174 | @GET("api/v1/teacher/getStudentList") |
174 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); | 175 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); |
175 | 176 | ||
176 | @GET("api/v1/teacher/getStudentList") | 177 | @GET("api/v1/teacher/getStudentList") |
177 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); | 178 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); |
178 | 179 | ||
179 | @GET("api/v1/answer/listRecordForTeacher") | 180 | @GET("api/v1/answer/listRecordForTeacher") |
180 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); | 181 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); |
181 | 182 | ||
182 | @GET("api/v1/homework/listHomeworkByStuId") | 183 | @GET("api/v1/homework/listHomeworkByStuId") |
183 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); | 184 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); |
184 | 185 | ||
185 | @POST | 186 | @POST |
186 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); | 187 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); |
187 | 188 | ||
188 | @Multipart | 189 | @Multipart |
189 | @POST("api/v1/homework/uploadHomework") | 190 | @POST("api/v1/homework/uploadHomework") |
190 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); | 191 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); |
191 | 192 | ||
192 | @POST("api/v1/homework/uploadHomeworkAction") | 193 | @POST("api/v1/homework/uploadHomeworkAction") |
193 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); | 194 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); |
194 | 195 | ||
195 | @GET("api/v1/homework/removeHomework") | 196 | @GET("api/v1/homework/removeHomework") |
196 | Single<ResponseResult<Boolean>> deleteHomework( | 197 | Single<ResponseResult<Boolean>> deleteHomework( |
197 | @Header("Authorization") String token, | 198 | @Header("Authorization") String token, |
198 | @Query("homeworkId") String homeworkId | 199 | @Query("homeworkId") String homeworkId |
199 | ); | 200 | ); |
200 | 201 | ||
202 | @GET("api/v1/homework/listHomeworkById") | ||
203 | Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); | ||
204 | |||
201 | } | 205 | } |
202 | 206 | ||
203 | public static String getUserId() { | 207 | public static String getUserId() { |
204 | return (String) SharedPreferencesUtil.getData("userId", ""); | 208 | return (String) SharedPreferencesUtil.getData("userId", ""); |
205 | } | 209 | } |
206 | 210 | ||
207 | public static String getHeader() { | 211 | public static String getHeader() { |
208 | return (String) SharedPreferencesUtil.getData("token", ""); | 212 | return (String) SharedPreferencesUtil.getData("token", ""); |
209 | } | 213 | } |
210 | 214 | ||
211 | public static String getBaiduToken() { | 215 | public static String getBaiduToken() { |
212 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); | 216 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); |
213 | } | 217 | } |
214 | 218 | ||
215 | public static Single<BaiduInput> inputImage(String filePath, String id) { | 219 | public static Single<BaiduInput> inputImage(String filePath, String id) { |
216 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 220 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
217 | String base64 = BitmapUtils.fileToBase64(filePath); | 221 | String base64 = BitmapUtils.fileToBase64(filePath); |
218 | File file = new File(filePath); | 222 | File file = new File(filePath); |
219 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); | 223 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); |
220 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) | 224 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) |
221 | .flatMap(token -> { | 225 | .flatMap(token -> { |
222 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); | 226 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); |
223 | }); | 227 | }); |
224 | } | 228 | } |
225 | 229 | ||
226 | public static Single<ResponseResult> uploadImage(String path, String id) { | 230 | public static Single<ResponseResult> uploadImage(String path, String id) { |
227 | File file = new File(path); | 231 | File file = new File(path); |
228 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 232 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
229 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 233 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
230 | return service_url.uploadImage(getHeader(), part, id); | 234 | return service_url.uploadImage(getHeader(), part, id); |
231 | } | 235 | } |
232 | 236 | ||
233 | 237 | ||
234 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { | 238 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { |
235 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); | 239 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); |
236 | } | 240 | } |
237 | 241 | ||
238 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { | 242 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { |
239 | File file = new File(path); | 243 | File file = new File(path); |
240 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 244 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
241 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 245 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
242 | Map<String, Object> map = new HashMap<>(); | 246 | Map<String, Object> map = new HashMap<>(); |
243 | map.put("condition", param); | 247 | map.put("condition", param); |
244 | setSubscribe(service_url.addError(part, map), observer); | 248 | setSubscribe(service_url.addError(part, map), observer); |
245 | } | 249 | } |
246 | 250 | ||
247 | 251 | ||
248 | public static void cut(String base64, Observer<CutPicBean> observer) { | 252 | public static void cut(String base64, Observer<CutPicBean> observer) { |
249 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 253 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
250 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); | 254 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); |
251 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); | 255 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); |
252 | } | 256 | } |
253 | 257 | ||
254 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | 258 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { |
255 | setSubscribe(service_url.editError(getHeader(), map), observer); | 259 | setSubscribe(service_url.editError(getHeader(), map), observer); |
256 | } | 260 | } |
257 | 261 | ||
258 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { | 262 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { |
259 | setSubscribe(service_url.updateError(getHeader(), map), observer); | 263 | setSubscribe(service_url.updateError(getHeader(), map), observer); |
260 | } | 264 | } |
261 | 265 | ||
262 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { | 266 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { |
263 | setSubscribe(service_url.deleteError(getHeader(), map), observer); | 267 | setSubscribe(service_url.deleteError(getHeader(), map), observer); |
264 | } | 268 | } |
265 | 269 | ||
266 | public static void getBaiduToken(Observer<JsonObject> observer) { | 270 | public static void getBaiduToken(Observer<JsonObject> observer) { |
267 | 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); | 271 | 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); |
268 | } | 272 | } |
269 | 273 | ||
270 | public static Single<JsonObject> getBaiduTokenOcr() { | 274 | public static Single<JsonObject> getBaiduTokenOcr() { |
271 | return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError(); | 275 | return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError(); |
272 | } | 276 | } |
273 | 277 | ||
274 | public static void removeWriting(String base64, Observer<JsonObject> observer) { | 278 | public static void removeWriting(String base64, Observer<JsonObject> observer) { |
275 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 279 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
276 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | 280 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); |
277 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); | 281 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); |
278 | } | 282 | } |
279 | 283 | ||
280 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | 284 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { |
281 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); | 285 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); |
282 | } | 286 | } |
283 | 287 | ||
284 | public static void logout(Observer<ResponseBody> observer) { | 288 | public static void logout(Observer<ResponseBody> observer) { |
285 | setSubscribe(service_url.logout(), observer); | 289 | setSubscribe(service_url.logout(), observer); |
286 | } | 290 | } |
287 | 291 | ||
288 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { | 292 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { |
289 | setSubscribe(service_url.editStudent(getHeader(), body), observable); | 293 | setSubscribe(service_url.editStudent(getHeader(), body), observable); |
290 | } | 294 | } |
291 | 295 | ||
292 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { | 296 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { |
293 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); | 297 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); |
294 | } | 298 | } |
295 | 299 | ||
296 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { | 300 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { |
297 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 301 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
298 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 302 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
299 | Map<String, Object> map = new HashMap<>(); | 303 | Map<String, Object> map = new HashMap<>(); |
300 | map.put("stuId", stuId); | 304 | map.put("stuId", stuId); |
301 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); | 305 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); |
302 | } | 306 | } |
303 | 307 | ||
304 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { | 308 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { |
305 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 309 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
306 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 310 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
307 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); | 311 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); |
308 | } | 312 | } |
309 | 313 | ||
310 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | 314 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { |
311 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); | 315 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); |
312 | } | 316 | } |
313 | 317 | ||
314 | 318 | ||
315 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { | 319 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { |
316 | setSubscribe(service_url.editUser(getHeader(), body), observer); | 320 | setSubscribe(service_url.editUser(getHeader(), body), observer); |
317 | } | 321 | } |
318 | 322 | ||
319 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { | 323 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { |
320 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | 324 | setSubscribe(service_url.changePassword(getHeader(), body), observer); |
321 | } | 325 | } |
322 | 326 | ||
323 | 327 | ||
324 | public static void searchById(String userId, Observer<ResponseBody> observer) { | 328 | public static void searchById(String userId, Observer<ResponseBody> observer) { |
325 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | 329 | setSubscribe(service_url.searchById(getHeader(), userId), observer); |
326 | } | 330 | } |
327 | 331 | ||
328 | 332 | ||
329 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | 333 | public static void login(RequestBody body, Observer<ResponseBody> observer) { |
330 | setSubscribe(service_url.login(body), observer); | 334 | setSubscribe(service_url.login(body), observer); |
331 | } | 335 | } |
332 | 336 | ||
333 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { | 337 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { |
334 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | 338 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); |
335 | } | 339 | } |
336 | 340 | ||
337 | 341 | ||
338 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { | 342 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { |
339 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); | 343 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); |
340 | } | 344 | } |
341 | 345 | ||
342 | public static void getChildrenList(Observer<ResponseBody> observer) { | 346 | public static void getChildrenList(Observer<ResponseBody> observer) { |
343 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | 347 | setSubscribe(service_url.getChildrenList(getHeader()), observer); |
344 | } | 348 | } |
345 | 349 | ||
346 | 350 | ||
347 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { | 351 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { |
348 | setSubscribe(service_url.registerParent(body), observer); | 352 | setSubscribe(service_url.registerParent(body), observer); |
349 | } | 353 | } |
350 | 354 | ||
351 | 355 | ||
352 | public static void listChildren(Observer<ResponseBody> observer) { | 356 | public static void listChildren(Observer<ResponseBody> observer) { |
353 | setSubscribe(service_url.listChildren(getHeader()), observer); | 357 | setSubscribe(service_url.listChildren(getHeader()), observer); |
354 | } | 358 | } |
355 | 359 | ||
356 | public static void listStudent(Observer<ResponseBody> observer) { | 360 | public static void listStudent(Observer<ResponseBody> observer) { |
357 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 361 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
358 | } | 362 | } |
359 | 363 | ||
360 | public static Single<ResponseResult<List<Student>>> listStudent() { | 364 | public static Single<ResponseResult<List<Student>>> listStudent() { |
361 | return service_url.getStudentList2(getHeader(), getUserId()); | 365 | return service_url.getStudentList2(getHeader(), getUserId()); |
362 | } | 366 | } |
363 | 367 | ||
364 | public static void listRecord(Observer<ResponseBody> observer) { | 368 | public static void listRecord(Observer<ResponseBody> observer) { |
365 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 369 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
366 | } | 370 | } |
367 | 371 | ||
368 | 372 | ||
369 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { | 373 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { |
370 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | 374 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); |
371 | } | 375 | } |
372 | 376 | ||
373 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { | 377 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { |
374 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | 378 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); |
375 | } | 379 | } |
376 | 380 | ||
377 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { | 381 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { |
378 | setSubscribe(service_url.getError(getHeader(), map), observer); | 382 | setSubscribe(service_url.getError(getHeader(), map), observer); |
379 | } | 383 | } |
380 | 384 | ||
381 | 385 | ||
382 | public static RequestBody getMapRequestBody(Map map) { | 386 | public static RequestBody getMapRequestBody(Map map) { |
383 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | 387 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); |
384 | } | 388 | } |
385 | 389 | ||
386 | 390 | ||
387 | public static RequestBody getArrayRequestBody(List list) { | 391 | public static RequestBody getArrayRequestBody(List list) { |
388 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | 392 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); |
389 | } | 393 | } |
390 | 394 | ||
391 | public static RequestBody getFileRequestBody(File file) { | 395 | public static RequestBody getFileRequestBody(File file) { |
392 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | 396 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); |
393 | } | 397 | } |
394 | 398 | ||
395 | public static RequestBody getFileRequestBody(byte[] bytes) { | 399 | public static RequestBody getFileRequestBody(byte[] bytes) { |
396 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | 400 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); |
397 | } | 401 | } |
398 | 402 | ||
399 | public static RequestBody getObjectRequestBody(Object obj) { | 403 | public static RequestBody getObjectRequestBody(Object obj) { |
400 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | 404 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); |
401 | } | 405 | } |
402 | 406 | ||
403 | public static RequestBody getStringRequestBody(String str) { | 407 | public static RequestBody getStringRequestBody(String str) { |
404 | return RequestBody.create(MediaType.parse("text/plain"), str); | 408 | return RequestBody.create(MediaType.parse("text/plain"), str); |
405 | } | 409 | } |
406 | 410 | ||
407 | 411 | ||
408 | /** | 412 | /** |
409 | * 插入观察者 | 413 | * 插入观察者 |
410 | * | 414 | * |
411 | * @param observable | 415 | * @param observable |
412 | * @param observer | 416 | * @param observer |
413 | * @param <T> | 417 | * @param <T> |
414 | */ | 418 | */ |
415 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | 419 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { |
416 | observable.subscribeOn(Schedulers.io())//子线程访问网络 | 420 | observable.subscribeOn(Schedulers.io())//子线程访问网络 |
417 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 | 421 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 |
418 | .subscribe(observer); | 422 | .subscribe(observer); |
419 | } | 423 | } |
420 | 424 | ||
421 | } | 425 | } |
422 | 426 |