Commit d3618d3f authored by 张释方's avatar 张释方

完成热门景点功能1

parent f6e839cc
package com.mints.street.adapter
import android.content.Context
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.street.R
import com.mints.street.databinding.ItemHotViewAdapterBinding
class ItemHotViewAdapter(val context: Context, var list: List<String>?) :
AbstractVLayoutBaseAdapter<ItemHotViewAdapterBinding, List<String>?>(
context,list,1
) {
override fun onBindViewHolder(holder: BindingViewHolder<ItemHotViewAdapterBinding>, position: Int) {
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
bgLayoutParams.width = a.widthPixels
holder.itemView.setOnClickListener {
}
}
override fun getItemCount() = list?.size?: 0
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_hot_view_adapter
}
\ No newline at end of file
package com.mints.street.bean
class HotViewBean {
}
\ No newline at end of file
package com.mints.street.widget.dialog
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.mints.street.R
import com.mints.street.adapter.ItemEnterDestinationAdapter
import com.mints.street.adapter.ItemHotViewAdapter
import com.mints.street.bean.VreperienceBean
import com.mints.street.main.home.HomeFragment
import com.mints.street.main.home.HomeViewModel
class HotViewDialog(context: FragmentActivity, viewModel: HomeViewModel, homeFragment: HomeFragment) {
private var mBottomSheetDialog:BottomSheetDialog?=null
private var context:FragmentActivity
private var viewModel:HomeViewModel?=null
private var homeFragment:HomeFragment?=null
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
private var itemHotViewAdapter: ItemHotViewAdapter?=null
// private var itemHotViewAdapter: ItemEnterDestinationAdapter?=null
init {
this.context=context
this.viewModel=viewModel
this.homeFragment=homeFragment
}
//
fun init():HotViewDialog{
//创建弹窗
if (mBottomSheetDialog!=null) return this
mBottomSheetDialog= BottomSheetDialog(context)
val view1:View=LayoutInflater.from(context).inflate(R.layout.layout_hotview,null)
mBottomSheetDialog!!.setContentView(view1)
mBottomSheetDialog!!.window!!.findViewById<View>(R.id.design_bottom_sheet).setBackgroundColor(Color.TRANSPARENT)
val iv_close:ImageView=view1.findViewById(R.id.iv_close)
val recycler_view:RecyclerView=view1.findViewById(R.id.recycler_view)
vLayout = VirtualLayoutManager(context!!);
mAdapter = DelegateAdapter(vLayout,false)
recycler_view.layoutManager = vLayout
recycler_view.adapter = mAdapter
if (itemHotViewAdapter == null){
itemHotViewAdapter = ItemHotViewAdapter(context!!, listOf("1","3","1","3","1","3","1","3"))
mAdapter?.addAdapter(itemHotViewAdapter)
}
itemHotViewAdapter!!.list=listOf("1","3","1","3","1","3","1","3")
// viewModel?.getChooseExperienceHeadData()
// viewModel?.VreperienceBean?.observe(homeFragment!!, androidx.lifecycle.Observer {
// if (itemHotViewAdapter == null){
// itemHotViewAdapter = ItemEnterDestinationAdapter(context!!, false,it?.data)
// mAdapter?.addAdapter(itemHotViewAdapter)
// }
// itemHotViewAdapter?.list = it?.data!!
// mAdapter?.notifyDataSetChanged()
// })
iv_close.setOnClickListener{
mBottomSheetDialog!!.dismiss()
}
return this
}
/**
* 展示
*/
fun show() {
mBottomSheetDialog?.show()
}
fun onDestroy() {
mBottomSheetDialog = null
}
}
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.ItemHotViewAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bg"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:padding="10dp">
<com.mints.street.widget.XCRoundRectImageView
android:id="@+id/image1"
android:layout_width="100dp"
android:layout_height="70dp"
android:src="@mipmap/icon_card6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:src="@mipmap/icon_card6" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="景点名称"
android:textColor="@color/black"
android:textSize="18dp"
app:layout_constraintStart_toEndOf="@+id/image1"
app:layout_constraintTop_toTopOf="@+id/image1" />
<View
android:id="@+id/view"
android:layout_width="1dp"
android:layout_height="14dp"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="@+id/textView3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="@+id/textView3"
tools:ignore="MissingConstraints" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="距离"
android:layout_marginLeft="2dp"
android:textSize="14dp"
tools:text="距离"
android:textColor="#99000000"
app:layout_constraintStart_toEndOf="@+id/view"
app:layout_constraintTop_toTopOf="@+id/textView2" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="景点介绍。。。"
tools:text="景点介绍。。。"
android:textColor="#99000000"
app:layout_constraintStart_toEndOf="@+id/image1"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
<TextView
android:background="@drawable/shape_btn_friends_unenabled"
tools:text="看街景"
android:id="@+id/textView5"
android:layout_width="70dp"d
android:gravity="center"
android:layout_height="20dp"
android:textSize="12sp"
android:textColor="@color/black"
android:text="看街景"
app:layout_constraintBottom_toBottomOf="@+id/image1"
app:layout_constraintStart_toEndOf="@+id/image1" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment