正在显示
14 个修改的文件
包含
392 行增加
和
33 行删除
@@ -20,7 +20,7 @@ open class MaterialClassify( | @@ -20,7 +20,7 @@ open class MaterialClassify( | ||
20 | var name: String, | 20 | var name: String, |
21 | var weigh: Int, | 21 | var weigh: Int, |
22 | var level: String, | 22 | var level: String, |
23 | - var list: List<MaterialChild> | 23 | + var child: List<MaterialChild> |
24 | ) | 24 | ) |
25 | 25 | ||
26 | open class MaterialPage( | 26 | open class MaterialPage( |
@@ -37,6 +37,20 @@ open class MaterialChild( | @@ -37,6 +37,20 @@ open class MaterialChild( | ||
37 | var type: Int, | 37 | var type: Int, |
38 | var name: String, | 38 | var name: String, |
39 | var weigh: Int, | 39 | var weigh: Int, |
40 | + var level: String, | ||
41 | + var child: List<MaterialChildSecond>? | ||
42 | +) | ||
43 | + | ||
44 | +/** | ||
45 | + * 资料库分类子次级分类 | ||
46 | + */ | ||
47 | +open class MaterialChildSecond( | ||
48 | + var id: Int, | ||
49 | + var company_id: Int, | ||
50 | + var pid: Int, | ||
51 | + var type: Int, | ||
52 | + var name: String, | ||
53 | + var weigh: Int, | ||
40 | var level: String | 54 | var level: String |
41 | ) | 55 | ) |
42 | 56 |
@@ -11,6 +11,7 @@ import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean | @@ -11,6 +11,7 @@ import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean | ||
11 | import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.BankViewModel | 11 | import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.BankViewModel |
12 | import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean | 12 | import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean |
13 | import com.br_technology.securitytrain_master.util.TYPE_All | 13 | import com.br_technology.securitytrain_master.util.TYPE_All |
14 | +import com.br_technology.securitytrain_master.util.sp_job_id | ||
14 | import com.br_technology.securitytrain_master.util.sp_job_id_select | 15 | import com.br_technology.securitytrain_master.util.sp_job_id_select |
15 | import com.br_technology.securitytrain_master.util.sp_job_name_select | 16 | import com.br_technology.securitytrain_master.util.sp_job_name_select |
16 | import com.br_technology.securitytrain_master.view.ClassifyPop | 17 | import com.br_technology.securitytrain_master.view.ClassifyPop |
@@ -35,7 +36,11 @@ class BankFragment : | @@ -35,7 +36,11 @@ class BankFragment : | ||
35 | DialogStar(requireActivity()) | 36 | DialogStar(requireActivity()) |
36 | } | 37 | } |
37 | 38 | ||
38 | - private var posId: Int = sp_job_id_select | 39 | + private var posId: Int = if (sp_job_id_select == 0) { |
40 | + sp_job_id | ||
41 | + } else { | ||
42 | + sp_job_id_select | ||
43 | + } | ||
39 | 44 | ||
40 | override fun initData() { | 45 | override fun initData() { |
41 | super.initData() | 46 | super.initData() |
@@ -8,12 +8,18 @@ import androidx.core.content.ContextCompat | @@ -8,12 +8,18 @@ import androidx.core.content.ContextCompat | ||
8 | import androidx.recyclerview.widget.RecyclerView | 8 | import androidx.recyclerview.widget.RecyclerView |
9 | import com.br_technology.securitytrain_master.R | 9 | import com.br_technology.securitytrain_master.R |
10 | import com.br_technology.securitytrain_master.base.common.ConstantParamKey.DOC_ID | 10 | import com.br_technology.securitytrain_master.base.common.ConstantParamKey.DOC_ID |
11 | +import com.br_technology.securitytrain_master.base.network.response.BaseResponse | ||
12 | +import com.br_technology.securitytrain_master.base.network.response.CommonPage | ||
11 | import com.br_technology.securitytrain_master.databinding.ActivityDatabaseBinding | 13 | import com.br_technology.securitytrain_master.databinding.ActivityDatabaseBinding |
14 | +import com.br_technology.securitytrain_master.ui.bean.MaterialChild | ||
15 | +import com.br_technology.securitytrain_master.ui.bean.MaterialChildSecond | ||
12 | import com.br_technology.securitytrain_master.ui.bean.MaterialClassify | 16 | import com.br_technology.securitytrain_master.ui.bean.MaterialClassify |
17 | +import com.br_technology.securitytrain_master.ui.bean.MaterialPage | ||
13 | import com.br_technology.securitytrain_master.ui.view.home.adapter.ClassifyAdapter | 18 | import com.br_technology.securitytrain_master.ui.view.home.adapter.ClassifyAdapter |
14 | import com.br_technology.securitytrain_master.ui.view.home.adapter.RecommendDataAdapter | 19 | import com.br_technology.securitytrain_master.ui.view.home.adapter.RecommendDataAdapter |
15 | import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean | 20 | import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean |
16 | import com.br_technology.securitytrain_master.ui.view.home.viewmodel.DatabaseFViewModel | 21 | import com.br_technology.securitytrain_master.ui.view.home.viewmodel.DatabaseFViewModel |
22 | +import com.br_technology.securitytrain_master.view.DatabaseListPop | ||
17 | import com.br_technology.securitytrain_master.view.listener.OnItemClickListener | 23 | import com.br_technology.securitytrain_master.view.listener.OnItemClickListener |
18 | import com.google.android.material.tabs.TabLayout | 24 | import com.google.android.material.tabs.TabLayout |
19 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | 25 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity |
@@ -25,11 +31,28 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | @@ -25,11 +31,28 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | ||
25 | */ | 31 | */ |
26 | class DatabaseActivity : | 32 | class DatabaseActivity : |
27 | BaseLifeCycleActivity<DatabaseFViewModel, ActivityDatabaseBinding>(ActivityDatabaseBinding::inflate) { | 33 | BaseLifeCycleActivity<DatabaseFViewModel, ActivityDatabaseBinding>(ActivityDatabaseBinding::inflate) { |
28 | - | ||
29 | var page = 1 | 34 | var page = 1 |
30 | - | ||
31 | var mClassifyAdapter: ClassifyAdapter? = null | 35 | var mClassifyAdapter: ClassifyAdapter? = null |
32 | - var mRecommendAdapter: RecommendDataAdapter? = null | 36 | + private var mRecommendAdapter: RecommendDataAdapter? = null |
37 | + | ||
38 | + private var popData: DatabaseListPop? = null | ||
39 | + | ||
40 | + private fun showPopData() { | ||
41 | + popData = DatabaseListPop(this) | ||
42 | + val list = mViewModel.selectClassify.value?.child | ||
43 | + var popChild = mViewModel.popChild.value | ||
44 | + if (popChild == null) { | ||
45 | + popChild = mViewModel.sortChild.value | ||
46 | + } | ||
47 | + mViewModel.sortSecond.value?.let { second -> popData?.addList(list!!, second, popChild!!) } | ||
48 | + popData?.iClickChild = object : DatabaseListPop.IClickChild { | ||
49 | + override fun child(child: MaterialChild, data: MaterialChildSecond) { | ||
50 | + mViewModel.popChild.value = child | ||
51 | + mViewModel.sortSecond.value = data | ||
52 | + } | ||
53 | + } | ||
54 | + popData?.showAsDropDown(binding.type) | ||
55 | + } | ||
33 | 56 | ||
34 | override fun initView() { | 57 | override fun initView() { |
35 | super.initView() | 58 | super.initView() |
@@ -97,6 +120,10 @@ class DatabaseActivity : | @@ -97,6 +120,10 @@ class DatabaseActivity : | ||
97 | } | 120 | } |
98 | } | 121 | } |
99 | }) | 122 | }) |
123 | + | ||
124 | + type.setOnClickListener { | ||
125 | + showPopData() | ||
126 | + } | ||
100 | } | 127 | } |
101 | } | 128 | } |
102 | 129 | ||
@@ -124,7 +151,7 @@ class DatabaseActivity : | @@ -124,7 +151,7 @@ class DatabaseActivity : | ||
124 | binding.classify.adapter = mClassifyAdapter | 151 | binding.classify.adapter = mClassifyAdapter |
125 | mClassifyAdapter?.addListener(object : OnItemClickListener<MaterialClassify> { | 152 | mClassifyAdapter?.addListener(object : OnItemClickListener<MaterialClassify> { |
126 | override fun onClick(position: Int, data: MaterialClassify) { | 153 | override fun onClick(position: Int, data: MaterialClassify) { |
127 | - mViewModel.sortId.value = data.id | 154 | + val list = data.child |
128 | mClassifyAdapter?.let { classifyAdapter -> | 155 | mClassifyAdapter?.let { classifyAdapter -> |
129 | val oldIndex = classifyAdapter.index; | 156 | val oldIndex = classifyAdapter.index; |
130 | if (oldIndex != position) { | 157 | if (oldIndex != position) { |
@@ -135,15 +162,37 @@ class DatabaseActivity : | @@ -135,15 +162,37 @@ class DatabaseActivity : | ||
135 | classifyAdapter.notifyItemChanged(position) | 162 | classifyAdapter.notifyItemChanged(position) |
136 | } | 163 | } |
137 | } | 164 | } |
165 | + if (list.isNotEmpty()) { | ||
166 | + mViewModel.selectClassify.value = data | ||
167 | + } else { | ||
168 | + mViewModel.classifyDataList.value = BaseResponse( | ||
169 | + MaterialPage(CommonPage(0, "10", 1, 1, listOf())) | ||
170 | + ) | ||
171 | + } | ||
138 | } | 172 | } |
139 | }) | 173 | }) |
140 | if (data.list.isNotEmpty()) { | 174 | if (data.list.isNotEmpty()) { |
141 | page = 1 | 175 | page = 1 |
142 | - mViewModel.sortId.value = data.list[0].id | 176 | + val dataClassify = data.list[0] |
177 | + mViewModel.selectClassify.value = dataClassify | ||
143 | } | 178 | } |
144 | }) | 179 | }) |
145 | - mViewModel.sortId.observe(this, { | 180 | + mViewModel.selectClassify.observe(this, { |
181 | + val list = it.child | ||
182 | + if (list.isNotEmpty()) { | ||
183 | + mViewModel.sortChild.value = list[0] | ||
184 | + mViewModel.popChild.value = list[0] | ||
185 | + } | ||
186 | + }) | ||
187 | + mViewModel.sortSecond.observe(this, { | ||
146 | mViewModel.getDataList(page) | 188 | mViewModel.getDataList(page) |
189 | + binding.type.text = it.name | ||
190 | + }) | ||
191 | + mViewModel.sortChild.observe(this, { | ||
192 | + val child = it.child | ||
193 | + if (child != null && child.isNotEmpty()) { | ||
194 | + mViewModel.sortSecond.value = child[0] | ||
195 | + } | ||
147 | }) | 196 | }) |
148 | mViewModel.classifyDataList.observe(this, { | 197 | mViewModel.classifyDataList.observe(this, { |
149 | val data = it.data | 198 | val data = it.data |
1 | package com.br_technology.securitytrain_master.ui.view.home.activity | 1 | package com.br_technology.securitytrain_master.ui.view.home.activity |
2 | 2 | ||
3 | +import android.annotation.SuppressLint | ||
3 | import android.content.Intent | 4 | import android.content.Intent |
5 | +import android.net.http.SslError | ||
6 | +import android.os.Build | ||
4 | import android.view.View | 7 | import android.view.View |
5 | import android.view.ViewGroup | 8 | import android.view.ViewGroup |
6 | -import android.webkit.WebChromeClient | ||
7 | -import android.webkit.WebResourceRequest | ||
8 | -import android.webkit.WebView | ||
9 | -import android.webkit.WebViewClient | 9 | +import android.webkit.* |
10 | import com.br_technology.securitytrain_master.R | 10 | import com.br_technology.securitytrain_master.R |
11 | -import com.br_technology.securitytrain_master.base.common.ConstantParamKey | ||
12 | import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL | 11 | import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL |
13 | import com.br_technology.securitytrain_master.base.repository.BaseRepository | 12 | import com.br_technology.securitytrain_master.base.repository.BaseRepository |
14 | import com.br_technology.securitytrain_master.base.view.BaseViewModel | 13 | import com.br_technology.securitytrain_master.base.view.BaseViewModel |
@@ -25,13 +24,15 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | @@ -25,13 +24,15 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity | ||
25 | * auth:张继 | 24 | * auth:张继 |
26 | * des: | 25 | * des: |
27 | */ | 26 | */ |
28 | -class WebViewActivity : BaseLifeCycleActivity<BaseViewModel<BaseRepository>,ActivityWebBinding>(ActivityWebBinding::inflate) { | 27 | +class WebViewActivity : |
28 | + BaseLifeCycleActivity<BaseViewModel<BaseRepository>, ActivityWebBinding>(ActivityWebBinding::inflate) { | ||
29 | var webView: WebView? = null | 29 | var webView: WebView? = null |
30 | 30 | ||
31 | override fun initData() { | 31 | override fun initData() { |
32 | intent.getStringExtra(COMMON_URL)?.let { webView?.loadUrl(it) } | 32 | intent.getStringExtra(COMMON_URL)?.let { webView?.loadUrl(it) } |
33 | } | 33 | } |
34 | 34 | ||
35 | + @SuppressLint("SetJavaScriptEnabled") | ||
35 | override fun initView() { | 36 | override fun initView() { |
36 | webView = findViewById(R.id.web_view) | 37 | webView = findViewById(R.id.web_view) |
37 | val toolBar = findViewById<ViewToolBar>(R.id.tool_bar) | 38 | val toolBar = findViewById<ViewToolBar>(R.id.tool_bar) |
@@ -46,8 +47,64 @@ class WebViewActivity : BaseLifeCycleActivity<BaseViewModel<BaseRepository>,Acti | @@ -46,8 +47,64 @@ class WebViewActivity : BaseLifeCycleActivity<BaseViewModel<BaseRepository>,Acti | ||
46 | } | 47 | } |
47 | } | 48 | } |
48 | }) | 49 | }) |
50 | + webView?.settings?.let { | ||
51 | + it.javaScriptEnabled = true | ||
52 | + val ws = webView!!.settings | ||
53 | + // 网页内容的宽度是否可大于WebView控件的宽度 | ||
54 | + // 网页内容的宽度是否可大于WebView控件的宽度 | ||
55 | + ws.loadWithOverviewMode = false | ||
56 | + // 保存表单数据 | ||
57 | + // 保存表单数据 | ||
58 | + ws.saveFormData = true | ||
59 | + // 是否应该支持使用其屏幕缩放控件和手势缩放 | ||
60 | + // 是否应该支持使用其屏幕缩放控件和手势缩放 | ||
61 | + ws.setSupportZoom(true) | ||
62 | + ws.builtInZoomControls = true | ||
63 | + ws.displayZoomControls = false | ||
64 | + ws.allowFileAccessFromFileURLs = true | ||
65 | + ws.allowFileAccess = true | ||
66 | + // 启动应用缓存 | ||
67 | + // 启动应用缓存 | ||
68 | + ws.setAppCacheEnabled(true) | ||
69 | + // 设置缓存模式 | ||
70 | + // 设置缓存模式 | ||
71 | + ws.cacheMode = WebSettings.LOAD_DEFAULT | ||
72 | + // setDefaultZoom api19被弃用 | ||
73 | + // 设置此属性,可任意比例缩放。 | ||
74 | + // setDefaultZoom api19被弃用 | ||
75 | + // 设置此属性,可任意比例缩放。 | ||
76 | + ws.useWideViewPort = true | ||
77 | + // 不缩放 | ||
78 | + // 不缩放 | ||
79 | + webView!!.setInitialScale(100) | ||
80 | + // 告诉WebView启用JavaScript执行。默认的是false。 | ||
81 | + // 告诉WebView启用JavaScript执行。默认的是false。 | ||
82 | + ws.javaScriptEnabled = true | ||
83 | + // 页面加载好以后,再放开图片 | ||
84 | + // 页面加载好以后,再放开图片 | ||
85 | + ws.blockNetworkImage = false | ||
86 | + // 使用localStorage则必须打开 | ||
87 | + // 使用localStorage则必须打开 | ||
88 | + ws.domStorageEnabled = true | ||
89 | + // 排版适应屏幕 | ||
90 | + // 排版适应屏幕 | ||
91 | + ws.layoutAlgorithm = WebSettings.LayoutAlgorithm.NARROW_COLUMNS | ||
92 | + // WebView是否新窗口打开(加了后可能打不开网页) | ||
93 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
94 | + ws.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW | ||
95 | + } | ||
96 | + } | ||
97 | +// WebView.setWebContentsDebuggingEnabled(true) | ||
49 | webView?.webViewClient = | 98 | webView?.webViewClient = |
50 | object : WebViewClient() { | 99 | object : WebViewClient() { |
100 | + override fun onReceivedSslError( | ||
101 | + view: WebView?, | ||
102 | + handler: SslErrorHandler?, | ||
103 | + error: SslError? | ||
104 | + ) { | ||
105 | + super.onReceivedSslError(view, handler, error) | ||
106 | + handler?.proceed() | ||
107 | + } | ||
51 | 108 | ||
52 | override fun shouldOverrideUrlLoading( | 109 | override fun shouldOverrideUrlLoading( |
53 | view: WebView?, | 110 | view: WebView?, |
@@ -59,14 +116,13 @@ class WebViewActivity : BaseLifeCycleActivity<BaseViewModel<BaseRepository>,Acti | @@ -59,14 +116,13 @@ class WebViewActivity : BaseLifeCycleActivity<BaseViewModel<BaseRepository>,Acti | ||
59 | Intent( | 116 | Intent( |
60 | this@WebViewActivity, | 117 | this@WebViewActivity, |
61 | FileReadActivity::class.java | 118 | FileReadActivity::class.java |
62 | - ).putExtra(ConstantParamKey.COMMON_URL, url.toString()) | 119 | + ).putExtra(COMMON_URL, url.toString()) |
63 | ) | 120 | ) |
64 | return true | 121 | return true |
65 | } | 122 | } |
66 | } | 123 | } |
67 | return !request?.url.toString().contains("http") || !request?.url.toString() | 124 | return !request?.url.toString().contains("http") || !request?.url.toString() |
68 | .startsWith("http") | 125 | .startsWith("http") |
69 | - | ||
70 | } | 126 | } |
71 | 127 | ||
72 | } | 128 | } |
@@ -161,9 +161,11 @@ class HomeFragment : | @@ -161,9 +161,11 @@ class HomeFragment : | ||
161 | .into(it.imageView) | 161 | .into(it.imageView) |
162 | it.imageView.setOnClickListener { | 162 | it.imageView.setOnClickListener { |
163 | data?.let { res -> | 163 | data?.let { res -> |
164 | + val url = "https://mobile.anqixing.com" | ||
164 | startActivity( | 165 | startActivity( |
165 | Intent(requireContext(), WebViewActivity::class.java) | 166 | Intent(requireContext(), WebViewActivity::class.java) |
166 | - .putExtra(COMMON_URL, res.href) | 167 | +// .putExtra(COMMON_URL, res.href) |
168 | + .putExtra(COMMON_URL, url) | ||
167 | ) | 169 | ) |
168 | } | 170 | } |
169 | } | 171 | } |
@@ -7,9 +7,7 @@ import com.br_technology.securitytrain_master.base.network.response.CommonList | @@ -7,9 +7,7 @@ import com.br_technology.securitytrain_master.base.network.response.CommonList | ||
7 | import com.br_technology.securitytrain_master.base.network.response.CommonPage | 7 | import com.br_technology.securitytrain_master.base.network.response.CommonPage |
8 | import com.br_technology.securitytrain_master.base.repository.DocRepository | 8 | import com.br_technology.securitytrain_master.base.repository.DocRepository |
9 | import com.br_technology.securitytrain_master.base.view.BaseViewModel | 9 | import com.br_technology.securitytrain_master.base.view.BaseViewModel |
10 | -import com.br_technology.securitytrain_master.ui.bean.FavoriteData | ||
11 | -import com.br_technology.securitytrain_master.ui.bean.MaterialClassify | ||
12 | -import com.br_technology.securitytrain_master.ui.bean.MaterialPage | 10 | +import com.br_technology.securitytrain_master.ui.bean.* |
13 | 11 | ||
14 | /** | 12 | /** |
15 | * createTime:2021/7/27 15:48 | 13 | * createTime:2021/7/27 15:48 |
@@ -26,7 +24,11 @@ class DatabaseFViewModel : BaseViewModel<DocRepository>() { | @@ -26,7 +24,11 @@ class DatabaseFViewModel : BaseViewModel<DocRepository>() { | ||
26 | val classify = MutableLiveData<BaseResponse<CommonList<MaterialClassify>>>() | 24 | val classify = MutableLiveData<BaseResponse<CommonList<MaterialClassify>>>() |
27 | val classifyDataList = MutableLiveData<BaseResponse<MaterialPage>>() | 25 | val classifyDataList = MutableLiveData<BaseResponse<MaterialPage>>() |
28 | val type = MutableLiveData<Int>() | 26 | val type = MutableLiveData<Int>() |
29 | - val sortId = MutableLiveData<Int>() | 27 | + |
28 | + val selectClassify = MutableLiveData<MaterialClassify>() | ||
29 | + val sortChild = MutableLiveData<MaterialChild>() | ||
30 | + val sortSecond = MutableLiveData<MaterialChildSecond>() | ||
31 | + val popChild = MutableLiveData<MaterialChild>() | ||
30 | var favoriteResponse = MutableLiveData<BaseResponse<Void>>() | 32 | var favoriteResponse = MutableLiveData<BaseResponse<Void>>() |
31 | 33 | ||
32 | fun collect( | 34 | fun collect( |
@@ -43,10 +45,10 @@ class DatabaseFViewModel : BaseViewModel<DocRepository>() { | @@ -43,10 +45,10 @@ class DatabaseFViewModel : BaseViewModel<DocRepository>() { | ||
43 | 45 | ||
44 | fun getDataList(page: Int) { | 46 | fun getDataList(page: Int) { |
45 | type.value?.let { | 47 | type.value?.let { |
46 | - sortId.value?.let { it1 -> | 48 | + sortSecond.value?.let { it1 -> |
47 | mRepository.getDocList( | 49 | mRepository.getDocList( |
48 | it, | 50 | it, |
49 | - it1, "", page, 10, classifyDataList | 51 | + it1.id, "", page, 10, classifyDataList |
50 | ) | 52 | ) |
51 | } | 53 | } |
52 | } | 54 | } |
1 | +package com.br_technology.securitytrain_master.view | ||
2 | + | ||
3 | +import android.app.Activity | ||
4 | +import android.content.Context | ||
5 | +import android.view.LayoutInflater | ||
6 | +import android.view.View | ||
7 | +import android.view.ViewGroup | ||
8 | +import android.widget.PopupWindow | ||
9 | +import androidx.core.content.ContextCompat | ||
10 | +import com.br_technology.securitytrain_master.R | ||
11 | +import com.br_technology.securitytrain_master.base.view.BaseAdapter | ||
12 | +import com.br_technology.securitytrain_master.databinding.ItemDatabaseChild1Binding | ||
13 | +import com.br_technology.securitytrain_master.databinding.ItemDatabaseChild2Binding | ||
14 | +import com.br_technology.securitytrain_master.databinding.PopDatabaseListBinding | ||
15 | +import com.br_technology.securitytrain_master.expand.addItemDecorationCustom | ||
16 | +import com.br_technology.securitytrain_master.expand.screenHeight | ||
17 | +import com.br_technology.securitytrain_master.expand.screenWidth | ||
18 | +import com.br_technology.securitytrain_master.ui.bean.MaterialChild | ||
19 | +import com.br_technology.securitytrain_master.ui.bean.MaterialChildSecond | ||
20 | + | ||
21 | +class DatabaseListPop(activity: Activity) : PopupWindow(activity) { | ||
22 | + private var mMaterialChild = mutableListOf<MaterialChild>() | ||
23 | + private val binding by lazy { | ||
24 | + PopDatabaseListBinding.inflate(LayoutInflater.from(activity)) | ||
25 | + } | ||
26 | + var iClickChild: IClickChild? = null | ||
27 | + private var childAdapter: DataListChild1? = null | ||
28 | + | ||
29 | + private var childSecond: MaterialChildSecond? = null | ||
30 | + private var child: MaterialChild? = null | ||
31 | + | ||
32 | + interface IClickChild { | ||
33 | + fun child(child: MaterialChild, data: MaterialChildSecond) | ||
34 | + } | ||
35 | + | ||
36 | + init { | ||
37 | + contentView = binding.root | ||
38 | + width = contentView.screenWidth() | ||
39 | + height = contentView.screenHeight() | ||
40 | + setBackgroundDrawable(ContextCompat.getDrawable(activity, android.R.color.transparent)) | ||
41 | + isOutsideTouchable = false | ||
42 | + | ||
43 | + binding.apply { | ||
44 | + dataList.addItemDecorationCustom(1) | ||
45 | + childAdapter = DataListChild1().apply { | ||
46 | + addList(mMaterialChild) | ||
47 | + } | ||
48 | + dataList.adapter = childAdapter | ||
49 | + } | ||
50 | + } | ||
51 | + | ||
52 | + fun addList(list: List<MaterialChild>, second: MaterialChildSecond, child: MaterialChild) { | ||
53 | + childAdapter?.addList(list) | ||
54 | + childSecond = second | ||
55 | + this.child = child | ||
56 | + } | ||
57 | + | ||
58 | + inner class DataListChild1 : BaseAdapter<MaterialChild, ItemDatabaseChild1Binding>() { | ||
59 | + override fun getViewBinding( | ||
60 | + context: Context, | ||
61 | + parent: ViewGroup, | ||
62 | + viewType: Int, | ||
63 | + from: LayoutInflater | ||
64 | + ): ItemDatabaseChild1Binding { | ||
65 | + return ItemDatabaseChild1Binding.inflate(from, parent, false) | ||
66 | + } | ||
67 | + | ||
68 | + override fun onBind(holder: ItemDatabaseChild1Binding, position: Int, data: MaterialChild) { | ||
69 | + holder.tvTitleChild1.text = data.name | ||
70 | + holder.tvTitleChild1.setTextColor( | ||
71 | + ContextCompat.getColor( | ||
72 | + binding.root.context, | ||
73 | + R.color.color_26292C | ||
74 | + ) | ||
75 | + ) | ||
76 | + data.child?.let { | ||
77 | + holder.listChild.adapter = DataListChild2().apply { | ||
78 | + addList(it) | ||
79 | + setChild(data) | ||
80 | + } | ||
81 | + } | ||
82 | + val isChild = child?.id == data.id | ||
83 | + holder.listChild.visibility = if (isChild) { | ||
84 | + View.VISIBLE | ||
85 | + } else { | ||
86 | + View.GONE | ||
87 | + } | ||
88 | + holder.llTitle.setOnClickListener { | ||
89 | + val isVis = holder.listChild.visibility == View.VISIBLE | ||
90 | + holder.listChild.visibility = if (isVis) { | ||
91 | + View.GONE | ||
92 | + } else { | ||
93 | + View.VISIBLE | ||
94 | + } | ||
95 | + } | ||
96 | + } | ||
97 | + } | ||
98 | + | ||
99 | + inner class DataListChild2 : BaseAdapter<MaterialChildSecond, ItemDatabaseChild2Binding>() { | ||
100 | + override fun getViewBinding( | ||
101 | + context: Context, | ||
102 | + parent: ViewGroup, | ||
103 | + viewType: Int, | ||
104 | + from: LayoutInflater | ||
105 | + ): ItemDatabaseChild2Binding { | ||
106 | + return ItemDatabaseChild2Binding.inflate(from, parent, false) | ||
107 | + } | ||
108 | + | ||
109 | + private var childData: MaterialChild? = null | ||
110 | + fun setChild(child: MaterialChild) { | ||
111 | + childData = child | ||
112 | + } | ||
113 | + | ||
114 | + override fun onBind( | ||
115 | + holder: ItemDatabaseChild2Binding, | ||
116 | + position: Int, | ||
117 | + data: MaterialChildSecond | ||
118 | + ) { | ||
119 | + val bool = childSecond != null && childSecond?.id == data.id | ||
120 | + val color = if (bool) { | ||
121 | + ContextCompat.getColor(binding.root.context, R.color.color_25) | ||
122 | + } else { | ||
123 | + ContextCompat.getColor(binding.root.context, R.color.color_26292C) | ||
124 | + } | ||
125 | + holder.tvTitleChild2.setTextColor(color) | ||
126 | + holder.tvTitleChild2.text = data.name | ||
127 | + holder.tvTitleChild2.setOnClickListener { | ||
128 | + childData?.let { | ||
129 | + if (iClickChild != null) { | ||
130 | + iClickChild!!.child(childData!!, data) | ||
131 | + } | ||
132 | + } | ||
133 | + dismiss() | ||
134 | + } | ||
135 | + } | ||
136 | + } | ||
137 | +} |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | android:nestedScrollingEnabled="false" | 26 | android:nestedScrollingEnabled="false" |
27 | android:overScrollMode="never" | 27 | android:overScrollMode="never" |
28 | android:scrollbars="none" | 28 | android:scrollbars="none" |
29 | - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"></androidx.recyclerview.widget.RecyclerView> | 29 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/> |
30 | </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> | 30 | </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
31 | 31 | ||
32 | </LinearLayout> | 32 | </LinearLayout> |
@@ -36,6 +36,7 @@ | @@ -36,6 +36,7 @@ | ||
36 | android:id="@+id/classify" | 36 | android:id="@+id/classify" |
37 | android:layout_width="match_parent" | 37 | android:layout_width="match_parent" |
38 | android:layout_height="wrap_content" | 38 | android:layout_height="wrap_content" |
39 | + android:layout_gravity="center_vertical" | ||
39 | android:orientation="horizontal" | 40 | android:orientation="horizontal" |
40 | android:overScrollMode="never" | 41 | android:overScrollMode="never" |
41 | android:paddingTop="10dp" | 42 | android:paddingTop="10dp" |
@@ -45,7 +46,7 @@ | @@ -45,7 +46,7 @@ | ||
45 | 46 | ||
46 | <FrameLayout | 47 | <FrameLayout |
47 | android:layout_width="match_parent" | 48 | android:layout_width="match_parent" |
48 | - android:layout_height="0.5dp" | 49 | + android:layout_height="30dp" |
49 | android:background="@color/color_f2f3"> | 50 | android:background="@color/color_f2f3"> |
50 | 51 | ||
51 | <TextView | 52 | <TextView |
@@ -59,7 +60,7 @@ | @@ -59,7 +60,7 @@ | ||
59 | android:text="通用知识" | 60 | android:text="通用知识" |
60 | android:textColor="@color/color_25" | 61 | android:textColor="@color/color_25" |
61 | android:textSize="12sp" | 62 | android:textSize="12sp" |
62 | - android:visibility="gone" /> | 63 | + android:visibility="visible" /> |
63 | </FrameLayout> | 64 | </FrameLayout> |
64 | 65 | ||
65 | <FrameLayout | 66 | <FrameLayout |
@@ -14,16 +14,12 @@ | @@ -14,16 +14,12 @@ | ||
14 | android:visibility="visible" | 14 | android:visibility="visible" |
15 | app:toolTitle="课程详情" /> | 15 | app:toolTitle="课程详情" /> |
16 | 16 | ||
17 | -<!-- <com.br_technology.securitytrain_master.view.MyVideoPlayer--> | ||
18 | -<!-- android:id="@+id/video_player"--> | ||
19 | -<!-- android:layout_width="match_parent"--> | ||
20 | -<!-- android:layout_height="210dp" />--> | ||
21 | - | ||
22 | <ImageView | 17 | <ImageView |
23 | android:scaleType="fitXY" | 18 | android:scaleType="fitXY" |
24 | android:id="@+id/iv_top" | 19 | android:id="@+id/iv_top" |
25 | android:layout_width="match_parent" | 20 | android:layout_width="match_parent" |
26 | - android:layout_height="210dp"/> | 21 | + android:layout_height="210dp" |
22 | + android:contentDescription="@null" /> | ||
27 | 23 | ||
28 | <com.google.android.material.tabs.TabLayout | 24 | <com.google.android.material.tabs.TabLayout |
29 | android:id="@+id/tab_layout" | 25 | android:id="@+id/tab_layout" |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <TextView xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <TextView xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:id="@+id/classify" | 3 | android:id="@+id/classify" |
4 | android:layout_width="wrap_content" | 4 | android:layout_width="wrap_content" |
5 | - android:layout_height="match_parent" | 5 | + android:layout_height="28dp" |
6 | android:background="@drawable/classify_text_back" | 6 | android:background="@drawable/classify_text_back" |
7 | android:gravity="center" | 7 | android:gravity="center" |
8 | android:paddingStart="16dp" | 8 | android:paddingStart="16dp" |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<LinearLayout 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 | + android:gravity="center_vertical" | ||
7 | + android:orientation="vertical"> | ||
8 | + | ||
9 | + <LinearLayout | ||
10 | + android:id="@+id/ll_title" | ||
11 | + android:layout_width="match_parent" | ||
12 | + android:layout_height="40dp" | ||
13 | + android:background="@color/white" | ||
14 | + android:gravity="center_vertical" | ||
15 | + android:orientation="horizontal" | ||
16 | + android:paddingStart="16dp" | ||
17 | + android:paddingEnd="16dp"> | ||
18 | + | ||
19 | + <TextView | ||
20 | + android:id="@+id/tv_title_child_1" | ||
21 | + android:layout_width="0dp" | ||
22 | + android:layout_height="match_parent" | ||
23 | + android:layout_weight="1" | ||
24 | + android:gravity="center_vertical" /> | ||
25 | + | ||
26 | + <ImageView | ||
27 | + android:layout_width="wrap_content" | ||
28 | + android:layout_height="wrap_content" | ||
29 | + android:contentDescription="@null" | ||
30 | + android:rotation="90" | ||
31 | + android:src="@mipmap/ic_arrow" /> | ||
32 | + </LinearLayout> | ||
33 | + | ||
34 | + <View | ||
35 | + android:layout_width="match_parent" | ||
36 | + android:layout_height="1px" | ||
37 | + android:layout_marginStart="16dp" | ||
38 | + android:layout_marginEnd="16dp" | ||
39 | + android:background="@color/color_c8" /> | ||
40 | + | ||
41 | + <androidx.recyclerview.widget.RecyclerView | ||
42 | + android:id="@+id/list_child" | ||
43 | + android:layout_width="match_parent" | ||
44 | + android:layout_height="wrap_content" | ||
45 | + android:nestedScrollingEnabled="false" | ||
46 | + android:overScrollMode="never" | ||
47 | + android:scrollbars="none" | ||
48 | + android:visibility="gone" | ||
49 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | ||
50 | +</LinearLayout> |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + android:layout_width="match_parent" | ||
4 | + android:layout_height="wrap_content" | ||
5 | + android:orientation="vertical"> | ||
6 | + | ||
7 | + <TextView | ||
8 | + android:id="@+id/tv_title_child_2" | ||
9 | + android:layout_width="match_parent" | ||
10 | + android:layout_height="40dp" | ||
11 | + android:background="@color/white" | ||
12 | + android:gravity="center_vertical" | ||
13 | + android:paddingStart="26dp" | ||
14 | + android:paddingEnd="26dp" /> | ||
15 | + | ||
16 | + <View | ||
17 | + android:layout_width="match_parent" | ||
18 | + android:layout_height="1px" | ||
19 | + android:layout_marginStart="16dp" | ||
20 | + android:layout_marginEnd="16dp" | ||
21 | + android:background="@color/color_c8" /> | ||
22 | +</LinearLayout> |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<LinearLayout 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:background="@android:color/transparent" | ||
7 | + android:orientation="vertical"> | ||
8 | + | ||
9 | + <View | ||
10 | + android:layout_width="match_parent" | ||
11 | + android:layout_height="?actionBarSize" /> | ||
12 | + | ||
13 | + <View | ||
14 | + android:layout_width="match_parent" | ||
15 | + android:layout_height="80dp" /> | ||
16 | + | ||
17 | + <androidx.recyclerview.widget.RecyclerView | ||
18 | + android:id="@+id/data_list" | ||
19 | + android:layout_width="match_parent" | ||
20 | + android:layout_height="0dp" | ||
21 | + android:layout_weight="1" | ||
22 | + android:overScrollMode="never" | ||
23 | + android:scrollbars="none" | ||
24 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | ||
25 | +</LinearLayout> |
-
请 注册 或 登录 后发表评论