|
@@ -1,76 +0,0 @@
|
|
|
-package com.develop.main.adapter
|
|
|
-
|
|
|
-import android.content.Context
|
|
|
-import android.os.Bundle
|
|
|
-import android.view.LayoutInflater
|
|
|
-import android.view.View
|
|
|
-import android.view.ViewGroup
|
|
|
-import android.widget.ImageView
|
|
|
-import android.widget.RelativeLayout
|
|
|
-import androidx.recyclerview.widget.RecyclerView
|
|
|
-import coil.load
|
|
|
-import coil.transform.RoundedCornersTransformation
|
|
|
-import com.develop.base.ext.globalApp
|
|
|
-import com.develop.base.ext.navigateTo
|
|
|
-import com.develop.base.ext.resId2Dimension
|
|
|
-import com.develop.common.data_repo.db.HomeBannerModel
|
|
|
-import com.develop.common.router.Screens
|
|
|
-import com.develop.common.tag.Downloaded
|
|
|
-import com.develop.common.tag.FOOD_LIST_TYPE
|
|
|
-import com.develop.common.tag.FOOL_LIST_TITLE
|
|
|
-import com.develop.main.R
|
|
|
-import com.develop.main.ui.HomeActivity
|
|
|
-
|
|
|
-import com.youth.banner.adapter.BannerAdapter
|
|
|
-
|
|
|
-class HomeBannerAdapter(var bannerDataList: MutableList<HomeBannerModel>) :
|
|
|
- BannerAdapter<HomeBannerModel, HomeBannerAdapter.ViewHolder>(bannerDataList) {
|
|
|
-
|
|
|
-
|
|
|
- private lateinit var context: Context
|
|
|
-
|
|
|
-
|
|
|
- var onBannerItemClickListener: OnBannerItemClickListener? = null
|
|
|
-
|
|
|
- class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
|
- var ivBanner: ImageView = itemView.findViewById(R.id.iv_banner)
|
|
|
- val netRecipesLayout: RelativeLayout = itemView.findViewById(R.id.net_recipes_layout)
|
|
|
- var downloadLayout: RelativeLayout = itemView.findViewById(R.id.download_layout)
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- override fun onCreateHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
|
|
- context = parent.context
|
|
|
- return ViewHolder(
|
|
|
- LayoutInflater.from(context).inflate(R.layout.item_home_banner, parent, false)
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- override fun onBindView(holder: ViewHolder, data: HomeBannerModel, position: Int, size: Int) {
|
|
|
- holder.ivBanner.load(data.cover){
|
|
|
- transformations(RoundedCornersTransformation(dp30,dp30,dp30,dp30))
|
|
|
- }
|
|
|
- holder.downloadLayout.setOnClickListener {
|
|
|
- (context as HomeActivity).navigateTo(Screens.Cook.FOOD_LIST) {
|
|
|
- val bundle = Bundle()
|
|
|
- bundle.putString(
|
|
|
- FOOL_LIST_TITLE,
|
|
|
- globalApp().getString(com.develop.common.R.string.download)
|
|
|
- )
|
|
|
- bundle.putInt(FOOD_LIST_TYPE, Downloaded)
|
|
|
- with(bundle)
|
|
|
- }
|
|
|
- }
|
|
|
- holder.netRecipesLayout.setOnClickListener {
|
|
|
- onBannerItemClickListener?.onNetRecipesClick(data)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- interface OnBannerItemClickListener {
|
|
|
- fun onNetRecipesClick(bannerModel: HomeBannerModel)
|
|
|
- }
|
|
|
-
|
|
|
- companion object {
|
|
|
- var dp30 = (com.develop.base.R.dimen.convert_30px).resId2Dimension()
|
|
|
- }
|
|
|
-}
|