作者 zhangji

我的证件未写完

正在显示 18 个修改的文件 包含 232 行增加77 行删除
... ... @@ -26,6 +26,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SecurityTrainMaster"
... ... @@ -193,8 +194,9 @@
<activity
android:name=".ui.view.home.activity.course.LocationSignActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" />
<activity android:name=".ui.view.home.activity.course.CoursePractiseActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"/>
<activity
android:name=".ui.view.home.activity.course.CoursePractiseActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" />
<activity android:name=".ui.view.bank.activity.AnswerRecordDetailsActivity" />
<activity android:name=".ui.view.bank.activity.WrongQuestionsActivity" />
... ...
package com.br_technology.securitytrain_master.base.network.api
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetail
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.network.response.*
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.login.bean.LoginBean
import io.reactivex.rxjava3.core.Observable
... ... @@ -197,7 +194,7 @@ interface UserApi : ApiService {
fun certList(
@Field("page") page: Int,
@Field("page_num") page_num: String
): Observable<BaseResponse<CommonPage<UserCert>>>
): Observable<BaseResponse<CommonDataList<CommonPage<UserCert>>>>
/**
* 证件详情
... ...
... ... @@ -2,10 +2,7 @@ package com.br_technology.securitytrain_master.base.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetail
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.network.response.*
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.login.bean.LoginBean
... ... @@ -108,7 +105,7 @@ class UserRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat
fun certList(
page: Int,
page_num: String,
liveData: MutableLiveData<BaseResponse<CommonPage<UserCert>>>
liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<UserCert>>>>
) {
addRequest(userService.certList(page, page_num), liveData)
}
... ...
... ... @@ -45,6 +45,9 @@ abstract class BaseMultiAdapter<T, VB : ViewBinding> : RecyclerView.Adapter<Base
abstract fun onBind(holder: VB, position: Int)
fun getData(position: Int):T?{
return list?.get(position)
}
override fun getItemCount(): Int {
return if (list.isEmpty()) {
... ... @@ -81,6 +84,11 @@ abstract class BaseMultiAdapter<T, VB : ViewBinding> : RecyclerView.Adapter<Base
notifyItemChanged(position, list.size)
}
fun addListClear(t: List<T>) {
list.clear()
list.addAll(t)
notifyDataSetChanged()
}
protected fun startActivity(context: Context, cls: Class<out Activity>) {
startActivity(context, cls, null)
}
... ...
... ... @@ -38,7 +38,14 @@ fun ImageView.courseHead(pic: String) {
fun ImageView.loadPic(pic: String) {
Glide.with(this)
.load(pic)
.placeholder(R.mipmap.placeholder_head)
.apply(RequestOptions().centerCrop())
.into(this)
}
fun ImageView.loadPicNoCrop(pic: String,width:Int,height:Int) {
Glide.with(this)
.load(pic)
.override(width,height)
.into(this)
}
... ...
... ... @@ -77,6 +77,7 @@ open class UserCertDetail(
var mobile: String, // 手机号
var valid: Int, // 有效期
var start_time: String, // 生效时间
var update_time: String, // 生效时间
var end_time: String, // 失效时间
var status: String, // 审核状态1=待审核2=审核通过3=审核驳回
var cert: UserCertData,
... ...
package com.br_technology.securitytrain_master.ui.view.mine.activity
import android.view.View
import android.widget.TimePicker
import com.bigkoo.pickerview.builder.TimePickerBuilder
import com.bigkoo.pickerview.configure.PickerOptions
import com.bigkoo.pickerview.listener.OnTimeSelectListener
import com.bigkoo.pickerview.view.TimePickerView
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.ActivityCredentialsUploadBinding
import com.br_technology.securitytrain_master.expand.dp2px
import com.br_technology.securitytrain_master.expand.loadPicNoCrop
import com.br_technology.securitytrain_master.expand.screenWidth
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.CredentialsUpLoadViewModel
import com.br_technology.securitytrain_master.util.GlideEnginePic
import com.luck.picture.lib.PictureSelector
import com.luck.picture.lib.config.PictureMimeType
import com.luck.picture.lib.entity.LocalMedia
import com.luck.picture.lib.listener.OnResultCallbackListener
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
import java.util.*
/**
* Time: 8/2/2021 13:55
... ... @@ -15,6 +29,9 @@ class CredentialsUpLoadActivity :
BaseLifeCycleActivity<CredentialsUpLoadViewModel, ActivityCredentialsUploadBinding>(
ActivityCredentialsUploadBinding::inflate
), View.OnClickListener {
private var path: String = ""
override fun initDataObserver() {
}
... ... @@ -23,14 +40,55 @@ class CredentialsUpLoadActivity :
super.initData()
binding.apply {
tvUpload.setOnClickListener(this@CredentialsUpLoadActivity)
uploadPic.setOnClickListener {
selectPicture()
// PictureSelector.create(this@CredentialsUpLoadActivity)
}
selectionPeriod.setOnClickListener {
selectTime()
}
}
// // 根据类型跳转
// CenterToast(this@MyCredentialsActivity).setTitle("上传成功").show()
}
override fun onClick(v: View?) {
when (v!!.id) {
when (v?.id) {
R.id.tv_upload -> {
}
}
}
private fun selectPicture() {
val width = mRootView.screenWidth() - 64.dp2px()
PictureSelector.create(this)
.openGallery(PictureMimeType.ofImage())
.imageEngine(GlideEnginePic.createGlideEngine())
.forResult(object : OnResultCallbackListener<LocalMedia> {
override fun onResult(result: MutableList<LocalMedia>?) {
path = result?.get(0)?.realPath ?: ""
if (path.isNotEmpty()) {
binding.uploadPic.loadPicNoCrop(path, width, 208.dp2px())
}
}
override fun onCancel() {
}
})
}
private fun selectTime() {
TimePickerBuilder(baseContext, object : OnTimeSelectListener {
override fun onTimeSelect(date: Date?, v: View?) {
}
}).build().show()
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.activity
import android.content.Intent
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.ActivityMyCredentialsBinding
import com.br_technology.securitytrain_master.expand.addItemDecoration2
import com.br_technology.securitytrain_master.expand.dp2px
import com.br_technology.securitytrain_master.ui.bean.UserCert
import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendData
import com.br_technology.securitytrain_master.ui.view.mine.adapter.MyCredentialsAdapter
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyCredentialsViewModel
... ... @@ -21,43 +23,59 @@ class MyCredentialsActivity :
BaseLifeCycleActivity<MyCredentialsViewModel, ActivityMyCredentialsBinding>(
ActivityMyCredentialsBinding::inflate
) {
private val adapter: MyCredentialsAdapter by lazy {
MyCredentialsAdapter()
}
private var page: Int = 1
override fun initDataObserver() {
mViewModel.liveData.observe(this) {
if (it.data.list.data.size < 10) {
binding.smartRefresh.setNoMoreData(true)
}
if (page == 1) {
adapter.addListClear(it.data.list.data)
} else {
adapter.addList(it.data.list.data)
}
}
}
override fun initData() {
super.initData()
binding.apply {
recyclerview.addItemDecoration2(2, 8.dp2px(), 16.dp2px())
val recommendList = mutableListOf(
RecommendData(
R.mipmap.card_back,
"思维",
"从这个角度"
),
RecommendData(
R.mipmap.card_back,
"思维",
"从这个角度"
),
RecommendData(
R.mipmap.card_back,
"思维",
"从这个角度"
),
)
val myCredentialsAdapter = MyCredentialsAdapter()
myCredentialsAdapter.addListener(object : OnItemClickListener<RecommendData> {
override fun onClick(position: Int, data: RecommendData) {
// 根据类型跳转
CenterToast(this@MyCredentialsActivity).setTitle("上传成功").show()
smartRefresh.setOnRefreshListener {
smartRefresh.setNoMoreData(false)
page = 1
mViewModel.certList(page)
smartRefresh.finishRefresh()
}
smartRefresh.setOnLoadMoreListener {
++page
mViewModel.certList(page)
smartRefresh.finishLoadMore()
}
recyclerview.addItemDecoration2(2, 8.dp2px(), 16.dp2px())
adapter.addListener(object : OnItemClickListener<UserCert> {
override fun onClick(position: Int, data: UserCert) {
val intent = Intent(baseContext, MyCredentialsDetailActivity::class.java)
intent.putExtra("id", data.id)
startActivity(intent)
}
})
recyclerview.adapter = myCredentialsAdapter
myCredentialsAdapter.addList(recommendList)
adapter.setAddCertListener {
// 添加
startActivity(CredentialsUpLoadActivity::class.java)
}
recyclerview.adapter = adapter
}
}
override fun onResume() {
super.onResume()
binding.smartRefresh.autoRefresh()
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.activity
import com.br_technology.securitytrain_master.databinding.ActivityMyCredentialsDetailBinding
import com.br_technology.securitytrain_master.expand.loadPic
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyCredentialDetailViewModel
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
... ... @@ -14,7 +15,15 @@ class MyCredentialsDetailActivity :
ActivityMyCredentialsDetailBinding::inflate
) {
override fun initDataObserver() {
mViewModel.liveData.observe(this) {
binding.apply {
pictureIv.loadPic(it.data.detail.image_text)
certName.text = it.data.detail.cert.name
certDeadline.text = it.data.detail.end_time
certStartTime.text = it.data.detail.start_time
certUpTime.text = it.data.detail.update_time
}
}
}
override fun initData() {
... ... @@ -26,4 +35,10 @@ class MyCredentialsDetailActivity :
}
}
}
override fun onResume() {
super.onResume()
val id = intent.getIntExtra("id", -1)
mViewModel.certDetail(id)
}
}
\ No newline at end of file
... ...
... ... @@ -8,6 +8,9 @@ import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.view.BaseMultiAdapter
import com.br_technology.securitytrain_master.databinding.ItemMyCredentialsUploadBinding
import com.br_technology.securitytrain_master.databinding.ItemMycredentialsShowBinding
import com.br_technology.securitytrain_master.expand.glideRound
import com.br_technology.securitytrain_master.expand.loadPic
import com.br_technology.securitytrain_master.ui.bean.UserCert
import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendData
/**
... ... @@ -15,7 +18,8 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendData
* Author: Captain
* Description: 初见时你很迷人
*/
class MyCredentialsAdapter : BaseMultiAdapter<RecommendData, ViewBinding>() {
class MyCredentialsAdapter : BaseMultiAdapter<UserCert, ViewBinding>() {
private lateinit var addCertListener:()->Unit
override fun getViewBinding(
context: Context,
parent: ViewGroup,
... ... @@ -31,6 +35,11 @@ class MyCredentialsAdapter : BaseMultiAdapter<RecommendData, ViewBinding>() {
override fun onBind(holder: ViewBinding, position: Int) {
if (holder is ItemMycredentialsShowBinding) {
holder.apply {
val userCert = getData(position)
certPicIv.loadPic(userCert?.image_text?:"")
certValidityPeriod.text="有效期:${userCert?.end_time}"
}
holder.root.setOnClickListener {
listener?.onClick(position, list[position])
}
... ... @@ -38,7 +47,9 @@ class MyCredentialsAdapter : BaseMultiAdapter<RecommendData, ViewBinding>() {
if (holder is ItemMyCredentialsUploadBinding) {
holder.root.setOnClickListener {
listener?.onClick(position, RecommendData(R.mipmap.card_back, "", ""))
if (::addCertListener.isInitialized) {
addCertListener.invoke()
}
}
}
}
... ... @@ -59,4 +70,7 @@ class MyCredentialsAdapter : BaseMultiAdapter<RecommendData, ViewBinding>() {
}
}
fun setAddCertListener(callBack:()->Unit){
this.addCertListener=callBack
}
}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@ class MyErrorQuestionFragment :
override fun initDataObserver() {
mViewModel.liveData.observe(this) {
map[type] = false
if (it.data.list.data.size <= 20) {
if (it.data.list.data.size < 20) {
binding.smartRefresh.setNoMoreData(true)
}
if (page == 1) {
... ...
... ... @@ -10,4 +10,7 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository
* Description: 初见时你很迷人
*/
class MyCredentialsRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetail
import com.br_technology.securitytrain_master.base.repository.UserRepository
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.bean.UserCertDetail
import com.br_technology.securitytrain_master.ui.view.mine.repository.MyCredentialsDetailRepository
/**
... ... @@ -8,5 +13,9 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyCredenti
* Author: Captain
* Description: 初见时你很迷人
*/
class MyCredentialDetailViewModel : BaseViewModel<MyCredentialsDetailRepository>() {
class MyCredentialDetailViewModel : BaseViewModel<UserRepository>() {
val liveData: MutableLiveData<BaseResponse<CommonDetail<UserCertDetail>>> = MutableLiveData()
fun certDetail(id:Int){
mRepository.certDetail(id,liveData)
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.repository.UserRepository
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.bean.UserCert
import com.br_technology.securitytrain_master.ui.view.mine.repository.MyCredentialsRepository
/**
... ... @@ -8,5 +15,11 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyCredenti
* Author: Captain
* Description: 初见时你很迷人
*/
class MyCredentialsViewModel : BaseViewModel<MyCredentialsRepository>() {
class MyCredentialsViewModel : BaseViewModel<UserRepository>() {
val liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<UserCert>>>> = MutableLiveData()
fun certList(page:Int){
mRepository.certList(page,"10",liveData)
}
}
\ No newline at end of file
... ...
... ... @@ -15,22 +15,27 @@
<ImageView
android:layout_width="311dp"
android:id="@+id/upload_pic"
android:layout_width="match_parent"
android:layout_height="208dp"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="33dp"
android:scaleType="fitXY"
android:src="@mipmap/upload_credentials_bg" />
<LinearLayout
android:layout_width="311dp"
android:id="@+id/select_type"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="24dp"
android:background="@drawable/solid_eff2_8"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
... ... @@ -49,15 +54,17 @@
</LinearLayout>
<LinearLayout
android:layout_width="311dp"
android:id="@+id/selection_period"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="24dp"
android:background="@drawable/solid_eff2_8"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
... ... @@ -67,13 +74,13 @@
android:textSize="14sp" />
<EditText
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:background="@null"
android:hint="请输入"
android:hint="请选择初始取证时间"
android:textColor="@color/color_32"
android:textColorHint="@color/color_96"
android:textSize="14sp" />
... ... @@ -91,9 +98,10 @@
<TextView
android:id="@+id/tv_upload"
android:layout_width="343dp"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="42dp"
android:background="@drawable/solid_25_4"
... ...
... ... @@ -13,16 +13,21 @@
android:layout_height="wrap_content"
app:toolTitle="我的证书" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
android:paddingBottom="16dp"
app:spanCount="2" />
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
android:paddingBottom="16dp"
app:spanCount="2" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</LinearLayout>
\ No newline at end of file
... ...
... ... @@ -14,12 +14,12 @@
app:toolTitle="我的证书" />
<ImageView
android:id="@+id/picture_iv"
android:layout_width="311dp"
android:layout_height="208dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="33dp"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher" />
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="311dp"
... ... @@ -30,13 +30,13 @@
android:orientation="vertical">
<TextView
android:id="@+id/cert_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:drawableStart="@mipmap/credentials_icon"
android:drawablePadding="9dp"
android:text="三级电焊工证"
android:textColor="@color/color_32"
android:textSize="16sp"
android:textStyle="bold" />
... ... @@ -56,14 +56,14 @@
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:id="@+id/cert_deadline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="41dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:gravity="end"
android:text="2020-02-02"
android:textColor="@color/color_96"
android:textSize="12sp" />
... ... @@ -84,14 +84,14 @@
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:id="@+id/cert_up_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="41dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:gravity="end"
android:text="2020-02-02"
android:textColor="@color/color_96"
android:textSize="12sp" />
... ... @@ -112,14 +112,14 @@
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:id="@+id/cert_start_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="41dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:gravity="end"
android:text="2020-02-02"
android:textColor="@color/color_96"
android:textSize="12sp" />
... ...
... ... @@ -6,8 +6,9 @@
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cert_pic_iv"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:contentDescription="@string/logo"
... ... @@ -20,18 +21,17 @@
android:layout_marginTop="12dp"
android:gravity="center_vertical"
android:minHeight="26dp"
android:text="三级电焊证"
android:textColor="@color/color_32"
android:textSize="14sp" />
<TextView
android:id="@+id/cert_validity_period"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:gravity="center_vertical"
android:text="有效期:2020-09-10"
android:textColor="@color/color_96"
android:textSize="12sp" />
</LinearLayout>
\ No newline at end of file
... ...