正在显示
6 个修改的文件
包含
121 行增加
和
10 行删除
@@ -21,11 +21,13 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.NoticeBean | @@ -21,11 +21,13 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.NoticeBean | ||
21 | import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean | 21 | import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean |
22 | import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean | 22 | import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean |
23 | import com.br_technology.securitytrain_master.ui.view.home.viewmodel.HomeViewModel | 23 | import com.br_technology.securitytrain_master.ui.view.home.viewmodel.HomeViewModel |
24 | +import com.br_technology.securitytrain_master.view.DialogNotice | ||
24 | import com.br_technology.securitytrain_master.view.listener.OnItemClickListener | 25 | import com.br_technology.securitytrain_master.view.listener.OnItemClickListener |
25 | import com.bumptech.glide.Glide | 26 | import com.bumptech.glide.Glide |
26 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners | 27 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners |
27 | import com.bumptech.glide.request.RequestOptions | 28 | import com.bumptech.glide.request.RequestOptions |
28 | import com.gyf.immersionbar.components.SimpleImmersionOwner | 29 | import com.gyf.immersionbar.components.SimpleImmersionOwner |
30 | +import com.luck.picture.lib.tools.ToastUtils | ||
29 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment | 31 | import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment |
30 | import com.youth.banner.adapter.BannerImageAdapter | 32 | import com.youth.banner.adapter.BannerImageAdapter |
31 | import com.youth.banner.holder.BannerImageHolder | 33 | import com.youth.banner.holder.BannerImageHolder |
@@ -46,6 +48,10 @@ class HomeFragment : | @@ -46,6 +48,10 @@ class HomeFragment : | ||
46 | private var videoLessonList: MutableList<VideoLessonBean.ListBean.DataBean>? = null | 48 | private var videoLessonList: MutableList<VideoLessonBean.ListBean.DataBean>? = null |
47 | private var recommendDataAdapter: RecommendDataAdapter? = null | 49 | private var recommendDataAdapter: RecommendDataAdapter? = null |
48 | private var videoCourseAdapter: VideoCourseAdapter? = null | 50 | private var videoCourseAdapter: VideoCourseAdapter? = null |
51 | + | ||
52 | + private val dialogNotice by lazy { | ||
53 | + DialogNotice(requireContext()) | ||
54 | + } | ||
49 | override fun initDataObserver() { | 55 | override fun initDataObserver() { |
50 | //获取banner数据 | 56 | //获取banner数据 |
51 | mViewModel.mBannerBean.observe(this, { | 57 | mViewModel.mBannerBean.observe(this, { |
@@ -56,12 +62,16 @@ class HomeFragment : | @@ -56,12 +62,16 @@ class HomeFragment : | ||
56 | //获取最新公告 | 62 | //获取最新公告 |
57 | mViewModel.mNoticeBean.observe(this, { | 63 | mViewModel.mNoticeBean.observe(this, { |
58 | val data = it.data.list | 64 | val data = it.data.list |
59 | - for (news in data) { | 65 | + for (index in data.indices) { |
60 | val textView = TextView(context) | 66 | val textView = TextView(context) |
61 | textView.maxLines = 1 | 67 | textView.maxLines = 1 |
62 | - textView.text = news.title | 68 | + textView.text = data[index].title |
63 | textView.ellipsize = TextUtils.TruncateAt.END | 69 | textView.ellipsize = TextUtils.TruncateAt.END |
70 | + textView.tag = index | ||
64 | textView.setOnClickListener { | 71 | textView.setOnClickListener { |
72 | + val position = textView.tag as Int | ||
73 | + // 公告弹框 | ||
74 | + dialogNotice.setTitle(data[position].des).show() | ||
65 | } | 75 | } |
66 | binding.flipperScan.addView( | 76 | binding.flipperScan.addView( |
67 | textView, ViewGroup.LayoutParams( | 77 | textView, ViewGroup.LayoutParams( |
@@ -70,6 +80,22 @@ class HomeFragment : | @@ -70,6 +80,22 @@ class HomeFragment : | ||
70 | ) | 80 | ) |
71 | ) | 81 | ) |
72 | } | 82 | } |
83 | +// for (news in data) { | ||
84 | +// val textView = TextView(context) | ||
85 | +// textView.maxLines = 1 | ||
86 | +// textView.text = news.title | ||
87 | +// textView.ellipsize = TextUtils.TruncateAt.END | ||
88 | +// textView.setOnClickListener { | ||
89 | +// // 公告弹框 | ||
90 | +// ToastUtils.s(requireContext(),"aaa") | ||
91 | +// } | ||
92 | +// binding.flipperScan.addView( | ||
93 | +// textView, ViewGroup.LayoutParams( | ||
94 | +// ViewGroup.LayoutParams.MATCH_PARENT, | ||
95 | +// ViewGroup.LayoutParams.WRAP_CONTENT | ||
96 | +// ) | ||
97 | +// ) | ||
98 | +// } | ||
73 | if (data.size > 1) { | 99 | if (data.size > 1) { |
74 | binding.flipperScan.flipInterval = 3000 | 100 | binding.flipperScan.flipInterval = 3000 |
75 | binding.flipperScan.startFlipping() | 101 | binding.flipperScan.startFlipping() |
@@ -35,6 +35,7 @@ class MineFragment | @@ -35,6 +35,7 @@ class MineFragment | ||
35 | Glide.with(requireActivity()).load(it.data.info.avatar) | 35 | Glide.with(requireActivity()).load(it.data.info.avatar) |
36 | .placeholder(R.mipmap.placeholder_head).into(binding.ivIcon) | 36 | .placeholder(R.mipmap.placeholder_head).into(binding.ivIcon) |
37 | identity = it.data.info.identity | 37 | identity = it.data.info.identity |
38 | + binding.departmentName.text = it.data.info.department_name.plus(" - ").plus(it.data.info.pos_name) | ||
38 | }) | 39 | }) |
39 | 40 | ||
40 | mViewModel.mCommonBean.observe(this,{ | 41 | mViewModel.mCommonBean.observe(this,{ |
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 com.br_technology.securitytrain_master.R | ||
8 | +import com.br_technology.securitytrain_master.databinding.DialogNoticeBinding | ||
9 | +import com.br_technology.securitytrain_master.expand.dp2px | ||
10 | +import com.br_technology.securitytrain_master.expand.screenWidth | ||
11 | + | ||
12 | +/** | ||
13 | + * auth: 张继 | ||
14 | + * date: 2022/2/9 16:41 | ||
15 | + * dsc: 通知 | ||
16 | + * updateInfo: | ||
17 | + */ | ||
18 | +class DialogNotice(context: Context) : Dialog(context, R.style.UserDefaultDialog) { | ||
19 | + private val binding by lazy { | ||
20 | + DialogNoticeBinding.inflate(LayoutInflater.from(context)) | ||
21 | + } | ||
22 | + override fun onCreate(savedInstanceState: Bundle?) { | ||
23 | + super.onCreate(savedInstanceState) | ||
24 | + setContentView(binding.root) | ||
25 | + val attributes = window?.attributes | ||
26 | + attributes?.width = binding.root.screenWidth() - 80.dp2px() | ||
27 | + // 点击区域外取消 | ||
28 | + setCanceledOnTouchOutside(false) | ||
29 | + setCancelable(false) | ||
30 | + binding.determine.setOnClickListener { | ||
31 | + dismiss() | ||
32 | + } | ||
33 | + } | ||
34 | + | ||
35 | + fun setTitle(title: String): DialogNotice { | ||
36 | + binding.title.text = title | ||
37 | + return this | ||
38 | + } | ||
39 | + | ||
40 | +} |
app/src/main/res/layout/dialog_notice.xml
0 → 100644
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_4" | ||
8 | + android:orientation="vertical"> | ||
9 | + | ||
10 | + <ImageView | ||
11 | + android:layout_width="match_parent" | ||
12 | + android:layout_height="wrap_content" | ||
13 | + android:contentDescription="@string/logo" | ||
14 | + android:scaleType="fitXY" | ||
15 | + android:src="@mipmap/icon_notice" /> | ||
16 | + | ||
17 | + <androidx.core.widget.NestedScrollView | ||
18 | + android:layout_width="match_parent" | ||
19 | + android:layout_height="220dp" | ||
20 | + android:layout_marginHorizontal="16dp" | ||
21 | + android:layout_marginTop="32dp" | ||
22 | + android:scrollbars="none"> | ||
23 | + | ||
24 | + <TextView | ||
25 | + android:id="@+id/title" | ||
26 | + android:layout_width="match_parent" | ||
27 | + android:layout_height="match_parent" | ||
28 | + android:textColor="@color/color_252" | ||
29 | + android:textSize="18sp" /> | ||
30 | + </androidx.core.widget.NestedScrollView> | ||
31 | + | ||
32 | + <TextView | ||
33 | + android:id="@+id/determine" | ||
34 | + android:layout_width="130dp" | ||
35 | + android:layout_height="45dp" | ||
36 | + android:layout_gravity="center_horizontal" | ||
37 | + android:layout_marginTop="15dp" | ||
38 | + android:layout_marginBottom="20dp" | ||
39 | + android:background="@drawable/solid_25_4" | ||
40 | + android:gravity="center" | ||
41 | + android:text="确定" | ||
42 | + android:textColor="@color/white" | ||
43 | + android:textSize="15sp" /> | ||
44 | + | ||
45 | +</LinearLayout> |
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
3 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
5 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
@@ -7,6 +8,7 @@ | @@ -7,6 +8,7 @@ | ||
7 | <include layout="@layout/layout_tool_bar_theme" /> | 8 | <include layout="@layout/layout_tool_bar_theme" /> |
8 | 9 | ||
9 | <androidx.core.widget.NestedScrollView | 10 | <androidx.core.widget.NestedScrollView |
11 | + android:fillViewport="true" | ||
10 | android:layout_width="match_parent" | 12 | android:layout_width="match_parent" |
11 | android:layout_height="match_parent"> | 13 | android:layout_height="match_parent"> |
12 | 14 | ||
@@ -16,7 +18,6 @@ | @@ -16,7 +18,6 @@ | ||
16 | android:layout_height="match_parent" | 18 | android:layout_height="match_parent" |
17 | android:orientation="vertical"> | 19 | android:orientation="vertical"> |
18 | 20 | ||
19 | - | ||
20 | <LinearLayout | 21 | <LinearLayout |
21 | android:layout_width="match_parent" | 22 | android:layout_width="match_parent" |
22 | android:layout_height="wrap_content" | 23 | android:layout_height="wrap_content" |
@@ -57,8 +58,8 @@ | @@ -57,8 +58,8 @@ | ||
57 | android:layout_marginTop="26dp" /> | 58 | android:layout_marginTop="26dp" /> |
58 | 59 | ||
59 | <LinearLayout | 60 | <LinearLayout |
60 | - android:layout_width="wrap_content" | ||
61 | - android:layout_height="match_parent" | 61 | + android:layout_width="0dp" |
62 | + android:layout_height="wrap_content" | ||
62 | android:layout_marginStart="20dp" | 63 | android:layout_marginStart="20dp" |
63 | android:layout_marginTop="26dp" | 64 | android:layout_marginTop="26dp" |
64 | android:layout_weight="1" | 65 | android:layout_weight="1" |
@@ -68,7 +69,6 @@ | @@ -68,7 +69,6 @@ | ||
68 | android:id="@+id/tv_name" | 69 | android:id="@+id/tv_name" |
69 | android:layout_width="wrap_content" | 70 | android:layout_width="wrap_content" |
70 | android:layout_height="wrap_content" | 71 | android:layout_height="wrap_content" |
71 | - android:text="" | ||
72 | android:textColor="@color/white" | 72 | android:textColor="@color/white" |
73 | android:textSize="28sp" /> | 73 | android:textSize="28sp" /> |
74 | 74 | ||
@@ -77,17 +77,16 @@ | @@ -77,17 +77,16 @@ | ||
77 | android:layout_width="wrap_content" | 77 | android:layout_width="wrap_content" |
78 | android:layout_height="wrap_content" | 78 | android:layout_height="wrap_content" |
79 | android:layout_marginTop="8dp" | 79 | android:layout_marginTop="8dp" |
80 | - android:drawableStart="@mipmap/mine_phone" | ||
81 | android:drawablePadding="4dp" | 80 | android:drawablePadding="4dp" |
82 | - android:text="" | ||
83 | android:textColor="@color/white" | 81 | android:textColor="@color/white" |
84 | - android:textSize="12sp" /> | 82 | + android:textSize="12sp" |
83 | + app:drawableStartCompat="@mipmap/mine_phone" /> | ||
85 | 84 | ||
86 | <TextView | 85 | <TextView |
86 | + android:id="@+id/department_name" | ||
87 | android:layout_width="wrap_content" | 87 | android:layout_width="wrap_content" |
88 | android:layout_height="wrap_content" | 88 | android:layout_height="wrap_content" |
89 | android:layout_marginTop="8dp" | 89 | android:layout_marginTop="8dp" |
90 | - android:text="工程部-设备工程师" | ||
91 | android:textColor="@color/white" | 90 | android:textColor="@color/white" |
92 | android:textSize="12sp" /> | 91 | android:textSize="12sp" /> |
93 | 92 |
40.1 KB
-
请 注册 或 登录 后发表评论