作者 zhangji

增加公告详情

... ... @@ -21,11 +21,13 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.NoticeBean
import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean
import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
import com.br_technology.securitytrain_master.ui.view.home.viewmodel.HomeViewModel
import com.br_technology.securitytrain_master.view.DialogNotice
import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.gyf.immersionbar.components.SimpleImmersionOwner
import com.luck.picture.lib.tools.ToastUtils
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
import com.youth.banner.adapter.BannerImageAdapter
import com.youth.banner.holder.BannerImageHolder
... ... @@ -46,6 +48,10 @@ class HomeFragment :
private var videoLessonList: MutableList<VideoLessonBean.ListBean.DataBean>? = null
private var recommendDataAdapter: RecommendDataAdapter? = null
private var videoCourseAdapter: VideoCourseAdapter? = null
private val dialogNotice by lazy {
DialogNotice(requireContext())
}
override fun initDataObserver() {
//获取banner数据
mViewModel.mBannerBean.observe(this, {
... ... @@ -56,12 +62,16 @@ class HomeFragment :
//获取最新公告
mViewModel.mNoticeBean.observe(this, {
val data = it.data.list
for (news in data) {
for (index in data.indices) {
val textView = TextView(context)
textView.maxLines = 1
textView.text = news.title
textView.text = data[index].title
textView.ellipsize = TextUtils.TruncateAt.END
textView.tag = index
textView.setOnClickListener {
val position = textView.tag as Int
// 公告弹框
dialogNotice.setTitle(data[position].des).show()
}
binding.flipperScan.addView(
textView, ViewGroup.LayoutParams(
... ... @@ -70,6 +80,22 @@ class HomeFragment :
)
)
}
// for (news in data) {
// val textView = TextView(context)
// textView.maxLines = 1
// textView.text = news.title
// textView.ellipsize = TextUtils.TruncateAt.END
// textView.setOnClickListener {
// // 公告弹框
// ToastUtils.s(requireContext(),"aaa")
// }
// binding.flipperScan.addView(
// textView, ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT,
// ViewGroup.LayoutParams.WRAP_CONTENT
// )
// )
// }
if (data.size > 1) {
binding.flipperScan.flipInterval = 3000
binding.flipperScan.startFlipping()
... ...
... ... @@ -35,6 +35,7 @@ class MineFragment
Glide.with(requireActivity()).load(it.data.info.avatar)
.placeholder(R.mipmap.placeholder_head).into(binding.ivIcon)
identity = it.data.info.identity
binding.departmentName.text = it.data.info.department_name.plus(" - ").plus(it.data.info.pos_name)
})
mViewModel.mCommonBean.observe(this,{
... ...
package com.br_technology.securitytrain_master.view
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.DialogNoticeBinding
import com.br_technology.securitytrain_master.expand.dp2px
import com.br_technology.securitytrain_master.expand.screenWidth
/**
* auth: 张继
* date: 2022/2/9 16:41
* dsc: 通知
* updateInfo:
*/
class DialogNotice(context: Context) : Dialog(context, R.style.UserDefaultDialog) {
private val binding by lazy {
DialogNoticeBinding.inflate(LayoutInflater.from(context))
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
val attributes = window?.attributes
attributes?.width = binding.root.screenWidth() - 80.dp2px()
// 点击区域外取消
setCanceledOnTouchOutside(false)
setCancelable(false)
binding.determine.setOnClickListener {
dismiss()
}
}
fun setTitle(title: String): DialogNotice {
binding.title.text = title
return this
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:background="@drawable/solid_ff_4"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/logo"
android:scaleType="fitXY"
android:src="@mipmap/icon_notice" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="32dp"
android:scrollbars="none">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/color_252"
android:textSize="18sp" />
</androidx.core.widget.NestedScrollView>
<TextView
android:id="@+id/determine"
android:layout_width="130dp"
android:layout_height="45dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:layout_marginBottom="20dp"
android:background="@drawable/solid_25_4"
android:gravity="center"
android:text="确定"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
... ... @@ -7,6 +8,7 @@
<include layout="@layout/layout_tool_bar_theme" />
<androidx.core.widget.NestedScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
... ... @@ -16,7 +18,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
... ... @@ -57,8 +58,8 @@
android:layout_marginTop="26dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="26dp"
android:layout_weight="1"
... ... @@ -68,7 +69,6 @@
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/white"
android:textSize="28sp" />
... ... @@ -77,17 +77,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:drawableStart="@mipmap/mine_phone"
android:drawablePadding="4dp"
android:text=""
android:textColor="@color/white"
android:textSize="12sp" />
android:textSize="12sp"
app:drawableStartCompat="@mipmap/mine_phone" />
<TextView
android:id="@+id/department_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="工程部-设备工程师"
android:textColor="@color/white"
android:textSize="12sp" />
... ...