作者 杨谦

1.人脸识别等

正在显示 55 个修改的文件 包含 1285 行增加441 行删除
@@ -59,6 +59,7 @@ dependencies { @@ -59,6 +59,7 @@ dependencies {
59 implementation 'androidx.appcompat:appcompat:1.1.0' 59 implementation 'androidx.appcompat:appcompat:1.1.0'
60 implementation 'com.google.android.material:material:1.1.0' 60 implementation 'com.google.android.material:material:1.1.0'
61 implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 61 implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  62 + implementation project(path: ':Library')
62 testImplementation 'junit:junit:4.+' 63 testImplementation 'junit:junit:4.+'
63 androidTestImplementation 'androidx.test.ext:junit:1.1.1' 64 androidTestImplementation 'androidx.test.ext:junit:1.1.1'
64 androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 65 androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
@@ -9,8 +9,8 @@ import java.io.File @@ -9,8 +9,8 @@ import java.io.File
9 * Description: 初见时你很迷人 9 * Description: 初见时你很迷人
10 */ 10 */
11 object Constant { 11 object Constant {
12 -// const val BASE_URL = "https://admin.anqixing.com"  
13 - const val BASE_URL = "https://security.brofirst.cn" 12 + const val BASE_URL = "https://admin.anqixing.com"
  13 +// const val BASE_URL = "https://security.brofirst.cn"
14 // const val BASE_URL = "https://test.admin.anqixing.com" 14 // const val BASE_URL = "https://test.admin.anqixing.com"
15 const val USERNAME_KEY = "username" 15 const val USERNAME_KEY = "username"
16 const val USERID_KEY = "userid" 16 const val USERID_KEY = "userid"
@@ -67,6 +67,8 @@ object Constant { @@ -67,6 +67,8 @@ object Constant {
67 67
68 val ACCOUNT_DIR: String = 68 val ACCOUNT_DIR: String =
69 Environment.getExternalStorageDirectory().toString() + File.separator.toString() + "images/" 69 Environment.getExternalStorageDirectory().toString() + File.separator.toString() + "images/"
  70 + val ACCOUNT_DIR_PIC: String =
  71 + Environment.getExternalStorageDirectory().toString() + File.separator.toString() + "Pictures/"
70 72
71 /** Milliseconds used for UI animations */ 73 /** Milliseconds used for UI animations */
72 const val ANIMATION_FAST_MILLIS = 50L 74 const val ANIMATION_FAST_MILLIS = 50L
1 package com.wjx.android.wanandroidmvvm.network 1 package com.wjx.android.wanandroidmvvm.network
2 2
3 import android.util.Log 3 import android.util.Log
4 -import com.br_technology.securitytrain_master.util.token  
5 import com.br_technology.securitytrain_master.base.common.Constant 4 import com.br_technology.securitytrain_master.base.common.Constant
  5 +import com.br_technology.securitytrain_master.util.token
6 import okhttp3.Interceptor 6 import okhttp3.Interceptor
7 import okhttp3.OkHttpClient 7 import okhttp3.OkHttpClient
8 import okhttp3.Response 8 import okhttp3.Response
@@ -59,7 +59,7 @@ class RetrofitFactory private constructor() { @@ -59,7 +59,7 @@ class RetrofitFactory private constructor() {
59 59
60 Log.e("request-----", request.toString()) 60 Log.e("request-----", request.toString())
61 Log.e("response-----", requestUrl+""+getResponseInfo(response)) 61 Log.e("response-----", requestUrl+""+getResponseInfo(response))
62 -// Log.e("requestUrl-----", requestUrl) 62 + Log.e("requestUrl-----", requestUrl)
63 63
64 64
65 //只保存登录或者注册 65 //只保存登录或者注册
@@ -349,4 +349,24 @@ interface ApiService { @@ -349,4 +349,24 @@ interface ApiService {
349 @Field("page") page: Int, 349 @Field("page") page: Int,
350 @Field("page_num") page_num: Int 350 @Field("page_num") page_num: Int
351 ): Observable<BaseResponse<CommonDataList<CommonPage<ScoreLog>>>> 351 ): Observable<BaseResponse<CommonDataList<CommonPage<ScoreLog>>>>
  352 +
  353 + /**
  354 + * 删除人脸
  355 + */
  356 + @POST("api/check_face/deletePerson")
  357 + fun deleteFace(): Observable<BaseResponse<Void>>
  358 +
  359 + /**
  360 + * 检测人脸
  361 + */
  362 + @FormUrlEncoded
  363 + @POST("/api/check_face/checkFace")
  364 + fun checkFace(@Field("url") url: String): Observable<BaseResponse<Void>>
  365 +
  366 + /**
  367 + * 上传人脸
  368 + */
  369 + @FormUrlEncoded
  370 + @POST("/api/check_face/createPerson")
  371 + fun setFace(@Field("url") url: String): Observable<BaseResponse<Void>>
352 } 372 }
@@ -4,8 +4,8 @@ import androidx.lifecycle.MutableLiveData @@ -4,8 +4,8 @@ import androidx.lifecycle.MutableLiveData
4 import com.br_technology.securitytrain_master.base.common.Constant 4 import com.br_technology.securitytrain_master.base.common.Constant
5 import com.br_technology.securitytrain_master.base.common.State 5 import com.br_technology.securitytrain_master.base.common.State
6 import com.br_technology.securitytrain_master.base.common.StateType 6 import com.br_technology.securitytrain_master.base.common.StateType
7 -import com.br_technology.securitytrain_master.base.repository.BaseRepository  
8 import com.br_technology.securitytrain_master.base.network.response.BaseResponse 7 import com.br_technology.securitytrain_master.base.network.response.BaseResponse
  8 +import com.br_technology.securitytrain_master.base.repository.BaseRepository
9 import io.reactivex.rxjava3.core.Observer 9 import io.reactivex.rxjava3.core.Observer
10 import io.reactivex.rxjava3.disposables.Disposable 10 import io.reactivex.rxjava3.disposables.Disposable
11 import retrofit2.HttpException 11 import retrofit2.HttpException
@@ -35,7 +35,6 @@ class BaseObserver<T : BaseResponse<*>>( @@ -35,7 +35,6 @@ class BaseObserver<T : BaseResponse<*>>(
35 } 35 }
36 Constant.NOT_LOGIN -> { 36 Constant.NOT_LOGIN -> {
37 // UserInfo.instance.logoutSuccess() 37 // UserInfo.instance.logoutSuccess()
38 -  
39 loadState.postValue(State(StateType.ERROR, message = "请重新登录")) 38 loadState.postValue(State(StateType.ERROR, message = "请重新登录"))
40 // BaseApplication.instance.applicationContext.startActivity(Intent(BaseApplication.instance.applicationContext,AccountLoginActivity::class.java).setFlags(InT)) 39 // BaseApplication.instance.applicationContext.startActivity(Intent(BaseApplication.instance.applicationContext,AccountLoginActivity::class.java).setFlags(InT))
41 } 40 }
@@ -10,6 +10,13 @@ import com.br_technology.securitytrain_master.ui.bean.* @@ -10,6 +10,13 @@ import com.br_technology.securitytrain_master.ui.bean.*
10 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 11 import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
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.wjx.android.wanandroidmvvm.base.observer.BaseObserver
  14 +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
  15 +import io.reactivex.rxjava3.schedulers.Schedulers
  16 +import okhttp3.MediaType
  17 +import okhttp3.MultipartBody
  18 +import okhttp3.RequestBody
  19 +import java.io.File
13 20
14 /** 21 /**
15 * Author by YSir 22 * Author by YSir
@@ -17,7 +24,7 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean @@ -17,7 +24,7 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
17 * description 24 * description
18 * PS: Not easy to write code, please indicate. 25 * PS: Not easy to write code, please indicate.
19 */ 26 */
20 -class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadState) { 27 +class LessonRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
21 28
22 fun workType( 29 fun workType(
23 liveData: MutableLiveData<BaseResponse<WorkTypeBean>> 30 liveData: MutableLiveData<BaseResponse<WorkTypeBean>>
@@ -191,4 +198,36 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt @@ -191,4 +198,36 @@ class LessonRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSt
191 ) { 198 ) {
192 addRequest(lessonService.collect(type, favorite_id), liveData) 199 addRequest(lessonService.collect(type, favorite_id), liveData)
193 } 200 }
  201 +
  202 + fun uploadFile(
  203 + path: String,
  204 + liveData: MutableLiveData<BaseResponse<UploadFileData>>
  205 + ) {
  206 + val file = File(path)
  207 + if (file.exists()) {
  208 + MultipartBody.Part.createFormData(
  209 + "file", file.name, RequestBody.create(MediaType.parse("multipart/form-data"), file)
  210 + )
  211 + apiService.uploadFile(
  212 + MultipartBody.Part.createFormData(
  213 + "file",
  214 + file.name,
  215 + RequestBody.create(MediaType.parse("multipart/form-data"), file)
  216 + )
  217 + )
  218 + .subscribeOn(Schedulers.io())
  219 + .observeOn(AndroidSchedulers.mainThread())
  220 + .subscribe(
  221 + BaseObserver(
  222 + liveData,
  223 + loadState,
  224 + this
  225 + )
  226 + )
  227 + }
  228 + }
  229 +
  230 + fun checkFace(url: String, liveData: MutableLiveData<BaseResponse<Void>>) {
  231 + addRequest(apiService.checkFace(url), liveData)
  232 + }
194 } 233 }
@@ -5,6 +5,13 @@ import com.br_technology.securitytrain_master.base.common.State @@ -5,6 +5,13 @@ import com.br_technology.securitytrain_master.base.common.State
5 import com.br_technology.securitytrain_master.base.network.response.* 5 import com.br_technology.securitytrain_master.base.network.response.*
6 import com.br_technology.securitytrain_master.ui.bean.* 6 import com.br_technology.securitytrain_master.ui.bean.*
7 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData 7 import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
  8 +import com.wjx.android.wanandroidmvvm.base.observer.BaseObserver
  9 +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
  10 +import io.reactivex.rxjava3.schedulers.Schedulers
  11 +import okhttp3.MediaType
  12 +import okhttp3.MultipartBody
  13 +import okhttp3.RequestBody
  14 +import java.io.File
8 15
9 /** 16 /**
10 * Author by YSir 17 * Author by YSir
@@ -12,7 +19,7 @@ import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData @@ -12,7 +19,7 @@ import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
12 * description 19 * description
13 * PS: Not easy to write code, please indicate. 20 * PS: Not easy to write code, please indicate.
14 */ 21 */
15 -class TrainRepository(loadState: MutableLiveData<State>) : ApiRepository(loadState) { 22 +class TrainRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
16 23
17 fun getTrainLessonList( 24 fun getTrainLessonList(
18 type: Int, 25 type: Int,
@@ -115,4 +122,36 @@ class TrainRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSta @@ -115,4 +122,36 @@ class TrainRepository(loadState: MutableLiveData<State>) : ApiRepository(loadSta
115 ) { 122 ) {
116 addRequest(itemService.scoreLog(page, page_num), liveData) 123 addRequest(itemService.scoreLog(page, page_num), liveData)
117 } 124 }
  125 +
  126 + fun uploadFile(
  127 + path: String,
  128 + liveData: MutableLiveData<BaseResponse<UploadFileData>>
  129 + ) {
  130 + val file = File(path)
  131 + if (file.exists()) {
  132 + MultipartBody.Part.createFormData(
  133 + "file", file.name, RequestBody.create(MediaType.parse("multipart/form-data"), file)
  134 + )
  135 + apiService.uploadFile(
  136 + MultipartBody.Part.createFormData(
  137 + "file",
  138 + file.name,
  139 + RequestBody.create(MediaType.parse("multipart/form-data"), file)
  140 + )
  141 + )
  142 + .subscribeOn(Schedulers.io())
  143 + .observeOn(AndroidSchedulers.mainThread())
  144 + .subscribe(
  145 + BaseObserver(
  146 + liveData,
  147 + loadState,
  148 + this
  149 + )
  150 + )
  151 + }
  152 + }
  153 +
  154 + fun checkFace(url: String, liveData: MutableLiveData<BaseResponse<Void>>) {
  155 + addRequest(apiService.checkFace(url), liveData)
  156 + }
118 } 157 }
1 package com.br_technology.securitytrain_master.expand 1 package com.br_technology.securitytrain_master.expand
2 2
3 -import android.R.attr  
4 import android.content.Context 3 import android.content.Context
5 import android.graphics.Point 4 import android.graphics.Point
6 import android.graphics.Rect 5 import android.graphics.Rect
7 import android.text.Spannable 6 import android.text.Spannable
8 import android.text.SpannableString 7 import android.text.SpannableString
9 import android.text.style.AbsoluteSizeSpan 8 import android.text.style.AbsoluteSizeSpan
10 -import android.util.Log  
11 import android.view.View 9 import android.view.View
12 import android.view.WindowManager 10 import android.view.WindowManager
13 import android.view.inputmethod.InputMethodManager 11 import android.view.inputmethod.InputMethodManager
@@ -66,12 +64,13 @@ fun RecyclerView.addItemDecoration3(spanCount: Int, spacing: Int, top: Int) { @@ -66,12 +64,13 @@ fun RecyclerView.addItemDecoration3(spanCount: Int, spacing: Int, top: Int) {
66 else -> { 64 else -> {
67 outRect.top = top 65 outRect.top = top
68 outRect.left = spacing 66 outRect.left = spacing
69 - outRect.right=0 67 + outRect.right = 0
70 } 68 }
71 } 69 }
72 } 70 }
73 }) 71 })
74 } 72 }
  73 +
75 fun RecyclerView.addItemDecoration2(spanCount: Int, spacing: Int, top: Int) { 74 fun RecyclerView.addItemDecoration2(spanCount: Int, spacing: Int, top: Int) {
76 this.addItemDecoration(object : RecyclerView.ItemDecoration() { 75 this.addItemDecoration(object : RecyclerView.ItemDecoration() {
77 override fun getItemOffsets( 76 override fun getItemOffsets(
@@ -92,21 +91,46 @@ fun RecyclerView.addItemDecoration2(spanCount: Int, spacing: Int, top: Int) { @@ -92,21 +91,46 @@ fun RecyclerView.addItemDecoration2(spanCount: Int, spacing: Int, top: Int) {
92 else -> { 91 else -> {
93 outRect.top = top 92 outRect.top = top
94 outRect.left = spacing 93 outRect.left = spacing
95 - outRect.right=0 94 + outRect.right = 0
  95 + }
96 } 96 }
97 } 97 }
  98 + })
  99 +}
  100 +
  101 +fun RecyclerView.addItemDecorationCustom(spacing: Int) {
  102 + this.addItemDecoration(object : RecyclerView.ItemDecoration() {
  103 + override fun getItemOffsets(
  104 + outRect: Rect,
  105 + view: View,
  106 + parent: RecyclerView,
  107 + state: RecyclerView.State
  108 + ) {
  109 + super.getItemOffsets(outRect, view, parent, state)
  110 + //这里是关键,需要根据你有几列来判断
  111 + val position: Int = parent.getChildAdapterPosition(view) // item position
  112 + outRect.top = 0
  113 + outRect.left = 0
  114 + outRect.right = 0
  115 + outRect.bottom = spacing
98 } 116 }
99 }) 117 })
100 } 118 }
101 119
102 fun TextView.percentage() { 120 fun TextView.percentage() {
103 val text = this.text 121 val text = this.text
104 - val span=SpannableString(text)  
105 - span.setSpan(AbsoluteSizeSpan(20.dp2px()),0,text.length-1,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)  
106 - this.text=span 122 + val span = SpannableString(text)
  123 + span.setSpan(
  124 + AbsoluteSizeSpan(20.dp2px()),
  125 + 0,
  126 + text.length - 1,
  127 + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
  128 + )
  129 + this.text = span
107 } 130 }
108 131
109 fun View.hideSoftInputFromWindow() { 132 fun View.hideSoftInputFromWindow() {
110 - val inputMethodManager=this.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager  
111 - inputMethodManager.hideSoftInputFromWindow(this.windowToken,0) 133 + val inputMethodManager =
  134 + this.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
  135 + inputMethodManager.hideSoftInputFromWindow(this.windowToken, 0)
112 } 136 }
1 package com.br_technology.securitytrain_master.ui.view.bank.activity 1 package com.br_technology.securitytrain_master.ui.view.bank.activity
2 2
3 import android.app.Activity 3 import android.app.Activity
4 -import android.content.Intent  
5 import android.view.View 4 import android.view.View
6 import androidx.activity.result.contract.ActivityResultContracts 5 import androidx.activity.result.contract.ActivityResultContracts
7 -import androidx.core.content.ContextCompat  
8 -import com.br_technology.securitytrain_master.R  
9 import com.br_technology.securitytrain_master.base.common.ConstantType 6 import com.br_technology.securitytrain_master.base.common.ConstantType
10 import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding 7 import com.br_technology.securitytrain_master.databinding.ActivityPracticeBinding
11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter 8 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
@@ -13,7 +10,6 @@ import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeVie @@ -13,7 +10,6 @@ import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeVie
13 import com.br_technology.securitytrain_master.view.DialogDetermine 10 import com.br_technology.securitytrain_master.view.DialogDetermine
14 import com.br_technology.securitytrain_master.view.DialogTitle 11 import com.br_technology.securitytrain_master.view.DialogTitle
15 import com.br_technology.securitytrain_master.view.listener.DialogListener 12 import com.br_technology.securitytrain_master.view.listener.DialogListener
16 -import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener  
17 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 13 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
18 14
19 /** 15 /**
@@ -68,24 +64,6 @@ class PracticeActivity : @@ -68,24 +64,6 @@ class PracticeActivity :
68 binding.toolBar.setTitle(ConstantType.getTestType(contentType)) 64 binding.toolBar.setTitle(ConstantType.getTestType(contentType))
69 mViewModel.itemStart(contentId, contentType) 65 mViewModel.itemStart(contentId, contentType)
70 binding.apply { 66 binding.apply {
71 - toolBar.setRightText("答题卡")  
72 - toolBar.setRightTextDrawable(  
73 - ContextCompat.getDrawable(  
74 - baseContext,  
75 - R.mipmap.answer_sheet  
76 - )  
77 - )  
78 - // 答题卡点击事件  
79 - toolBar.addRightListener(object : ToolBarClickListener {  
80 - override fun onClick(view: View) {  
81 - val intent = Intent(this@PracticeActivity, AnswerSheetActivity::class.java)  
82 - .putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())  
83 - .putExtra("showCorrect", mPagerAdapter.showCorrect)  
84 - .putExtra("title", binding.toolBar.getTitle())  
85 -  
86 - startForResult.launch(intent)  
87 - }  
88 - })  
89 // 显示交卷 67 // 显示交卷
90 finishJob.visibility = View.VISIBLE 68 finishJob.visibility = View.VISIBLE
91 // 上一题 69 // 上一题
@@ -164,6 +142,4 @@ class PracticeActivity : @@ -164,6 +142,4 @@ class PracticeActivity :
164 } 142 }
165 } 143 }
166 } 144 }
167 -  
168 -  
169 } 145 }
1 package com.br_technology.securitytrain_master.ui.view.bank.fragment 1 package com.br_technology.securitytrain_master.ui.view.bank.fragment
2 2
3 import android.content.Intent 3 import android.content.Intent
4 -import android.os.Bundle  
5 -import android.view.View  
6 import androidx.recyclerview.widget.LinearLayoutManager 4 import androidx.recyclerview.widget.LinearLayoutManager
7 import com.br_technology.securitytrain_master.R 5 import com.br_technology.securitytrain_master.R
8 import com.br_technology.securitytrain_master.base.common.ConstantType 6 import com.br_technology.securitytrain_master.base.common.ConstantType
@@ -11,16 +9,14 @@ import com.br_technology.securitytrain_master.ui.view.bank.activity.* @@ -11,16 +9,14 @@ import com.br_technology.securitytrain_master.ui.view.bank.activity.*
11 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticeAdapter 9 import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticeAdapter
12 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean 10 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
13 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.BankViewModel 11 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.BankViewModel
14 -import com.br_technology.securitytrain_master.ui.view.home.event.GetWorkTypeEvent 12 +import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
15 import com.br_technology.securitytrain_master.util.TYPE_All 13 import com.br_technology.securitytrain_master.util.TYPE_All
16 -import com.br_technology.securitytrain_master.util.TYPE_HOME  
17 -import com.br_technology.securitytrain_master.util.sp_job_name 14 +import com.br_technology.securitytrain_master.util.sp_job_id_select
  15 +import com.br_technology.securitytrain_master.util.sp_job_name_select
18 import com.br_technology.securitytrain_master.view.ClassifyPop 16 import com.br_technology.securitytrain_master.view.ClassifyPop
19 import com.br_technology.securitytrain_master.view.DialogStar 17 import com.br_technology.securitytrain_master.view.DialogStar
20 import com.br_technology.securitytrain_master.view.listener.DialogListener 18 import com.br_technology.securitytrain_master.view.listener.DialogListener
21 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 19 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
22 -import org.greenrobot.eventbus.EventBus  
23 -import org.greenrobot.eventbus.Subscribe  
24 20
25 /** 21 /**
26 * createTime:2021/7/27 15:47 22 * createTime:2021/7/27 15:47
@@ -39,24 +35,25 @@ class BankFragment : @@ -39,24 +35,25 @@ class BankFragment :
39 DialogStar(requireActivity()) 35 DialogStar(requireActivity())
40 } 36 }
41 37
42 - override fun onViewCreated(view: View, savedInstanceState: Bundle?) {  
43 - super.onViewCreated(view, savedInstanceState)  
44 - EventBus.getDefault().register(this)  
45 - }  
46 -  
47 - override fun onDestroyView() {  
48 - super.onDestroyView()  
49 - EventBus.getDefault().unregister(this)  
50 - } 38 + private var posId: Int = sp_job_id_select
51 39
52 override fun initData() { 40 override fun initData() {
53 super.initData() 41 super.initData()
  42 + classifyPop.setIClickListener(object : ClassifyPop.IClickListener {
  43 + override fun work(data: WorkTypeBean.ListBean) {
  44 + data.let {
  45 + posId = it.id
  46 + binding.type.text = (it.name)
  47 + refresh()
  48 + }
  49 + }
  50 + })
54 practiceList = mutableListOf() 51 practiceList = mutableListOf()
55 - mViewModel.practiceList(page, 20) 52 + refresh()
56 mViewModel.getAbout() 53 mViewModel.getAbout()
57 binding.apply { 54 binding.apply {
58 // 标题栏类型 55 // 标题栏类型
59 - type.text = sp_job_name 56 + type.text = sp_job_name_select
60 type.setOnClickListener { 57 type.setOnClickListener {
61 if (mViewModel.beanData().value == null) { 58 if (mViewModel.beanData().value == null) {
62 mViewModel.workType() 59 mViewModel.workType()
@@ -66,6 +63,14 @@ class BankFragment : @@ -66,6 +63,14 @@ class BankFragment :
66 } 63 }
67 } 64 }
68 } 65 }
  66 + change.setOnClickListener {
  67 + if (it.isPressed) {
  68 + refresh()
  69 + }
  70 + }
  71 + refreshLayout.setOnLoadMoreListener {
  72 + initLoadMore()
  73 + }
69 // 模拟考试 74 // 模拟考试
70 mockExam.setOnClickListener { 75 mockExam.setOnClickListener {
71 startActivity(MockExamActivity::class.java) 76 startActivity(MockExamActivity::class.java)
@@ -102,12 +107,6 @@ class BankFragment : @@ -102,12 +107,6 @@ class BankFragment :
102 } 107 }
103 108
104 initLoadMore() 109 initLoadMore()
105 -  
106 - swipeRefreshlayout.setOnRefreshListener {  
107 - practiceAdapter?.loadMoreModule?.isEnableLoadMore = false  
108 - page = 1  
109 - mViewModel.practiceList(page, 20)  
110 - }  
111 } 110 }
112 111
113 // 挑战答题弹框 112 // 挑战答题弹框
@@ -119,13 +118,18 @@ class BankFragment : @@ -119,13 +118,18 @@ class BankFragment :
119 }) 118 })
120 } 119 }
121 120
  121 + private fun refresh() {
  122 + page = 1
  123 + mViewModel.practiceList(page, 20, posId)
  124 + binding.refreshLayout.setEnableRefresh(false)
  125 + binding.refreshLayout.setEnableLoadMore(false)
  126 + }
  127 +
122 private fun initLoadMore() { 128 private fun initLoadMore() {
123 - practiceAdapter?.loadMoreModule?.setOnLoadMoreListener {  
124 page++ 129 page++
125 - binding.swipeRefreshlayout.isRefreshing = false  
126 - practiceAdapter?.loadMoreModule?.isEnableLoadMore = true  
127 - mViewModel.practiceList(page, 20)  
128 - } 130 + mViewModel.practiceList(page, 20, posId)
  131 + binding.refreshLayout.setEnableRefresh(false)
  132 + binding.refreshLayout.setEnableLoadMore(false)
129 practiceAdapter?.loadMoreModule?.isAutoLoadMore = true 133 practiceAdapter?.loadMoreModule?.isAutoLoadMore = true
130 practiceAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false 134 practiceAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
131 } 135 }
@@ -143,27 +147,14 @@ class BankFragment : @@ -143,27 +147,14 @@ class BankFragment :
143 }) 147 })
144 //专项练习列表 148 //专项练习列表
145 mViewModel.mPracticeBean.observe(this, { 149 mViewModel.mPracticeBean.observe(this, {
146 - binding.swipeRefreshlayout.isRefreshing = false  
147 - practiceAdapter?.loadMoreModule?.isEnableLoadMore = true  
148 - 150 + binding.refreshLayout.finishLoadMore()
  151 + binding.refreshLayout.finishRefresh()
  152 + binding.refreshLayout.setEnableLoadMore(it.data.list.size == 20)
149 if (page == 1) { 153 if (page == 1) {
150 practiceAdapter?.setList(it.data.list) 154 practiceAdapter?.setList(it.data.list)
151 } else { 155 } else {
152 practiceAdapter?.addData(it.data.list) 156 practiceAdapter?.addData(it.data.list)
153 } 157 }
154 -  
155 - if (it.data.list.size <= 20) {  
156 - practiceAdapter?.loadMoreModule?.loadMoreEnd()  
157 - } else {  
158 - practiceAdapter?.loadMoreModule?.loadMoreComplete()  
159 - }  
160 }) 158 })
161 } 159 }
162 -  
163 - @Subscribe  
164 - fun eventGet(data: GetWorkTypeEvent) {  
165 - if (data.type == TYPE_HOME || data.type == TYPE_All) {  
166 - binding.type.text = (data.name)  
167 - }  
168 - }  
169 } 160 }
@@ -9,7 +9,6 @@ import com.br_technology.securitytrain_master.ui.bean.AnswerAbout @@ -9,7 +9,6 @@ import com.br_technology.securitytrain_master.ui.bean.AnswerAbout
9 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean 9 import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
10 import com.br_technology.securitytrain_master.ui.view.bank.repository.BankRepository 10 import com.br_technology.securitytrain_master.ui.view.bank.repository.BankRepository
11 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean 11 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
12 -import com.br_technology.securitytrain_master.util.sp_job_id  
13 12
14 /** 13 /**
15 * createTime:2021/7/27 15:48 14 * createTime:2021/7/27 15:48
@@ -36,8 +35,9 @@ class BankViewModel : BaseViewModel<BankRepository>() { @@ -36,8 +35,9 @@ class BankViewModel : BaseViewModel<BankRepository>() {
36 var mPracticeBean: MutableLiveData<BaseResponse<CommonList<PracticeBean>>> = MutableLiveData() 35 var mPracticeBean: MutableLiveData<BaseResponse<CommonList<PracticeBean>>> = MutableLiveData()
37 fun practiceList( 36 fun practiceList(
38 page: Int, 37 page: Int,
39 - page_num: Int 38 + page_num: Int,
  39 + pos_id: Int
40 ) { 40 ) {
41 - mRepository.practiceList(sp_job_id, page, page_num, mPracticeBean) 41 + mRepository.practiceList(pos_id, page, page_num, mPracticeBean)
42 } 42 }
43 } 43 }
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.os.Bundle 3 import android.os.Bundle
  4 +import android.view.View
  5 +import androidx.core.content.ContextCompat
4 import androidx.fragment.app.FragmentPagerAdapter 6 import androidx.fragment.app.FragmentPagerAdapter
  7 +import com.br_technology.securitytrain_master.R
5 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter 8 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter
6 import com.br_technology.securitytrain_master.databinding.ActivityLiveCourseBinding 9 import com.br_technology.securitytrain_master.databinding.ActivityLiveCourseBinding
7 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.BankViewModel 10 import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.BankViewModel
@@ -9,7 +12,9 @@ import com.br_technology.securitytrain_master.ui.view.home.event.GetWorkTypeEven @@ -9,7 +12,9 @@ import com.br_technology.securitytrain_master.ui.view.home.event.GetWorkTypeEven
9 import com.br_technology.securitytrain_master.ui.view.home.fragment.OnLiveCourseFragment 12 import com.br_technology.securitytrain_master.ui.view.home.fragment.OnLiveCourseFragment
10 import com.br_technology.securitytrain_master.util.TYPE_All 13 import com.br_technology.securitytrain_master.util.TYPE_All
11 import com.br_technology.securitytrain_master.util.TYPE_LIVE 14 import com.br_technology.securitytrain_master.util.TYPE_LIVE
  15 +import com.br_technology.securitytrain_master.util.sp_job_name
12 import com.br_technology.securitytrain_master.view.ClassifyPop 16 import com.br_technology.securitytrain_master.view.ClassifyPop
  17 +import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
13 import com.google.android.material.tabs.TabLayout 18 import com.google.android.material.tabs.TabLayout
14 import com.gyf.immersionbar.ImmersionBar 19 import com.gyf.immersionbar.ImmersionBar
15 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 20 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
@@ -57,24 +62,24 @@ class LiveCourseActivity @@ -57,24 +62,24 @@ class LiveCourseActivity
57 override fun initData() { 62 override fun initData() {
58 super.initData() 63 super.initData()
59 binding.apply { 64 binding.apply {
60 -// toolBar.setRightText(sp_job_name)  
61 -// toolBar.setRightTextDrawable(  
62 -// ContextCompat.getDrawable(  
63 -// baseContext,  
64 -// R.mipmap.down_arrow  
65 -// )  
66 -// )  
67 -// toolBar.addRightListener(object : ToolBarClickListener {  
68 -// override fun onClick(view: View) {  
69 -// if (mViewModel.beanData().value == null) {  
70 -// mViewModel.workType()  
71 -// } else {  
72 -// mViewModel.beanData().value?.apply {  
73 -// classifyPop.showAsDropDown(binding.toolBar)  
74 -// }  
75 -// }  
76 -// }  
77 -// }) 65 + toolBar.setRightText(sp_job_name)
  66 + toolBar.setRightTextDrawable(
  67 + ContextCompat.getDrawable(
  68 + baseContext,
  69 + R.mipmap.down_arrow
  70 + )
  71 + )
  72 + toolBar.addRightListener(object : ToolBarClickListener {
  73 + override fun onClick(view: View) {
  74 + if (mViewModel.beanData().value == null) {
  75 + mViewModel.workType()
  76 + } else {
  77 + mViewModel.beanData().value?.apply {
  78 + classifyPop.showAsDropDown(binding.toolBar)
  79 + }
  80 + }
  81 + }
  82 + })
78 val searchResultAdapter = BasePagerAdapter( 83 val searchResultAdapter = BasePagerAdapter(
79 supportFragmentManager, 84 supportFragmentManager,
80 FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT 85 FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
@@ -2,6 +2,8 @@ package com.br_technology.securitytrain_master.ui.view.home.activity @@ -2,6 +2,8 @@ package com.br_technology.securitytrain_master.ui.view.home.activity
2 2
3 import android.content.Intent 3 import android.content.Intent
4 import android.os.Bundle 4 import android.os.Bundle
  5 +import android.view.View
  6 +import androidx.core.content.ContextCompat
5 import com.br_technology.securitytrain_master.R 7 import com.br_technology.securitytrain_master.R
6 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 8 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
7 import com.br_technology.securitytrain_master.databinding.ActivityOnlineBinding 9 import com.br_technology.securitytrain_master.databinding.ActivityOnlineBinding
@@ -11,7 +13,13 @@ import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType @@ -11,7 +13,13 @@ import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType
11 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity 13 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity
12 import com.br_technology.securitytrain_master.ui.view.home.adapter.VideoCourseAdapter 14 import com.br_technology.securitytrain_master.ui.view.home.adapter.VideoCourseAdapter
13 import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean 15 import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
  16 +import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
14 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.OnlineViewModel 17 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.OnlineViewModel
  18 +import com.br_technology.securitytrain_master.util.TYPE_All
  19 +import com.br_technology.securitytrain_master.util.sp_job_id_select
  20 +import com.br_technology.securitytrain_master.util.sp_job_name_select
  21 +import com.br_technology.securitytrain_master.view.ClassifyPop
  22 +import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
15 import com.chad.library.adapter.base.listener.OnLoadMoreListener 23 import com.chad.library.adapter.base.listener.OnLoadMoreListener
16 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 24 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
17 25
@@ -24,13 +32,41 @@ class OnlineActivity : @@ -24,13 +32,41 @@ class OnlineActivity :
24 BaseLifeCycleActivity<OnlineViewModel, ActivityOnlineBinding>(ActivityOnlineBinding::inflate) { 32 BaseLifeCycleActivity<OnlineViewModel, ActivityOnlineBinding>(ActivityOnlineBinding::inflate) {
25 private var videoLessonList: MutableList<VideoLessonBean.ListBean.DataBean>? = null 33 private var videoLessonList: MutableList<VideoLessonBean.ListBean.DataBean>? = null
26 private var page = 1 34 private var page = 1
27 - var videoCourseAdapter: VideoCourseAdapter? = null  
28 35
  36 + private val classifyPop by lazy {
  37 + ClassifyPop(this, TYPE_All)
  38 + }
  39 + private var posId: Int = sp_job_id_select
  40 + var videoCourseAdapter: VideoCourseAdapter? = null
29 override fun onCreate(savedInstanceState: Bundle?) { 41 override fun onCreate(savedInstanceState: Bundle?) {
30 super.onCreate(savedInstanceState) 42 super.onCreate(savedInstanceState)
  43 + classifyPop.setIClickListener(object : ClassifyPop.IClickListener {
  44 + override fun work(data: WorkTypeBean.ListBean) {
  45 + data.let {
  46 + posId = it.id
  47 + binding.toolBar.setRightText(it.name)
  48 + page = 1
  49 + loadData()
  50 + }
  51 + }
  52 + })
31 videoLessonList = mutableListOf() 53 videoLessonList = mutableListOf()
32 - mViewModel.videoLessons(1, "", page) 54 + loadData()
33 binding.apply { 55 binding.apply {
  56 + toolBar.setRightText(sp_job_name_select)
  57 + toolBar.setRightTextDrawable(
  58 + ContextCompat.getDrawable(
  59 + baseContext,
  60 + R.mipmap.down_arrow
  61 + )
  62 + )
  63 +
  64 + toolBar.addRightListener(object : ToolBarClickListener {
  65 + override fun onClick(view: View) {
  66 + mViewModel.workType()
  67 + }
  68 + })
  69 +
34 onlineRecycler.addItemDecoration2(2, 15, 24) 70 onlineRecycler.addItemDecoration2(2, 15, 24)
35 videoCourseAdapter = 71 videoCourseAdapter =
36 VideoCourseAdapter(R.layout.adapter_video_course, videoLessonList) 72 VideoCourseAdapter(R.layout.adapter_video_course, videoLessonList)
@@ -54,11 +90,12 @@ class OnlineActivity : @@ -54,11 +90,12 @@ class OnlineActivity :
54 swipeRefreshlayout.setOnRefreshListener { 90 swipeRefreshlayout.setOnRefreshListener {
55 videoCourseAdapter?.loadMoreModule?.isEnableLoadMore = false 91 videoCourseAdapter?.loadMoreModule?.isEnableLoadMore = false
56 page = 1 92 page = 1
57 - mViewModel.videoLessons(1, "", page) 93 + loadData()
58 } 94 }
59 } 95 }
60 } 96 }
61 97
  98 +
62 override fun initDataObserver() { 99 override fun initDataObserver() {
63 mViewModel.mVideoLessonBean.observe(this, { 100 mViewModel.mVideoLessonBean.observe(this, {
64 binding.swipeRefreshlayout.isRefreshing = false 101 binding.swipeRefreshlayout.isRefreshing = false
@@ -72,26 +109,26 @@ class OnlineActivity : @@ -72,26 +109,26 @@ class OnlineActivity :
72 } else { 109 } else {
73 videoLessonList?.let { it1 -> videoCourseAdapter?.addData(it1) } 110 videoLessonList?.let { it1 -> videoCourseAdapter?.addData(it1) }
74 } 111 }
75 -  
76 -// if (it.data.list.data != null) {  
77 -// if (it.data.list.data.size < 10) {  
78 -// videoCourseAdapter?.loadMoreModule?.loadMoreEnd()  
79 -// } else {  
80 -// videoCourseAdapter?.loadMoreModule?.loadMoreComplete()  
81 -// }  
82 -// }  
83 ++page 112 ++page
84 }) 113 })
  114 + mViewModel.mWorkTypeBean.observe(this, {
  115 + classifyPop.setList(it.data.list)
  116 + if (!classifyPop.isShowing) {
  117 + classifyPop.showAsDropDown(binding.toolBar)
  118 + }
  119 + })
  120 + }
  121 +
  122 + private fun loadData() {
  123 + mViewModel.videoLessons(1, "", page, posId)
85 } 124 }
86 125
87 fun initLoadMore() { 126 fun initLoadMore() {
88 videoCourseAdapter?.loadMoreModule?.setOnLoadMoreListener(object : OnLoadMoreListener { 127 videoCourseAdapter?.loadMoreModule?.setOnLoadMoreListener(object : OnLoadMoreListener {
89 override fun onLoadMore() { 128 override fun onLoadMore() {
90 binding.swipeRefreshlayout.isRefreshing = false 129 binding.swipeRefreshlayout.isRefreshing = false
91 -// videoCourseAdapter?.loadMoreModule?.isEnableLoadMore = true  
92 - mViewModel.videoLessons(1, "", page) 130 + loadData()
93 } 131 }
94 -  
95 }) 132 })
96 videoCourseAdapter?.loadMoreModule?.isAutoLoadMore = true 133 videoCourseAdapter?.loadMoreModule?.isAutoLoadMore = true
97 videoCourseAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false 134 videoCourseAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
@@ -32,6 +32,7 @@ class SearchActivity : @@ -32,6 +32,7 @@ class SearchActivity :
32 32
33 // 清空历史记录 33 // 清空历史记录
34 clear.setOnClickListener { 34 clear.setOnClickListener {
  35 + if (it.isPressed) {
35 DialogSureCancel(this@SearchActivity).setListener(object : DialogListener { 36 DialogSureCancel(this@SearchActivity).setListener(object : DialogListener {
36 override fun determine() { 37 override fun determine() {
37 // 清空记录 38 // 清空记录
@@ -39,6 +40,7 @@ class SearchActivity : @@ -39,6 +40,7 @@ class SearchActivity :
39 } 40 }
40 }).show() 41 }).show()
41 } 42 }
  43 + }
42 44
43 clearEdit.setOnClickListener { 45 clearEdit.setOnClickListener {
44 searchEdit.setText("") 46 searchEdit.setText("")
@@ -75,8 +77,8 @@ class SearchActivity : @@ -75,8 +77,8 @@ class SearchActivity :
75 } 77 }
76 } 78 }
77 79
78 - override fun initData() {  
79 - super.initData() 80 + override fun onResume() {
  81 + super.onResume()
80 mViewModel.searchLog() 82 mViewModel.searchLog()
81 } 83 }
82 84
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.content.Intent 3 import android.content.Intent
  4 +import android.view.View
  5 +import androidx.core.content.ContextCompat
4 import androidx.recyclerview.widget.LinearLayoutManager 6 import androidx.recyclerview.widget.LinearLayoutManager
5 import com.br_technology.securitytrain_master.R 7 import com.br_technology.securitytrain_master.R
6 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 8 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
@@ -9,7 +11,13 @@ import com.br_technology.securitytrain_master.ui.bean.CourseParam @@ -9,7 +11,13 @@ import com.br_technology.securitytrain_master.ui.bean.CourseParam
9 import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity 11 import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity
10 import com.br_technology.securitytrain_master.ui.view.home.adapter.TextLessonsAdapter 12 import com.br_technology.securitytrain_master.ui.view.home.adapter.TextLessonsAdapter
11 import com.br_technology.securitytrain_master.ui.view.home.bean.TextLessonBean 13 import com.br_technology.securitytrain_master.ui.view.home.bean.TextLessonBean
  14 +import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
12 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.TextCourseViewModel 15 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.TextCourseViewModel
  16 +import com.br_technology.securitytrain_master.util.TYPE_All
  17 +import com.br_technology.securitytrain_master.util.sp_job_id_select
  18 +import com.br_technology.securitytrain_master.util.sp_job_name_select
  19 +import com.br_technology.securitytrain_master.view.ClassifyPop
  20 +import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
13 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 21 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
14 22
15 23
@@ -23,23 +31,52 @@ class TextCourseActivity : @@ -23,23 +31,52 @@ class TextCourseActivity :
23 private var textLessonList: MutableList<TextLessonBean.ListBean.DataBean>? = null 31 private var textLessonList: MutableList<TextLessonBean.ListBean.DataBean>? = null
24 private var textLessonsAdapter: TextLessonsAdapter? = null 32 private var textLessonsAdapter: TextLessonsAdapter? = null
25 private var page = 1 33 private var page = 1
  34 + private val classifyPop by lazy {
  35 + ClassifyPop(this, TYPE_All)
  36 + }
  37 + private var posId: Int = sp_job_id_select
  38 +
  39 + private fun loadData() {
  40 + mViewModel.textLessons("", page, posId)
  41 + }
  42 +
26 override fun initData() { 43 override fun initData() {
27 super.initData() 44 super.initData()
28 - mViewModel.textLessons("", page)  
29 - 45 + loadData()
30 binding.apply { 46 binding.apply {
31 initAdapter() 47 initAdapter()
32 initLoadMore() 48 initLoadMore()
33 swipeRefreshlayout.setOnRefreshListener { 49 swipeRefreshlayout.setOnRefreshListener {
34 page = 1 50 page = 1
35 - mViewModel.textLessons("", page) 51 + loadData()
36 } 52 }
37 swipeRefreshlayout.setOnLoadMoreListener { 53 swipeRefreshlayout.setOnLoadMoreListener {
38 page++ 54 page++
39 - mViewModel.textLessons("", page) 55 + loadData()
40 } 56 }
  57 + toolBar.setRightText(sp_job_name_select)
  58 + toolBar.setRightTextDrawable(
  59 + ContextCompat.getDrawable(
  60 + baseContext,
  61 + R.mipmap.down_arrow
  62 + )
  63 + )
  64 + toolBar.addRightListener(object : ToolBarClickListener {
  65 + override fun onClick(view: View) {
  66 + mViewModel.workType()
  67 + }
  68 + })
  69 + }
  70 + classifyPop.setIClickListener(object : ClassifyPop.IClickListener {
  71 + override fun work(data: WorkTypeBean.ListBean) {
  72 + data.let {
  73 + posId = it.id
  74 + binding.toolBar.setRightText(it.name)
  75 + page = 1
  76 + loadData()
41 } 77 }
42 - 78 + }
  79 + })
43 } 80 }
44 81
45 private fun initAdapter() { 82 private fun initAdapter() {
@@ -62,19 +99,16 @@ class TextCourseActivity : @@ -62,19 +99,16 @@ class TextCourseActivity :
62 } 99 }
63 100
64 fun initLoadMore() { 101 fun initLoadMore() {
65 -// textLessonsAdapter?.loadMoreModule?.setOnLoadMoreListener(object : OnLoadMoreListener {  
66 -// override fun onLoadMore() {  
67 -// binding.swipeRefreshlayout.finishLoadMore()  
68 -// binding.swipeRefreshlayout.finishRefresh()  
69 -//  
70 -// }  
71 -// })  
72 -// textLessonsAdapter?.loadMoreModule?.isAutoLoadMore = true  
73 -// textLessonsAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false  
74 } 102 }
75 103
76 104
77 override fun initDataObserver() { 105 override fun initDataObserver() {
  106 + mViewModel.mWorkTypeBean.observe(this, {
  107 + classifyPop.setList(it.data.list)
  108 + if (!classifyPop.isShowing) {
  109 + classifyPop.showAsDropDown(binding.toolBar)
  110 + }
  111 + })
78 mViewModel.mTextLessonBean.observe(this, { 112 mViewModel.mTextLessonBean.observe(this, {
79 binding.swipeRefreshlayout.finishLoadMore() 113 binding.swipeRefreshlayout.finishLoadMore()
80 binding.swipeRefreshlayout.finishRefresh() 114 binding.swipeRefreshlayout.finishRefresh()
1 package com.br_technology.securitytrain_master.ui.view.home.activity.course 1 package com.br_technology.securitytrain_master.ui.view.home.activity.course
2 2
  3 +import android.Manifest
  4 +import android.content.Intent
  5 +import android.text.TextUtils
3 import androidx.fragment.app.FragmentPagerAdapter 6 import androidx.fragment.app.FragmentPagerAdapter
4 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 7 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
5 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter 8 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter
6 import com.br_technology.securitytrain_master.databinding.ActivityOnlineDetailBinding 9 import com.br_technology.securitytrain_master.databinding.ActivityOnlineDetailBinding
  10 +import com.br_technology.securitytrain_master.ext.initPermissions
7 import com.br_technology.securitytrain_master.ui.bean.* 11 import com.br_technology.securitytrain_master.ui.bean.*
8 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_LIVE 12 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_LIVE
9 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_NORMAL 13 import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_NORMAL
@@ -14,8 +18,13 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean @@ -14,8 +18,13 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
14 import com.br_technology.securitytrain_master.ui.view.home.fragment.CourseListFragment 18 import com.br_technology.securitytrain_master.ui.view.home.fragment.CourseListFragment
15 import com.br_technology.securitytrain_master.ui.view.home.fragment.OnlineDetailFragment 19 import com.br_technology.securitytrain_master.ui.view.home.fragment.OnlineDetailFragment
16 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CourseDetailViewModel 20 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CourseDetailViewModel
  21 +import com.br_technology.securitytrain_master.util.CameraUtil
  22 +import com.br_technology.securitytrain_master.util.FaceUtil
  23 +import com.br_technology.securitytrain_master.view.DialogCheckIDCard
  24 +import com.br_technology.securitytrain_master.view.DialogTrainLoading
17 import com.bumptech.glide.Glide 25 import com.bumptech.glide.Glide
18 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 26 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
  27 +import java.io.File
19 28
20 29
21 /** 30 /**
@@ -33,6 +42,64 @@ class CourseDetailActivity @@ -33,6 +42,64 @@ class CourseDetailActivity
33 private var mWorkBean: WorkTypeBean? = null 42 private var mWorkBean: WorkTypeBean? = null
34 private var mapWork = mutableMapOf<Int, WorkTypeBean.ListBean>() 43 private var mapWork = mutableMapOf<Int, WorkTypeBean.ListBean>()
35 44
  45 + private var dialogId: DialogCheckIDCard? = null
  46 + private var permissionCount = 0
  47 + private var fileUploadTemp: File? = null
  48 + private val faceUtil = FaceUtil()
  49 + private var dialogLoading: DialogTrainLoading? = null
  50 +
  51 + private fun showDialogId() {
  52 + if (dialogId == null) {
  53 + dialogId = DialogCheckIDCard(this)
  54 + dialogId!!.setListener({
  55 + dialogId!!.dismiss()
  56 + finish()
  57 + }, {
  58 + initPermissions(
  59 + Manifest.permission.CAMERA,
  60 + Manifest.permission.WRITE_EXTERNAL_STORAGE,
  61 + onGranted = {
  62 + if (permissionCount == 0) {
  63 + permissionCount++
  64 + if (CameraUtil.isSupportFrontCamera()) {
  65 + faceUtil.startCaptureFace(this, object : FaceUtil.ICapture {
  66 + override fun capture(file: File) {
  67 + fileUploadTemp = file
  68 + }
  69 + })
  70 + }
  71 + }
  72 + },
  73 + onDenied = {
  74 + }, onDeniedNever = {
  75 + })
  76 + })
  77 + }
  78 + dialogId!!.show()
  79 + }
  80 +
  81 + private fun dialogLoading() {
  82 + if (dialogLoading == null) {
  83 + dialogLoading = DialogTrainLoading(this)
  84 + }
  85 + dialogLoading!!.show()
  86 + }
  87 +
  88 + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
  89 + super.onActivityResult(requestCode, resultCode, data)
  90 + if (requestCode == FaceUtil.FRONT_CAPTURE_CODE) {
  91 + permissionCount = 0
  92 + fileUploadTemp?.let {
  93 + faceUtil.compressFile(this, fileUploadTemp!!, object : FaceUtil.ICompress {
  94 + override fun compress(file: File) {
  95 + dialogLoading()
  96 + mViewModel.uploadFace(file.path)
  97 + }
  98 + })
  99 + }
  100 + }
  101 + }
  102 +
36 override fun initDataObserver() { 103 override fun initDataObserver() {
37 // 培训视频课程 104 // 培训视频课程
38 mViewModel.mVideoLesson.observe(this, { 105 mViewModel.mVideoLesson.observe(this, {
@@ -80,7 +147,8 @@ class CourseDetailActivity @@ -80,7 +147,8 @@ class CourseDetailActivity
80 ) 147 )
81 searchResultAdapter?.addData(list.toMutableList()) 148 searchResultAdapter?.addData(list.toMutableList())
82 } 149 }
83 - else -> {} 150 + else -> {
  151 + }
84 } 152 }
85 } 153 }
86 val titles = listOf("课程详情", "课程列表") 154 val titles = listOf("课程详情", "课程列表")
@@ -143,6 +211,35 @@ class CourseDetailActivity @@ -143,6 +211,35 @@ class CourseDetailActivity
143 tabLayout.setupWithViewPager(viewPager) 211 tabLayout.setupWithViewPager(viewPager)
144 } 212 }
145 }) 213 })
  214 +
  215 + mViewModel.mFaceFile.observe(this, {
  216 + it.let {
  217 + if (!TextUtils.isEmpty(it.data.fullurl)) {
  218 + mViewModel.checkFace(it.data.fullurl)
  219 + } else {
  220 + showTip(it.msg)
  221 + if (dialogLoading != null) {
  222 + dialogLoading!!.dismiss()
  223 + }
  224 + }
  225 + }
  226 + })
  227 +
  228 + mViewModel.mFaceCheck.observe(this, {
  229 + if (dialogLoading != null) {
  230 + dialogLoading!!.dismiss()
  231 + }
  232 + it.let {
  233 + if (it.code == 1) {
  234 + if (dialogId != null) {
  235 + dialogId!!.dismiss()
  236 + }
  237 + } else {
  238 + finish()
  239 + showTip(it.msg)
  240 + }
  241 + }
  242 + })
146 } 243 }
147 244
148 private fun setPosName(posIds: String): String { 245 private fun setPosName(posIds: String): String {
@@ -190,6 +287,9 @@ class CourseDetailActivity @@ -190,6 +287,9 @@ class CourseDetailActivity
190 mViewModel.offLessonDetail(it.mLessonId.toInt()) 287 mViewModel.offLessonDetail(it.mLessonId.toInt())
191 } 288 }
192 } 289 }
  290 + if (it.type != TYPE_COURSE_DETAIL_ITEM_OFF) {
  291 + showDialogId()
  292 + }
193 } 293 }
194 }) 294 })
195 } 295 }
@@ -203,7 +203,7 @@ class CoursePractiseActivity : @@ -203,7 +203,7 @@ class CoursePractiseActivity :
203 } else { 203 } else {
204 ToastUtils.s(baseContext, it.msg) 204 ToastUtils.s(baseContext, it.msg)
205 } 205 }
206 - countDown(it.data.over_second) 206 +// countDown(it.data.over_second)
207 } 207 }
208 208
209 mViewModel.subSingleData.observe(this) { 209 mViewModel.subSingleData.observe(this) {
@@ -10,3 +10,5 @@ class GetWorkTypeEvent(var id: Int, var name: String, var type: Int) @@ -10,3 +10,5 @@ class GetWorkTypeEvent(var id: Int, var name: String, var type: Int)
10 class StatusTypeEvent(var id: Int, var name: String) 10 class StatusTypeEvent(var id: Int, var name: String)
11 11
12 class TransType(var id: Int) 12 class TransType(var id: Int)
  13 +
  14 +class CheckFace()
@@ -7,7 +7,7 @@ import androidx.recyclerview.widget.GridLayoutManager @@ -7,7 +7,7 @@ import androidx.recyclerview.widget.GridLayoutManager
7 import androidx.recyclerview.widget.LinearLayoutManager 7 import androidx.recyclerview.widget.LinearLayoutManager
8 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 8 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
9 import com.br_technology.securitytrain_master.databinding.FragmentResultBinding 9 import com.br_technology.securitytrain_master.databinding.FragmentResultBinding
10 -import com.br_technology.securitytrain_master.expand.addItemDecoration2 10 +import com.br_technology.securitytrain_master.expand.addItemDecorationCustom
11 import com.br_technology.securitytrain_master.ui.bean.* 11 import com.br_technology.securitytrain_master.ui.bean.*
12 import com.br_technology.securitytrain_master.ui.view.home.activity.DatabaseDetailActivity 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 13 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity
@@ -18,7 +18,6 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean @@ -18,7 +18,6 @@ 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.ui.view.mine.activity.LiveWebActivity
20 import com.br_technology.securitytrain_master.util.TranslateUnit 20 import com.br_technology.securitytrain_master.util.TranslateUnit
21 -import com.br_technology.securitytrain_master.view.VerticalDecoration  
22 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 21 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
23 import org.greenrobot.eventbus.EventBus 22 import org.greenrobot.eventbus.EventBus
24 import org.greenrobot.eventbus.Subscribe 23 import org.greenrobot.eventbus.Subscribe
@@ -56,16 +55,11 @@ class ResultFragment(val type: Int) : @@ -56,16 +55,11 @@ class ResultFragment(val type: Int) :
56 binding.apply { 55 binding.apply {
57 when (type) { 56 when (type) {
58 0 -> { 57 0 -> {
59 - result.addItemDecoration2(2, 15, 16) 58 + result.addItemDecorationCustom(TranslateUnit.dp2px(context, 16f))
60 result.layoutManager = GridLayoutManager(requireActivity(), 2) 59 result.layoutManager = GridLayoutManager(requireActivity(), 2)
61 } 60 }
62 else -> { 61 else -> {
63 - result.addItemDecoration(  
64 - VerticalDecoration(  
65 - TranslateUnit.dp2px(context, 16f),  
66 - 0  
67 - )  
68 - ) 62 + result.addItemDecorationCustom(TranslateUnit.dp2px(context, 16f))
69 result.layoutManager = LinearLayoutManager(requireActivity()) 63 result.layoutManager = LinearLayoutManager(requireActivity())
70 } 64 }
71 } 65 }
@@ -5,10 +5,7 @@ import com.br_technology.securitytrain_master.base.network.response.BaseResponse @@ -5,10 +5,7 @@ import com.br_technology.securitytrain_master.base.network.response.BaseResponse
5 import com.br_technology.securitytrain_master.base.network.response.CommonDetail 5 import com.br_technology.securitytrain_master.base.network.response.CommonDetail
6 import com.br_technology.securitytrain_master.base.repository.LessonRepository 6 import com.br_technology.securitytrain_master.base.repository.LessonRepository
7 import com.br_technology.securitytrain_master.base.view.BaseViewModel 7 import com.br_technology.securitytrain_master.base.view.BaseViewModel
8 -import com.br_technology.securitytrain_master.ui.bean.LessonClassDetail  
9 -import com.br_technology.securitytrain_master.ui.bean.LessonLive  
10 -import com.br_technology.securitytrain_master.ui.bean.LessonOfflineDetail  
11 -import com.br_technology.securitytrain_master.ui.bean.LessonTrainVideoDetail 8 +import com.br_technology.securitytrain_master.ui.bean.*
12 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean 9 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
13 10
14 /** 11 /**
@@ -23,6 +20,9 @@ class CourseDetailViewModel : BaseViewModel<LessonRepository>() { @@ -23,6 +20,9 @@ class CourseDetailViewModel : BaseViewModel<LessonRepository>() {
23 var mLessonOff = MutableLiveData<BaseResponse<CommonDetail<LessonOfflineDetail>>>() 20 var mLessonOff = MutableLiveData<BaseResponse<CommonDetail<LessonOfflineDetail>>>()
24 var mWorkBean = MutableLiveData<BaseResponse<WorkTypeBean>>() 21 var mWorkBean = MutableLiveData<BaseResponse<WorkTypeBean>>()
25 22
  23 + var mFaceFile = MutableLiveData<BaseResponse<UploadFileData>>()
  24 + var mFaceCheck = MutableLiveData<BaseResponse<Void>>()
  25 +
26 fun videoLessonsDetail( 26 fun videoLessonsDetail(
27 id: Int 27 id: Int
28 ) { 28 ) {
@@ -44,4 +44,12 @@ class CourseDetailViewModel : BaseViewModel<LessonRepository>() { @@ -44,4 +44,12 @@ class CourseDetailViewModel : BaseViewModel<LessonRepository>() {
44 fun workType() { 44 fun workType() {
45 mRepository.workType(mWorkBean) 45 mRepository.workType(mWorkBean)
46 } 46 }
  47 +
  48 + fun uploadFace(filePath: String) {
  49 + mRepository.uploadFile(filePath, mFaceFile)
  50 + }
  51 +
  52 + fun checkFace(url: String) {
  53 + mRepository.checkFace(url, mFaceCheck)
  54 + }
47 } 55 }
@@ -4,8 +4,8 @@ import androidx.lifecycle.MutableLiveData @@ -4,8 +4,8 @@ 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.view.BaseViewModel 5 import com.br_technology.securitytrain_master.base.view.BaseViewModel
6 import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean 6 import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
  7 +import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
7 import com.br_technology.securitytrain_master.ui.view.home.repository.OnlineRepository 8 import com.br_technology.securitytrain_master.ui.view.home.repository.OnlineRepository
8 -import com.br_technology.securitytrain_master.util.sp_job_id  
9 9
10 /** 10 /**
11 * createTime:2021/7/27 15:48 11 * createTime:2021/7/27 15:48
@@ -18,8 +18,14 @@ class OnlineViewModel : BaseViewModel<OnlineRepository>() { @@ -18,8 +18,14 @@ class OnlineViewModel : BaseViewModel<OnlineRepository>() {
18 fun videoLessons( 18 fun videoLessons(
19 is_rec: Int, 19 is_rec: Int,
20 keyword: String, 20 keyword: String,
21 - page: Int 21 + page: Int,
  22 + pos_id: Int
22 ) { 23 ) {
23 - mRepository.videoLessons(is_rec, keyword, sp_job_id, page, 10, mVideoLessonBean) 24 + mRepository.videoLessons(is_rec, keyword, pos_id, page, 10, mVideoLessonBean)
  25 + }
  26 +
  27 + var mWorkTypeBean: MutableLiveData<BaseResponse<WorkTypeBean>> = MutableLiveData()
  28 + fun workType() {
  29 + mRepository.workType(mWorkTypeBean)
24 } 30 }
25 } 31 }
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 3 import androidx.lifecycle.MutableLiveData
4 -import com.br_technology.securitytrain_master.util.sp_job_id 4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
5 import com.br_technology.securitytrain_master.base.view.BaseViewModel 5 import com.br_technology.securitytrain_master.base.view.BaseViewModel
6 import com.br_technology.securitytrain_master.ui.view.home.bean.TextLessonBean 6 import com.br_technology.securitytrain_master.ui.view.home.bean.TextLessonBean
7 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean 7 import com.br_technology.securitytrain_master.ui.view.home.bean.WorkTypeBean
8 import com.br_technology.securitytrain_master.ui.view.home.repository.TextCourseRepository 8 import com.br_technology.securitytrain_master.ui.view.home.repository.TextCourseRepository
9 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse  
10 9
11 /** 10 /**
12 * createTime:2021/7/27 15:48 11 * createTime:2021/7/27 15:48
@@ -19,8 +18,9 @@ class TextCourseViewModel : BaseViewModel<TextCourseRepository>() { @@ -19,8 +18,9 @@ class TextCourseViewModel : BaseViewModel<TextCourseRepository>() {
19 fun textLessons( 18 fun textLessons(
20 keyword: String, 19 keyword: String,
21 page: Int, 20 page: Int,
  21 + pos_id: Int
22 ) { 22 ) {
23 - mRepository.textLessons(keyword, sp_job_id, page, 10, mTextLessonBean) 23 + mRepository.textLessons(keyword, pos_id, page, 10, mTextLessonBean)
24 } 24 }
25 25
26 26
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.Manifest
  4 +import android.content.Intent
3 import android.os.Bundle 5 import android.os.Bundle
  6 +import android.text.TextUtils
4 import android.view.View 7 import android.view.View
5 import androidx.core.content.ContextCompat 8 import androidx.core.content.ContextCompat
6 import androidx.fragment.app.FragmentPagerAdapter 9 import androidx.fragment.app.FragmentPagerAdapter
@@ -10,15 +13,21 @@ import com.br_technology.securitytrain_master.base.common.ConstantType.TYPE_CLAS @@ -10,15 +13,21 @@ import com.br_technology.securitytrain_master.base.common.ConstantType.TYPE_CLAS
10 import com.br_technology.securitytrain_master.base.common.ConstantType.TYPE_CLASS_PRACTICE 13 import com.br_technology.securitytrain_master.base.common.ConstantType.TYPE_CLASS_PRACTICE
11 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter 14 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter
12 import com.br_technology.securitytrain_master.databinding.ActivityClassDutyBinding 15 import com.br_technology.securitytrain_master.databinding.ActivityClassDutyBinding
  16 +import com.br_technology.securitytrain_master.ext.initPermissions
13 import com.br_technology.securitytrain_master.ui.view.home.adapter.StatusName 17 import com.br_technology.securitytrain_master.ui.view.home.adapter.StatusName
14 import com.br_technology.securitytrain_master.ui.view.home.event.StatusTypeEvent 18 import com.br_technology.securitytrain_master.ui.view.home.event.StatusTypeEvent
15 import com.br_technology.securitytrain_master.ui.view.mine.fragment.ClassDutyCourseFragment 19 import com.br_technology.securitytrain_master.ui.view.mine.fragment.ClassDutyCourseFragment
16 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyViewModel 20 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyViewModel
  21 +import com.br_technology.securitytrain_master.util.CameraUtil
  22 +import com.br_technology.securitytrain_master.util.FaceUtil
  23 +import com.br_technology.securitytrain_master.view.DialogCheckIDCard
  24 +import com.br_technology.securitytrain_master.view.DialogTrainLoading
17 import com.br_technology.securitytrain_master.view.StatusPop 25 import com.br_technology.securitytrain_master.view.StatusPop
18 import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener 26 import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
19 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 27 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
20 import org.greenrobot.eventbus.EventBus 28 import org.greenrobot.eventbus.EventBus
21 import org.greenrobot.eventbus.Subscribe 29 import org.greenrobot.eventbus.Subscribe
  30 +import java.io.File
22 31
23 /** 32 /**
24 * Time: 8/3/2021 11:15 33 * Time: 8/3/2021 11:15
@@ -28,7 +37,61 @@ import org.greenrobot.eventbus.Subscribe @@ -28,7 +37,61 @@ import org.greenrobot.eventbus.Subscribe
28 */ 37 */
29 class ClassDutyActivity : 38 class ClassDutyActivity :
30 BaseLifeCycleActivity<ClassDutyViewModel, ActivityClassDutyBinding>(ActivityClassDutyBinding::inflate) { 39 BaseLifeCycleActivity<ClassDutyViewModel, ActivityClassDutyBinding>(ActivityClassDutyBinding::inflate) {
  40 + private var dialogId: DialogCheckIDCard? = null
  41 + private var permissionCount = 0
  42 + private var fileUploadTemp: File? = null
  43 + private val faceUtil = FaceUtil()
  44 + private var dialogLoading: DialogTrainLoading? = null
  45 + private var isChecked = false
31 46
  47 + fun showDialogId() {
  48 + if (dialogId == null) {
  49 + dialogId = DialogCheckIDCard(this)
  50 + dialogId!!.setListener({ dialogId!!.dismiss() }, {
  51 + initPermissions(
  52 + Manifest.permission.CAMERA,
  53 + Manifest.permission.WRITE_EXTERNAL_STORAGE,
  54 + onGranted = {
  55 + if (permissionCount == 0) {
  56 + permissionCount++
  57 + if (CameraUtil.isSupportFrontCamera()) {
  58 + faceUtil.startCaptureFace(this, object : FaceUtil.ICapture {
  59 + override fun capture(file: File) {
  60 + fileUploadTemp = file
  61 + }
  62 + })
  63 + }
  64 + }
  65 + },
  66 + onDenied = {
  67 + }, onDeniedNever = {
  68 + })
  69 + })
  70 + }
  71 + dialogId!!.show()
  72 + }
  73 +
  74 + private fun dialogLoading() {
  75 + if (dialogLoading == null) {
  76 + dialogLoading = DialogTrainLoading(this)
  77 + }
  78 + dialogLoading!!.show()
  79 + }
  80 +
  81 + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
  82 + super.onActivityResult(requestCode, resultCode, data)
  83 + if (requestCode == FaceUtil.FRONT_CAPTURE_CODE) {
  84 + permissionCount = 0
  85 + fileUploadTemp?.let {
  86 + faceUtil.compressFile(this, fileUploadTemp!!, object : FaceUtil.ICompress {
  87 + override fun compress(file: File) {
  88 + dialogLoading()
  89 + mViewModel.uploadFace(file.path)
  90 + }
  91 + })
  92 + }
  93 + }
  94 + }
32 95
33 private val classifyPop by lazy { 96 private val classifyPop by lazy {
34 //type 状态0=全部1=已完成2=未完成 97 //type 状态0=全部1=已完成2=未完成
@@ -53,6 +116,34 @@ class ClassDutyActivity : @@ -53,6 +116,34 @@ class ClassDutyActivity :
53 } 116 }
54 117
55 override fun initDataObserver() { 118 override fun initDataObserver() {
  119 + mViewModel.mFaceFile.observe(this, {
  120 + it.let {
  121 + if (!TextUtils.isEmpty(it.data.fullurl)) {
  122 + mViewModel.checkFace(it.data.fullurl)
  123 + } else {
  124 + showTip(it.msg)
  125 + if (dialogLoading != null) {
  126 + dialogLoading!!.dismiss()
  127 + }
  128 + }
  129 + }
  130 + })
  131 +
  132 + mViewModel.mFaceCheck.observe(this, {
  133 + if (dialogLoading != null) {
  134 + dialogLoading!!.dismiss()
  135 + }
  136 + it.let {
  137 + if (it.code == 1) {
  138 + if (dialogId != null) {
  139 + dialogId!!.dismiss()
  140 + }
  141 + isChecked = true
  142 + } else {
  143 + showTip(it.msg)
  144 + }
  145 + }
  146 + })
56 } 147 }
57 148
58 override fun initData() { 149 override fun initData() {
@@ -93,4 +184,8 @@ class ClassDutyActivity : @@ -93,4 +184,8 @@ class ClassDutyActivity :
93 tabLayout.setupWithViewPager(viewPager) 184 tabLayout.setupWithViewPager(viewPager)
94 } 185 }
95 } 186 }
  187 +
  188 + fun isChecked(): Boolean {
  189 + return isChecked
  190 + }
96 } 191 }
@@ -103,6 +103,7 @@ class CredentialsUpLoadActivity : @@ -103,6 +103,7 @@ class CredentialsUpLoadActivity :
103 binding.apply { 103 binding.apply {
104 // 上传照片 104 // 上传照片
105 tvUpload.setOnClickListener { 105 tvUpload.setOnClickListener {
  106 + if (it.isPressed) {
106 tvUpload.isClickable = false 107 tvUpload.isClickable = false
107 if (path.isEmpty()) { 108 if (path.isEmpty()) {
108 showTip("请选择证件照片") 109 showTip("请选择证件照片")
@@ -121,6 +122,7 @@ class CredentialsUpLoadActivity : @@ -121,6 +122,7 @@ class CredentialsUpLoadActivity :
121 } 122 }
122 mViewModel.certAdd(id, typeId, path, dateTime, endTime) 123 mViewModel.certAdd(id, typeId, path, dateTime, endTime)
123 } 124 }
  125 + }
124 126
125 // 选择图片 127 // 选择图片
126 uploadPic.setOnClickListener { 128 uploadPic.setOnClickListener {
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.Manifest 3 import android.Manifest
  4 +import android.content.Intent
4 import android.text.TextUtils 5 import android.text.TextUtils
5 import android.view.View 6 import android.view.View
6 import com.br_technology.securitytrain_master.R 7 import com.br_technology.securitytrain_master.R
7 import com.br_technology.securitytrain_master.databinding.ActivityEditPersonalInfoBinding 8 import com.br_technology.securitytrain_master.databinding.ActivityEditPersonalInfoBinding
8 import com.br_technology.securitytrain_master.ext.initPermissions 9 import com.br_technology.securitytrain_master.ext.initPermissions
9 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.EditPersonalInfoViewModel 10 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.EditPersonalInfoViewModel
  11 +import com.br_technology.securitytrain_master.util.CameraUtil
  12 +import com.br_technology.securitytrain_master.util.FaceUtil
10 import com.br_technology.securitytrain_master.util.GlideEnginePic 13 import com.br_technology.securitytrain_master.util.GlideEnginePic
11 import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener 14 import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
12 import com.bumptech.glide.Glide 15 import com.bumptech.glide.Glide
@@ -16,6 +19,7 @@ import com.luck.picture.lib.config.PictureMimeType @@ -16,6 +19,7 @@ import com.luck.picture.lib.config.PictureMimeType
16 import com.luck.picture.lib.entity.LocalMedia 19 import com.luck.picture.lib.entity.LocalMedia
17 import com.luck.picture.lib.listener.OnResultCallbackListener 20 import com.luck.picture.lib.listener.OnResultCallbackListener
18 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 21 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
  22 +import java.io.File
19 23
20 /** 24 /**
21 * Time: 7/31/2021 14:32 25 * Time: 7/31/2021 14:32
@@ -28,6 +32,8 @@ class EditPersonalInfoActivity : @@ -28,6 +32,8 @@ class EditPersonalInfoActivity :
28 ), View.OnClickListener { 32 ), View.OnClickListener {
29 private var avatar: String? = null 33 private var avatar: String? = null
30 34
  35 + private var permissionCount = 0
  36 +
31 override fun initDataObserver() { 37 override fun initDataObserver() {
32 //显示我的信息 38 //显示我的信息
33 mViewModel.mMineInfoBean.observe(this, { 39 mViewModel.mMineInfoBean.observe(this, {
@@ -39,7 +45,11 @@ class EditPersonalInfoActivity : @@ -39,7 +45,11 @@ class EditPersonalInfoActivity :
39 avatar = it.data.info.avatar 45 avatar = it.data.info.avatar
40 Glide.with(this).load(avatar) 46 Glide.with(this).load(avatar)
41 .placeholder(R.mipmap.placeholder_head).into(binding.ivIcon) 47 .placeholder(R.mipmap.placeholder_head).into(binding.ivIcon)
42 - 48 + binding.tvPhoneFace.text = if (it.data.info.is_check_face.equals("1")) {
  49 + "可重置"
  50 + } else {
  51 + "去设置"
  52 + }
43 }) 53 })
44 //图片上传成功 54 //图片上传成功
45 mViewModel.mUploadFileData.observe(this, { 55 mViewModel.mUploadFileData.observe(this, {
@@ -51,12 +61,29 @@ class EditPersonalInfoActivity : @@ -51,12 +61,29 @@ class EditPersonalInfoActivity :
51 } 61 }
52 }) 62 })
53 //保存修改 63 //保存修改
54 - mViewModel.mCommonBean.observe(this,{ 64 + mViewModel.mCommonBean.observe(this, {
55 it.let { 65 it.let {
56 showTip("修改成功") 66 showTip("修改成功")
57 finish() 67 finish()
58 } 68 }
59 }) 69 })
  70 + //
  71 + mViewModel.mUploadFaceFileData.observe(this, {
  72 + it.let {
  73 + if (!TextUtils.isEmpty(it.data.fullurl)) {
  74 + mViewModel.changeFace(it.data.fullurl)
  75 + } else {
  76 + showTip(it.msg)
  77 + }
  78 + }
  79 + })
  80 + mViewModel.deleteResponse.observe(this, {
  81 + showTip(it.msg)
  82 + refresh()
  83 + })
  84 + mViewModel.changeResponse.observe(this, {
  85 + refresh()
  86 + })
60 } 87 }
61 88
62 override fun initView() { 89 override fun initView() {
@@ -66,29 +93,77 @@ class EditPersonalInfoActivity : @@ -66,29 +93,77 @@ class EditPersonalInfoActivity :
66 93
67 override fun initData() { 94 override fun initData() {
68 super.initData() 95 super.initData()
  96 + refresh()
69 ImmersionBar.with(this@EditPersonalInfoActivity).statusBarDarkFont(true).init() 97 ImmersionBar.with(this@EditPersonalInfoActivity).statusBarDarkFont(true).init()
70 binding.apply { 98 binding.apply {
71 llChangePwd.setOnClickListener(this@EditPersonalInfoActivity) 99 llChangePwd.setOnClickListener(this@EditPersonalInfoActivity)
  100 + llChangeFace.setOnClickListener(this@EditPersonalInfoActivity)
72 llChangePhone.setOnClickListener(this@EditPersonalInfoActivity) 101 llChangePhone.setOnClickListener(this@EditPersonalInfoActivity)
73 rlUpLoadImage.setOnClickListener(this@EditPersonalInfoActivity) 102 rlUpLoadImage.setOnClickListener(this@EditPersonalInfoActivity)
74 toolBar.addLeftListener(object : ToolBarClickListener { 103 toolBar.addLeftListener(object : ToolBarClickListener {
75 override fun onClick(view: View) { 104 override fun onClick(view: View) {
76 //退出时保存 105 //退出时保存
77 - avatar?.let { mViewModel.changePersonalInfo(it,binding.tvName.text.toString(),"") } 106 + avatar?.let {
  107 + mViewModel.changePersonalInfo(
  108 + it,
  109 + binding.tvName.text.toString(),
  110 + ""
  111 + )
  112 + }
78 } 113 }
79 114
80 }) 115 })
81 } 116 }
82 } 117 }
83 118
84 - override fun onResume() {  
85 - super.onResume()  
86 - //获取我的数据 119 + fun refresh() {
87 mViewModel.getMineInfo() 120 mViewModel.getMineInfo()
88 } 121 }
89 122
  123 + var fileUploadTemp: File? = null
  124 +
  125 + private val faceUtil = FaceUtil()
  126 +
  127 + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
  128 + super.onActivityResult(requestCode, resultCode, data)
  129 + if (requestCode == FaceUtil.FRONT_CAPTURE_CODE) {
  130 + permissionCount = 0
  131 + fileUploadTemp?.let {
  132 + faceUtil.compressFile(this, fileUploadTemp!!, object : FaceUtil.ICompress {
  133 + override fun compress(file: File) {
  134 + mViewModel.uploadFaceFile(file)
  135 + }
  136 + })
  137 + }
  138 + }
  139 + }
  140 +
90 override fun onClick(v: View?) { 141 override fun onClick(v: View?) {
91 when (v!!.id) { 142 when (v!!.id) {
  143 + R.id.ll_change_face -> {
  144 + val status = binding.tvPhoneFace.text.toString() == "可重置"
  145 + if (status) {
  146 + mViewModel.deleteFace()
  147 + } else {
  148 + initPermissions(Manifest.permission.CAMERA,
  149 + Manifest.permission.WRITE_EXTERNAL_STORAGE,
  150 + onGranted = {
  151 + if (permissionCount == 0) {
  152 + permissionCount++
  153 + if (CameraUtil.isSupportFrontCamera()) {
  154 + faceUtil.startCaptureFace(this, object : FaceUtil.ICapture {
  155 + override fun capture(file: File) {
  156 + fileUploadTemp = file
  157 + }
  158 + })
  159 + }
  160 + }
  161 + },
  162 + onDenied = {
  163 + }, onDeniedNever = {
  164 + })
  165 + }
  166 + }
92 R.id.ll_change_pwd -> { 167 R.id.ll_change_pwd -> {
93 //修改密码 168 //修改密码
94 startActivity(ChangePwdActivity::class.java) 169 startActivity(ChangePwdActivity::class.java)
@@ -124,9 +199,7 @@ class EditPersonalInfoActivity : @@ -124,9 +199,7 @@ class EditPersonalInfoActivity :
124 } 199 }
125 200
126 override fun onCancel() { 201 override fun onCancel() {
127 -  
128 } 202 }
129 -  
130 }) 203 })
131 }, 204 },
132 onDenied = { 205 onDenied = {
@@ -137,7 +210,6 @@ class EditPersonalInfoActivity : @@ -137,7 +210,6 @@ class EditPersonalInfoActivity :
137 } 210 }
138 211
139 //上传图片 212 //上传图片
140 -  
141 fun uploadFile(path: String) { 213 fun uploadFile(path: String) {
142 mViewModel.uploadFile(path) 214 mViewModel.uploadFile(path)
143 } 215 }
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 android.content.Intent
4 -import com.br_technology.securitytrain_master.R  
5 import com.br_technology.securitytrain_master.databinding.ActivityMyCredentialsBinding 4 import com.br_technology.securitytrain_master.databinding.ActivityMyCredentialsBinding
6 import com.br_technology.securitytrain_master.expand.addItemDecoration2 5 import com.br_technology.securitytrain_master.expand.addItemDecoration2
7 import com.br_technology.securitytrain_master.expand.dp2px 6 import com.br_technology.securitytrain_master.expand.dp2px
8 import com.br_technology.securitytrain_master.ui.bean.UserCert 7 import com.br_technology.securitytrain_master.ui.bean.UserCert
9 -import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendData  
10 import com.br_technology.securitytrain_master.ui.view.mine.adapter.MyCredentialsAdapter 8 import com.br_technology.securitytrain_master.ui.view.mine.adapter.MyCredentialsAdapter
11 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyCredentialsViewModel 9 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyCredentialsViewModel
12 -import com.br_technology.securitytrain_master.view.CenterToast  
13 import com.br_technology.securitytrain_master.view.listener.OnItemClickListener 10 import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
14 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 11 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
15 12
@@ -43,7 +40,6 @@ class MyCredentialsActivity : @@ -43,7 +40,6 @@ class MyCredentialsActivity :
43 override fun initData() { 40 override fun initData() {
44 super.initData() 41 super.initData()
45 42
46 -  
47 binding.apply { 43 binding.apply {
48 smartRefresh.setOnRefreshListener { 44 smartRefresh.setOnRefreshListener {
49 smartRefresh.setNoMoreData(false) 45 smartRefresh.setNoMoreData(false)
@@ -3,7 +3,6 @@ package com.br_technology.securitytrain_master.ui.view.mine.activity @@ -3,7 +3,6 @@ package com.br_technology.securitytrain_master.ui.view.mine.activity
3 import androidx.fragment.app.FragmentPagerAdapter 3 import androidx.fragment.app.FragmentPagerAdapter
4 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter 4 import com.br_technology.securitytrain_master.base.view.BasePagerAdapter
5 import com.br_technology.securitytrain_master.databinding.ActivityQuestionRecordBinding 5 import com.br_technology.securitytrain_master.databinding.ActivityQuestionRecordBinding
6 -import com.br_technology.securitytrain_master.ui.view.mine.fragment.MockExaminationFragment  
7 import com.br_technology.securitytrain_master.ui.view.mine.fragment.SpecialExercisesFragment 6 import com.br_technology.securitytrain_master.ui.view.mine.fragment.SpecialExercisesFragment
8 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.QuestionRecordViewModel 7 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.QuestionRecordViewModel
9 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 8 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
@@ -40,6 +39,7 @@ class QuestionRecordActivity : @@ -40,6 +39,7 @@ class QuestionRecordActivity :
40 searchResultAdapter.addTitle(titles) 39 searchResultAdapter.addTitle(titles)
41 viewPager.adapter = searchResultAdapter 40 viewPager.adapter = searchResultAdapter
42 tabLayout.setupWithViewPager(viewPager) 41 tabLayout.setupWithViewPager(viewPager)
  42 + viewPager.offscreenPageLimit = 3
43 } 43 }
44 } 44 }
45 45
@@ -4,14 +4,11 @@ import android.content.Context @@ -4,14 +4,11 @@ import android.content.Context
4 import android.view.LayoutInflater 4 import android.view.LayoutInflater
5 import android.view.ViewGroup 5 import android.view.ViewGroup
6 import androidx.viewbinding.ViewBinding 6 import androidx.viewbinding.ViewBinding
7 -import com.br_technology.securitytrain_master.R  
8 import com.br_technology.securitytrain_master.base.view.BaseMultiAdapter 7 import com.br_technology.securitytrain_master.base.view.BaseMultiAdapter
9 import com.br_technology.securitytrain_master.databinding.ItemMyCredentialsUploadBinding 8 import com.br_technology.securitytrain_master.databinding.ItemMyCredentialsUploadBinding
10 import com.br_technology.securitytrain_master.databinding.ItemMycredentialsShowBinding 9 import com.br_technology.securitytrain_master.databinding.ItemMycredentialsShowBinding
11 -import com.br_technology.securitytrain_master.expand.glideRound  
12 import com.br_technology.securitytrain_master.expand.loadPic 10 import com.br_technology.securitytrain_master.expand.loadPic
13 import com.br_technology.securitytrain_master.ui.bean.UserCert 11 import com.br_technology.securitytrain_master.ui.bean.UserCert
14 -import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendData  
15 12
16 /** 13 /**
17 * Time: 8/2/2021 9:06 14 * Time: 8/2/2021 9:06
@@ -39,6 +36,7 @@ class MyCredentialsAdapter : BaseMultiAdapter<UserCert, ViewBinding>() { @@ -39,6 +36,7 @@ class MyCredentialsAdapter : BaseMultiAdapter<UserCert, ViewBinding>() {
39 val userCert = getData(position) 36 val userCert = getData(position)
40 certPicIv.loadPic(userCert?.image_text?:"") 37 certPicIv.loadPic(userCert?.image_text?:"")
41 certValidityPeriod.text="有效期:${userCert?.end_time}" 38 certValidityPeriod.text="有效期:${userCert?.end_time}"
  39 + certValidityPeriodName.text="${userCert?.credentials_name}"
42 } 40 }
43 holder.root.setOnClickListener { 41 holder.root.setOnClickListener {
44 listener?.onClick(position, list[position]) 42 listener?.onClick(position, list[position])
@@ -36,6 +36,24 @@ public class MineInfoBean { @@ -36,6 +36,24 @@ public class MineInfoBean {
36 private Integer expires_in; 36 private Integer expires_in;
37 private String company_name; 37 private String company_name;
38 private String department_name; 38 private String department_name;
  39 + private String company_check_face;
  40 + private String is_check_face;
  41 +
  42 + public String getIs_check_face() {
  43 + return is_check_face;
  44 + }
  45 +
  46 + public void setIs_check_face(String is_check_face) {
  47 + this.is_check_face = is_check_face;
  48 + }
  49 +
  50 + public String getCompany_check_face() {
  51 + return company_check_face;
  52 + }
  53 +
  54 + public void setCompany_check_face(String company_check_face) {
  55 + this.company_check_face = company_check_face;
  56 + }
39 57
40 public Integer getId() { 58 public Integer getId() {
41 return id; 59 return id;
@@ -4,21 +4,23 @@ import android.annotation.SuppressLint @@ -4,21 +4,23 @@ import android.annotation.SuppressLint
4 import android.content.Intent 4 import android.content.Intent
5 import android.os.Bundle 5 import android.os.Bundle
6 import android.view.View 6 import android.view.View
  7 +import android.view.ViewGroup
7 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 8 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
8 import com.br_technology.securitytrain_master.base.common.ConstantType 9 import com.br_technology.securitytrain_master.base.common.ConstantType
9 import com.br_technology.securitytrain_master.databinding.FragmentClassDutyCourseBinding 10 import com.br_technology.securitytrain_master.databinding.FragmentClassDutyCourseBinding
  11 +import com.br_technology.securitytrain_master.expand.addItemDecorationCustom
10 import com.br_technology.securitytrain_master.ui.bean.* 12 import com.br_technology.securitytrain_master.ui.bean.*
11 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity 13 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity
12 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CoursePractiseActivity 14 import com.br_technology.securitytrain_master.ui.view.home.activity.course.CoursePractiseActivity
13 import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity 15 import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity
14 import com.br_technology.securitytrain_master.ui.view.home.event.StatusTypeEvent 16 import com.br_technology.securitytrain_master.ui.view.home.event.StatusTypeEvent
  17 +import com.br_technology.securitytrain_master.ui.view.mine.activity.ClassDutyActivity
15 import com.br_technology.securitytrain_master.ui.view.mine.activity.LiveWebActivity 18 import com.br_technology.securitytrain_master.ui.view.mine.activity.LiveWebActivity
16 import com.br_technology.securitytrain_master.ui.view.mine.adapter.CourseAdapter 19 import com.br_technology.securitytrain_master.ui.view.mine.adapter.CourseAdapter
17 import com.br_technology.securitytrain_master.ui.view.mine.adapter.TrainTestAdapter 20 import com.br_technology.securitytrain_master.ui.view.mine.adapter.TrainTestAdapter
18 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyCourseViewModel 21 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyCourseViewModel
19 import com.br_technology.securitytrain_master.util.TranslateUnit 22 import com.br_technology.securitytrain_master.util.TranslateUnit
20 import com.br_technology.securitytrain_master.view.DialogMention 23 import com.br_technology.securitytrain_master.view.DialogMention
21 -import com.br_technology.securitytrain_master.view.VerticalDecoration  
22 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 24 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
23 import org.greenrobot.eventbus.EventBus 25 import org.greenrobot.eventbus.EventBus
24 import org.greenrobot.eventbus.Subscribe 26 import org.greenrobot.eventbus.Subscribe
@@ -104,7 +106,7 @@ class ClassDutyCourseFragment(val type: Int) : @@ -104,7 +106,7 @@ class ClassDutyCourseFragment(val type: Int) :
104 if (page == 1) { 106 if (page == 1) {
105 trainTestAdapter = TrainTestAdapter() 107 trainTestAdapter = TrainTestAdapter()
106 trainTestAdapter?.setListener(this) 108 trainTestAdapter?.setListener(this)
107 - trainTestAdapter?.addData(transPracticeData(list)) 109 + trainTestAdapter?.setList(transPracticeData(list))
108 binding.recyclerview.adapter = trainTestAdapter 110 binding.recyclerview.adapter = trainTestAdapter
109 boolData(list.isNotEmpty()) 111 boolData(list.isNotEmpty())
110 } else { 112 } else {
@@ -119,7 +121,7 @@ class ClassDutyCourseFragment(val type: Int) : @@ -119,7 +121,7 @@ class ClassDutyCourseFragment(val type: Int) :
119 if (page == 1) { 121 if (page == 1) {
120 trainTestAdapter = TrainTestAdapter() 122 trainTestAdapter = TrainTestAdapter()
121 trainTestAdapter?.setListener(this) 123 trainTestAdapter?.setListener(this)
122 - trainTestAdapter?.addData(transExamData(list)) 124 + trainTestAdapter?.setList(transExamData(list))
123 binding.recyclerview.adapter = trainTestAdapter 125 binding.recyclerview.adapter = trainTestAdapter
124 boolData(list.isNotEmpty()) 126 boolData(list.isNotEmpty())
125 } else { 127 } else {
@@ -169,7 +171,6 @@ class ClassDutyCourseFragment(val type: Int) : @@ -169,7 +171,6 @@ class ClassDutyCourseFragment(val type: Int) :
169 } else { 171 } else {
170 View.GONE 172 View.GONE
171 } 173 }
172 - ll.visibility = vsi  
173 } 174 }
174 175
175 } 176 }
@@ -186,12 +187,14 @@ class ClassDutyCourseFragment(val type: Int) : @@ -186,12 +187,14 @@ class ClassDutyCourseFragment(val type: Int) :
186 187
187 override fun initView() { 188 override fun initView() {
188 super.initView() 189 super.initView()
189 - binding.recyclerview.addItemDecoration(  
190 - VerticalDecoration(  
191 - TranslateUnit.dp2px(context, 16f),  
192 - 0  
193 - )  
194 - ) 190 + if (type == ConstantType.TYPE_CLASS_COURSE) {
  191 + val param = binding.recyclerview.layoutParams as ViewGroup.MarginLayoutParams
  192 + param.bottomMargin = TranslateUnit.dp2px(context, 32f)
  193 + param.topMargin = TranslateUnit.dp2px(context, 16f)
  194 + } else {
  195 + binding.ll.visibility = View.GONE
  196 + }
  197 + binding.recyclerview.addItemDecorationCustom(TranslateUnit.dp2px(context, 16f))
195 binding.smartRefresh.setOnRefreshListener { 198 binding.smartRefresh.setOnRefreshListener {
196 refreshData() 199 refreshData()
197 } 200 }
@@ -239,13 +242,16 @@ class ClassDutyCourseFragment(val type: Int) : @@ -239,13 +242,16 @@ class ClassDutyCourseFragment(val type: Int) :
239 } 242 }
240 } 243 }
241 244
242 - //todo 时间校验限制等  
243 - fun checkTime(exam: ExamBean) {  
244 - }  
245 -  
246 override fun itemClick(item: TrainTestData) { 245 override fun itemClick(item: TrainTestData) {
247 var bool = true 246 var bool = true
248 if (!item.isTest) { 247 if (!item.isTest) {
  248 + if (activity is ClassDutyActivity) {
  249 + val classDutyActivity = activity as ClassDutyActivity
  250 + if (!classDutyActivity.isChecked()) {
  251 + classDutyActivity.showDialogId()
  252 + return
  253 + }
  254 + }
249 try { 255 try {
250 val simple = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA) 256 val simple = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA)
251 val start = simple.parse(item.exam?.exam_start_time ?: "0").time 257 val start = simple.parse(item.exam?.exam_start_time ?: "0").time
@@ -4,10 +4,12 @@ import android.content.Intent @@ -4,10 +4,12 @@ import android.content.Intent
4 import android.os.Bundle 4 import android.os.Bundle
5 import android.view.View 5 import android.view.View
6 import com.br_technology.securitytrain_master.databinding.FragmentSpecialExercisesBinding 6 import com.br_technology.securitytrain_master.databinding.FragmentSpecialExercisesBinding
  7 +import com.br_technology.securitytrain_master.expand.addItemDecorationCustom
7 import com.br_technology.securitytrain_master.ui.bean.AnswerRecord 8 import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
8 import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerRecordDetailsActivity 9 import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerRecordDetailsActivity
9 import com.br_technology.securitytrain_master.ui.view.mine.adapter.SpecialExercisesAdapter 10 import com.br_technology.securitytrain_master.ui.view.mine.adapter.SpecialExercisesAdapter
10 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.SpecialExercisesFragmentViewModel 11 import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.SpecialExercisesFragmentViewModel
  12 +import com.br_technology.securitytrain_master.util.TranslateUnit
11 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 13 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
12 import kotlin.properties.Delegates 14 import kotlin.properties.Delegates
13 15
@@ -32,6 +34,9 @@ class SpecialExercisesFragment @@ -32,6 +34,9 @@ class SpecialExercisesFragment
32 private val map = hashMapOf(1 to true, 2 to true, 3 to true, 4 to true) 34 private val map = hashMapOf(1 to true, 2 to true, 3 to true, 4 to true)
33 override fun initDataObserver() { 35 override fun initDataObserver() {
34 mViewModel.liveData.observe(this) { 36 mViewModel.liveData.observe(this) {
  37 + binding.smartRefresh.finishRefresh()
  38 + binding.smartRefresh.finishLoadMore()
  39 + binding.smartRefresh.setEnableRefresh(true)
35 if (it.data.list.data.size <= 20) { 40 if (it.data.list.data.size <= 20) {
36 binding.smartRefresh.setNoMoreData(true) 41 binding.smartRefresh.setNoMoreData(true)
37 } 42 }
@@ -58,15 +63,10 @@ class SpecialExercisesFragment @@ -58,15 +63,10 @@ class SpecialExercisesFragment
58 63
59 binding.apply { 64 binding.apply {
60 smartRefresh.setOnRefreshListener { 65 smartRefresh.setOnRefreshListener {
61 - page = 1  
62 - smartRefresh.setNoMoreData(false)  
63 - mViewModel.errorSubList(type, page)  
64 - smartRefresh.finishRefresh() 66 + refresh()
65 } 67 }
66 smartRefresh.setOnLoadMoreListener { 68 smartRefresh.setOnLoadMoreListener {
67 - ++page  
68 - mViewModel.errorSubList(type, page)  
69 - smartRefresh.finishLoadMore() 69 + loadMore()
70 } 70 }
71 recyclerview.adapter = exercisesAdapter 71 recyclerview.adapter = exercisesAdapter
72 exercisesAdapter.setOnItemClickListener { adapter, view, position -> 72 exercisesAdapter.setOnItemClickListener { adapter, view, position ->
@@ -74,15 +74,27 @@ class SpecialExercisesFragment @@ -74,15 +74,27 @@ class SpecialExercisesFragment
74 intent.putExtra("id", exercisesAdapter.data[position].id) 74 intent.putExtra("id", exercisesAdapter.data[position].id)
75 startActivity(intent) 75 startActivity(intent)
76 } 76 }
  77 + recyclerview.addItemDecorationCustom(TranslateUnit.dp2px(context, 16f))
77 } 78 }
78 } 79 }
79 80
  81 + private fun refresh() {
  82 + page = 1
  83 + mViewModel.errorSubList(type, page)
  84 + binding.smartRefresh.setEnableRefresh(false)
  85 + binding.smartRefresh.setEnableLoadMore(false)
  86 + }
  87 +
  88 + private fun loadMore(){
  89 + ++page
  90 + mViewModel.errorSubList(type, page)
  91 + binding.smartRefresh.setEnableRefresh(false)
  92 + binding.smartRefresh.setEnableLoadMore(false)
  93 + }
  94 +
80 override fun onResume() { 95 override fun onResume() {
81 super.onResume() 96 super.onResume()
82 - if (map[type] == true) {  
83 - map[type] = false  
84 - binding.smartRefresh.autoRefresh()  
85 - } 97 + refresh()
86 } 98 }
87 99
88 companion object { 100 companion object {
@@ -13,14 +13,13 @@ import okhttp3.MediaType @@ -13,14 +13,13 @@ import okhttp3.MediaType
13 import okhttp3.MultipartBody 13 import okhttp3.MultipartBody
14 import okhttp3.RequestBody 14 import okhttp3.RequestBody
15 import java.io.File 15 import java.io.File
16 -import java.net.URLEncoder  
17 16
18 /** 17 /**
19 * Time: 7/31/2021 14:33 18 * Time: 7/31/2021 14:33
20 * Author: Captain 19 * Author: Captain
21 * Description: 初见时你很迷人 20 * Description: 初见时你很迷人
22 */ 21 */
23 -class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepository(loadState) { 22 +class EditPersonalInfoRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
24 23
25 fun getMineInfo( 24 fun getMineInfo(
26 liveData: MutableLiveData<BaseResponse<MineInfoBean>> 25 liveData: MutableLiveData<BaseResponse<MineInfoBean>>
@@ -42,19 +41,18 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo @@ -42,19 +41,18 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo
42 path: String, 41 path: String,
43 liveData: MutableLiveData<BaseResponse<UploadFileData>> 42 liveData: MutableLiveData<BaseResponse<UploadFileData>>
44 ) { 43 ) {
45 -  
46 - val imageRequestFile: RequestBody?  
47 - var imageBody: MultipartBody.Part? = null  
48 val file = File(path) 44 val file = File(path)
49 if (file.exists()) { 45 if (file.exists()) {
50 - imageRequestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file)  
51 - imageBody = MultipartBody.Part.createFormData( 46 + MultipartBody.Part.createFormData(
  47 + "file", file.name, RequestBody.create(MediaType.parse("multipart/form-data"), file)
  48 + )
  49 + apiService.uploadFile(
  50 + MultipartBody.Part.createFormData(
52 "file", 51 "file",
53 - URLEncoder.encode(file.name, "UTF-8"), imageRequestFile!! 52 + file.name,
  53 + RequestBody.create(MediaType.parse("multipart/form-data"), file)
  54 + )
54 ) 55 )
55 - }  
56 -  
57 - apiService.uploadFile(imageBody!!)  
58 .subscribeOn(Schedulers.io()) 56 .subscribeOn(Schedulers.io())
59 .observeOn(AndroidSchedulers.mainThread()) 57 .observeOn(AndroidSchedulers.mainThread())
60 .subscribe( 58 .subscribe(
@@ -65,6 +63,7 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo @@ -65,6 +63,7 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo
65 ) 63 )
66 ) 64 )
67 } 65 }
  66 + }
68 67
69 fun changePersonalInfo( 68 fun changePersonalInfo(
70 avatar: String, 69 avatar: String,
@@ -72,7 +71,7 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo @@ -72,7 +71,7 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo
72 bio: String, 71 bio: String,
73 liveData: MutableLiveData<BaseResponse<Void>> 72 liveData: MutableLiveData<BaseResponse<Void>>
74 ) { 73 ) {
75 - apiService.changePersonalInfo(avatar,nickname,bio) 74 + apiService.changePersonalInfo(avatar, nickname, bio)
76 .subscribeOn(Schedulers.io()) 75 .subscribeOn(Schedulers.io())
77 .observeOn(AndroidSchedulers.mainThread()) 76 .observeOn(AndroidSchedulers.mainThread())
78 .subscribe( 77 .subscribe(
@@ -82,6 +81,13 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo @@ -82,6 +81,13 @@ class EditPersonalInfoRepository(val loadState: MutableLiveData<State>): ApiRepo
82 this 81 this
83 ) 82 )
84 ) 83 )
  84 + }
  85 +
  86 + fun deleteFace(liveData: MutableLiveData<BaseResponse<Void>>) {
  87 + addRequest(apiService.deleteFace(), liveData)
  88 + }
85 89
  90 + fun setFace(url: String, liveData: MutableLiveData<BaseResponse<Void>>) {
  91 + addRequest(apiService.setFace(url), liveData)
86 } 92 }
87 } 93 }
1 package com.br_technology.securitytrain_master.ui.view.mine.viewmodel 1 package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
2 2
  3 +import androidx.lifecycle.MutableLiveData
  4 +import com.br_technology.securitytrain_master.base.network.response.BaseResponse
3 import com.br_technology.securitytrain_master.base.repository.TrainRepository 5 import com.br_technology.securitytrain_master.base.repository.TrainRepository
4 import com.br_technology.securitytrain_master.base.view.BaseViewModel 6 import com.br_technology.securitytrain_master.base.view.BaseViewModel
  7 +import com.br_technology.securitytrain_master.ui.bean.UploadFileData
5 8
6 /** 9 /**
7 * Time: 8/3/2021 11:16 10 * Time: 8/3/2021 11:16
@@ -9,4 +12,14 @@ import com.br_technology.securitytrain_master.base.view.BaseViewModel @@ -9,4 +12,14 @@ import com.br_technology.securitytrain_master.base.view.BaseViewModel
9 * Description: 初见时你很迷人 12 * Description: 初见时你很迷人
10 */ 13 */
11 class ClassDutyViewModel : BaseViewModel<TrainRepository>() { 14 class ClassDutyViewModel : BaseViewModel<TrainRepository>() {
  15 + var mFaceFile = MutableLiveData<BaseResponse<UploadFileData>>()
  16 + var mFaceCheck = MutableLiveData<BaseResponse<Void>>()
  17 +
  18 + fun uploadFace(filePath: String) {
  19 + mRepository.uploadFile(filePath, mFaceFile)
  20 + }
  21 +
  22 + fun checkFace(url: String) {
  23 + mRepository.checkFace(url, mFaceCheck)
  24 + }
12 } 25 }
1 package com.br_technology.securitytrain_master.ui.view.mine.viewmodel 1 package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
2 2
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.view.BaseViewModel 5 import com.br_technology.securitytrain_master.base.view.BaseViewModel
5 import com.br_technology.securitytrain_master.ui.bean.UploadFileData 6 import com.br_technology.securitytrain_master.ui.bean.UploadFileData
6 import com.br_technology.securitytrain_master.ui.view.mine.bean.MineInfoBean 7 import com.br_technology.securitytrain_master.ui.view.mine.bean.MineInfoBean
7 import com.br_technology.securitytrain_master.ui.view.mine.repository.EditPersonalInfoRepository 8 import com.br_technology.securitytrain_master.ui.view.mine.repository.EditPersonalInfoRepository
8 -import com.br_technology.securitytrain_master.base.network.response.BaseResponse 9 +import java.io.File
9 10
10 /** 11 /**
11 * Time: 7/31/2021 14:38 12 * Time: 7/31/2021 14:38
@@ -14,20 +15,35 @@ import com.br_technology.securitytrain_master.base.network.response.BaseResponse @@ -14,20 +15,35 @@ import com.br_technology.securitytrain_master.base.network.response.BaseResponse
14 */ 15 */
15 class EditPersonalInfoViewModel : BaseViewModel<EditPersonalInfoRepository>() { 16 class EditPersonalInfoViewModel : BaseViewModel<EditPersonalInfoRepository>() {
16 var mUploadFileData: MutableLiveData<BaseResponse<UploadFileData>> = MutableLiveData() 17 var mUploadFileData: MutableLiveData<BaseResponse<UploadFileData>> = MutableLiveData()
  18 + var mUploadFaceFileData: MutableLiveData<BaseResponse<UploadFileData>> = MutableLiveData()
  19 + var deleteResponse: MutableLiveData<BaseResponse<Void>> = MutableLiveData()
  20 + var changeResponse: MutableLiveData<BaseResponse<Void>> = MutableLiveData()
17 21
18 fun uploadFile(path: String) { 22 fun uploadFile(path: String) {
19 mRepository.uploadFile(path, mUploadFileData) 23 mRepository.uploadFile(path, mUploadFileData)
20 } 24 }
21 25
  26 + fun uploadFaceFile(file: File) {
  27 + mRepository.uploadFile(file.path, mUploadFaceFileData)
  28 + }
  29 +
22 var mMineInfoBean: MutableLiveData<BaseResponse<MineInfoBean>> = MutableLiveData() 30 var mMineInfoBean: MutableLiveData<BaseResponse<MineInfoBean>> = MutableLiveData()
23 31
24 fun getMineInfo() { 32 fun getMineInfo() {
25 - mRepository.getMineInfo( mMineInfoBean) 33 + mRepository.getMineInfo(mMineInfoBean)
26 } 34 }
27 35
28 var mCommonBean: MutableLiveData<BaseResponse<Void>> = MutableLiveData() 36 var mCommonBean: MutableLiveData<BaseResponse<Void>> = MutableLiveData()
29 37
30 - fun changePersonalInfo(avatar: String,nickname: String,bio: String) {  
31 - mRepository.changePersonalInfo(avatar, nickname,bio,mCommonBean) 38 + fun changePersonalInfo(avatar: String, nickname: String, bio: String) {
  39 + mRepository.changePersonalInfo(avatar, nickname, bio, mCommonBean)
  40 + }
  41 +
  42 + fun deleteFace() {
  43 + mRepository.deleteFace(deleteResponse)
  44 + }
  45 +
  46 + fun changeFace(url: String) {
  47 + mRepository.setFace(url, changeResponse)
32 } 48 }
33 } 49 }
  1 +package com.br_technology.securitytrain_master.util
  2 +
  3 +import android.hardware.Camera
  4 +import android.hardware.Camera.getNumberOfCameras
  5 +import android.os.Build
  6 +
  7 +
  8 +/**
  9 + * Author by YSir
  10 + * Date on 2022/3/24.
  11 + * description
  12 + * PS: Not easy to write code, please indicate.
  13 + */
  14 +object CameraUtil {
  15 +
  16 + fun isSupportFrontCamera(): Boolean {
  17 + if (!hasGingerBread()) {
  18 + return false
  19 + }
  20 + val numberOfCameras = getNumberOfCameras()
  21 + val cameraInfo = Camera.CameraInfo()
  22 + for (i in 0..numberOfCameras) {
  23 + Camera.getCameraInfo(i, cameraInfo)
  24 + if (1 == cameraInfo.facing) {
  25 + return true
  26 + }
  27 + }
  28 + return false
  29 + }
  30 +
  31 + private fun hasGingerBread(): Boolean {
  32 + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
  33 + }
  34 +
  35 +}
  1 +package com.br_technology.securitytrain_master.util
  2 +
  3 +import android.app.Activity
  4 +import android.content.ContentValues
  5 +import android.content.Intent
  6 +import android.hardware.camera2.CameraCharacteristics
  7 +import android.net.Uri
  8 +import android.os.Build
  9 +import android.provider.MediaStore
  10 +import androidx.core.content.FileProvider
  11 +import com.br_technology.securitytrain_master.base.common.Constant
  12 +import com.netease.image.library.config.CompressConfig
  13 +import com.netease.image.library.core.CompressImageUtil
  14 +import com.netease.image.library.listener.CompressResultListener
  15 +import java.io.File
  16 +
  17 +/**
  18 + * Author by YSir
  19 + * Date on 2022/3/26.
  20 + * description
  21 + * PS: Not easy to write code, please indicate.
  22 + */
  23 +class FaceUtil {
  24 + companion object{
  25 + const val FRONT_CAPTURE_CODE = 998
  26 + }
  27 +
  28 + private val photoUtils = PhotoUtils()
  29 + private var fileUploadTemp: File? = null
  30 + private var compressImageUtil: CompressImageUtil? = null
  31 +
  32 + interface ICapture {
  33 + fun capture(file: File)
  34 + }
  35 +
  36 + interface ICompress{
  37 + fun compress(file: File)
  38 + }
  39 +
  40 + fun startCaptureFace(activity: Activity, iCapture: ICapture) {
  41 + val intent: Intent
  42 + val pictureUri: Uri
  43 + //也就是我之前创建的存放头像的文件夹(目录)
  44 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
  45 + photoUtils.createDirs()
  46 + fileUploadTemp =
  47 + File(Constant.ACCOUNT_DIR_PIC, "person_face_${System.currentTimeMillis()}.jpeg")
  48 + } else {
  49 + photoUtils.createPicDirs()
  50 + fileUploadTemp =
  51 + File(Constant.ACCOUNT_DIR, "person_face_${System.currentTimeMillis()}.jpeg")
  52 + }
  53 + // 判断当前系统
  54 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  55 + intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
  56 + //这一句非常重要
  57 + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
  58 + val strPackageName = activity.packageName
  59 + intent.putExtra(
  60 + "android.intent.extras.CAMERA_FACING",
  61 + CameraCharacteristics.LENS_FACING_BACK
  62 + )
  63 + intent.putExtra("android.intent.extras.LENS_FACING_FRONT", 1)
  64 + intent.putExtra("android.intent.extra.USE_FRONT_CAMERA", true);
  65 + intent.putExtra("camerafacing", "front");
  66 + intent.putExtra("previous_mode", "front");
  67 +
  68 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
  69 + // 通过 MediaStore API 插入file 为了拿到系统裁剪要保存到的uri(因为App没有权限不能访问公共存储空间,需要通过 MediaStore API来操作)
  70 + intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
  71 + val values = ContentValues()
  72 + values.put(MediaStore.Images.Media.DATA, fileUploadTemp!!.absolutePath)
  73 + values.put(MediaStore.Images.Media.DISPLAY_NAME, fileUploadTemp!!.name)
  74 + values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
  75 + pictureUri =
  76 + activity.contentResolver.insert(
  77 + MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
  78 + values
  79 + )!!
  80 + } else {
  81 + //""中的内容是随意的,但最好用package名.provider名的形式,清晰明了
  82 + pictureUri =
  83 + FileProvider.getUriForFile(
  84 + activity,
  85 + "$strPackageName.provider",
  86 + fileUploadTemp!!
  87 + )
  88 + }
  89 + } else {
  90 + intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
  91 + pictureUri = Uri.fromFile(fileUploadTemp)
  92 + }
  93 + // 去拍照,拍照的结果存到pictureUri对应的路径中
  94 + intent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri)
  95 + activity.startActivityForResult(intent, FRONT_CAPTURE_CODE)
  96 + iCapture.capture(fileUploadTemp!!)
  97 + }
  98 +
  99 + fun compressFile(activity: Activity,file: File,iCompress: ICompress) {
  100 + if (compressImageUtil == null) {
  101 + val compressConfig: CompressConfig = CompressConfig.builder()
  102 + .setUnCompressMinPixel(1000) // 最小像素不压缩,默认值:1000
  103 + .setUnCompressNormalPixel(2000) // 标准像素不压缩,默认值:2000
  104 +// .setMaxPixel(1000) // 长或宽不超过的最大像素 (单位px),默认值:1200
  105 + .setMaxSize(3 * 1024 * 1024) // 压缩到的最大大小 (单位B),默认值:200 * 1024 = 200KB
  106 + .enablePixelCompress(true) // 是否启用像素压缩,默认值:true
  107 + .enableQualityCompress(true) // 是否启用质量压缩,默认值:true
  108 + .enableReserveRaw(true) // 是否保留源文件,默认值:true
  109 + .setCacheDir(activity.cacheDir.path) // 压缩后缓存图片路径,默认值:Constants.COMPRESS_CACHE
  110 + .setShowCompressDialog(false) // 是否显示压缩进度条,默认值:false
  111 + .create()
  112 + compressImageUtil = CompressImageUtil(activity, compressConfig)
  113 + }
  114 + compressImageUtil!!.compress(file.path, object : CompressResultListener {
  115 + override fun onCompressSuccess(imgPath: String) {
  116 + iCompress.compress(File(imgPath))
  117 + }
  118 +
  119 + override fun onCompressFailed(imgPath: String, error: String) {
  120 + iCompress.compress(File(imgPath))
  121 + }
  122 + })
  123 + }
  124 +}
@@ -39,17 +39,18 @@ class PhotoUtils { @@ -39,17 +39,18 @@ class PhotoUtils {
39 var CUTTING_IMAGE_NAME = "PhotoCopy.jpg" 39 var CUTTING_IMAGE_NAME = "PhotoCopy.jpg"
40 40
41 private var mCallBack: PhotoCallBack? = null 41 private var mCallBack: PhotoCallBack? = null
42 - 42 + private var isFront: Boolean = false
43 43
44 companion object { 44 companion object {
45 - private var instance:PhotoUtils ? = null 45 + private var instance: PhotoUtils? = null
46 get() { 46 get() {
47 - if (field == null){ 47 + if (field == null) {
48 field = PhotoUtils() 48 field = PhotoUtils()
49 } 49 }
50 return field 50 return field
51 } 51 }
52 - fun get(): PhotoUtils{ 52 +
  53 + fun get(): PhotoUtils {
53 return instance!! 54 return instance!!
54 } 55 }
55 } 56 }
@@ -61,21 +62,14 @@ class PhotoUtils { @@ -61,21 +62,14 @@ class PhotoUtils {
61 * @return 62 * @return
62 */ 63 */
63 private fun checkCameraPermission(context: Activity): Boolean { 64 private fun checkCameraPermission(context: Activity): Boolean {
64 - var isPermission = false  
65 - isPermission = if (ContextCompat.checkSelfPermission( 65 + return (ContextCompat.checkSelfPermission(
66 context, 66 context,
67 Manifest.permission.WRITE_EXTERNAL_STORAGE 67 Manifest.permission.WRITE_EXTERNAL_STORAGE
68 ) == PackageManager.PERMISSION_GRANTED 68 ) == PackageManager.PERMISSION_GRANTED
69 && ContextCompat.checkSelfPermission( 69 && ContextCompat.checkSelfPermission(
70 context, 70 context,
71 Manifest.permission.CAMERA 71 Manifest.permission.CAMERA
72 - ) == PackageManager.PERMISSION_GRANTED  
73 - ) {  
74 - true  
75 - } else {  
76 - false  
77 - }  
78 - return isPermission 72 + ) == PackageManager.PERMISSION_GRANTED)
79 } 73 }
80 74
81 /** 75 /**
@@ -98,17 +92,10 @@ class PhotoUtils { @@ -98,17 +92,10 @@ class PhotoUtils {
98 * @return 92 * @return
99 */ 93 */
100 private fun checkAlbumPermission(context: Activity): Boolean { 94 private fun checkAlbumPermission(context: Activity): Boolean {
101 - var isPermission = false  
102 - isPermission = if (ContextCompat.checkSelfPermission( 95 + return ContextCompat.checkSelfPermission(
103 context, 96 context,
104 Manifest.permission.WRITE_EXTERNAL_STORAGE 97 Manifest.permission.WRITE_EXTERNAL_STORAGE
105 ) == PackageManager.PERMISSION_GRANTED 98 ) == PackageManager.PERMISSION_GRANTED
106 - ) {  
107 - true  
108 - } else {  
109 - false  
110 - }  
111 - return isPermission  
112 } 99 }
113 100
114 /** 101 /**
@@ -119,7 +106,7 @@ class PhotoUtils { @@ -119,7 +106,7 @@ class PhotoUtils {
119 */ 106 */
120 private fun requestAlbumPermissions(context: Activity) { 107 private fun requestAlbumPermissions(context: Activity) {
121 // 权限还没有授予,进行申请 108 // 权限还没有授予,进行申请
122 - val permissions = arrayOf<String>(Manifest.permission.WRITE_EXTERNAL_STORAGE) 109 + val permissions = arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
123 ActivityCompat.requestPermissions(context, permissions, REQUEST_ALBUM_PERMISSIONS) 110 ActivityCompat.requestPermissions(context, permissions, REQUEST_ALBUM_PERMISSIONS)
124 } 111 }
125 112
@@ -176,37 +163,6 @@ class PhotoUtils { @@ -176,37 +163,6 @@ class PhotoUtils {
176 } 163 }
177 REQUEST_IMAGE_CAMERA -> { 164 REQUEST_IMAGE_CAMERA -> {
178 val pictureFile = File(Constant.ACCOUNT_DIR, IMAGE_NAME) 165 val pictureFile = File(Constant.ACCOUNT_DIR, IMAGE_NAME)
179 - // //鲁班压缩图片  
180 -// Luban.with(context)  
181 -// .load(pictureFile)  
182 -// .ignoreBy(100)  
183 -// .filter(new CompressionPredicate() {  
184 -// @Override  
185 -// public boolean apply(String path) {  
186 -// return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));  
187 -// }  
188 -// })  
189 -// .setCompressListener(new OnCompressListener() {  
190 -// @Override  
191 -// public void onStart() {  
192 -// // TODO 压缩开始前调用,可以在方法内启动 loading UI  
193 -//// ProgressUtils.showProgressDialog(context);  
194 -// }  
195 -//  
196 -// @Override  
197 -// public void onSuccess(File file) {  
198 -// // TODO 压缩成功后调用,返回压缩后的图片文件  
199 -// String newPath = file.getAbsolutePath();  
200 -// if (mCallBack != null)  
201 -// mCallBack.onSuccessListener(newPath);  
202 -//// ProgressUtils.dismissProgressDialog();  
203 -// }  
204 -//  
205 -// @Override  
206 -// public void onError(Throwable e) {  
207 -// // TODO 当压缩过程出现问题时调用  
208 -// }  
209 -// }).launch();  
210 val cameraUri: Uri 166 val cameraUri: Uri
211 cameraUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 167 cameraUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
212 val strPackageName = context.packageName 168 val strPackageName = context.packageName
@@ -239,7 +195,7 @@ class PhotoUtils { @@ -239,7 +195,7 @@ class PhotoUtils {
239 } 195 }
240 REQUEST_IMAGE_CUTTING -> { 196 REQUEST_IMAGE_CUTTING -> {
241 val pictureFile1 = File(Constant.ACCOUNT_DIR, IMAGE_NAME) 197 val pictureFile1 = File(Constant.ACCOUNT_DIR, IMAGE_NAME)
242 - if (mCallBack != null) mCallBack!!.onSuccessListener(Constant.ACCOUNT_DIR.toString() + CUTTING_IMAGE_NAME) 198 + if (mCallBack != null) mCallBack!!.onSuccessListener(Constant.ACCOUNT_DIR + CUTTING_IMAGE_NAME)
243 //保存照片到系统相册中 199 //保存照片到系统相册中
244 try { 200 try {
245 MediaStore.Images.Media.insertImage( 201 MediaStore.Images.Media.insertImage(
@@ -270,7 +226,7 @@ class PhotoUtils { @@ -270,7 +226,7 @@ class PhotoUtils {
270 * 226 *
271 * @param context 227 * @param context
272 */ 228 */
273 - fun startAlbum(context: Activity, fileName: String, callBack: PhotoCallBack?) { 229 + private fun startAlbum(context: Activity, fileName: String, callBack: PhotoCallBack?) {
274 // createDirs(); 230 // createDirs();
275 CUTTING_IMAGE_NAME = fileName 231 CUTTING_IMAGE_NAME = fileName
276 mCallBack = callBack 232 mCallBack = callBack
@@ -291,12 +247,16 @@ class PhotoUtils { @@ -291,12 +247,16 @@ class PhotoUtils {
291 startCamera(context, CUTTING_IMAGE_NAME, mCallBack) 247 startCamera(context, CUTTING_IMAGE_NAME, mCallBack)
292 } 248 }
293 249
  250 + private fun startFrontCamera(context: Activity) {
  251 + startFrontCamera(context, CUTTING_IMAGE_NAME, mCallBack)
  252 + }
  253 +
294 /** 254 /**
295 * 启动系统相机 255 * 启动系统相机
296 * 256 *
297 * @param context 257 * @param context
298 */ 258 */
299 - fun startCamera(context: Activity, fileName: String, callBack: PhotoCallBack?) { 259 + private fun startCamera(context: Activity, fileName: String, callBack: PhotoCallBack?) {
300 CUTTING_IMAGE_NAME = fileName 260 CUTTING_IMAGE_NAME = fileName
301 mCallBack = callBack 261 mCallBack = callBack
302 createDirs() 262 createDirs()
@@ -322,6 +282,32 @@ class PhotoUtils { @@ -322,6 +282,32 @@ class PhotoUtils {
322 context.startActivityForResult(intent, REQUEST_IMAGE_CAMERA) 282 context.startActivityForResult(intent, REQUEST_IMAGE_CAMERA)
323 } 283 }
324 284
  285 + fun startFrontCamera(context: Activity, fileName: String, callBack: PhotoCallBack?) {
  286 + CUTTING_IMAGE_NAME = fileName
  287 + mCallBack = callBack
  288 + createDirs()
  289 + val intent: Intent
  290 + val pictureUri: Uri
  291 + //也就是我之前创建的存放头像的文件夹(目录)
  292 + val pictureFile = File(Constant.ACCOUNT_DIR, IMAGE_NAME)
  293 + // 判断当前系统
  294 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  295 + intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
  296 + //这一句非常重要
  297 + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
  298 + val strPackageName = context.packageName
  299 + //""中的内容是随意的,但最好用package名.provider名的形式,清晰明了
  300 + pictureUri = FileProvider.getUriForFile(context, "$strPackageName.provider", pictureFile)
  301 + } else {
  302 + intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
  303 + pictureUri = Uri.fromFile(pictureFile)
  304 + }
  305 + // 去拍照,拍照的结果存到pictureUri对应的路径中
  306 + intent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri)
  307 + intent.putExtra("android.intent.extras.CAMERA_FACING", 1)
  308 + context.startActivityForResult(intent, REQUEST_IMAGE_CAMERA)
  309 + }
  310 +
325 /** 311 /**
326 * 启动系统裁剪 312 * 启动系统裁剪
327 * 313 *
@@ -425,13 +411,13 @@ class PhotoUtils { @@ -425,13 +411,13 @@ class PhotoUtils {
425 val view: View = 411 val view: View =
426 LayoutInflater.from(activity).inflate(R.layout.dialog_photo, null) //获取自定义布局 412 LayoutInflater.from(activity).inflate(R.layout.dialog_photo, null) //获取自定义布局
427 val tvCancel: TextView = view.findViewById(R.id.tv_photo_cancel) 413 val tvCancel: TextView = view.findViewById(R.id.tv_photo_cancel)
428 - tvCancel.setOnClickListener(object : View.OnClickListener{ 414 + tvCancel.setOnClickListener(object : View.OnClickListener {
429 override fun onClick(view: View?) { 415 override fun onClick(view: View?) {
430 DialogBottomUtils.get().dismissDialog() 416 DialogBottomUtils.get().dismissDialog()
431 } 417 }
432 }) 418 })
433 val tvAlbum: TextView = view.findViewById(R.id.tv_photo_from_album) 419 val tvAlbum: TextView = view.findViewById(R.id.tv_photo_from_album)
434 - tvAlbum.setOnClickListener(object : View.OnClickListener{ 420 + tvAlbum.setOnClickListener(object : View.OnClickListener {
435 override fun onClick(view: View?) { 421 override fun onClick(view: View?) {
436 if (checkAlbumPermission(activity)) { 422 if (checkAlbumPermission(activity)) {
437 startAlbum(activity) 423 startAlbum(activity)
@@ -442,7 +428,7 @@ class PhotoUtils { @@ -442,7 +428,7 @@ class PhotoUtils {
442 } 428 }
443 }) 429 })
444 val tvCamera: TextView = view.findViewById(R.id.tv_photo_from_camera) 430 val tvCamera: TextView = view.findViewById(R.id.tv_photo_from_camera)
445 - tvCamera.setOnClickListener(object : View.OnClickListener{ 431 + tvCamera.setOnClickListener(object : View.OnClickListener {
446 override fun onClick(view: View?) { 432 override fun onClick(view: View?) {
447 if (checkCameraPermission(activity)) { 433 if (checkCameraPermission(activity)) {
448 startCamera(activity) 434 startCamera(activity)
@@ -455,13 +441,20 @@ class PhotoUtils { @@ -455,13 +441,20 @@ class PhotoUtils {
455 DialogBottomUtils.get().showDialogBottom(activity, view) 441 DialogBottomUtils.get().showDialogBottom(activity, view)
456 } 442 }
457 443
458 - private fun createDirs() { 444 + fun createDirs() {
459 val fileDir = File(Constant.ACCOUNT_DIR) 445 val fileDir = File(Constant.ACCOUNT_DIR)
460 if (!fileDir.exists()) { 446 if (!fileDir.exists()) {
461 fileDir.mkdirs() 447 fileDir.mkdirs()
462 } 448 }
463 } 449 }
464 450
  451 + fun createPicDirs() {
  452 + val fileDir = File(Constant.ACCOUNT_DIR_PIC)
  453 + if (!fileDir.exists()) {
  454 + fileDir.mkdirs()
  455 + }
  456 + }
  457 +
465 fun dismissDialog() { 458 fun dismissDialog() {
466 DialogBottomUtils.get().dismissDialog() 459 DialogBottomUtils.get().dismissDialog()
467 } 460 }
@@ -15,7 +15,9 @@ const val USERID = "userId" @@ -15,7 +15,9 @@ const val USERID = "userId"
15 const val PHONE_NUMBER = "phone_number" 15 const val PHONE_NUMBER = "phone_number"
16 const val IS_LOGIN = "is_login" 16 const val IS_LOGIN = "is_login"
17 const val POI_ID = "pos_id" 17 const val POI_ID = "pos_id"
  18 +const val POI_ID_ = "pos_id_"
18 const val POI_NAME = "pos_name" 19 const val POI_NAME = "pos_name"
  20 +const val POI_NAME_ = "pos_name_"
19 21
20 22
21 var token by SpUtil(TOKEN, "") 23 var token by SpUtil(TOKEN, "")
@@ -23,7 +25,9 @@ var userId by SpUtil(USERID, 0) @@ -23,7 +25,9 @@ var userId by SpUtil(USERID, 0)
23 var phone_number by SpUtil(PHONE_NUMBER, "") 25 var phone_number by SpUtil(PHONE_NUMBER, "")
24 var is_login by SpUtil(IS_LOGIN, false) 26 var is_login by SpUtil(IS_LOGIN, false)
25 var sp_job_id by SpUtil(POI_ID, 0) 27 var sp_job_id by SpUtil(POI_ID, 0)
26 -var sp_job_name by SpUtil(POI_NAME, "") 28 +var sp_job_id_select by SpUtil(POI_ID_, 0)
  29 +var sp_job_name by SpUtil(POI_NAME_, "")
  30 +var sp_job_name_select by SpUtil(POI_NAME_, "工种")
27 31
28 const val TYPE_LIVE = 0 32 const val TYPE_LIVE = 0
29 const val TYPE_HOME = 1 33 const val TYPE_HOME = 1
@@ -11,8 +11,8 @@ import com.br_technology.securitytrain_master.expand.screenWidth @@ -11,8 +11,8 @@ import com.br_technology.securitytrain_master.expand.screenWidth
11 import com.br_technology.securitytrain_master.ui.view.home.adapter.TextCourseTypeAdapter 11 import com.br_technology.securitytrain_master.ui.view.home.adapter.TextCourseTypeAdapter
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.ui.view.home.event.GetWorkTypeEvent 13 import com.br_technology.securitytrain_master.ui.view.home.event.GetWorkTypeEvent
14 -import com.br_technology.securitytrain_master.util.sp_job_id  
15 -import com.br_technology.securitytrain_master.util.sp_job_name 14 +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.view.listener.OnItemClickListener 16 import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
17 import org.greenrobot.eventbus.EventBus 17 import org.greenrobot.eventbus.EventBus
18 18
@@ -30,13 +30,22 @@ class ClassifyPop(context: Activity, type: Int) : PopupWindow(context) { @@ -30,13 +30,22 @@ class ClassifyPop(context: Activity, type: Int) : PopupWindow(context) {
30 PopClassifyBinding.inflate(LayoutInflater.from(context)) 30 PopClassifyBinding.inflate(LayoutInflater.from(context))
31 } 31 }
32 32
  33 + interface IClickListener {
  34 + fun work(data: WorkTypeBean.ListBean)
  35 + }
  36 +
  37 + private var iClickListener: IClickListener? = null
  38 +
  39 + fun setIClickListener(iClickListener: IClickListener) {
  40 + this.iClickListener = iClickListener
  41 + }
  42 +
33 fun setList(workTypeList: MutableList<WorkTypeBean.ListBean>) { 43 fun setList(workTypeList: MutableList<WorkTypeBean.ListBean>) {
34 mWorkTypeList = workTypeList 44 mWorkTypeList = workTypeList
35 mWorkTypeList?.let { textCourseTypeAdapter?.addList(it) } 45 mWorkTypeList?.let { textCourseTypeAdapter?.addList(it) }
36 } 46 }
37 47
38 init { 48 init {
39 -  
40 contentView = binding.root 49 contentView = binding.root
41 width = contentView.screenWidth() 50 width = contentView.screenWidth()
42 height = contentView.screenHeight() 51 height = contentView.screenHeight()
@@ -61,12 +70,16 @@ class ClassifyPop(context: Activity, type: Int) : PopupWindow(context) { @@ -61,12 +70,16 @@ class ClassifyPop(context: Activity, type: Int) : PopupWindow(context) {
61 val index: Int = (mWorkTypeList?.size ?: mWorkTypeList?.size) as Int 70 val index: Int = (mWorkTypeList?.size ?: mWorkTypeList?.size) as Int
62 if (index > pos) { 71 if (index > pos) {
63 mWorkTypeList?.get(pos)!!.let { 72 mWorkTypeList?.get(pos)!!.let {
64 - sp_job_id = it.id  
65 - sp_job_name = it.name 73 + sp_job_id_select = it.id
  74 + sp_job_name_select = it.name
66 } 75 }
  76 + if (iClickListener == null) {
67 EventBus.getDefault().post( 77 EventBus.getDefault().post(
68 mWorkTypeList?.get(pos)!! 78 mWorkTypeList?.get(pos)!!
69 .let { it1 -> GetWorkTypeEvent(it1.id, it1.name, type) }) 79 .let { it1 -> GetWorkTypeEvent(it1.id, it1.name, type) })
  80 + } else {
  81 + iClickListener?.work(mWorkTypeList?.get(pos)!!)
  82 + }
70 } 83 }
71 dismiss() 84 dismiss()
72 } 85 }
  1 +package com.br_technology.securitytrain_master.view
  2 +
  3 +import android.app.Dialog
  4 +import android.content.Context
  5 +import android.os.Bundle
  6 +import android.view.LayoutInflater
  7 +import android.view.View
  8 +import com.br_technology.securitytrain_master.R
  9 +import com.br_technology.securitytrain_master.databinding.DialogCheckIdBinding
  10 +import com.br_technology.securitytrain_master.expand.dp2px
  11 +import com.br_technology.securitytrain_master.expand.screenWidth
  12 +
  13 +/**
  14 + * Author by YSir
  15 + * Date on 2022/3/26.
  16 + * description
  17 + * PS: Not easy to write code, please indicate.
  18 + */
  19 +class DialogCheckIDCard(context: Context) : Dialog(context, R.style.UserDefaultDialog) {
  20 + private val binding by lazy {
  21 + DialogCheckIdBinding.inflate(LayoutInflater.from(context))
  22 + }
  23 +
  24 + override fun onCreate(savedInstanceState: Bundle?) {
  25 + super.onCreate(savedInstanceState)
  26 + setContentView(binding.root)
  27 + val attributes = window?.attributes
  28 + attributes?.width = binding.root.screenWidth() - 32.dp2px()
  29 + // 点击区域外取消
  30 + setCanceledOnTouchOutside(false)
  31 + setCancelable(false)
  32 + }
  33 +
  34 + fun setListener(listenerLeft: View.OnClickListener, listenerRight: View.OnClickListener): DialogCheckIDCard {
  35 + binding.apply {
  36 + btnLeft.setOnClickListener { listenerLeft.onClick(it) }
  37 + btnRight.setOnClickListener { listenerRight.onClick(it) }
  38 + }
  39 + return this
  40 + }
  41 +}
@@ -5,12 +5,8 @@ import android.content.Context @@ -5,12 +5,8 @@ import android.content.Context
5 import android.os.Bundle 5 import android.os.Bundle
6 import android.text.Spannable 6 import android.text.Spannable
7 import android.text.SpannableString 7 import android.text.SpannableString
8 -import android.text.style.AbsoluteSizeSpan  
9 -import android.text.style.ForegroundColorSpan  
10 -import android.view.Gravity  
11 import android.view.LayoutInflater 8 import android.view.LayoutInflater
12 import android.view.View 9 import android.view.View
13 -import androidx.core.content.ContextCompat  
14 import androidx.core.view.isVisible 10 import androidx.core.view.isVisible
15 import com.br_technology.securitytrain_master.R 11 import com.br_technology.securitytrain_master.R
16 import com.br_technology.securitytrain_master.databinding.DialogTitleBinding 12 import com.br_technology.securitytrain_master.databinding.DialogTitleBinding
@@ -62,18 +58,18 @@ class DialogTitle(context: Context) : Dialog(context, R.style.UserDefaultDialog) @@ -62,18 +58,18 @@ class DialogTitle(context: Context) : Dialog(context, R.style.UserDefaultDialog)
62 58
63 fun setTitleSpan(title: String): DialogTitle { 59 fun setTitleSpan(title: String): DialogTitle {
64 val span: Spannable = SpannableString(title) 60 val span: Spannable = SpannableString(title)
65 - span.setSpan(  
66 - AbsoluteSizeSpan(36.dp2px()),  
67 - 2,  
68 - title.length - 2,  
69 - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE  
70 - )  
71 - span.setSpan(  
72 - ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_25)),  
73 - 2,  
74 - title.length - 2,  
75 - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE  
76 - ); 61 +// span.setSpan(
  62 +// AbsoluteSizeSpan(36.dp2px()),
  63 +// 2,
  64 +// title.length - 2,
  65 +// Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
  66 +// )
  67 +// span.setSpan(
  68 +// ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_25)),
  69 +// 2,
  70 +// title.length - 2,
  71 +// Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
  72 +// );
77 binding.title.text = span 73 binding.title.text = span
78 return this 74 return this
79 } 75 }
@@ -116,7 +112,7 @@ class DialogTitle(context: Context) : Dialog(context, R.style.UserDefaultDialog) @@ -116,7 +112,7 @@ class DialogTitle(context: Context) : Dialog(context, R.style.UserDefaultDialog)
116 112
117 fun setInfo(title: String): DialogTitle { 113 fun setInfo(title: String): DialogTitle {
118 binding.info.text = title 114 binding.info.text = title
119 - binding.info.gravity = Gravity.START 115 +// binding.info.gravity = Gravity.START
120 binding.info.visibility = View.VISIBLE 116 binding.info.visibility = View.VISIBLE
121 return this 117 return this
122 } 118 }
@@ -97,7 +97,6 @@ @@ -97,7 +97,6 @@
97 android:layout_weight="1" 97 android:layout_weight="1"
98 android:orientation="vertical" /> 98 android:orientation="vertical" />
99 99
100 -  
101 <TextView 100 <TextView
102 android:id="@+id/tv_upload" 101 android:id="@+id/tv_upload"
103 android:layout_width="match_parent" 102 android:layout_width="match_parent"
@@ -22,8 +22,12 @@ @@ -22,8 +22,12 @@
22 android:padding="12dp" 22 android:padding="12dp"
23 android:src="@mipmap/ic_back" /> 23 android:src="@mipmap/ic_back" />
24 24
25 - <View 25 + <TextView
26 android:layout_width="0dp" 26 android:layout_width="0dp"
  27 + android:text="资料库"
  28 + android:gravity="center"
  29 + android:textColor="@color/black"
  30 + android:textSize="18sp"
27 android:layout_height="match_parent" 31 android:layout_height="match_parent"
28 android:layout_weight="1" /> 32 android:layout_weight="1" />
29 33
@@ -24,277 +24,318 @@ @@ -24,277 +24,318 @@
24 <com.br_technology.securitytrain_master.util.CircleImageView 24 <com.br_technology.securitytrain_master.util.CircleImageView
25 android:id="@+id/iv_icon" 25 android:id="@+id/iv_icon"
26 android:layout_width="72dp" 26 android:layout_width="72dp"
27 - android:layout_height="72dp"/> 27 + android:layout_height="72dp" />
28 28
29 <ImageView 29 <ImageView
30 - android:layout_alignParentEnd="true"  
31 - android:layout_alignParentBottom="true"  
32 android:layout_width="wrap_content" 30 android:layout_width="wrap_content"
33 android:layout_height="wrap_content" 31 android:layout_height="wrap_content"
  32 + android:layout_alignParentEnd="true"
  33 + android:layout_alignParentBottom="true"
34 android:src="@mipmap/edit_camera" /> 34 android:src="@mipmap/edit_camera" />
35 35
36 </RelativeLayout> 36 </RelativeLayout>
37 37
38 <LinearLayout 38 <LinearLayout
39 - android:layout_marginTop="40dp"  
40 - android:orientation="horizontal"  
41 android:layout_width="match_parent" 39 android:layout_width="match_parent"
42 - android:layout_height="48dp"> 40 + android:layout_height="48dp"
  41 + android:layout_marginTop="40dp"
  42 + android:orientation="horizontal">
43 43
44 <TextView 44 <TextView
  45 + android:layout_width="wrap_content"
  46 + android:layout_height="wrap_content"
45 android:layout_gravity="center_vertical" 47 android:layout_gravity="center_vertical"
46 android:layout_marginStart="16dp" 48 android:layout_marginStart="16dp"
47 - android:textColor="@color/color_32"  
48 - android:textSize="14sp"  
49 android:text="姓名:" 49 android:text="姓名:"
50 - android:layout_width="wrap_content"  
51 - android:layout_height="wrap_content"/> 50 + android:textColor="@color/color_32"
  51 + android:textSize="14sp" />
52 52
53 <TextView 53 <TextView
54 android:id="@+id/tv_name" 54 android:id="@+id/tv_name"
  55 + android:layout_width="wrap_content"
  56 + android:layout_height="wrap_content"
  57 + android:layout_gravity="center_vertical"
55 android:layout_marginEnd="4dp" 58 android:layout_marginEnd="4dp"
  59 + android:layout_weight="1"
56 android:gravity="end" 60 android:gravity="end"
57 - android:layout_gravity="center_vertical"  
58 - android:textColor="@color/color_96"  
59 - android:textSize="14sp"  
60 android:text="赵丽静" 61 android:text="赵丽静"
61 - android:layout_weight="1"  
62 - android:layout_width="wrap_content"  
63 - android:layout_height="wrap_content"/> 62 + android:textColor="@color/color_96"
  63 + android:textSize="14sp" />
64 64
65 <ImageView 65 <ImageView
66 - android:visibility="invisible"  
67 - android:layout_marginEnd="16dp" 66 + android:layout_width="wrap_content"
  67 + android:layout_height="wrap_content"
68 android:layout_gravity="center_vertical" 68 android:layout_gravity="center_vertical"
  69 + android:layout_marginEnd="16dp"
69 android:src="@mipmap/ic_arrow" 70 android:src="@mipmap/ic_arrow"
70 - android:layout_width="wrap_content"  
71 - android:layout_height="wrap_content"/> 71 + android:visibility="invisible" />
72 72
73 </LinearLayout> 73 </LinearLayout>
74 74
75 <View 75 <View
  76 + android:layout_width="match_parent"
  77 + android:layout_height="1dp"
76 android:layout_marginStart="16dp" 78 android:layout_marginStart="16dp"
77 - android:background="@color/color_f7" 79 + android:background="@color/color_f7"/>
  80 +
  81 + <LinearLayout
  82 + android:id="@+id/ll_change_face"
78 android:layout_width="match_parent" 83 android:layout_width="match_parent"
79 - android:layout_height="1dp"> 84 + android:layout_height="48dp"
  85 + android:orientation="horizontal">
80 86
81 - </View> 87 + <TextView
  88 + android:layout_width="wrap_content"
  89 + android:layout_height="wrap_content"
  90 + android:layout_gravity="center_vertical"
  91 + android:layout_marginStart="16dp"
  92 + android:text="人脸识别:"
  93 + android:textColor="@color/color_32"
  94 + android:textSize="14sp" />
  95 +
  96 + <TextView
  97 + android:id="@+id/tv_phone_face"
  98 + android:layout_width="0dp"
  99 + android:layout_height="wrap_content"
  100 + android:layout_gravity="center_vertical"
  101 + android:layout_marginEnd="4dp"
  102 + android:layout_weight="1"
  103 + android:gravity="end"
  104 + android:text="未设置"
  105 + android:textColor="@color/color_96"
  106 + android:textSize="14sp" />
  107 +
  108 + <ImageView
  109 + android:layout_width="wrap_content"
  110 + android:layout_height="wrap_content"
  111 + android:layout_gravity="center_vertical"
  112 + android:layout_marginEnd="16dp"
  113 + android:contentDescription="@null"
  114 + android:src="@mipmap/ic_arrow" />
  115 +
  116 + </LinearLayout>
  117 +
  118 + <View
  119 + android:layout_width="match_parent"
  120 + android:layout_height="1dp"
  121 + android:layout_marginStart="16dp"
  122 + android:background="@color/color_f7"/>
82 123
83 <LinearLayout 124 <LinearLayout
84 android:id="@+id/ll_change_phone" 125 android:id="@+id/ll_change_phone"
85 - android:orientation="horizontal"  
86 android:layout_width="match_parent" 126 android:layout_width="match_parent"
87 - android:layout_height="48dp"> 127 + android:layout_height="48dp"
  128 + android:orientation="horizontal">
88 129
89 <TextView 130 <TextView
  131 + android:layout_width="wrap_content"
  132 + android:layout_height="wrap_content"
90 android:layout_gravity="center_vertical" 133 android:layout_gravity="center_vertical"
91 android:layout_marginStart="16dp" 134 android:layout_marginStart="16dp"
92 - android:textColor="@color/color_32"  
93 - android:textSize="14sp"  
94 android:text="手机号:" 135 android:text="手机号:"
95 - android:layout_width="wrap_content"  
96 - android:layout_height="wrap_content"/> 136 + android:textColor="@color/color_32"
  137 + android:textSize="14sp" />
97 138
98 <TextView 139 <TextView
99 android:id="@+id/tv_phone_number" 140 android:id="@+id/tv_phone_number"
  141 + android:layout_width="wrap_content"
  142 + android:layout_height="wrap_content"
  143 + android:layout_gravity="center_vertical"
100 android:layout_marginEnd="4dp" 144 android:layout_marginEnd="4dp"
  145 + android:layout_weight="1"
101 android:gravity="end" 146 android:gravity="end"
102 - android:layout_gravity="center_vertical"  
103 - android:textColor="@color/color_96"  
104 - android:textSize="14sp"  
105 android:text="15435643667" 147 android:text="15435643667"
106 - android:layout_weight="1"  
107 - android:layout_width="wrap_content"  
108 - android:layout_height="wrap_content"/> 148 + android:textColor="@color/color_96"
  149 + android:textSize="14sp" />
109 150
110 <ImageView 151 <ImageView
111 - android:layout_marginEnd="16dp"  
112 - android:layout_gravity="center_vertical"  
113 - android:src="@mipmap/ic_arrow"  
114 android:layout_width="wrap_content" 152 android:layout_width="wrap_content"
115 - android:layout_height="wrap_content"/> 153 + android:layout_height="wrap_content"
  154 + android:layout_gravity="center_vertical"
  155 + android:layout_marginEnd="16dp"
  156 + android:src="@mipmap/ic_arrow" />
116 157
117 </LinearLayout> 158 </LinearLayout>
118 159
119 <View 160 <View
120 - android:layout_marginStart="16dp"  
121 - android:background="@color/color_f7"  
122 android:layout_width="match_parent" 161 android:layout_width="match_parent"
123 - android:layout_height="1dp"> 162 + android:layout_height="1dp"
  163 + android:layout_marginStart="16dp"
  164 + android:background="@color/color_f7">
124 165
125 </View> 166 </View>
126 167
127 <LinearLayout 168 <LinearLayout
128 android:id="@+id/ll_change_pwd" 169 android:id="@+id/ll_change_pwd"
129 - android:orientation="horizontal"  
130 android:layout_width="match_parent" 170 android:layout_width="match_parent"
131 - android:layout_height="48dp"> 171 + android:layout_height="48dp"
  172 + android:orientation="horizontal">
132 173
133 <TextView 174 <TextView
  175 + android:layout_width="wrap_content"
  176 + android:layout_height="wrap_content"
134 android:layout_gravity="center_vertical" 177 android:layout_gravity="center_vertical"
135 android:layout_marginStart="16dp" 178 android:layout_marginStart="16dp"
136 - android:textColor="@color/color_32"  
137 - android:textSize="14sp"  
138 android:text="密码:" 179 android:text="密码:"
139 - android:layout_width="wrap_content"  
140 - android:layout_height="wrap_content"/> 180 + android:textColor="@color/color_32"
  181 + android:textSize="14sp" />
141 182
142 <TextView 183 <TextView
  184 + android:layout_width="wrap_content"
  185 + android:layout_height="wrap_content"
  186 + android:layout_gravity="center_vertical"
143 android:layout_marginEnd="4dp" 187 android:layout_marginEnd="4dp"
  188 + android:layout_weight="1"
144 android:gravity="end" 189 android:gravity="end"
145 - android:layout_gravity="center_vertical"  
146 - android:textColor="@color/color_96"  
147 - android:textSize="14sp"  
148 android:text="" 190 android:text=""
149 - android:layout_weight="1"  
150 - android:layout_width="wrap_content"  
151 - android:layout_height="wrap_content"/> 191 + android:textColor="@color/color_96"
  192 + android:textSize="14sp" />
152 193
153 <ImageView 194 <ImageView
154 - android:layout_marginEnd="16dp"  
155 - android:layout_gravity="center_vertical"  
156 - android:src="@mipmap/ic_arrow"  
157 android:layout_width="wrap_content" 195 android:layout_width="wrap_content"
158 - android:layout_height="wrap_content"/> 196 + android:layout_height="wrap_content"
  197 + android:layout_gravity="center_vertical"
  198 + android:layout_marginEnd="16dp"
  199 + android:src="@mipmap/ic_arrow" />
159 200
160 </LinearLayout> 201 </LinearLayout>
161 202
162 <View 203 <View
163 - android:background="@color/color_f7"  
164 android:layout_width="match_parent" 204 android:layout_width="match_parent"
165 - android:layout_height="8dp"> 205 + android:layout_height="8dp"
  206 + android:background="@color/color_f7">
166 207
167 </View> 208 </View>
168 209
169 <LinearLayout 210 <LinearLayout
170 - android:orientation="horizontal"  
171 android:layout_width="match_parent" 211 android:layout_width="match_parent"
172 - android:layout_height="48dp"> 212 + android:layout_height="48dp"
  213 + android:orientation="horizontal">
173 214
174 <TextView 215 <TextView
  216 + android:layout_width="wrap_content"
  217 + android:layout_height="wrap_content"
175 android:layout_gravity="center_vertical" 218 android:layout_gravity="center_vertical"
176 android:layout_marginStart="16dp" 219 android:layout_marginStart="16dp"
177 - android:textColor="@color/color_32"  
178 - android:textSize="14sp"  
179 android:text="身份证号:" 220 android:text="身份证号:"
180 - android:layout_width="wrap_content"  
181 - android:layout_height="wrap_content"/> 221 + android:textColor="@color/color_32"
  222 + android:textSize="14sp" />
182 223
183 <TextView 224 <TextView
184 android:id="@+id/tv_identity" 225 android:id="@+id/tv_identity"
  226 + android:layout_width="wrap_content"
  227 + android:layout_height="wrap_content"
  228 + android:layout_gravity="center_vertical"
185 android:layout_marginEnd="4dp" 229 android:layout_marginEnd="4dp"
  230 + android:layout_weight="1"
186 android:gravity="end" 231 android:gravity="end"
187 - android:layout_gravity="center_vertical"  
188 - android:textColor="@color/color_96"  
189 - android:textSize="14sp"  
190 android:text="154356436675475467567435" 232 android:text="154356436675475467567435"
191 - android:layout_weight="1"  
192 - android:layout_width="wrap_content"  
193 - android:layout_height="wrap_content"/> 233 + android:textColor="@color/color_96"
  234 + android:textSize="14sp" />
194 235
195 <ImageView 236 <ImageView
196 - android:visibility="invisible"  
197 - android:layout_marginEnd="16dp" 237 + android:layout_width="wrap_content"
  238 + android:layout_height="wrap_content"
198 android:layout_gravity="center_vertical" 239 android:layout_gravity="center_vertical"
  240 + android:layout_marginEnd="16dp"
199 android:src="@mipmap/ic_arrow" 241 android:src="@mipmap/ic_arrow"
200 - android:layout_width="wrap_content"  
201 - android:layout_height="wrap_content"/> 242 + android:visibility="invisible" />
202 243
203 </LinearLayout> 244 </LinearLayout>
204 245
205 <View 246 <View
206 - android:layout_marginStart="16dp"  
207 - android:background="@color/color_f7"  
208 android:layout_width="match_parent" 247 android:layout_width="match_parent"
209 - android:layout_height="1dp"> 248 + android:layout_height="1dp"
  249 + android:layout_marginStart="16dp"
  250 + android:background="@color/color_f7">
210 251
211 </View> 252 </View>
212 253
213 <LinearLayout 254 <LinearLayout
214 - android:orientation="horizontal"  
215 android:layout_width="match_parent" 255 android:layout_width="match_parent"
216 - android:layout_height="48dp"> 256 + android:layout_height="48dp"
  257 + android:orientation="horizontal">
217 258
218 <TextView 259 <TextView
  260 + android:layout_width="wrap_content"
  261 + android:layout_height="wrap_content"
219 android:layout_gravity="center_vertical" 262 android:layout_gravity="center_vertical"
220 android:layout_marginStart="16dp" 263 android:layout_marginStart="16dp"
221 - android:textColor="@color/color_32"  
222 - android:textSize="14sp"  
223 android:text="部门:" 264 android:text="部门:"
224 - android:layout_width="wrap_content"  
225 - android:layout_height="wrap_content"/> 265 + android:textColor="@color/color_32"
  266 + android:textSize="14sp" />
226 267
227 <TextView 268 <TextView
228 android:id="@+id/tv_department_name" 269 android:id="@+id/tv_department_name"
  270 + android:layout_width="wrap_content"
  271 + android:layout_height="wrap_content"
  272 + android:layout_gravity="center_vertical"
229 android:layout_marginEnd="4dp" 273 android:layout_marginEnd="4dp"
  274 + android:layout_weight="1"
230 android:gravity="end" 275 android:gravity="end"
231 - android:layout_gravity="center_vertical"  
232 - android:textColor="@color/color_96"  
233 - android:textSize="14sp"  
234 android:text="工程部" 276 android:text="工程部"
235 - android:layout_weight="1"  
236 - android:layout_width="wrap_content"  
237 - android:layout_height="wrap_content"/> 277 + android:textColor="@color/color_96"
  278 + android:textSize="14sp" />
238 279
239 <ImageView 280 <ImageView
240 - android:visibility="invisible"  
241 - android:layout_marginEnd="16dp" 281 + android:layout_width="wrap_content"
  282 + android:layout_height="wrap_content"
242 android:layout_gravity="center_vertical" 283 android:layout_gravity="center_vertical"
  284 + android:layout_marginEnd="16dp"
243 android:src="@mipmap/ic_arrow" 285 android:src="@mipmap/ic_arrow"
244 - android:layout_width="wrap_content"  
245 - android:layout_height="wrap_content"/> 286 + android:visibility="invisible" />
246 287
247 </LinearLayout> 288 </LinearLayout>
248 289
249 <View 290 <View
250 - android:layout_marginStart="16dp"  
251 - android:background="@color/color_f7"  
252 android:layout_width="match_parent" 291 android:layout_width="match_parent"
253 - android:layout_height="1dp"> 292 + android:layout_height="1dp"
  293 + android:layout_marginStart="16dp"
  294 + android:background="@color/color_f7">
254 295
255 </View> 296 </View>
256 297
257 <LinearLayout 298 <LinearLayout
258 - android:orientation="horizontal"  
259 android:layout_width="match_parent" 299 android:layout_width="match_parent"
260 - android:layout_height="48dp"> 300 + android:layout_height="48dp"
  301 + android:orientation="horizontal">
261 302
262 <TextView 303 <TextView
  304 + android:layout_width="wrap_content"
  305 + android:layout_height="wrap_content"
263 android:layout_gravity="center_vertical" 306 android:layout_gravity="center_vertical"
264 android:layout_marginStart="16dp" 307 android:layout_marginStart="16dp"
265 - android:textColor="@color/color_32"  
266 - android:textSize="14sp"  
267 android:text="岗位:" 308 android:text="岗位:"
268 - android:layout_width="wrap_content"  
269 - android:layout_height="wrap_content"/> 309 + android:textColor="@color/color_32"
  310 + android:textSize="14sp" />
270 311
271 <TextView 312 <TextView
272 android:id="@+id/tv_pos_name" 313 android:id="@+id/tv_pos_name"
  314 + android:layout_width="wrap_content"
  315 + android:layout_height="wrap_content"
  316 + android:layout_gravity="center_vertical"
273 android:layout_marginEnd="4dp" 317 android:layout_marginEnd="4dp"
  318 + android:layout_weight="1"
274 android:gravity="end" 319 android:gravity="end"
275 - android:layout_gravity="center_vertical"  
276 - android:textColor="@color/color_96"  
277 - android:textSize="14sp"  
278 android:text="设备工程师" 320 android:text="设备工程师"
279 - android:layout_weight="1"  
280 - android:layout_width="wrap_content"  
281 - android:layout_height="wrap_content"/> 321 + android:textColor="@color/color_96"
  322 + android:textSize="14sp" />
282 323
283 <ImageView 324 <ImageView
284 - android:visibility="invisible"  
285 - android:layout_marginEnd="16dp" 325 + android:layout_width="wrap_content"
  326 + android:layout_height="wrap_content"
286 android:layout_gravity="center_vertical" 327 android:layout_gravity="center_vertical"
  328 + android:layout_marginEnd="16dp"
287 android:src="@mipmap/ic_arrow" 329 android:src="@mipmap/ic_arrow"
288 - android:layout_width="wrap_content"  
289 - android:layout_height="wrap_content"/> 330 + android:visibility="invisible" />
290 331
291 </LinearLayout> 332 </LinearLayout>
292 333
293 <View 334 <View
294 - android:layout_marginStart="16dp"  
295 - android:background="@color/color_f7"  
296 android:layout_width="match_parent" 335 android:layout_width="match_parent"
297 - android:layout_height="1dp"> 336 + android:layout_height="1dp"
  337 + android:layout_marginStart="16dp"
  338 + android:background="@color/color_f7">
298 339
299 </View> 340 </View>
300 </LinearLayout> 341 </LinearLayout>
@@ -31,8 +31,7 @@ @@ -31,8 +31,7 @@
31 android:id="@+id/tool_bar" 31 android:id="@+id/tool_bar"
32 android:layout_width="match_parent" 32 android:layout_width="match_parent"
33 android:layout_height="44dp" 33 android:layout_height="44dp"
34 - android:layout_below="@id/toolbar"  
35 - app:toolTitle="每日一练" /> 34 + android:layout_below="@id/toolbar" />
36 35
37 </RelativeLayout> 36 </RelativeLayout>
38 37
@@ -22,10 +22,14 @@ @@ -22,10 +22,14 @@
22 android:padding="12dp" 22 android:padding="12dp"
23 android:src="@mipmap/ic_back" /> 23 android:src="@mipmap/ic_back" />
24 24
25 - <View 25 + <TextView
  26 + android:text="课程详情"
26 android:layout_width="0dp" 27 android:layout_width="0dp"
  28 + android:gravity="center"
  29 + android:textColor="@color/black"
  30 + android:textSize="18sp"
27 android:layout_height="match_parent" 31 android:layout_height="match_parent"
28 - android:layout_weight="1" /> 32 + android:layout_weight="1"/>
29 33
30 <ImageView 34 <ImageView
31 android:id="@+id/start" 35 android:id="@+id/start"
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 android:layout_height="wrap_content" 12 android:layout_height="wrap_content"
13 android:layout_marginStart="12dp" 13 android:layout_marginStart="12dp"
14 android:layout_marginTop="13dp" 14 android:layout_marginTop="13dp"
  15 + android:layout_marginEnd="12dp"
15 android:drawableStart="@mipmap/pdf" 16 android:drawableStart="@mipmap/pdf"
16 android:drawablePadding="8dp" 17 android:drawablePadding="8dp"
17 android:gravity="center_vertical" 18 android:gravity="center_vertical"
  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:layout_marginStart="40dp"
  6 + android:layout_marginEnd="40dp"
  7 + android:background="@drawable/solid_ff_8"
  8 + android:orientation="vertical">
  9 +
  10 + <TextView
  11 + android:layout_width="match_parent"
  12 + android:layout_height="wrap_content"
  13 + android:layout_marginStart="16dp"
  14 + android:layout_marginTop="32dp"
  15 + android:layout_marginEnd="16dp"
  16 + android:textSize="16sp"
  17 + android:textColor="@color/black"
  18 + android:gravity="center"
  19 + android:text="身份信息验证" />
  20 +
  21 + <TextView
  22 + android:id="@+id/info"
  23 + android:layout_width="match_parent"
  24 + android:layout_height="wrap_content"
  25 + android:layout_marginStart="16dp"
  26 + android:layout_marginTop="10dp"
  27 + android:layout_marginEnd="16dp"
  28 + android:layout_marginBottom="16dp"
  29 + android:gravity="top|center_horizontal"
  30 + android:text="设置人脸识别照片为本人学习"
  31 + android:textColor="@color/color_96"
  32 + android:textSize="14sp"
  33 + android:visibility="visible" />
  34 +
  35 + <androidx.appcompat.widget.LinearLayoutCompat
  36 + android:layout_width="match_parent"
  37 + android:layout_height="wrap_content"
  38 + android:layout_marginTop="24dp"
  39 + android:layout_marginBottom="24dp"
  40 + android:gravity="center_horizontal"
  41 + android:orientation="horizontal">
  42 +
  43 + <TextView
  44 + android:id="@+id/btn_left"
  45 + android:layout_width="118dp"
  46 + android:layout_height="40dp"
  47 + android:layout_gravity="center_horizontal"
  48 + android:background="@drawable/solid_ce_4"
  49 + android:gravity="center"
  50 + android:text="取消"
  51 + android:textColor="@color/exo_black_opacity_60"
  52 + android:textSize="15sp" />
  53 +
  54 + <View
  55 + android:id="@+id/space"
  56 + android:layout_width="@dimen/dp_40"
  57 + android:layout_height="40dp" />
  58 +
  59 + <TextView
  60 + android:id="@+id/btn_right"
  61 + android:layout_width="118dp"
  62 + android:layout_height="40dp"
  63 + android:layout_gravity="center_horizontal"
  64 + android:background="@drawable/solid_25_4"
  65 + android:gravity="center"
  66 + android:text="人脸识别"
  67 + android:textColor="@color/white"
  68 + android:textSize="15sp" />
  69 + </androidx.appcompat.widget.LinearLayoutCompat>
  70 +
  71 +</LinearLayout>
@@ -28,6 +28,8 @@ @@ -28,6 +28,8 @@
28 android:layout_marginStart="16dp" 28 android:layout_marginStart="16dp"
29 android:layout_marginTop="32dp" 29 android:layout_marginTop="32dp"
30 android:layout_marginEnd="16dp" 30 android:layout_marginEnd="16dp"
  31 + android:textSize="16sp"
  32 + android:textColor="@color/black"
31 android:gravity="center" 33 android:gravity="center"
32 android:text="答对6道题" /> 34 android:text="答对6道题" />
33 35
@@ -42,7 +44,7 @@ @@ -42,7 +44,7 @@
42 android:gravity="top|center_horizontal" 44 android:gravity="top|center_horizontal"
43 android:text="共9道题" 45 android:text="共9道题"
44 android:textColor="@color/color_96" 46 android:textColor="@color/color_96"
45 - android:textSize="12sp" 47 + android:textSize="14sp"
46 android:visibility="visible" /> 48 android:visibility="visible" />
47 49
48 <androidx.appcompat.widget.LinearLayoutCompat 50 <androidx.appcompat.widget.LinearLayoutCompat
@@ -47,7 +47,8 @@ @@ -47,7 +47,8 @@
47 47
48 <LinearLayout 48 <LinearLayout
49 android:layout_width="match_parent" 49 android:layout_width="match_parent"
50 - android:layout_height="wrap_content" 50 + android:layout_height="0dp"
  51 + android:layout_weight="1"
51 android:orientation="vertical"> 52 android:orientation="vertical">
52 53
53 <LinearLayout 54 <LinearLayout
@@ -154,8 +155,8 @@ @@ -154,8 +155,8 @@
154 android:textColor="@color/color_32" 155 android:textColor="@color/color_32"
155 android:textSize="18sp" /> 156 android:textSize="18sp" />
156 157
157 - <androidx.swiperefreshlayout.widget.SwipeRefreshLayout  
158 - android:id="@+id/swipeRefreshlayout" 158 + <com.scwang.smart.refresh.layout.SmartRefreshLayout
  159 + android:id="@+id/refresh_layout"
159 android:layout_width="match_parent" 160 android:layout_width="match_parent"
160 android:layout_height="0dp" 161 android:layout_height="0dp"
161 android:layout_weight="1"> 162 android:layout_weight="1">
@@ -165,14 +166,16 @@ @@ -165,14 +166,16 @@
165 android:id="@+id/practice" 166 android:id="@+id/practice"
166 android:layout_width="match_parent" 167 android:layout_width="match_parent"
167 android:layout_height="wrap_content" 168 android:layout_height="wrap_content"
168 - android:layout_marginStart="16dp"  
169 - android:layout_marginEnd="16dp"  
170 android:nestedScrollingEnabled="false" 169 android:nestedScrollingEnabled="false"
171 android:overScrollMode="never" 170 android:overScrollMode="never"
172 android:paddingHorizontal="16dp" 171 android:paddingHorizontal="16dp"
173 android:scrollbars="none" 172 android:scrollbars="none"
174 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 173 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
175 - </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> 174 +
  175 + <com.scwang.smart.refresh.footer.ClassicsFooter
  176 + android:layout_width="match_parent"
  177 + android:layout_height="wrap_content" />
  178 + </com.scwang.smart.refresh.layout.SmartRefreshLayout>
176 179
177 </LinearLayout> 180 </LinearLayout>
178 181
@@ -14,7 +14,6 @@ @@ -14,7 +14,6 @@
14 android:gravity="center" 14 android:gravity="center"
15 android:visibility="gone" /> 15 android:visibility="gone" />
16 16
17 -  
18 <LinearLayout 17 <LinearLayout
19 android:id="@+id/lay_data" 18 android:id="@+id/lay_data"
20 android:layout_width="match_parent" 19 android:layout_width="match_parent"
@@ -30,22 +29,20 @@ @@ -30,22 +29,20 @@
30 29
31 <com.scwang.smart.refresh.header.ClassicsHeader 30 <com.scwang.smart.refresh.header.ClassicsHeader
32 android:layout_width="match_parent" 31 android:layout_width="match_parent"
33 - android:layout_height="wrap_content"/> 32 + android:layout_height="wrap_content" />
34 33
35 <androidx.recyclerview.widget.RecyclerView 34 <androidx.recyclerview.widget.RecyclerView
36 android:id="@+id/recyclerview" 35 android:id="@+id/recyclerview"
37 android:layout_width="match_parent" 36 android:layout_width="match_parent"
38 android:layout_height="wrap_content" 37 android:layout_height="wrap_content"
39 - android:layout_marginStart="16dp"  
40 - android:layout_marginEnd="16dp"  
41 - android:layout_marginBottom="32dp" 38 + android:layout_marginTop="16dp"
42 android:overScrollMode="never" 39 android:overScrollMode="never"
43 android:scrollbars="none" 40 android:scrollbars="none"
44 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 41 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
45 42
46 <com.scwang.smart.refresh.footer.ClassicsFooter 43 <com.scwang.smart.refresh.footer.ClassicsFooter
47 android:layout_width="match_parent" 44 android:layout_width="match_parent"
48 - android:layout_height="wrap_content"/> 45 + android:layout_height="wrap_content" />
49 </com.scwang.smart.refresh.layout.SmartRefreshLayout> 46 </com.scwang.smart.refresh.layout.SmartRefreshLayout>
50 47
51 <LinearLayout 48 <LinearLayout
@@ -58,7 +55,6 @@ @@ -58,7 +55,6 @@
58 android:layout_marginBottom="16dp" 55 android:layout_marginBottom="16dp"
59 android:orientation="horizontal"> 56 android:orientation="horizontal">
60 57
61 -  
62 <ProgressBar 58 <ProgressBar
63 android:id="@+id/pr_upload_value" 59 android:id="@+id/pr_upload_value"
64 style="@android:style/Widget.ProgressBar.Horizontal" 60 style="@android:style/Widget.ProgressBar.Horizontal"
@@ -6,18 +6,22 @@ @@ -6,18 +6,22 @@
6 android:orientation="vertical"> 6 android:orientation="vertical">
7 7
8 <ImageView 8 <ImageView
9 - android:layout_width="match_parent"  
10 - android:layout_height="wrap_content" 9 + android:layout_width="128dp"
  10 + android:layout_height="128dp"
  11 + android:layout_marginTop="16dp"
11 android:layout_gravity="center_horizontal" 12 android:layout_gravity="center_horizontal"
12 android:contentDescription="@string/logo" 13 android:contentDescription="@string/logo"
13 - android:scaleType="fitXY"  
14 android:src="@mipmap/my_credentials_upload_bg" /> 14 android:src="@mipmap/my_credentials_upload_bg" />
15 15
16 <TextView 16 <TextView
17 android:layout_width="wrap_content" 17 android:layout_width="wrap_content"
18 android:layout_height="wrap_content" 18 android:layout_height="wrap_content"
  19 + android:minHeight="26dp"
  20 + android:layout_marginTop="12dp"
  21 + android:gravity="center"
19 android:layout_gravity="center" 22 android:layout_gravity="center"
  23 + android:textSize="@dimen/sp_14"
20 android:textColor="@color/black" 24 android:textColor="@color/black"
21 android:layout_marginBottom="32dp" 25 android:layout_marginBottom="32dp"
22 - android:text="上传证"/> 26 + android:text="上传证"/>
23 </LinearLayout> 27 </LinearLayout>
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 android:src="@mipmap/card_back" /> 15 android:src="@mipmap/card_back" />
16 16
17 <TextView 17 <TextView
  18 + android:id="@+id/cert_validity_period_name"
18 android:layout_width="wrap_content" 19 android:layout_width="wrap_content"
19 android:layout_height="wrap_content" 20 android:layout_height="wrap_content"
20 android:layout_gravity="center_horizontal" 21 android:layout_gravity="center_horizontal"
@@ -4,7 +4,6 @@ @@ -4,7 +4,6 @@
4 android:layout_width="match_parent" 4 android:layout_width="match_parent"
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"  
8 android:layout_marginStart="16dp" 7 android:layout_marginStart="16dp"
9 android:layout_marginEnd="16dp" 8 android:layout_marginEnd="16dp"
10 android:orientation="vertical"> 9 android:orientation="vertical">
1 include ':app' 1 include ':app'
2 rootProject.name = "SecurityTrain-Master" 2 rootProject.name = "SecurityTrain-Master"
  3 +include ':Library'