正在显示
24 个修改的文件
包含
413 行增加
和
13 行删除
@@ -10,8 +10,8 @@ import java.io.File | @@ -10,8 +10,8 @@ import java.io.File | ||
10 | */ | 10 | */ |
11 | object Constant { | 11 | object Constant { |
12 | // const val BASE_URL = "https://security.brofirst.cn/" | 12 | // const val BASE_URL = "https://security.brofirst.cn/" |
13 | -// const val BASE_URL = "http://security.brofirst.cn/" | ||
14 | - const val BASE_URL = "https://test.mobile.anqixing.com/" | 13 | + const val BASE_URL = "http://security.brofirst.cn/" |
14 | +// const val BASE_URL = "https://test.mobile.anqixing.com/" | ||
15 | // const val BASE_URL = "http://admin.anqixing.com" | 15 | // const val BASE_URL = "http://admin.anqixing.com" |
16 | const val USERNAME_KEY = "username" | 16 | const val USERNAME_KEY = "username" |
17 | const val USERID_KEY = "userid" | 17 | const val USERID_KEY = "userid" |
@@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.base.network.api | @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.base.network.api | ||
3 | import com.br_technology.securitytrain_master.base.network.response.* | 3 | import com.br_technology.securitytrain_master.base.network.response.* |
4 | import com.br_technology.securitytrain_master.ui.bean.* | 4 | import com.br_technology.securitytrain_master.ui.bean.* |
5 | import com.br_technology.securitytrain_master.ui.view.login.bean.LoginBean | 5 | import com.br_technology.securitytrain_master.ui.view.login.bean.LoginBean |
6 | +import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatDetailBean | ||
6 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean | 7 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean |
7 | import io.reactivex.rxjava3.core.Observable | 8 | import io.reactivex.rxjava3.core.Observable |
8 | import retrofit2.http.* | 9 | import retrofit2.http.* |
@@ -267,6 +268,33 @@ interface UserApi : ApiService { | @@ -267,6 +268,33 @@ interface UserApi : ApiService { | ||
267 | @Field("page_num") page_num: Int | 268 | @Field("page_num") page_num: Int |
268 | ): Observable<BaseResponse<CommonDataList<CommonPage<ChatRecordBean>>>> | 269 | ): Observable<BaseResponse<CommonDataList<CommonPage<ChatRecordBean>>>> |
269 | 270 | ||
271 | + | ||
272 | + /** | ||
273 | + * 教师消息列表 | ||
274 | + * @param page 页数 | ||
275 | + * @param page_num 每页显示数量 | ||
276 | + */ | ||
277 | + @FormUrlEncoded | ||
278 | + @POST("/api/teachermessage/msg_detail") | ||
279 | + fun msgDetail( | ||
280 | + @Field("page") page: Int, | ||
281 | + @Field("page_num") page_num: Int, | ||
282 | + @Field("teacher_id") teacherId: Int, | ||
283 | + ): Observable<BaseResponse<CommonDetail<CommonPage<ChatDetailBean>>>> | ||
284 | + | ||
285 | + /** | ||
286 | + * 教师消息列表 | ||
287 | + * @param page 页数 | ||
288 | + * @param page_num 每页显示数量 | ||
289 | + */ | ||
290 | + @FormUrlEncoded | ||
291 | + @POST("/api/teachermessage/return_msg") | ||
292 | + fun sendMsg( | ||
293 | + @Field("teacher_id") teacherId: Int, | ||
294 | + @Field("content") content: String, | ||
295 | + ): Observable<BaseResponse<Any>> | ||
296 | + | ||
297 | + | ||
270 | /** | 298 | /** |
271 | * 删除证件 | 299 | * 删除证件 |
272 | * @param id 证件id | 300 | * @param id 证件id |
@@ -10,6 +10,7 @@ import android.text.style.AbsoluteSizeSpan | @@ -10,6 +10,7 @@ import android.text.style.AbsoluteSizeSpan | ||
10 | import android.util.Log | 10 | import android.util.Log |
11 | import android.view.View | 11 | import android.view.View |
12 | import android.view.WindowManager | 12 | import android.view.WindowManager |
13 | +import android.view.inputmethod.InputMethodManager | ||
13 | import android.widget.TextView | 14 | import android.widget.TextView |
14 | import androidx.recyclerview.widget.RecyclerView | 15 | import androidx.recyclerview.widget.RecyclerView |
15 | 16 | ||
@@ -104,3 +105,8 @@ fun TextView.percentage() { | @@ -104,3 +105,8 @@ fun TextView.percentage() { | ||
104 | span.setSpan(AbsoluteSizeSpan(20.dp2px()),0,text.length-1,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | 105 | span.setSpan(AbsoluteSizeSpan(20.dp2px()),0,text.length-1,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) |
105 | this.text=span | 106 | this.text=span |
106 | } | 107 | } |
108 | + | ||
109 | +fun View.hideSoftInputFromWindow() { | ||
110 | + val inputMethodManager=this.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||
111 | + inputMethodManager.hideSoftInputFromWindow(this.windowToken,0) | ||
112 | +} |
@@ -76,7 +76,7 @@ class OnLiveCourseFragment | @@ -76,7 +76,7 @@ class OnLiveCourseFragment | ||
76 | if (status == "1") { | 76 | if (status == "1") { |
77 | url = adapter.data.get(position).playerUrl | 77 | url = adapter.data.get(position).playerUrl |
78 | } | 78 | } |
79 | - val title = adapter.data.get(position).name | 79 | + val title = adapter.data[position].name |
80 | val intent = Intent(requireActivity(), LiveWebActivity::class.java) | 80 | val intent = Intent(requireActivity(), LiveWebActivity::class.java) |
81 | intent.putExtra("url", url) | 81 | intent.putExtra("url", url) |
82 | intent.putExtra("title", title) | 82 | intent.putExtra("title", title) |
@@ -16,6 +16,7 @@ import com.br_technology.securitytrain_master.ui.view.home.adapter.SearchAdapter | @@ -16,6 +16,7 @@ import com.br_technology.securitytrain_master.ui.view.home.adapter.SearchAdapter | ||
16 | import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean | 16 | import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean |
17 | import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean | 17 | import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean |
18 | import com.br_technology.securitytrain_master.ui.view.home.viewmodel.ResultViewModel | 18 | import com.br_technology.securitytrain_master.ui.view.home.viewmodel.ResultViewModel |
19 | +import com.br_technology.securitytrain_master.ui.view.mine.activity.LiveWebActivity | ||
19 | import com.br_technology.securitytrain_master.util.TranslateUnit | 20 | import com.br_technology.securitytrain_master.util.TranslateUnit |
20 | import com.br_technology.securitytrain_master.view.VerticalDecoration | 21 | import com.br_technology.securitytrain_master.view.VerticalDecoration |
21 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment | 22 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment |
@@ -186,6 +187,13 @@ class ResultFragment(val type: Int) : | @@ -186,6 +187,13 @@ class ResultFragment(val type: Int) : | ||
186 | ) | 187 | ) |
187 | } | 188 | } |
188 | ResultViewModel.ResultType.TYPE_ONE -> { | 189 | ResultViewModel.ResultType.TYPE_ONE -> { |
190 | + | ||
191 | + //todo 直播未写 | ||
192 | +// val title = item.videoData | ||
193 | + val intent = Intent(requireActivity(), LiveWebActivity::class.java) | ||
194 | +// intent.putExtra("url", url) | ||
195 | +// intent.putExtra("title", title) | ||
196 | + startActivity(intent) | ||
189 | } | 197 | } |
190 | ResultViewModel.ResultType.TYPE_TWO -> { | 198 | ResultViewModel.ResultType.TYPE_TWO -> { |
191 | val course = CourseParam() | 199 | val course = CourseParam() |
@@ -7,6 +7,7 @@ import com.br_technology.securitytrain_master.databinding.ActivityMobileLoginBin | @@ -7,6 +7,7 @@ import com.br_technology.securitytrain_master.databinding.ActivityMobileLoginBin | ||
7 | import com.br_technology.securitytrain_master.isPhone | 7 | import com.br_technology.securitytrain_master.isPhone |
8 | import com.br_technology.securitytrain_master.ui.view.login.viewmode.MobileLoginViewModel | 8 | import com.br_technology.securitytrain_master.ui.view.login.viewmode.MobileLoginViewModel |
9 | import com.br_technology.securitytrain_master.ui.view.main.MainActivity | 9 | import com.br_technology.securitytrain_master.ui.view.main.MainActivity |
10 | +import com.br_technology.securitytrain_master.util.userId | ||
10 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | 11 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity |
11 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers | 12 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers |
12 | import io.reactivex.rxjava3.core.Flowable | 13 | import io.reactivex.rxjava3.core.Flowable |
1 | package com.br_technology.securitytrain_master.ui.view.mine.activity | 1 | package com.br_technology.securitytrain_master.ui.view.mine.activity |
2 | 2 | ||
3 | -import com.br_technology.securitytrain_master.databinding.ActivityChatRecordBinding | 3 | +import android.os.Handler |
4 | +import android.os.Looper | ||
5 | +import androidx.recyclerview.widget.LinearLayoutManager | ||
6 | +import com.br_technology.securitytrain_master.databinding.ActivityChatBinding | ||
7 | +import com.br_technology.securitytrain_master.expand.hideSoftInputFromWindow | ||
8 | +import com.br_technology.securitytrain_master.ui.view.mine.adapter.ChatAdapter | ||
9 | +import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatDetailBean | ||
4 | import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ChatRecordViewModel | 10 | import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ChatRecordViewModel |
11 | +import com.gyf.immersionbar.ImmersionBar | ||
12 | +import com.scwang.smart.refresh.header.ClassicsHeader | ||
5 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | 13 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity |
6 | 14 | ||
7 | /** | 15 | /** |
@@ -11,15 +19,80 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | @@ -11,15 +19,80 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | ||
11 | * updateInfo: | 19 | * updateInfo: |
12 | */ | 20 | */ |
13 | class ChatActivity : | 21 | class ChatActivity : |
14 | - BaseLifeCycleActivity<ChatRecordViewModel, ActivityChatRecordBinding>(ActivityChatRecordBinding::inflate) { | 22 | + BaseLifeCycleActivity<ChatRecordViewModel, ActivityChatBinding>(ActivityChatBinding::inflate) { |
23 | + | ||
24 | + companion object { | ||
25 | + init { | ||
26 | + ClassicsHeader.REFRESH_HEADER_PULLING = "下拉可以加载..."; | ||
27 | + ClassicsHeader.REFRESH_HEADER_REFRESHING = "正在加载..."; | ||
28 | + ClassicsHeader.REFRESH_HEADER_RELEASE = "释放立即加载"; | ||
29 | + ClassicsHeader.REFRESH_HEADER_FINISH = "加载完成"; | ||
30 | + ClassicsHeader.REFRESH_HEADER_FAILED = "加载失败"; | ||
31 | + } | ||
32 | + } | ||
33 | + | ||
34 | + val adapter: ChatAdapter by lazy { | ||
35 | + ChatAdapter() | ||
36 | + } | ||
37 | + private var page = 1 | ||
38 | + private var teacherId = -1 | ||
39 | + | ||
15 | override fun initDataObserver() { | 40 | override fun initDataObserver() { |
41 | + mViewModel.detailLiveData.observe(this) { | ||
42 | + it.data.detail.data.forEach { bean -> | ||
43 | + bean.itemType = if (bean.from_id_type == "1") 0 else 1 | ||
44 | + } | ||
16 | 45 | ||
46 | + if (it.data.detail.data.size < 10) { | ||
47 | + binding.smartRefresh.finishRefreshWithNoMoreData() | ||
48 | + } | ||
49 | + if (page == 1) { | ||
50 | + binding.chatRv.scrollToPosition(0) | ||
51 | + adapter.setNewInstance(it.data.detail.data as MutableList<ChatDetailBean>) | ||
52 | + } else { | ||
53 | + adapter.addData(it.data.detail.data) | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | + mViewModel.sendLiveData.observe(this) { | ||
58 | + showTip("发送成功") | ||
59 | + binding.root.hideSoftInputFromWindow() | ||
60 | + binding.chatSend.isClickable = true | ||
61 | + binding.chatContent.setText("") | ||
62 | + page = 1 | ||
63 | + // 请求网络 | ||
64 | + mViewModel.msgDetail(page, teacherId) | ||
65 | + } | ||
17 | } | 66 | } |
18 | 67 | ||
19 | override fun initData() { | 68 | override fun initData() { |
20 | super.initData() | 69 | super.initData() |
70 | + ImmersionBar.with(this).transparentStatusBar().keyboardEnable(true).statusBarDarkFont(true) | ||
71 | + .init() | ||
72 | + | ||
73 | + // 教师id | ||
74 | + teacherId = intent.getIntExtra("id", -1) | ||
75 | + // 请求网络 | ||
76 | + mViewModel.msgDetail(page, teacherId) | ||
21 | binding.apply { | 77 | binding.apply { |
22 | -// chatRv.adapter= | 78 | + |
79 | + smartRefresh.setOnRefreshListener { | ||
80 | + ++page | ||
81 | + mViewModel.msgDetail(page, teacherId) | ||
82 | + smartRefresh.finishRefresh() | ||
83 | + } | ||
84 | + // 倒叙显示 | ||
85 | + val manager = LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, true) | ||
86 | + manager.stackFromEnd = true | ||
87 | + chatRv.layoutManager = manager | ||
88 | + // 设置适配器 | ||
89 | + chatRv.adapter = adapter | ||
90 | + // 发送评论 | ||
91 | + chatSend.setOnClickListener { | ||
92 | + chatSend.isClickable = false | ||
93 | + val content = chatContent.text.toString() | ||
94 | + mViewModel.sendMsg(content, teacherId) | ||
95 | + } | ||
23 | } | 96 | } |
24 | } | 97 | } |
25 | } | 98 | } |
app/src/main/java/com/br_technology/securitytrain_master/ui/view/mine/activity/ChatRecordActivity.kt
1 | package com.br_technology.securitytrain_master.ui.view.mine.activity | 1 | package com.br_technology.securitytrain_master.ui.view.mine.activity |
2 | 2 | ||
3 | +import android.content.Intent | ||
3 | import com.br_technology.securitytrain_master.databinding.ActivityChatRecordBinding | 4 | import com.br_technology.securitytrain_master.databinding.ActivityChatRecordBinding |
4 | import com.br_technology.securitytrain_master.ui.view.mine.adapter.ChatRecordAdapter | 5 | import com.br_technology.securitytrain_master.ui.view.mine.adapter.ChatRecordAdapter |
5 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean | 6 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean |
@@ -36,7 +37,6 @@ class ChatRecordActivity : | @@ -36,7 +37,6 @@ class ChatRecordActivity : | ||
36 | super.initData() | 37 | super.initData() |
37 | 38 | ||
38 | binding.apply { | 39 | binding.apply { |
39 | - smartRefresh.autoRefresh() | ||
40 | // 刷新 | 40 | // 刷新 |
41 | smartRefresh.setOnRefreshListener { | 41 | smartRefresh.setOnRefreshListener { |
42 | smartRefresh.setNoMoreData(false) | 42 | smartRefresh.setNoMoreData(false) |
@@ -53,9 +53,16 @@ class ChatRecordActivity : | @@ -53,9 +53,16 @@ class ChatRecordActivity : | ||
53 | chatRv.adapter = chatRecordAdapter | 53 | chatRv.adapter = chatRecordAdapter |
54 | } | 54 | } |
55 | 55 | ||
56 | - chatRecordAdapter.setOnItemClickListener { adapter, view, position -> | ||
57 | - startActivity(ChatActivity::class.java) | 56 | + chatRecordAdapter.setOnItemClickListener { _, _, position -> |
57 | + val id = chatRecordAdapter.data[position].id | ||
58 | + val intent = Intent(baseContext,ChatActivity::class.java) | ||
59 | + intent.putExtra("id",id) | ||
60 | + startActivity(intent) | ||
58 | } | 61 | } |
59 | } | 62 | } |
60 | 63 | ||
64 | + override fun onResume() { | ||
65 | + super.onResume() | ||
66 | + binding.smartRefresh.autoRefresh() | ||
67 | + } | ||
61 | } | 68 | } |
app/src/main/java/com/br_technology/securitytrain_master/ui/view/mine/adapter/ChatAdapter.kt
0 → 100644
1 | +package com.br_technology.securitytrain_master.ui.view.mine.adapter | ||
2 | + | ||
3 | +import android.view.View | ||
4 | +import android.widget.TextView | ||
5 | +import com.br_technology.securitytrain_master.R | ||
6 | +import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatDetailBean | ||
7 | +import com.bumptech.glide.Glide | ||
8 | +import com.bumptech.glide.load.resource.bitmap.CircleCrop | ||
9 | +import com.bumptech.glide.request.RequestOptions | ||
10 | +import com.chad.library.adapter.base.BaseMultiItemQuickAdapter | ||
11 | +import com.chad.library.adapter.base.viewholder.BaseViewHolder | ||
12 | + | ||
13 | +/** | ||
14 | + * auth: 张继 | ||
15 | + * date: 2022/2/7 10:41 | ||
16 | + * dsc: | ||
17 | + * updateInfo: | ||
18 | + */ | ||
19 | +class ChatAdapter : BaseMultiItemQuickAdapter<ChatDetailBean, BaseViewHolder>() { | ||
20 | + | ||
21 | + override fun convert(baseViewHolder: BaseViewHolder, chatBean: ChatDetailBean) { | ||
22 | + when (chatBean.itemType) { | ||
23 | + 0 -> { | ||
24 | + baseViewHolder.setText(R.id.chat_content, chatBean.content) | ||
25 | + .setText(R.id.chat_time, chatBean.create_time) | ||
26 | + val chatTime = baseViewHolder.getView<TextView>(R.id.chat_time) | ||
27 | + if (chatBean.is_show_time == 0) { | ||
28 | + chatTime.visibility = View.GONE | ||
29 | + } else { | ||
30 | + chatTime.visibility = View.VISIBLE | ||
31 | + } | ||
32 | + Glide.with(baseViewHolder.itemView.context) | ||
33 | + .load(chatBean.avatar) | ||
34 | + .apply(RequestOptions().transform(CircleCrop())) | ||
35 | + .into(baseViewHolder.getView(R.id.chat_avatar)) | ||
36 | + } | ||
37 | + 1 -> { | ||
38 | + baseViewHolder.setText(R.id.chat_content, chatBean.content) | ||
39 | + .setText(R.id.chat_time, chatBean.create_time) | ||
40 | + val chatTime = baseViewHolder.getView<TextView>(R.id.chat_time) | ||
41 | + if (chatBean.is_show_time == 0) { | ||
42 | + chatTime.visibility = View.GONE | ||
43 | + } else { | ||
44 | + chatTime.visibility = View.VISIBLE | ||
45 | + } | ||
46 | + Glide.with(baseViewHolder.itemView.context) | ||
47 | + .load(chatBean.avatar) | ||
48 | + .apply(RequestOptions().transform(CircleCrop())) | ||
49 | + .into(baseViewHolder.getView(R.id.chat_avatar)) | ||
50 | + } | ||
51 | + } | ||
52 | + } | ||
53 | + | ||
54 | + init { | ||
55 | + addItemType(0, R.layout.chat_life_adapter) | ||
56 | + addItemType(1, R.layout.chat_right_adapter) | ||
57 | + } | ||
58 | +} |
1 | package com.br_technology.securitytrain_master.ui.view.mine.bean | 1 | package com.br_technology.securitytrain_master.ui.view.mine.bean |
2 | 2 | ||
3 | +import com.chad.library.adapter.base.entity.MultiItemEntity | ||
4 | + | ||
3 | /** | 5 | /** |
4 | * auth: 张继 | 6 | * auth: 张继 |
5 | * date: 2022/1/27 13:58 | 7 | * date: 2022/1/27 13:58 |
@@ -21,4 +23,21 @@ data class Teacher( | @@ -21,4 +23,21 @@ data class Teacher( | ||
21 | val gender_text: String, | 23 | val gender_text: String, |
22 | val name: String, | 24 | val name: String, |
23 | val update_time_text: String | 25 | val update_time_text: String |
24 | -) | ||
26 | +) | ||
27 | + | ||
28 | +data class ChatDetailBean( | ||
29 | + val avatar: String, | ||
30 | + val content: String, | ||
31 | + val create_time: String, | ||
32 | + val delete_time: String, | ||
33 | + val from_id: Int, | ||
34 | + val from_id_type: String, | ||
35 | + val from_id_type_text: String, | ||
36 | + val id: Int, | ||
37 | + val is_read: String, | ||
38 | + val is_read_text: String, | ||
39 | + val is_show_time: Int, | ||
40 | + val msg_id: Int, | ||
41 | + val to_id: Int, | ||
42 | + val update_time: String, override var itemType: Int | ||
43 | +):MultiItemEntity |
@@ -4,8 +4,10 @@ import androidx.lifecycle.MutableLiveData | @@ -4,8 +4,10 @@ import androidx.lifecycle.MutableLiveData | ||
4 | import com.br_technology.securitytrain_master.base.common.State | 4 | import com.br_technology.securitytrain_master.base.common.State |
5 | import com.br_technology.securitytrain_master.base.network.response.BaseResponse | 5 | import com.br_technology.securitytrain_master.base.network.response.BaseResponse |
6 | import com.br_technology.securitytrain_master.base.network.response.CommonDataList | 6 | import com.br_technology.securitytrain_master.base.network.response.CommonDataList |
7 | +import com.br_technology.securitytrain_master.base.network.response.CommonDetail | ||
7 | import com.br_technology.securitytrain_master.base.network.response.CommonPage | 8 | import com.br_technology.securitytrain_master.base.network.response.CommonPage |
8 | import com.br_technology.securitytrain_master.base.repository.ApiRepository | 9 | import com.br_technology.securitytrain_master.base.repository.ApiRepository |
10 | +import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatDetailBean | ||
9 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean | 11 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean |
10 | 12 | ||
11 | /** | 13 | /** |
@@ -24,5 +26,21 @@ class ChatRepository(val loadState: MutableLiveData<State>) : ApiRepository(load | @@ -24,5 +26,21 @@ class ChatRepository(val loadState: MutableLiveData<State>) : ApiRepository(load | ||
24 | addRequest(userService.msgList(page, 20), liveData) | 26 | addRequest(userService.msgList(page, 20), liveData) |
25 | } | 27 | } |
26 | 28 | ||
29 | + fun msgDetail( | ||
30 | + page: Int, | ||
31 | + teacherId: Int, | ||
32 | + liveData: MutableLiveData<BaseResponse<CommonDetail<CommonPage<ChatDetailBean>>>> | ||
33 | + ) { | ||
34 | + addRequest(userService.msgDetail(page, 10, teacherId), liveData) | ||
35 | + } | ||
36 | + | ||
37 | + fun sendMsg( | ||
38 | + content: String, | ||
39 | + teacherId: Int, | ||
40 | + liveData: MutableLiveData<BaseResponse<Any>> | ||
41 | + ) { | ||
42 | + addRequest(userService.sendMsg(teacherId, content), liveData) | ||
43 | + } | ||
44 | + | ||
27 | 45 | ||
28 | } | 46 | } |
@@ -3,8 +3,10 @@ package com.br_technology.securitytrain_master.ui.view.mine.viewmodel | @@ -3,8 +3,10 @@ package com.br_technology.securitytrain_master.ui.view.mine.viewmodel | ||
3 | import androidx.lifecycle.MutableLiveData | 3 | import androidx.lifecycle.MutableLiveData |
4 | import com.br_technology.securitytrain_master.base.network.response.BaseResponse | 4 | import com.br_technology.securitytrain_master.base.network.response.BaseResponse |
5 | import com.br_technology.securitytrain_master.base.network.response.CommonDataList | 5 | import com.br_technology.securitytrain_master.base.network.response.CommonDataList |
6 | +import com.br_technology.securitytrain_master.base.network.response.CommonDetail | ||
6 | import com.br_technology.securitytrain_master.base.network.response.CommonPage | 7 | import com.br_technology.securitytrain_master.base.network.response.CommonPage |
7 | import com.br_technology.securitytrain_master.base.view.BaseViewModel | 8 | import com.br_technology.securitytrain_master.base.view.BaseViewModel |
9 | +import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatDetailBean | ||
8 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean | 10 | import com.br_technology.securitytrain_master.ui.view.mine.bean.ChatRecordBean |
9 | import com.br_technology.securitytrain_master.ui.view.mine.repository.ChatRepository | 11 | import com.br_technology.securitytrain_master.ui.view.mine.repository.ChatRepository |
10 | 12 | ||
@@ -18,7 +20,20 @@ class ChatRecordViewModel : BaseViewModel<ChatRepository>() { | @@ -18,7 +20,20 @@ class ChatRecordViewModel : BaseViewModel<ChatRepository>() { | ||
18 | val liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<ChatRecordBean>>>> = | 20 | val liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<ChatRecordBean>>>> = |
19 | MutableLiveData() | 21 | MutableLiveData() |
20 | 22 | ||
23 | + val detailLiveData: MutableLiveData<BaseResponse<CommonDetail<CommonPage<ChatDetailBean>>>> = | ||
24 | + MutableLiveData() | ||
25 | + val sendLiveData: MutableLiveData<BaseResponse<Any>> = MutableLiveData() | ||
26 | + | ||
21 | fun msgList(page: Int) { | 27 | fun msgList(page: Int) { |
22 | mRepository.msgList(page, liveData) | 28 | mRepository.msgList(page, liveData) |
23 | } | 29 | } |
30 | + | ||
31 | + fun msgDetail(page: Int, teacherId: Int) { | ||
32 | + mRepository.msgDetail(page, teacherId, detailLiveData) | ||
33 | + } | ||
34 | + | ||
35 | + | ||
36 | + fun sendMsg(content: String, teacherId: Int) { | ||
37 | + mRepository.sendMsg(content, teacherId, sendLiveData) | ||
38 | + } | ||
24 | } | 39 | } |
app/src/main/res/drawable/stroke_ed_4.xml
0 → 100644
app/src/main/res/layout/activity_chat.xml
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + android:layout_width="match_parent" | ||
5 | + android:layout_height="match_parent" | ||
6 | + android:orientation="vertical"> | ||
7 | + | ||
8 | + <include layout="@layout/layout_tool_bar" /> | ||
9 | + | ||
10 | + <com.br_technology.securitytrain_master.view.ViewToolBar | ||
11 | + android:id="@+id/tool_bar" | ||
12 | + android:layout_width="match_parent" | ||
13 | + android:layout_height="wrap_content" | ||
14 | + app:toolTitle="聊天记录" /> | ||
15 | + | ||
16 | + <com.scwang.smart.refresh.layout.SmartRefreshLayout | ||
17 | + android:id="@+id/smart_refresh" | ||
18 | + android:layout_width="match_parent" | ||
19 | + android:layout_height="0dp" | ||
20 | + android:layout_weight="1" | ||
21 | + app:srlEnableLoadMore="false"> | ||
22 | + | ||
23 | + <androidx.recyclerview.widget.RecyclerView | ||
24 | + android:id="@+id/chat_rv" | ||
25 | + android:layout_width="match_parent" | ||
26 | + android:layout_height="match_parent" | ||
27 | + android:layout_marginHorizontal="16dp" | ||
28 | + android:layout_marginTop="1dp" | ||
29 | + android:layout_marginBottom="15dp" | ||
30 | + android:overScrollMode="never" /> | ||
31 | + </com.scwang.smart.refresh.layout.SmartRefreshLayout> | ||
32 | + | ||
33 | + | ||
34 | + <androidx.appcompat.widget.LinearLayoutCompat | ||
35 | + android:layout_width="match_parent" | ||
36 | + android:layout_height="60dp" | ||
37 | + android:background="@color/white" | ||
38 | + android:orientation="horizontal" | ||
39 | + android:paddingHorizontal="16dp"> | ||
40 | + | ||
41 | + <androidx.appcompat.widget.AppCompatEditText | ||
42 | + android:id="@+id/chat_content" | ||
43 | + android:layout_width="0dp" | ||
44 | + android:layout_height="match_parent" | ||
45 | + android:layout_marginVertical="10dp" | ||
46 | + android:layout_weight="1" | ||
47 | + android:background="@drawable/stroke_ed_4" | ||
48 | + android:hint="输入新消息" | ||
49 | + android:textSize="14sp" | ||
50 | + android:singleLine="true" | ||
51 | + android:paddingHorizontal="10dp" /> | ||
52 | + | ||
53 | + <TextView | ||
54 | + android:id="@+id/chat_send" | ||
55 | + android:layout_width="80dp" | ||
56 | + android:layout_height="40dp" | ||
57 | + android:layout_gravity="center_vertical" | ||
58 | + android:layout_marginStart="15dp" | ||
59 | + android:background="@drawable/solid_25_4" | ||
60 | + android:gravity="center" | ||
61 | + android:text="发送" | ||
62 | + android:textColor="@color/white" | ||
63 | + android:textSize="16sp" /> | ||
64 | + | ||
65 | + </androidx.appcompat.widget.LinearLayoutCompat> | ||
66 | + | ||
67 | + | ||
68 | +</androidx.appcompat.widget.LinearLayoutCompat> |
@@ -23,8 +23,8 @@ | @@ -23,8 +23,8 @@ | ||
23 | android:layout_width="match_parent" | 23 | android:layout_width="match_parent" |
24 | android:layout_height="match_parent" | 24 | android:layout_height="match_parent" |
25 | android:layout_marginHorizontal="16dp" | 25 | android:layout_marginHorizontal="16dp" |
26 | - android:layout_marginTop="16dp" | ||
27 | - android:overScrollMode="never" | ||
28 | - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | 26 | + android:layout_marginTop="1dp" |
27 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
28 | + android:overScrollMode="never" /> | ||
29 | </com.scwang.smart.refresh.layout.SmartRefreshLayout> | 29 | </com.scwang.smart.refresh.layout.SmartRefreshLayout> |
30 | </androidx.appcompat.widget.LinearLayoutCompat> | 30 | </androidx.appcompat.widget.LinearLayoutCompat> |
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
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_marginTop="15dp" | ||
5 | android:layout_height="wrap_content"> | 6 | android:layout_height="wrap_content"> |
6 | 7 | ||
7 | 8 | ||
@@ -54,4 +55,5 @@ | @@ -54,4 +55,5 @@ | ||
54 | android:layout_marginVertical="15dp" | 55 | android:layout_marginVertical="15dp" |
55 | android:background="@color/color_eb" | 56 | android:background="@color/color_eb" |
56 | app:layout_constraintTop_toBottomOf="@id/chat_content" /> | 57 | app:layout_constraintTop_toBottomOf="@id/chat_content" /> |
58 | + | ||
57 | </androidx.constraintlayout.widget.ConstraintLayout> | 59 | </androidx.constraintlayout.widget.ConstraintLayout> |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + xmlns:tools="http://schemas.android.com/tools" | ||
5 | + android:layout_width="match_parent" | ||
6 | + android:layout_height="wrap_content"> | ||
7 | + | ||
8 | + | ||
9 | + <TextView | ||
10 | + android:id="@+id/chat_time" | ||
11 | + android:layout_marginTop="15dp" | ||
12 | + android:layout_width="match_parent" | ||
13 | + android:layout_height="wrap_content" | ||
14 | + android:gravity="center" | ||
15 | + android:textColor="@color/color_96" | ||
16 | + android:textSize="12sp" | ||
17 | + app:layout_constraintEnd_toEndOf="parent" | ||
18 | + app:layout_constraintStart_toStartOf="parent" | ||
19 | + app:layout_constraintTop_toTopOf="parent" /> | ||
20 | + | ||
21 | + <ImageView | ||
22 | + android:id="@+id/chat_avatar" | ||
23 | + android:layout_width="36dp" | ||
24 | + android:layout_height="36dp" | ||
25 | + android:layout_marginTop="15dp" | ||
26 | + android:contentDescription="@string/logo" | ||
27 | + app:layout_constraintStart_toStartOf="parent" | ||
28 | + app:layout_constraintTop_toBottomOf="@+id/chat_time" | ||
29 | + app:srcCompat="@mipmap/placeholder_head" /> | ||
30 | + | ||
31 | + <TextView | ||
32 | + android:id="@+id/chat_content" | ||
33 | + android:layout_width="wrap_content" | ||
34 | + android:layout_height="wrap_content" | ||
35 | + android:layout_marginStart="15dp" | ||
36 | + android:padding="12dp" | ||
37 | + android:layout_marginTop="15dp" | ||
38 | + android:textColor="@color/color_32" | ||
39 | + android:background="@drawable/solid_ff_4" | ||
40 | + android:textSize="15sp" | ||
41 | + app:layout_constraintStart_toEndOf="@+id/chat_avatar" | ||
42 | + app:layout_constraintTop_toBottomOf="@+id/chat_time" /> | ||
43 | + | ||
44 | + | ||
45 | +</androidx.constraintlayout.widget.ConstraintLayout> |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + android:layout_width="match_parent" | ||
5 | + android:layout_height="wrap_content"> | ||
6 | + | ||
7 | + | ||
8 | + <TextView | ||
9 | + android:id="@+id/chat_time" | ||
10 | + android:layout_marginTop="15dp" | ||
11 | + android:layout_width="match_parent" | ||
12 | + android:layout_height="wrap_content" | ||
13 | + android:gravity="center" | ||
14 | + android:textColor="@color/color_96" | ||
15 | + android:textSize="12sp" | ||
16 | + app:layout_constraintEnd_toEndOf="parent" | ||
17 | + app:layout_constraintStart_toStartOf="parent" | ||
18 | + app:layout_constraintTop_toTopOf="parent" /> | ||
19 | + | ||
20 | + <ImageView | ||
21 | + android:id="@+id/chat_avatar" | ||
22 | + android:layout_width="36dp" | ||
23 | + android:layout_height="36dp" | ||
24 | + android:layout_marginTop="15dp" | ||
25 | + android:contentDescription="@string/logo" | ||
26 | + app:layout_constraintEnd_toEndOf="parent" | ||
27 | + app:layout_constraintTop_toBottomOf="@+id/chat_time" | ||
28 | + app:srcCompat="@mipmap/placeholder_head" /> | ||
29 | + | ||
30 | + <TextView | ||
31 | + android:id="@+id/chat_content" | ||
32 | + android:layout_width="wrap_content" | ||
33 | + android:layout_height="wrap_content" | ||
34 | + android:layout_marginTop="15dp" | ||
35 | + android:layout_marginEnd="15dp" | ||
36 | + android:background="@drawable/solid_ff_4" | ||
37 | + android:padding="12dp" | ||
38 | + android:textColor="@color/color_32" | ||
39 | + android:textSize="15sp" | ||
40 | + app:layout_constraintEnd_toStartOf="@+id/chat_avatar" | ||
41 | + app:layout_constraintTop_toBottomOf="@+id/chat_time" /> | ||
42 | + | ||
43 | + | ||
44 | +</androidx.constraintlayout.widget.ConstraintLayout> |
-
请 注册 或 登录 后发表评论