|
@@ -11,6 +11,7 @@ import android.widget.TextView |
|
@@ -11,6 +11,7 @@ import android.widget.TextView |
11
|
import androidx.fragment.app.Fragment
|
11
|
import androidx.fragment.app.Fragment
|
12
|
import androidx.recyclerview.widget.RecyclerView
|
12
|
import androidx.recyclerview.widget.RecyclerView
|
13
|
import com.br_technology.securitytrain_master.R
|
13
|
import com.br_technology.securitytrain_master.R
|
|
|
14
|
+import com.br_technology.securitytrain_master.databinding.FragmentHomeBinding
|
14
|
import com.br_technology.securitytrain_master.ui.home.activity.DatabaseActivity
|
15
|
import com.br_technology.securitytrain_master.ui.home.activity.DatabaseActivity
|
15
|
import com.br_technology.securitytrain_master.ui.home.activity.SearchActivity
|
16
|
import com.br_technology.securitytrain_master.ui.home.activity.SearchActivity
|
16
|
import com.br_technology.securitytrain_master.ui.home.activity.TextCourseActivity
|
17
|
import com.br_technology.securitytrain_master.ui.home.activity.TextCourseActivity
|
|
@@ -18,9 +19,11 @@ import com.br_technology.securitytrain_master.ui.home.adapter.RecommendDataAdapt |
|
@@ -18,9 +19,11 @@ import com.br_technology.securitytrain_master.ui.home.adapter.RecommendDataAdapt |
18
|
import com.br_technology.securitytrain_master.ui.home.adapter.VideoCourseAdapter
|
19
|
import com.br_technology.securitytrain_master.ui.home.adapter.VideoCourseAdapter
|
19
|
import com.br_technology.securitytrain_master.ui.home.pojo.RecommendData
|
20
|
import com.br_technology.securitytrain_master.ui.home.pojo.RecommendData
|
20
|
import com.br_technology.securitytrain_master.ui.home.pojo.VideoCourse
|
21
|
import com.br_technology.securitytrain_master.ui.home.pojo.VideoCourse
|
|
|
22
|
+import com.br_technology.securitytrain_master.ui.home.viewmodel.MineViewModel
|
21
|
import com.bumptech.glide.Glide
|
23
|
import com.bumptech.glide.Glide
|
22
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
24
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
23
|
import com.bumptech.glide.request.RequestOptions
|
25
|
import com.bumptech.glide.request.RequestOptions
|
|
|
26
|
+import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
|
24
|
import com.youth.banner.Banner
|
27
|
import com.youth.banner.Banner
|
25
|
import com.youth.banner.adapter.BannerAdapter
|
28
|
import com.youth.banner.adapter.BannerAdapter
|
26
|
import com.youth.banner.adapter.BannerImageAdapter
|
29
|
import com.youth.banner.adapter.BannerImageAdapter
|
|
@@ -33,129 +36,129 @@ import com.youth.banner.indicator.CircleIndicator |
|
@@ -33,129 +36,129 @@ import com.youth.banner.indicator.CircleIndicator |
33
|
* auth:张继
|
36
|
* auth:张继
|
34
|
* des:
|
37
|
* des:
|
35
|
*/
|
38
|
*/
|
36
|
-//class HomeFragment :BaseLifeCycleFragment<MineViewModel>() {
|
|
|
37
|
-// override fun initDataObserver() {
|
|
|
38
|
-//
|
|
|
39
|
-// }
|
|
|
40
|
-//
|
|
|
41
|
-// override fun getLayoutId(): Int {
|
|
|
42
|
-// return R.layout.fragment_home
|
|
|
43
|
-// }
|
|
|
44
|
-//}
|
|
|
45
|
-class HomeFragment : Fragment() {
|
|
|
46
|
- override fun onCreateView(
|
|
|
47
|
- inflater: LayoutInflater,
|
|
|
48
|
- container: ViewGroup?,
|
|
|
49
|
- savedInstanceState: Bundle?
|
|
|
50
|
- ): View? {
|
|
|
51
|
- return inflater.inflate(R.layout.fragment_home, container, false)
|
|
|
52
|
- }
|
|
|
53
|
-
|
|
|
54
|
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
55
|
- super.onViewCreated(view, savedInstanceState)
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
- val banner: Banner<Int, BannerImageAdapter<Int>> = view.findViewById(R.id.banner)
|
|
|
59
|
- banner.setAdapter(object : BannerImageAdapter<Int>(
|
|
|
60
|
- mutableListOf(
|
|
|
61
|
- R.mipmap.banner,
|
|
|
62
|
- R.mipmap.banner,
|
|
|
63
|
- R.mipmap.banner
|
|
|
64
|
- )
|
|
|
65
|
- ) {
|
|
|
66
|
- override fun onBindView(
|
|
|
67
|
- holder: BannerImageHolder,
|
|
|
68
|
- data: Int,
|
|
|
69
|
- position: Int,
|
|
|
70
|
- size: Int
|
|
|
71
|
- ) {
|
|
|
72
|
- Glide.with(requireActivity())
|
|
|
73
|
- .load(data)
|
|
|
74
|
- .apply(RequestOptions.bitmapTransform(RoundedCorners(8)))
|
|
|
75
|
- .into(holder.imageView)
|
|
|
76
|
-
|
|
|
77
|
- }
|
|
|
78
|
- }).addBannerLifecycleObserver(this)
|
|
|
79
|
- .indicator = CircleIndicator(requireContext())
|
|
|
80
|
-
|
|
|
81
|
- // 共享资料库
|
|
|
82
|
- view.findViewById<TextView>(R.id.database).setOnClickListener {
|
|
|
83
|
- startActivity(DatabaseActivity::class.java)
|
|
|
84
|
- }
|
|
|
85
|
-
|
|
|
86
|
- // 共享资料库
|
|
|
87
|
- view.findViewById<TextView>(R.id.txt_course).setOnClickListener {
|
|
|
88
|
- startActivity(TextCourseActivity::class.java)
|
|
|
89
|
- }
|
|
|
90
|
- // 在线课程
|
|
|
91
|
- view.findViewById<TextView>(R.id.online_course).setOnClickListener {
|
|
|
92
|
-// startActivity()
|
|
|
93
|
- }
|
|
|
94
|
-
|
|
|
95
|
- // 视频课程
|
|
|
96
|
- val videoCourse: RecyclerView = view.findViewById(R.id.video_course)
|
|
|
97
|
- videoCourse.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
|
|
98
|
- override fun getItemOffsets(
|
|
|
99
|
- outRect: Rect,
|
|
|
100
|
- view: View,
|
|
|
101
|
- parent: RecyclerView,
|
|
|
102
|
- state: RecyclerView.State
|
|
|
103
|
- ) {
|
|
|
104
|
- super.getItemOffsets(outRect, view, parent, state)
|
|
|
105
|
- if (parent.getChildAdapterPosition(view) % 2 == 0) {
|
|
|
106
|
- outRect.top = 24
|
|
|
107
|
- outRect.right = 15
|
|
|
108
|
- } else {
|
|
|
109
|
- outRect.top = 24
|
|
|
110
|
- outRect.left = 15
|
|
|
111
|
- }
|
|
|
112
|
- }
|
|
|
113
|
- })
|
|
|
114
|
- val videoCourseAdapter = VideoCourseAdapter()
|
|
|
115
|
- val list = mutableListOf(
|
|
|
116
|
- VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
117
|
- VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
118
|
- VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
119
|
- VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
120
|
- )
|
|
|
121
|
- videoCourse.adapter = videoCourseAdapter
|
|
|
122
|
- videoCourseAdapter.addList(list)
|
|
|
123
|
-
|
|
|
124
|
- val recommendData: RecyclerView = view.findViewById(R.id.recommended_data)
|
|
|
125
|
- val recommendDataAdapter = RecommendDataAdapter()
|
|
|
126
|
- val recommendList = mutableListOf(
|
|
|
127
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
128
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
129
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
130
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
131
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
132
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
133
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
134
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
135
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
136
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
137
|
- RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
138
|
- )
|
|
|
139
|
- recommendData.adapter = recommendDataAdapter
|
|
|
140
|
- recommendDataAdapter.addList(recommendList)
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
- view.findViewById<View>(R.id.search).setOnClickListener {
|
|
|
144
|
- val intent = Intent(requireActivity(), SearchActivity::class.java)
|
|
|
145
|
- startActivity(intent)
|
|
|
146
|
- }
|
|
|
147
|
- }
|
|
|
148
|
-
|
39
|
+class HomeFragment : BaseLifeCycleFragment<MineViewModel,FragmentHomeBinding>(FragmentHomeBinding::inflate) {
|
|
|
40
|
+ override fun initDataObserver() {
|
149
|
|
41
|
|
150
|
- private fun startActivity(cls: Class<out Activity>) {
|
|
|
151
|
- startActivity(cls, null)
|
|
|
152
|
}
|
42
|
}
|
153
|
|
43
|
|
154
|
- private fun startActivity(cls: Class<out Activity>, bundle: Bundle?) {
|
|
|
155
|
- val intent = Intent(requireActivity(), cls)
|
|
|
156
|
- if (bundle != null) {
|
|
|
157
|
- intent.putExtras(bundle)
|
|
|
158
|
- }
|
|
|
159
|
- startActivity(intent)
|
44
|
+ override fun getLayoutId(): Int {
|
|
|
45
|
+ return R.layout.fragment_home
|
160
|
}
|
46
|
}
|
161
|
-} |
|
|
|
|
47
|
+}
|
|
|
48
|
+//class HomeFragment : Fragment() {
|
|
|
49
|
+// override fun onCreateView(
|
|
|
50
|
+// inflater: LayoutInflater,
|
|
|
51
|
+// container: ViewGroup?,
|
|
|
52
|
+// savedInstanceState: Bundle?
|
|
|
53
|
+// ): View? {
|
|
|
54
|
+// return inflater.inflate(R.layout.fragment_home, container, false)
|
|
|
55
|
+// }
|
|
|
56
|
+//
|
|
|
57
|
+// override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
58
|
+// super.onViewCreated(view, savedInstanceState)
|
|
|
59
|
+//
|
|
|
60
|
+//
|
|
|
61
|
+// val banner: Banner<Int, BannerImageAdapter<Int>> = view.findViewById(R.id.banner)
|
|
|
62
|
+// banner.setAdapter(object : BannerImageAdapter<Int>(
|
|
|
63
|
+// mutableListOf(
|
|
|
64
|
+// R.mipmap.banner,
|
|
|
65
|
+// R.mipmap.banner,
|
|
|
66
|
+// R.mipmap.banner
|
|
|
67
|
+// )
|
|
|
68
|
+// ) {
|
|
|
69
|
+// override fun onBindView(
|
|
|
70
|
+// holder: BannerImageHolder,
|
|
|
71
|
+// data: Int,
|
|
|
72
|
+// position: Int,
|
|
|
73
|
+// size: Int
|
|
|
74
|
+// ) {
|
|
|
75
|
+// Glide.with(requireActivity())
|
|
|
76
|
+// .load(data)
|
|
|
77
|
+// .apply(RequestOptions.bitmapTransform(RoundedCorners(8)))
|
|
|
78
|
+// .into(holder.imageView)
|
|
|
79
|
+//
|
|
|
80
|
+// }
|
|
|
81
|
+// }).addBannerLifecycleObserver(this)
|
|
|
82
|
+// .indicator = CircleIndicator(requireContext())
|
|
|
83
|
+//
|
|
|
84
|
+// // 共享资料库
|
|
|
85
|
+// view.findViewById<TextView>(R.id.database).setOnClickListener {
|
|
|
86
|
+// startActivity(DatabaseActivity::class.java)
|
|
|
87
|
+// }
|
|
|
88
|
+//
|
|
|
89
|
+// // 共享资料库
|
|
|
90
|
+// view.findViewById<TextView>(R.id.txt_course).setOnClickListener {
|
|
|
91
|
+// startActivity(TextCourseActivity::class.java)
|
|
|
92
|
+// }
|
|
|
93
|
+// // 在线课程
|
|
|
94
|
+// view.findViewById<TextView>(R.id.online_course).setOnClickListener {
|
|
|
95
|
+//// startActivity()
|
|
|
96
|
+// }
|
|
|
97
|
+//
|
|
|
98
|
+// // 视频课程
|
|
|
99
|
+// val videoCourse: RecyclerView = view.findViewById(R.id.video_course)
|
|
|
100
|
+// videoCourse.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
|
|
101
|
+// override fun getItemOffsets(
|
|
|
102
|
+// outRect: Rect,
|
|
|
103
|
+// view: View,
|
|
|
104
|
+// parent: RecyclerView,
|
|
|
105
|
+// state: RecyclerView.State
|
|
|
106
|
+// ) {
|
|
|
107
|
+// super.getItemOffsets(outRect, view, parent, state)
|
|
|
108
|
+// if (parent.getChildAdapterPosition(view) % 2 == 0) {
|
|
|
109
|
+// outRect.top = 24
|
|
|
110
|
+// outRect.right = 15
|
|
|
111
|
+// } else {
|
|
|
112
|
+// outRect.top = 24
|
|
|
113
|
+// outRect.left = 15
|
|
|
114
|
+// }
|
|
|
115
|
+// }
|
|
|
116
|
+// })
|
|
|
117
|
+// val videoCourseAdapter = VideoCourseAdapter()
|
|
|
118
|
+// val list = mutableListOf(
|
|
|
119
|
+// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
120
|
+// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
121
|
+// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
122
|
+// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
123
|
+// )
|
|
|
124
|
+// videoCourse.adapter = videoCourseAdapter
|
|
|
125
|
+// videoCourseAdapter.addList(list)
|
|
|
126
|
+//
|
|
|
127
|
+// val recommendData: RecyclerView = view.findViewById(R.id.recommended_data)
|
|
|
128
|
+// val recommendDataAdapter = RecommendDataAdapter()
|
|
|
129
|
+// val recommendList = mutableListOf(
|
|
|
130
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
131
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
132
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
133
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
134
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
135
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
136
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
137
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
138
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
139
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
140
|
+// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
141
|
+// )
|
|
|
142
|
+// recommendData.adapter = recommendDataAdapter
|
|
|
143
|
+// recommendDataAdapter.addList(recommendList)
|
|
|
144
|
+//
|
|
|
145
|
+//
|
|
|
146
|
+// view.findViewById<View>(R.id.search).setOnClickListener {
|
|
|
147
|
+// val intent = Intent(requireActivity(), SearchActivity::class.java)
|
|
|
148
|
+// startActivity(intent)
|
|
|
149
|
+// }
|
|
|
150
|
+// }
|
|
|
151
|
+//
|
|
|
152
|
+//
|
|
|
153
|
+// private fun startActivity(cls: Class<out Activity>) {
|
|
|
154
|
+// startActivity(cls, null)
|
|
|
155
|
+// }
|
|
|
156
|
+//
|
|
|
157
|
+// private fun startActivity(cls: Class<out Activity>, bundle: Bundle?) {
|
|
|
158
|
+// val intent = Intent(requireActivity(), cls)
|
|
|
159
|
+// if (bundle != null) {
|
|
|
160
|
+// intent.putExtras(bundle)
|
|
|
161
|
+// }
|
|
|
162
|
+// startActivity(intent)
|
|
|
163
|
+// }
|
|
|
164
|
+//} |