作者 杨谦

1.搜索

2.todo:班级任务跳转条件限制未知,我的各个页面数据业务逻辑未知
正在显示 18 个修改的文件 包含 607 行增加107 行删除
1 package com.br_technology.securitytrain_master.base.network.api 1 package com.br_technology.securitytrain_master.base.network.api
2 2
  3 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  4 +import com.br_technology.securitytrain_master.base.network.response.CommonList
3 import com.br_technology.securitytrain_master.ui.bean.RegisterCompany 5 import com.br_technology.securitytrain_master.ui.bean.RegisterCompany
4 import com.br_technology.securitytrain_master.ui.bean.SearchLog 6 import com.br_technology.securitytrain_master.ui.bean.SearchLog
5 import com.br_technology.securitytrain_master.ui.bean.UserRule 7 import com.br_technology.securitytrain_master.ui.bean.UserRule
6 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse  
7 -import com.br_technology.securitytrain_master.base.network.response.CommonList  
8 import io.reactivex.rxjava3.core.Observable 8 import io.reactivex.rxjava3.core.Observable
9 import retrofit2.http.* 9 import retrofit2.http.*
10 10
@@ -53,14 +53,12 @@ interface CommonApi : ApiService { @@ -53,14 +53,12 @@ interface CommonApi : ApiService {
53 /** 53 /**
54 * 历史搜索记录 54 * 历史搜索记录
55 */ 55 */
56 - @FormUrlEncoded  
57 @POST("/api/common/search_log") 56 @POST("/api/common/search_log")
58 fun searchLog(): Observable<BaseResponse<CommonList<SearchLog>>> 57 fun searchLog(): Observable<BaseResponse<CommonList<SearchLog>>>
59 58
60 /** 59 /**
61 * 清除搜索记录 60 * 清除搜索记录
62 */ 61 */
63 - @FormUrlEncoded  
64 @POST("/api/common/search_log_clear") 62 @POST("/api/common/search_log_clear")
65 fun searchLogClear(): Observable<BaseResponse<CommonList<SearchLog>>> 63 fun searchLogClear(): Observable<BaseResponse<CommonList<SearchLog>>>
66 64
1 package com.br_technology.securitytrain_master.base.network.api 1 package com.br_technology.securitytrain_master.base.network.api
2 2
3 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse  
4 -import com.br_technology.securitytrain_master.base.network.response.CommonDetail  
5 -import com.br_technology.securitytrain_master.base.network.response.CommonList 3 +import com.br_technology.securitytrain_master.base.network.response.*
6 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.home.bean.VideoLessonBean
7 import io.reactivex.rxjava3.core.Observable 6 import io.reactivex.rxjava3.core.Observable
8 import retrofit2.http.Field 7 import retrofit2.http.Field
9 import retrofit2.http.FieldMap 8 import retrofit2.http.FieldMap
@@ -31,7 +30,7 @@ interface LessonApi : ApiService { @@ -31,7 +30,7 @@ interface LessonApi : ApiService {
31 @Field("pos_id") pos_id: Int, 30 @Field("pos_id") pos_id: Int,
32 @Field("page") page: Int, 31 @Field("page") page: Int,
33 @Field("page_num") page_num: Int, 32 @Field("page_num") page_num: Int,
34 - ): Observable<BaseResponse<CommonList<LessonBean>>> 33 + ): Observable<BaseResponse<CommonDataList<CommonPage<LessonBean>>>>
35 34
36 /** 35 /**
37 * 文本课程详情 36 * 文本课程详情
@@ -61,7 +60,7 @@ interface LessonApi : ApiService { @@ -61,7 +60,7 @@ interface LessonApi : ApiService {
61 @Field("pos_id") pos_id: String, // 工种id 60 @Field("pos_id") pos_id: String, // 工种id
62 @Field("page") page: Int, 61 @Field("page") page: Int,
63 @Field("page_num") page_num: Int, 62 @Field("page_num") page_num: Int,
64 - ): Observable<BaseResponse<CommonList<LessonVideo>>> 63 + ): Observable<BaseResponse<CommonDataList<CommonPage<LessonVideo>>>>
65 64
66 /** 65 /**
67 * 视频课程详情 66 * 视频课程详情
@@ -88,6 +87,38 @@ interface LessonApi : ApiService { @@ -88,6 +87,38 @@ interface LessonApi : ApiService {
88 ): Observable<BaseResponse<CommonDetail<LessonClassDetail>>> 87 ): Observable<BaseResponse<CommonDetail<LessonClassDetail>>>
89 88
90 /** 89 /**
  90 + * 资料库列表
  91 + * @param keyword 搜索关键词
  92 + * @param page 页数
  93 + * @param page_num 每页显示数量
  94 + */
  95 + @FormUrlEncoded
  96 + @POST("/api/material/material_list")
  97 + fun searchDocList(
  98 + @Field("keyword") keyword: String,
  99 + @Field("sort_id") sort_id: Int,
  100 + @Field("page") page: Int,
  101 + @Field("page_num") page_num: Int
  102 + ): Observable<BaseResponse<MaterialPage>>
  103 +
  104 + /**
  105 + * 视频课程列表
  106 + * @param is_rec: Int, // 是否为推荐课程0=否1=是
  107 + * @param keyword: String, // 搜索关键词
  108 + * @param pos_id: String, // 工种id
  109 + * @param page 页数
  110 + * @param page_num 每页显示数量
  111 + */
  112 + @FormUrlEncoded
  113 + @POST("/api/lesson/lesson")
  114 + fun searchVideoList(
  115 + @Field("keyword") keyword: String, // 搜索关键词
  116 + @Field("pos_id") pos_id: String, // 工种id
  117 + @Field("page") page: Int,
  118 + @Field("page_num") page_num: Int,
  119 + ): Observable<BaseResponse<VideoLessonBean>>
  120 +
  121 + /**
91 * 直播课程列表 122 * 直播课程列表
92 * @param keyword 搜索关键词 123 * @param keyword 搜索关键词
93 * @param type 直播类型1=正在直播2=回放直播3=即将开播 124 * @param type 直播类型1=正在直播2=回放直播3=即将开播
@@ -101,7 +132,22 @@ interface LessonApi : ApiService { @@ -101,7 +132,22 @@ interface LessonApi : ApiService {
101 @Field("type") type: Int, // 直播类型1=正在直播2=回放直播3=即将开播 132 @Field("type") type: Int, // 直播类型1=正在直播2=回放直播3=即将开播
102 @Field("page") page: String, 133 @Field("page") page: String,
103 @Field("page_num") page_num: String, 134 @Field("page_num") page_num: String,
104 - ): Observable<BaseResponse<CommonList<LessonLive>>> 135 + ): Observable<BaseResponse<CommonDataList<CommonPage<LessonLive>>>>
  136 +
  137 + /**
  138 + * 直播课程列表
  139 + * @param keyword 搜索关键词
  140 + * @param type 直播类型1=正在直播2=回放直播3=即将开播
  141 + * @param page 页数
  142 + * @param page_num 每页显示数量
  143 + */
  144 + @FormUrlEncoded
  145 + @POST("/api/lesson/lesson_live")
  146 + fun lessonLiveList(
  147 + @Field("keyword") keyword: String, // 搜索关键词
  148 + @Field("page") page: String,
  149 + @Field("page_num") page_num: String,
  150 + ): Observable<BaseResponse<CommonDataList<CommonPage<LessonLive>>>>
105 151
106 /** 152 /**
107 * 直播课程详情 153 * 直播课程详情
@@ -3,10 +3,12 @@ package com.br_technology.securitytrain_master.base.repository @@ -3,10 +3,12 @@ package com.br_technology.securitytrain_master.base.repository
3 import androidx.lifecycle.MutableLiveData 3 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.CommonDetail 7 import com.br_technology.securitytrain_master.base.network.response.CommonDetail
7 -import com.br_technology.securitytrain_master.base.network.response.CommonList 8 +import com.br_technology.securitytrain_master.base.network.response.CommonPage
8 import com.br_technology.securitytrain_master.ui.bean.* 9 import com.br_technology.securitytrain_master.ui.bean.*
9 import com.br_technology.securitytrain_master.ui.view.home.bean.TextLessonDetailBean 10 import com.br_technology.securitytrain_master.ui.view.home.bean.TextLessonDetailBean
  11 +import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
10 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean 12 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
11 13
12 /** 14 /**
@@ -27,7 +29,7 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt @@ -27,7 +29,7 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt
27 keyword: String, 29 keyword: String,
28 pos_id: Int, 30 pos_id: Int,
29 page: Int, page_num: Int, 31 page: Int, page_num: Int,
30 - liveData: MutableLiveData<BaseResponse<CommonList<LessonBean>>> 32 + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<LessonBean>>>>
31 ) { 33 ) {
32 addRequest(lessonService.lessonTxtList(keyword, pos_id, page, page_num), liveData) 34 addRequest(lessonService.lessonTxtList(keyword, pos_id, page, page_num), liveData)
33 } 35 }
@@ -52,7 +54,7 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt @@ -52,7 +54,7 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt
52 pos_id: String, 54 pos_id: String,
53 page: Int, 55 page: Int,
54 page_num: Int, 56 page_num: Int,
55 - liveData: MutableLiveData<BaseResponse<CommonList<LessonVideo>>> 57 + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<LessonVideo>>>>
56 ) { 58 ) {
57 addRequest(lessonService.lessonVideoList(is_rec, keyword, pos_id, page, page_num), liveData) 59 addRequest(lessonService.lessonVideoList(is_rec, keyword, pos_id, page, page_num), liveData)
58 } 60 }
@@ -76,11 +78,48 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt @@ -76,11 +78,48 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt
76 type: Int, 78 type: Int,
77 page: String, 79 page: String,
78 page_num: String, 80 page_num: String,
79 - liveData: MutableLiveData<BaseResponse<CommonList<LessonLive>>> 81 + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<LessonLive>>>>
80 ) { 82 ) {
81 addRequest(lessonService.lessonLiveList(keyword, type, page, page_num), liveData) 83 addRequest(lessonService.lessonLiveList(keyword, type, page, page_num), liveData)
82 } 84 }
83 85
  86 + fun searchLiveList(
  87 + keyword: String,
  88 + page: String,
  89 + page_num: String,
  90 + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<LessonLive>>>>
  91 + ) {
  92 + addRequest(lessonService.lessonLiveList(keyword, page, page_num), liveData)
  93 + }
  94 +
  95 + fun searchVideoList(
  96 + keyword: String,
  97 + pos_id: String,
  98 + page: Int,
  99 + page_num: Int,
  100 + liveData: MutableLiveData<BaseResponse<VideoLessonBean>>
  101 + ) {
  102 + addRequest(lessonService.searchVideoList(keyword, pos_id, page, page_num), liveData)
  103 + }
  104 +
  105 + fun searchTxtList(
  106 + keyword: String,
  107 + pos_id: Int,
  108 + page: Int, page_num: Int,
  109 + liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<LessonBean>>>>
  110 + ) {
  111 + addRequest(lessonService.lessonTxtList(keyword, pos_id, page, page_num), liveData)
  112 + }
  113 +
  114 + fun searchMaterialList(
  115 + keyword: String,
  116 + pos_id: Int,
  117 + page: Int, page_num: Int,
  118 + liveData: MutableLiveData<BaseResponse<MaterialPage>>
  119 + ) {
  120 + addRequest(lessonService.searchDocList(keyword, pos_id, page, page_num), liveData)
  121 + }
  122 +
84 fun lessonLiveDetail( 123 fun lessonLiveDetail(
85 id: Int, 124 id: Int,
86 liveData: MutableLiveData<BaseResponse<CommonDetail<LessonLive>>> 125 liveData: MutableLiveData<BaseResponse<CommonDetail<LessonLive>>>
1 package com.br_technology.securitytrain_master.ui.bean 1 package com.br_technology.securitytrain_master.ui.bean
2 2
  3 +import java.io.Serializable
  4 +
3 /** 5 /**
4 * Author by YSir 6 * Author by YSir
5 * Date on 2022/1/8. 7 * Date on 2022/1/8.
@@ -18,7 +20,7 @@ open class Teacher( @@ -18,7 +20,7 @@ open class Teacher(
18 var id: Int, 20 var id: Int,
19 var name: String,//"测试讲师2", // 讲师名称 21 var name: String,//"测试讲师2", // 讲师名称
20 var avatar: String//"http://security.cn/assets/img/avatar.png" // 讲师头像 22 var avatar: String//"http://security.cn/assets/img/avatar.png" // 讲师头像
21 -) 23 +) : Serializable
22 24
23 //注册企业 25 //注册企业
24 open class RegisterCompany( 26 open class RegisterCompany(
@@ -2,6 +2,8 @@ package com.br_technology.securitytrain_master.ui.bean @@ -2,6 +2,8 @@ package com.br_technology.securitytrain_master.ui.bean
2 2
3 import android.os.Parcel 3 import android.os.Parcel
4 import android.os.Parcelable 4 import android.os.Parcelable
  5 +import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean
  6 +import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
5 import com.chad.library.adapter.base.entity.MultiItemEntity 7 import com.chad.library.adapter.base.entity.MultiItemEntity
6 8
7 /** 9 /**
@@ -134,3 +136,15 @@ open class TrainCourseDetailItemChild(var type: Int, var pos: Int) : MultiItemEn @@ -134,3 +136,15 @@ open class TrainCourseDetailItemChild(var type: Int, var pos: Int) : MultiItemEn
134 get() = type 136 get() = type
135 } 137 }
136 138
  139 +open class SearchEvent(var search: String)
  140 +
  141 +open class SearchBean(var type: Int) : MultiItemEntity {
  142 + var txtData: LessonBean? = null
  143 + var videoData: VideoLessonBean.ListBean.DataBean? = null
  144 + var liveData: LessonLive? = null
  145 + var materialData: RecommendBean.ListBean? = null
  146 +
  147 + override val itemType: Int
  148 + get() = type
  149 +}
  150 +
@@ -3,14 +3,18 @@ package com.br_technology.securitytrain_master.ui.view.home.activity @@ -3,14 +3,18 @@ package com.br_technology.securitytrain_master.ui.view.home.activity
3 import android.os.Bundle 3 import android.os.Bundle
4 import android.view.View 4 import android.view.View
5 import androidx.fragment.app.FragmentPagerAdapter 5 import androidx.fragment.app.FragmentPagerAdapter
  6 +import com.br_technology.securitytrain_master.base.view.BasePagerAdapter
6 import com.br_technology.securitytrain_master.databinding.ActivitySearchBinding 7 import com.br_technology.securitytrain_master.databinding.ActivitySearchBinding
  8 +import com.br_technology.securitytrain_master.ui.bean.SearchEvent
  9 +import com.br_technology.securitytrain_master.ui.bean.SearchLog
7 import com.br_technology.securitytrain_master.ui.view.home.adapter.HistoryAdapter 10 import com.br_technology.securitytrain_master.ui.view.home.adapter.HistoryAdapter
8 -import com.br_technology.securitytrain_master.base.view.BasePagerAdapter  
9 import com.br_technology.securitytrain_master.ui.view.home.fragment.ResultFragment 11 import com.br_technology.securitytrain_master.ui.view.home.fragment.ResultFragment
10 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.SearchViewModel 12 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.SearchViewModel
11 import com.br_technology.securitytrain_master.view.DialogSureCancel 13 import com.br_technology.securitytrain_master.view.DialogSureCancel
12 import com.br_technology.securitytrain_master.view.listener.DialogListener 14 import com.br_technology.securitytrain_master.view.listener.DialogListener
  15 +import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
13 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 16 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
  17 +import org.greenrobot.eventbus.EventBus
14 18
15 /** 19 /**
16 * createTime:2021/7/28 11:13 20 * createTime:2021/7/28 11:13
@@ -26,23 +30,12 @@ class SearchActivity : @@ -26,23 +30,12 @@ class SearchActivity :
26 finish() 30 finish()
27 } 31 }
28 32
29 - val historyAdapter = HistoryAdapter()  
30 - historyRecycler.adapter = historyAdapter  
31 - val listOf = listOf(  
32 - "历史标签记录历史标签记录历史标签记录历史标签记录",  
33 - "历史标签记录",  
34 - "历史标签记录",  
35 - "d",  
36 - "历史标签记录历史标签记录",  
37 - "历史标签记录历史标签记录历史标签记录",  
38 - "历史标签记录历史标签记录历史标签记录历史标签记录",  
39 - )  
40 - historyAdapter.addList(listOf)  
41 // 清空历史记录 33 // 清空历史记录
42 clear.setOnClickListener { 34 clear.setOnClickListener {
43 - DialogSureCancel(it.context).setListener(object : DialogListener { 35 + DialogSureCancel(this@SearchActivity).setListener(object : DialogListener {
44 override fun determine() { 36 override fun determine() {
45 // 清空记录 37 // 清空记录
  38 + mViewModel.clearLog()
46 } 39 }
47 }).show() 40 }).show()
48 } 41 }
@@ -57,6 +50,7 @@ class SearchActivity : @@ -57,6 +50,7 @@ class SearchActivity :
57 historyRecycler.visibility = View.GONE 50 historyRecycler.visibility = View.GONE
58 tabLayout.visibility = View.VISIBLE 51 tabLayout.visibility = View.VISIBLE
59 viewPager.visibility = View.VISIBLE 52 viewPager.visibility = View.VISIBLE
  53 + EventBus.getDefault().post(SearchEvent(searchEdit.text.toString()))
60 } 54 }
61 55
62 searchEdit.setOnClickListener { 56 searchEdit.setOnClickListener {
@@ -72,18 +66,43 @@ class SearchActivity : @@ -72,18 +66,43 @@ class SearchActivity :
72 FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT 66 FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
73 ) 67 )
74 val list = 68 val list =
75 - mutableListOf(ResultFragment(), ResultFragment(), ResultFragment(), ResultFragment()) 69 + mutableListOf(
  70 + ResultFragment(0),
  71 + ResultFragment(1),
  72 + ResultFragment(2),
  73 + ResultFragment(3)
  74 + )
76 val titles = listOf("在线课程", "直播课程", "文本课程", "资料库") 75 val titles = listOf("在线课程", "直播课程", "文本课程", "资料库")
77 searchResultAdapter.addData(list.toMutableList()) 76 searchResultAdapter.addData(list.toMutableList())
78 searchResultAdapter.addTitle(titles) 77 searchResultAdapter.addTitle(titles)
79 viewPager.adapter = searchResultAdapter 78 viewPager.adapter = searchResultAdapter
  79 + viewPager.offscreenPageLimit = 3
80 tabLayout.setupWithViewPager(viewPager) 80 tabLayout.setupWithViewPager(viewPager)
81 -  
82 -  
83 } 81 }
84 } 82 }
85 83
86 - override fun initDataObserver() { 84 + override fun initData() {
  85 + super.initData()
  86 + mViewModel.searchLog()
  87 + }
87 88
  89 + override fun initDataObserver() {
  90 + mViewModel.liveData.observe(this, {
  91 + val historyAdapter = HistoryAdapter()
  92 + binding.historyRecycler.adapter = historyAdapter
  93 + historyAdapter.addList(it.data.list)
  94 + historyAdapter.addListener(object : OnItemClickListener<SearchLog> {
  95 + override fun onClick(position: Int, data: SearchLog) {
  96 + EventBus.getDefault().post(SearchEvent(data.keyword))
  97 + binding.historyRecycler.visibility = View.GONE
  98 + binding.historyGroup.visibility = View.GONE
  99 + binding.tabLayout.visibility = View.VISIBLE
  100 + binding.viewPager.visibility = View.VISIBLE
  101 + }
  102 + })
  103 + })
  104 + mViewModel.clearData.observe(this, {
  105 + mViewModel.searchLog()
  106 + })
88 } 107 }
89 } 108 }
@@ -5,16 +5,17 @@ import android.view.LayoutInflater @@ -5,16 +5,17 @@ import android.view.LayoutInflater
5 import android.view.ViewGroup 5 import android.view.ViewGroup
6 import com.br_technology.securitytrain_master.base.view.BaseAdapter 6 import com.br_technology.securitytrain_master.base.view.BaseAdapter
7 import com.br_technology.securitytrain_master.databinding.AdapterHistoryBinding 7 import com.br_technology.securitytrain_master.databinding.AdapterHistoryBinding
  8 +import com.br_technology.securitytrain_master.ui.bean.SearchLog
8 9
9 /** 10 /**
10 * createTime:2021/7/28 11:50 11 * createTime:2021/7/28 11:50
11 * auth:张继 12 * auth:张继
12 * des: 13 * des:
13 */ 14 */
14 -class HistoryAdapter : BaseAdapter<String, AdapterHistoryBinding>() { 15 +class HistoryAdapter : BaseAdapter<SearchLog, AdapterHistoryBinding>() {
15 16
16 - override fun onBind(holder: AdapterHistoryBinding, position: Int, data: String) {  
17 - holder.name.text = data 17 + override fun onBind(holder: AdapterHistoryBinding, position: Int, data: SearchLog) {
  18 + holder.name.text = data.keyword
18 } 19 }
19 20
20 override fun getViewBinding( 21 override fun getViewBinding(
  1 +package com.br_technology.securitytrain_master.ui.view.home.adapter
  2 +
  3 +import android.annotation.SuppressLint
  4 +import android.view.View
  5 +import android.widget.ImageView
  6 +import android.widget.TextView
  7 +import com.br_technology.securitytrain_master.R
  8 +import com.br_technology.securitytrain_master.expand.glideRound
  9 +import com.br_technology.securitytrain_master.ui.bean.LessonBean
  10 +import com.br_technology.securitytrain_master.ui.bean.LessonLive
  11 +import com.br_technology.securitytrain_master.ui.bean.SearchBean
  12 +import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean
  13 +import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
  14 +import com.br_technology.securitytrain_master.util.CommonUtil
  15 +import com.bumptech.glide.Glide
  16 +import com.bumptech.glide.load.resource.bitmap.RoundedCorners
  17 +import com.bumptech.glide.request.RequestOptions
  18 +import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
  19 +import com.chad.library.adapter.base.viewholder.BaseViewHolder
  20 +
  21 +/**
  22 + * Author by YSir
  23 + * Date on 2022/1/26.c
  24 + * description
  25 + * PS: Not easy to write code, please indicate.
  26 + */
  27 +class SearchAdapter : BaseMultiItemQuickAdapter<SearchBean, BaseViewHolder>() {
  28 +
  29 + init {
  30 + addItemType(0, R.layout.adapter_video_course)
  31 + addItemType(1, R.layout.item_course)
  32 + addItemType(2, R.layout.adapter_recommend_data)
  33 + addItemType(3, R.layout.adapter_recommend_data)
  34 + }
  35 +
  36 + interface ISearchClick {
  37 + fun clickItem(item: SearchBean)
  38 + }
  39 +
  40 + private var mClickItem: ISearchClick? = null
  41 +
  42 + fun setIClickItem(iClickItem: ISearchClick) {
  43 + mClickItem = iClickItem
  44 + }
  45 +
  46 + override fun convert(holder: BaseViewHolder, item: SearchBean) {
  47 + when (item.type) {
  48 + 0 -> {
  49 + item.videoData?.let {
  50 + initVideo(holder, it)
  51 + }
  52 + }
  53 + 1 -> {
  54 + item.liveData?.let {
  55 + initLive(holder, it)
  56 + }
  57 + }
  58 + 2 -> {
  59 + item.txtData?.let {
  60 + initTxt(holder, it)
  61 + }
  62 + }
  63 + 3 -> {
  64 + item.materialData?.let {
  65 + initMaterial(holder, it)
  66 + }
  67 + }
  68 + }
  69 + holder.itemView.setOnClickListener {
  70 + mClickItem?.clickItem(item)
  71 + }
  72 + }
  73 +
  74 + @SuppressLint("SetTextI18n")
  75 + private fun initVideo(holder: BaseViewHolder, data: VideoLessonBean.ListBean.DataBean) {
  76 + holder.apply {
  77 + getView<ImageView>(R.id.video_pic).glideRound(data.image, 16)
  78 + getView<ImageView>(R.id.head).glideRound(data.teacher.avatar, 16)
  79 + getView<TextView>(R.id.name).text = data.teacher.name
  80 + getView<TextView>(R.id.course_name).text = data.name
  81 + getView<TextView>(R.id.lesson).text = "${data.class_hours}课时"
  82 + }
  83 + }
  84 +
  85 + @SuppressLint("SetTextI18n")
  86 + private fun initLive(holder: BaseViewHolder, data: LessonLive) {
  87 + holder.apply {
  88 + getView<TextView>(R.id.tv_title).text = CommonUtil.getTransStr(data.name)
  89 + getView<TextView>(R.id.tv_status).visibility = View.GONE
  90 + getView<TextView>(R.id.tv_time).text = ""
  91 + getView<TextView>(R.id.tv_lesson).text = "${data.class_hours}学时"
  92 + Glide.with(holder.itemView).load(data.image).error(R.mipmap.placeholder_head)
  93 + .into(getView(R.id.iv_pic))
  94 + }
  95 + }
  96 +
  97 + private fun initTxt(holder: BaseViewHolder, item: LessonBean) {
  98 + holder.apply {
  99 + getView<TextView>(R.id.name).text = item.name
  100 + getView<TextView>(R.id.info).text = item.des
  101 + Glide.with(context).load(item.image)
  102 + .apply(RequestOptions.bitmapTransform(RoundedCorners(16)))
  103 + .into(holder.getView(R.id.pic))
  104 + }
  105 + }
  106 +
  107 + private fun initMaterial(holder: BaseViewHolder, item: RecommendBean.ListBean) {
  108 + holder.apply {
  109 + getView<TextView>(R.id.name).text = item.name
  110 + getView<TextView>(R.id.info).text = item.des
  111 + Glide.with(context).load(item.image)
  112 + .apply(RequestOptions.bitmapTransform(RoundedCorners(16)))
  113 + .into(holder.getView(R.id.pic))
  114 + }
  115 + }
  116 +}
1 package com.br_technology.securitytrain_master.ui.view.home.fragment 1 package com.br_technology.securitytrain_master.ui.view.home.fragment
2 2
3 -import com.br_technology.securitytrain_master.R 3 +import android.content.Intent
  4 +import android.os.Bundle
  5 +import android.view.View
  6 +import androidx.recyclerview.widget.GridLayoutManager
  7 +import androidx.recyclerview.widget.LinearLayoutManager
  8 +import com.br_technology.securitytrain_master.base.common.ConstantParamKey
4 import com.br_technology.securitytrain_master.databinding.FragmentResultBinding 9 import com.br_technology.securitytrain_master.databinding.FragmentResultBinding
5 -import com.br_technology.securitytrain_master.ui.view.home.adapter.ResultAdapter  
6 -import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendData 10 +import com.br_technology.securitytrain_master.expand.addItemDecoration2
  11 +import com.br_technology.securitytrain_master.ui.bean.*
  12 +import com.br_technology.securitytrain_master.ui.view.home.activity.DatabaseDetailActivity
  13 +import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity
  14 +import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity
  15 +import com.br_technology.securitytrain_master.ui.view.home.adapter.SearchAdapter
  16 +import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean
  17 +import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
7 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.util.TranslateUnit
  20 +import com.br_technology.securitytrain_master.view.VerticalDecoration
8 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 21 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
  22 +import org.greenrobot.eventbus.EventBus
  23 +import org.greenrobot.eventbus.Subscribe
9 24
10 /** 25 /**
11 * createTime:2021/7/28 15:39 26 * createTime:2021/7/28 15:39
12 * auth:张继 27 * auth:张继
13 * des: 28 * des:
14 */ 29 */
15 -class ResultFragment : BaseLifeCycleFragment<ResultViewModel,FragmentResultBinding>(FragmentResultBinding::inflate) { 30 +class ResultFragment(val type: Int) :
  31 + BaseLifeCycleFragment<ResultViewModel, FragmentResultBinding>(FragmentResultBinding::inflate),
  32 + SearchAdapter.ISearchClick {
16 33
17 - override fun initData() {  
18 - super.initData() 34 + var page = 1
  35 + var keywords = ""
  36 +
  37 + override fun initView() {
  38 + super.initView()
  39 + var str = ""
  40 + when (type) {
  41 + ResultViewModel.ResultType.TYPE_ZERO -> {
  42 + str = "暂无在线课程"
  43 + }
  44 + ResultViewModel.ResultType.TYPE_ONE -> {
  45 + str = "暂无直播课程"
  46 + }
  47 + ResultViewModel.ResultType.TYPE_TWO -> {
  48 + str = "暂无文本课程"
  49 + }
  50 + ResultViewModel.ResultType.TYPE_THREE -> {
  51 + str = "暂无资料库"
  52 + }
  53 + }
  54 + binding.tvNoData.text = str
19 binding.apply { 55 binding.apply {
20 - val recommendList = mutableListOf(  
21 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
22 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
23 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
24 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
25 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
26 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
27 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
28 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高-中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
29 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
30 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
31 - RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),  
32 - )  
33 - val resultAdapter = ResultAdapter()  
34 - result.adapter = resultAdapter  
35 -// resultAdapter.addList(recommendList) 56 + when (type) {
  57 + 0 -> {
  58 + result.addItemDecoration2(2, 15, 16)
  59 + result.layoutManager = GridLayoutManager(requireActivity(), 2)
  60 + }
  61 + else -> {
  62 + result.addItemDecoration(
  63 + VerticalDecoration(
  64 + TranslateUnit.dp2px(context, 16f),
  65 + 0
  66 + )
  67 + )
  68 + result.layoutManager = LinearLayoutManager(requireActivity())
  69 + }
  70 + }
36 } 71 }
37 } 72 }
  73 +
  74 + var searchAdapter: SearchAdapter? = null
  75 +
  76 + override fun initData() {
  77 + super.initData()
  78 + refresh()
  79 + }
  80 +
38 override fun initDataObserver() { 81 override fun initDataObserver() {
  82 + mViewModel.videoData.observe(this, {
  83 + val data = it.data.list.data
  84 + setData(transData(data))
  85 + })
  86 + mViewModel.liveData.observe(this, {
  87 + val data = it.data.list.data
  88 + setData(transData(data))
  89 + })
  90 + mViewModel.txtData.observe(this, {
  91 + val data = it.data.list.data
  92 + setData(transData(data))
  93 + })
  94 +
  95 + mViewModel.materialData.observe(this, {
  96 + val data = it.data.list.data
  97 + setData(transData(data))
  98 + })
  99 + }
  100 +
  101 + private fun setData(data: List<SearchBean>) {
  102 + binding.smartRefresh.finishLoadMore()
  103 + binding.smartRefresh.finishRefresh()
  104 + binding.smartRefresh.setEnableLoadMore(data.size == 10)
  105 + if (page == 1) {
  106 + searchAdapter = SearchAdapter()
  107 + searchAdapter?.setList(data)
  108 + searchAdapter?.setIClickItem(this)
  109 + binding.result.adapter = searchAdapter
  110 + } else {
  111 + searchAdapter?.addData(data)
  112 + }
  113 + binding.smartRefresh.visibility = if (searchAdapter?.itemCount!! > 0) {
  114 + View.VISIBLE
  115 + } else {
  116 + View.GONE
  117 + }
  118 + binding.tvNoData.visibility = if (searchAdapter?.itemCount!! > 0) {
  119 + View.GONE
  120 + } else {
  121 + View.VISIBLE
  122 + }
39 123
40 } 124 }
  125 +
  126 + private fun transData(data: List<Any>): List<SearchBean> {
  127 + val list = mutableListOf<SearchBean>()
  128 + for (item in data) {
  129 + val putData = SearchBean(type)
  130 + if (item is LessonBean) {
  131 + putData.txtData = item
  132 + }
  133 + if (item is LessonLive) {
  134 + putData.liveData = item
  135 + }
  136 + if (item is VideoLessonBean.ListBean.DataBean) {
  137 + putData.videoData = item
  138 + }
  139 + if (item is RecommendBean.ListBean) {
  140 + putData.materialData = item
  141 + }
  142 + list.add(putData)
  143 + }
  144 + return list
  145 + }
  146 +
  147 + override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
  148 + super.onViewCreated(view, savedInstanceState)
  149 + EventBus.getDefault().register(this)
  150 + }
  151 +
  152 + override fun onDestroyView() {
  153 + EventBus.getDefault().unregister(this)
  154 + super.onDestroyView()
  155 + }
  156 +
  157 + fun refresh() {
  158 + page = 1
  159 + mViewModel.loadData(type, keywords, page)
  160 + }
  161 +
  162 + fun loadData() {
  163 + page++
  164 + mViewModel.loadData(type, keywords, page)
  165 + }
  166 +
  167 + @Subscribe
  168 + fun search(search: SearchEvent) {
  169 + keywords = search.search
  170 + refresh()
  171 + }
  172 +
  173 + override fun clickItem(item: SearchBean) {
  174 + when (type) {
  175 + ResultViewModel.ResultType.TYPE_ZERO -> {
  176 + val course = CourseParam()
  177 + val data = item.videoData
  178 + course.mLessonId = "${data?.id}"
  179 + course.isTrainClass = false
  180 + course.type = data?.type?.toInt() ?: 0
  181 + this@ResultFragment.startActivity(
  182 + Intent(
  183 + requireActivity(),
  184 + CourseDetailActivity::class.java
  185 + ).putExtra(ConstantParamKey.COURSE_BEAN, course)
  186 + )
  187 + }
  188 + ResultViewModel.ResultType.TYPE_ONE -> {
  189 + }
  190 + ResultViewModel.ResultType.TYPE_TWO -> {
  191 + val course = CourseParam()
  192 + val data = item.txtData
  193 + course.mLessonId = "${data?.id}"
  194 + course.isTrainClass = true
  195 + course.mTrainClassId = "${data?.train_class_id}"
  196 + this@ResultFragment.startActivity(
  197 + Intent(
  198 + requireActivity(),
  199 + TextDetailActivity::class.java
  200 + ).putExtra(ConstantParamKey.COURSE_BEAN, course)
  201 + )
  202 + }
  203 + ResultViewModel.ResultType.TYPE_THREE -> {
  204 + val data = item.materialData
  205 + this@ResultFragment.startActivity(
  206 + Intent(requireActivity(), DatabaseDetailActivity::class.java)
  207 + .putExtra(ConstantParamKey.DOC_ID, data?.id)
  208 + )
  209 + }
  210 + }
  211 + }
  212 +
41 } 213 }
1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel 1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel
2 2
  3 +import androidx.lifecycle.MutableLiveData
  4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  5 +import com.br_technology.securitytrain_master.base.network.response.CommonDataList
  6 +import com.br_technology.securitytrain_master.base.network.response.CommonPage
  7 +import com.br_technology.securitytrain_master.base.repository.LessonRepository
3 import com.br_technology.securitytrain_master.base.view.BaseViewModel 8 import com.br_technology.securitytrain_master.base.view.BaseViewModel
4 -import com.br_technology.securitytrain_master.ui.view.home.repository.ResultRepository 9 +import com.br_technology.securitytrain_master.ui.bean.LessonBean
  10 +import com.br_technology.securitytrain_master.ui.bean.LessonLive
  11 +import com.br_technology.securitytrain_master.ui.bean.MaterialPage
  12 +import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
  13 +import com.br_technology.securitytrain_master.util.sp_job_id
5 14
6 /** 15 /**
7 * createTime:2021/7/27 15:48 16 * createTime:2021/7/27 15:48
8 * auth:张继 17 * auth:张继
9 * des: 18 * des:
10 */ 19 */
11 -class ResultViewModel: BaseViewModel<ResultRepository>() { 20 +class ResultViewModel : BaseViewModel<LessonRepository>() {
  21 + val videoData = MutableLiveData<BaseResponse<VideoLessonBean>>()
  22 + val liveData = MutableLiveData<BaseResponse<CommonDataList<CommonPage<LessonLive>>>>()
  23 + val txtData = MutableLiveData<BaseResponse<CommonDataList<CommonPage<LessonBean>>>>()
  24 + val materialData = MutableLiveData<BaseResponse<MaterialPage>>()
  25 +
  26 + object ResultType {
  27 + const val TYPE_ZERO = 0
  28 + const val TYPE_ONE = 1
  29 + const val TYPE_TWO = 2
  30 + const val TYPE_THREE = 3
  31 + }
  32 +
  33 + fun loadData(
  34 + type:Int,
  35 + keyword: String,
  36 + page: Int
  37 + ) {
  38 + when (type) {
  39 + ResultType.TYPE_ZERO -> {
  40 + searchVideoList(keyword, page)
  41 + }
  42 + ResultType.TYPE_ONE -> {
  43 + searchLiveList(keyword, page)
  44 + }
  45 + ResultType.TYPE_TWO -> {
  46 + searchTxtList(keyword, page)
  47 + }
  48 + ResultType.TYPE_THREE -> {
  49 + searchMaterialList(keyword, page)
  50 + }
  51 + }
  52 + }
  53 +
  54 + fun searchVideoList(
  55 + keyword: String,
  56 + page: Int
  57 + ) {
  58 + mRepository.searchVideoList(keyword, sp_job_id.toString(), page, 10, videoData)
  59 + }
  60 +
  61 + fun searchLiveList(
  62 + keyword: String,
  63 + page: Int
  64 + ) {
  65 + mRepository.searchLiveList(keyword, page.toString(), "10", liveData)
  66 + }
  67 +
  68 + fun searchTxtList(
  69 + keyword: String,
  70 + page: Int
  71 + ) {
  72 + mRepository.searchTxtList(keyword, sp_job_id, page, 10, txtData)
  73 + }
  74 +
  75 + fun searchMaterialList(
  76 + keyword: String,
  77 + page: Int
  78 + ) {
  79 + mRepository.searchMaterialList(keyword, sp_job_id, page, 10, materialData)
  80 + }
12 } 81 }
1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel 1 package com.br_technology.securitytrain_master.ui.view.home.viewmodel
2 2
  3 +import androidx.lifecycle.MutableLiveData
  4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  5 +import com.br_technology.securitytrain_master.base.network.response.CommonList
  6 +import com.br_technology.securitytrain_master.base.repository.CommonRepository
3 import com.br_technology.securitytrain_master.base.view.BaseViewModel 7 import com.br_technology.securitytrain_master.base.view.BaseViewModel
4 -import com.br_technology.securitytrain_master.ui.view.home.repository.SearchRepository 8 +import com.br_technology.securitytrain_master.ui.bean.SearchLog
5 9
6 /** 10 /**
7 * createTime:2021/7/27 15:48 11 * createTime:2021/7/27 15:48
8 * auth:张继 12 * auth:张继
9 * des: 13 * des:
10 */ 14 */
11 -class SearchViewModel: BaseViewModel<SearchRepository>() { 15 +class SearchViewModel : BaseViewModel<CommonRepository>() {
  16 +
  17 + val liveData = MutableLiveData<BaseResponse<CommonList<SearchLog>>>()
  18 + val clearData = MutableLiveData<BaseResponse<CommonList<SearchLog>>>()
  19 +
  20 + fun searchLog() {
  21 + mRepository.searchLog(liveData)
  22 + }
  23 +
  24 + fun clearLog() {
  25 + mRepository.searchLogClear(clearData)
  26 + }
12 } 27 }
@@ -47,9 +47,6 @@ public class HtmlConvert { @@ -47,9 +47,6 @@ public class HtmlConvert {
47 element.removeAttr("class"); 47 element.removeAttr("class");
48 String souce = element.attr("src"); 48 String souce = element.attr("src");
49 if (loadImage(BaseApplication.Companion.getInstance().getApplicationContext())) { 49 if (loadImage(BaseApplication.Companion.getInstance().getApplicationContext())) {
50 -// if (!souce.startsWith("http")) {  
51 -// element.attr("src", ConnectUrl.BASE_URL_IMG() + souce);  
52 -// }  
53 if (element.hasParent()) { 50 if (element.hasParent()) {
54 Element parent = element.parent(); 51 Element parent = element.parent();
55 if (parent.tagName().equals("a")) { 52 if (parent.tagName().equals("a")) {
@@ -65,15 +62,12 @@ public class HtmlConvert { @@ -65,15 +62,12 @@ public class HtmlConvert {
65 } 62 }
66 } 63 }
67 } 64 }
68 -// element.attr("onclick",onClick(souce,arr));  
69 } 65 }
70 doc.select("br").remove(); 66 doc.select("br").remove();
71 -// int fontSize = SettingKits.getFontSize(BaseApplication.Companion.getInstance().getApplicationContext());  
72 - int fontSize = 0;  
73 List<Element> spanList = doc.select("span"); 67 List<Element> spanList = doc.select("span");
74 - for (Element element : spanList) {  
75 - updateStyle(element, "font-size", "small");  
76 - } 68 +// for (Element element : spanList) {
  69 +// updateStyle(element, "font-size", "0.15rem");
  70 +// }
77 Element head = doc.head(); 71 Element head = doc.head();
78 head.append("<meta charset=\"utf-8\">") 72 head.append("<meta charset=\"utf-8\">")
79 .append("<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />"); 73 .append("<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />");
@@ -85,10 +79,9 @@ public class HtmlConvert { @@ -85,10 +79,9 @@ public class HtmlConvert {
85 "img{max-width: 100%!important;height:auto}" + 79 "img{max-width: 100%!important;height:auto}" +
86 "video{width: 100%;display: block;}" + 80 "video{width: 100%;display: block;}" +
87 "p{padding:0px;overflow: hidden;" + 81 "p{padding:0px;overflow: hidden;" +
88 - "font-size:" + TextKits.fontSize(fontSize) + "px;" +  
89 "color:#ffffff;" + 82 "color:#ffffff;" +
90 "}" + 83 "}" +
91 - "span{color:#ffffff;text-indent:2em;}" + 84 + "span{color:#ffffff;}" +
92 "</style>"); 85 "</style>");
93 } else { 86 } else {
94 head.append("<style>" + 87 head.append("<style>" +
@@ -96,22 +89,15 @@ public class HtmlConvert { @@ -96,22 +89,15 @@ public class HtmlConvert {
96 "text-align:justify!important;text-justify:inter-ideograph!important;" + 89 "text-align:justify!important;text-justify:inter-ideograph!important;" +
97 "word-break:break-all!important;}" + 90 "word-break:break-all!important;}" +
98 "img{max-width: 100%!important;height:auto}" + 91 "img{max-width: 100%!important;height:auto}" +
99 - "p{font-size:" + TextKits.fontSize(fontSize) + "px" +  
100 - ";}" +  
101 "video{width:100%;}" + 92 "video{width:100%;}" +
102 - "span{text-indent:2em;}" +  
103 "</style>"); 93 "</style>");
104 } 94 }
105 -// if (listVideo.size() > 0) {  
106 -// head.append("<link href=\"file:///android_asset/video-js.min.css\" rel=\"stylesheet\"></link>" +  
107 -// "<script src=\"file:///android_asset/video.min.js\"></script>");  
108 -// }  
109 List<Element> elements = doc.select("p"); 95 List<Element> elements = doc.select("p");
110 for (Element element : elements) { 96 for (Element element : elements) {
111 List<Element> list1 = element.children(); 97 List<Element> list1 = element.children();
112 if (list1 == null || list1.isEmpty()) { 98 if (list1 == null || list1.isEmpty()) {
113 if (!isTextCenter(element)) { 99 if (!isTextCenter(element)) {
114 - updateStyle(element, "text-indent", "2em"); 100 + updateStyle(element, "text-indent", "0em");
115 } 101 }
116 } else { 102 } else {
117 int count = 0; 103 int count = 0;
@@ -126,7 +112,7 @@ public class HtmlConvert { @@ -126,7 +112,7 @@ public class HtmlConvert {
126 } 112 }
127 } 113 }
128 if (count == 0) { 114 if (count == 0) {
129 - updateStyle(element, "text-indent", "2em"); 115 + updateStyle(element, "text-indent", "0em");
130 } 116 }
131 } 117 }
132 } 118 }
@@ -144,9 +130,6 @@ public class HtmlConvert { @@ -144,9 +130,6 @@ public class HtmlConvert {
144 element.removeAttr("class"); 130 element.removeAttr("class");
145 String souce = element.attr("src"); 131 String souce = element.attr("src");
146 if (loadImage(BaseApplication.Companion.getInstance().getApplicationContext())) { 132 if (loadImage(BaseApplication.Companion.getInstance().getApplicationContext())) {
147 -// if (!souce.startsWith("http")) {  
148 -// element.attr("src", ConnectUrl.BASE_URL_IMG() + souce);  
149 -// }  
150 if (element.hasParent()) { 133 if (element.hasParent()) {
151 Element parent = element.parent(); 134 Element parent = element.parent();
152 if (parent.tagName().equals("a")) { 135 if (parent.tagName().equals("a")) {
@@ -157,14 +140,11 @@ public class HtmlConvert { @@ -157,14 +140,11 @@ public class HtmlConvert {
157 String url = "file:///android_res/mipmap/loading_web.png"; 140 String url = "file:///android_res/mipmap/loading_web.png";
158 element.attr("src", url); 141 element.attr("src", url);
159 } 142 }
160 -// element.attr("onclick",onClick(souce,arr));  
161 } 143 }
162 doc.select("br").remove(); 144 doc.select("br").remove();
163 -// int fontSize = SettingKits.getFontSize(BaseApplication.Companion.getInstance().getApplicationContext());  
164 - int fontSize = 0;  
165 List<Element> spanList = doc.select("span"); 145 List<Element> spanList = doc.select("span");
166 for (Element element : spanList) { 146 for (Element element : spanList) {
167 - updateStyle(element, "font-size", "small"); 147 + updateStyle(element, "font-size", "0.15rem");
168 } 148 }
169 Element head = doc.head(); 149 Element head = doc.head();
170 head.append("<meta charset=\"utf-8\">") 150 head.append("<meta charset=\"utf-8\">")
@@ -177,10 +157,9 @@ public class HtmlConvert { @@ -177,10 +157,9 @@ public class HtmlConvert {
177 "img{max-width: 100%!important;height:auto}" + 157 "img{max-width: 100%!important;height:auto}" +
178 "video{width: 100%;display: block;}" + 158 "video{width: 100%;display: block;}" +
179 "p{padding:0px;overflow: hidden;" + 159 "p{padding:0px;overflow: hidden;" +
180 - "font-size:" + TextKits.fontSize(fontSize) + "px;" +  
181 "color:#ffffff;" + 160 "color:#ffffff;" +
182 "}" + 161 "}" +
183 - "span{color:#ffffff;text-indent:2em;}" + 162 + "span{color:#ffffff;text-indent:0em;}" +
184 "</style>"); 163 "</style>");
185 } else { 164 } else {
186 head.append("<style>" + 165 head.append("<style>" +
@@ -188,10 +167,8 @@ public class HtmlConvert { @@ -188,10 +167,8 @@ public class HtmlConvert {
188 "text-align:justify!important;text-justify:inter-ideograph!important;" + 167 "text-align:justify!important;text-justify:inter-ideograph!important;" +
189 "word-break:break-all!important;}" + 168 "word-break:break-all!important;}" +
190 "img{max-width: 100%!important;height:auto}" + 169 "img{max-width: 100%!important;height:auto}" +
191 - "p{font-size:" + TextKits.fontSize(fontSize) + "px" +  
192 - ";}" +  
193 "video{width: 100%;height:260;}" + 170 "video{width: 100%;height:260;}" +
194 - "span{text-indent:2em;}" + 171 + "span{text-indent:0em;}" +
195 "</style>"); 172 "</style>");
196 } 173 }
197 List<Element> elements = doc.select("p"); 174 List<Element> elements = doc.select("p");
@@ -199,7 +176,7 @@ public class HtmlConvert { @@ -199,7 +176,7 @@ public class HtmlConvert {
199 List<Element> list1 = element.children(); 176 List<Element> list1 = element.children();
200 if (list1 == null || list1.isEmpty()) { 177 if (list1 == null || list1.isEmpty()) {
201 if (!isTextCenter(element)) { 178 if (!isTextCenter(element)) {
202 - updateStyle(element, "text-indent", "2em"); 179 + updateStyle(element, "text-indent", "0em");
203 } 180 }
204 } else { 181 } else {
205 int count = 0; 182 int count = 0;
@@ -214,7 +191,7 @@ public class HtmlConvert { @@ -214,7 +191,7 @@ public class HtmlConvert {
214 } 191 }
215 } 192 }
216 if (count == 0) { 193 if (count == 0) {
217 - updateStyle(element, "text-indent", "2em"); 194 + updateStyle(element, "text-indent", "0m");
218 } 195 }
219 } 196 }
220 } 197 }
@@ -38,6 +38,7 @@ open class DialogSureCancel(context: Context) : Dialog(context, R.style.UserDefa @@ -38,6 +38,7 @@ open class DialogSureCancel(context: Context) : Dialog(context, R.style.UserDefa
38 // 确定 38 // 确定
39 determine.setOnClickListener { 39 determine.setOnClickListener {
40 listener?.determine() 40 listener?.determine()
  41 + dismiss()
41 } 42 }
42 } 43 }
43 } 44 }
@@ -16,8 +16,8 @@ class MyWebView(context: Context, attrs: AttributeSet?) : WebView(context, attrs @@ -16,8 +16,8 @@ class MyWebView(context: Context, attrs: AttributeSet?) : WebView(context, attrs
16 16
17 init { 17 init {
18 settings.javaScriptEnabled = true 18 settings.javaScriptEnabled = true
19 - settings.minimumFontSize = 24.dp2px()  
20 - settings.defaultFixedFontSize = 32.dp2px() 19 + settings.minimumFontSize = 14.dp2px()
  20 + settings.defaultFixedFontSize = 15.dp2px()
21 settings.useWideViewPort = true 21 settings.useWideViewPort = true
22 settings.loadWithOverviewMode = true 22 settings.loadWithOverviewMode = true
23 settings.allowFileAccess = true 23 settings.allowFileAccess = true
@@ -94,7 +94,7 @@ @@ -94,7 +94,7 @@
94 <androidx.recyclerview.widget.RecyclerView 94 <androidx.recyclerview.widget.RecyclerView
95 android:id="@+id/history_recycler" 95 android:id="@+id/history_recycler"
96 android:layout_width="match_parent" 96 android:layout_width="match_parent"
97 - android:layout_height="match_parent" 97 + android:layout_height="wrap_content"
98 android:layout_marginStart="16dp" 98 android:layout_marginStart="16dp"
99 android:overScrollMode="never" 99 android:overScrollMode="never"
100 android:scrollbars="none" 100 android:scrollbars="none"
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 -<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 2 +<FrameLayout 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:id="@+id/result"  
5 android:layout_width="match_parent" 4 android:layout_width="match_parent"
6 - android:layout_height="match_parent"  
7 - android:overScrollMode="never"  
8 - android:paddingStart="16dp"  
9 - android:paddingEnd="16dp"  
10 - android:scrollbars="none"  
11 - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 5 + android:layout_height="match_parent">
  6 +
  7 + <TextView
  8 + android:id="@+id/tv_no_data"
  9 + android:layout_width="match_parent"
  10 + android:layout_height="wrap_content"
  11 + android:gravity="center"
  12 + android:layout_marginTop="24dp"
  13 + android:text="@string/app_name"
  14 + android:visibility="gone"
  15 + android:drawableTop="@mipmap/search_none" />
  16 +
  17 + <com.scwang.smart.refresh.layout.SmartRefreshLayout
  18 + android:id="@+id/smart_refresh"
  19 + android:layout_width="match_parent"
  20 + android:layout_height="match_parent">
  21 +
  22 + <com.scwang.smart.refresh.header.MaterialHeader
  23 + android:layout_width="match_parent"
  24 + android:layout_height="wrap_content" />
  25 +
  26 + <androidx.recyclerview.widget.RecyclerView
  27 + android:id="@+id/result"
  28 + android:layout_width="match_parent"
  29 + android:layout_height="match_parent"
  30 + android:overScrollMode="never"
  31 + android:paddingStart="16dp"
  32 + android:paddingEnd="16dp"
  33 + android:scrollbars="none" />
  34 +
  35 + <com.scwang.smart.refresh.footer.ClassicsFooter
  36 + android:layout_width="match_parent"
  37 + android:layout_height="wrap_content" />
  38 + </com.scwang.smart.refresh.layout.SmartRefreshLayout>
  39 +
  40 +</FrameLayout>
12 41
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
5 android:layout_height="wrap_content" 5 android:layout_height="wrap_content"
6 android:background="@color/white" 6 android:background="@color/white"
7 android:layout_marginBottom="16dp" 7 android:layout_marginBottom="16dp"
  8 + android:layout_marginStart="16dp"
  9 + android:layout_marginEnd="16dp"
8 android:orientation="vertical"> 10 android:orientation="vertical">
9 11
10 <LinearLayout 12 <LinearLayout