...
|
...
|
@@ -11,6 +11,7 @@ import android.widget.TextView |
|
|
import androidx.fragment.app.Fragment
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.br_technology.securitytrain_master.R
|
|
|
import com.br_technology.securitytrain_master.databinding.FragmentHomeBinding
|
|
|
import com.br_technology.securitytrain_master.ui.home.activity.DatabaseActivity
|
|
|
import com.br_technology.securitytrain_master.ui.home.activity.SearchActivity
|
|
|
import com.br_technology.securitytrain_master.ui.home.activity.TextCourseActivity
|
...
|
...
|
@@ -18,9 +19,11 @@ import com.br_technology.securitytrain_master.ui.home.adapter.RecommendDataAdapt |
|
|
import com.br_technology.securitytrain_master.ui.home.adapter.VideoCourseAdapter
|
|
|
import com.br_technology.securitytrain_master.ui.home.pojo.RecommendData
|
|
|
import com.br_technology.securitytrain_master.ui.home.pojo.VideoCourse
|
|
|
import com.br_technology.securitytrain_master.ui.home.viewmodel.MineViewModel
|
|
|
import com.bumptech.glide.Glide
|
|
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
|
|
import com.bumptech.glide.request.RequestOptions
|
|
|
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
|
|
|
import com.youth.banner.Banner
|
|
|
import com.youth.banner.adapter.BannerAdapter
|
|
|
import com.youth.banner.adapter.BannerImageAdapter
|
...
|
...
|
@@ -33,129 +36,129 @@ import com.youth.banner.indicator.CircleIndicator |
|
|
* auth:张继
|
|
|
* des:
|
|
|
*/
|
|
|
//class HomeFragment :BaseLifeCycleFragment<MineViewModel>() {
|
|
|
// override fun initDataObserver() {
|
|
|
//
|
|
|
// }
|
|
|
//
|
|
|
// override fun getLayoutId(): Int {
|
|
|
// return R.layout.fragment_home
|
|
|
// }
|
|
|
//}
|
|
|
class HomeFragment : Fragment() {
|
|
|
override fun onCreateView(
|
|
|
inflater: LayoutInflater,
|
|
|
container: ViewGroup?,
|
|
|
savedInstanceState: Bundle?
|
|
|
): View? {
|
|
|
return inflater.inflate(R.layout.fragment_home, container, false)
|
|
|
}
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
|
|
|
val banner: Banner<Int, BannerImageAdapter<Int>> = view.findViewById(R.id.banner)
|
|
|
banner.setAdapter(object : BannerImageAdapter<Int>(
|
|
|
mutableListOf(
|
|
|
R.mipmap.banner,
|
|
|
R.mipmap.banner,
|
|
|
R.mipmap.banner
|
|
|
)
|
|
|
) {
|
|
|
override fun onBindView(
|
|
|
holder: BannerImageHolder,
|
|
|
data: Int,
|
|
|
position: Int,
|
|
|
size: Int
|
|
|
) {
|
|
|
Glide.with(requireActivity())
|
|
|
.load(data)
|
|
|
.apply(RequestOptions.bitmapTransform(RoundedCorners(8)))
|
|
|
.into(holder.imageView)
|
|
|
|
|
|
}
|
|
|
}).addBannerLifecycleObserver(this)
|
|
|
.indicator = CircleIndicator(requireContext())
|
|
|
|
|
|
// 共享资料库
|
|
|
view.findViewById<TextView>(R.id.database).setOnClickListener {
|
|
|
startActivity(DatabaseActivity::class.java)
|
|
|
}
|
|
|
|
|
|
// 共享资料库
|
|
|
view.findViewById<TextView>(R.id.txt_course).setOnClickListener {
|
|
|
startActivity(TextCourseActivity::class.java)
|
|
|
}
|
|
|
// 在线课程
|
|
|
view.findViewById<TextView>(R.id.online_course).setOnClickListener {
|
|
|
// startActivity()
|
|
|
}
|
|
|
|
|
|
// 视频课程
|
|
|
val videoCourse: RecyclerView = view.findViewById(R.id.video_course)
|
|
|
videoCourse.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
|
|
override fun getItemOffsets(
|
|
|
outRect: Rect,
|
|
|
view: View,
|
|
|
parent: RecyclerView,
|
|
|
state: RecyclerView.State
|
|
|
) {
|
|
|
super.getItemOffsets(outRect, view, parent, state)
|
|
|
if (parent.getChildAdapterPosition(view) % 2 == 0) {
|
|
|
outRect.top = 24
|
|
|
outRect.right = 15
|
|
|
} else {
|
|
|
outRect.top = 24
|
|
|
outRect.left = 15
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
val videoCourseAdapter = VideoCourseAdapter()
|
|
|
val list = mutableListOf(
|
|
|
VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
)
|
|
|
videoCourse.adapter = videoCourseAdapter
|
|
|
videoCourseAdapter.addList(list)
|
|
|
|
|
|
val recommendData: RecyclerView = view.findViewById(R.id.recommended_data)
|
|
|
val recommendDataAdapter = RecommendDataAdapter()
|
|
|
val recommendList = mutableListOf(
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
)
|
|
|
recommendData.adapter = recommendDataAdapter
|
|
|
recommendDataAdapter.addList(recommendList)
|
|
|
|
|
|
|
|
|
view.findViewById<View>(R.id.search).setOnClickListener {
|
|
|
val intent = Intent(requireActivity(), SearchActivity::class.java)
|
|
|
startActivity(intent)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
class HomeFragment : BaseLifeCycleFragment<MineViewModel,FragmentHomeBinding>(FragmentHomeBinding::inflate) {
|
|
|
override fun initDataObserver() {
|
|
|
|
|
|
private fun startActivity(cls: Class<out Activity>) {
|
|
|
startActivity(cls, null)
|
|
|
}
|
|
|
|
|
|
private fun startActivity(cls: Class<out Activity>, bundle: Bundle?) {
|
|
|
val intent = Intent(requireActivity(), cls)
|
|
|
if (bundle != null) {
|
|
|
intent.putExtras(bundle)
|
|
|
}
|
|
|
startActivity(intent)
|
|
|
override fun getLayoutId(): Int {
|
|
|
return R.layout.fragment_home
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
|
|
}
|
|
|
//class HomeFragment : Fragment() {
|
|
|
// override fun onCreateView(
|
|
|
// inflater: LayoutInflater,
|
|
|
// container: ViewGroup?,
|
|
|
// savedInstanceState: Bundle?
|
|
|
// ): View? {
|
|
|
// return inflater.inflate(R.layout.fragment_home, container, false)
|
|
|
// }
|
|
|
//
|
|
|
// override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
// super.onViewCreated(view, savedInstanceState)
|
|
|
//
|
|
|
//
|
|
|
// val banner: Banner<Int, BannerImageAdapter<Int>> = view.findViewById(R.id.banner)
|
|
|
// banner.setAdapter(object : BannerImageAdapter<Int>(
|
|
|
// mutableListOf(
|
|
|
// R.mipmap.banner,
|
|
|
// R.mipmap.banner,
|
|
|
// R.mipmap.banner
|
|
|
// )
|
|
|
// ) {
|
|
|
// override fun onBindView(
|
|
|
// holder: BannerImageHolder,
|
|
|
// data: Int,
|
|
|
// position: Int,
|
|
|
// size: Int
|
|
|
// ) {
|
|
|
// Glide.with(requireActivity())
|
|
|
// .load(data)
|
|
|
// .apply(RequestOptions.bitmapTransform(RoundedCorners(8)))
|
|
|
// .into(holder.imageView)
|
|
|
//
|
|
|
// }
|
|
|
// }).addBannerLifecycleObserver(this)
|
|
|
// .indicator = CircleIndicator(requireContext())
|
|
|
//
|
|
|
// // 共享资料库
|
|
|
// view.findViewById<TextView>(R.id.database).setOnClickListener {
|
|
|
// startActivity(DatabaseActivity::class.java)
|
|
|
// }
|
|
|
//
|
|
|
// // 共享资料库
|
|
|
// view.findViewById<TextView>(R.id.txt_course).setOnClickListener {
|
|
|
// startActivity(TextCourseActivity::class.java)
|
|
|
// }
|
|
|
// // 在线课程
|
|
|
// view.findViewById<TextView>(R.id.online_course).setOnClickListener {
|
|
|
//// startActivity()
|
|
|
// }
|
|
|
//
|
|
|
// // 视频课程
|
|
|
// val videoCourse: RecyclerView = view.findViewById(R.id.video_course)
|
|
|
// videoCourse.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
|
|
// override fun getItemOffsets(
|
|
|
// outRect: Rect,
|
|
|
// view: View,
|
|
|
// parent: RecyclerView,
|
|
|
// state: RecyclerView.State
|
|
|
// ) {
|
|
|
// super.getItemOffsets(outRect, view, parent, state)
|
|
|
// if (parent.getChildAdapterPosition(view) % 2 == 0) {
|
|
|
// outRect.top = 24
|
|
|
// outRect.right = 15
|
|
|
// } else {
|
|
|
// outRect.top = 24
|
|
|
// outRect.left = 15
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
// val videoCourseAdapter = VideoCourseAdapter()
|
|
|
// val list = mutableListOf(
|
|
|
// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
// VideoCourse(R.mipmap.banner, "10课时", "自动化制作课程", "", "张钧-三岗职位培训班"),
|
|
|
// )
|
|
|
// videoCourse.adapter = videoCourseAdapter
|
|
|
// videoCourseAdapter.addList(list)
|
|
|
//
|
|
|
// val recommendData: RecyclerView = view.findViewById(R.id.recommended_data)
|
|
|
// val recommendDataAdapter = RecommendDataAdapter()
|
|
|
// val recommendList = mutableListOf(
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// RecommendData(R.mipmap.banner, "思维导图高分作文法(高中)议论", "从这个角度看,康得在不经意间这样说过,既然我已踏上了这条道路,那么"),
|
|
|
// )
|
|
|
// recommendData.adapter = recommendDataAdapter
|
|
|
// recommendDataAdapter.addList(recommendList)
|
|
|
//
|
|
|
//
|
|
|
// view.findViewById<View>(R.id.search).setOnClickListener {
|
|
|
// val intent = Intent(requireActivity(), SearchActivity::class.java)
|
|
|
// startActivity(intent)
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// private fun startActivity(cls: Class<out Activity>) {
|
|
|
// startActivity(cls, null)
|
|
|
// }
|
|
|
//
|
|
|
// private fun startActivity(cls: Class<out Activity>, bundle: Bundle?) {
|
|
|
// val intent = Intent(requireActivity(), cls)
|
|
|
// if (bundle != null) {
|
|
|
// intent.putExtras(bundle)
|
|
|
// }
|
|
|
// startActivity(intent)
|
|
|
// }
|
|
|
//} |
|
|
\ No newline at end of file |
...
|
...
|
|