Commit 494c548a authored by 张释方's avatar 张释方

解决冲突

parent 9b237c3a
package com.mints.street.adapter
import android.content.Context
import android.graphics.Point
import android.util.DisplayMetrics
import android.view.Display
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.utils.ImageLoader
import com.mints.street.R
import com.mints.street.bean.VrmapBean
import com.mints.street.databinding.ItemEnterDestinationAdapterBinding
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
/**
* Created by 冯瑞雨 on 2021/7/9.
* @param isMultipleLayout 是否是多布局
*/
class ItemEnterDestinationAdapter(val context: Context,val isMultipleLayout:Boolean)
:AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding,Any>(context,null,1) {
class ItemEnterDestinationAdapter(
val context: Context,
private val isMultipleLayout: Boolean,
val list: List<VrmapBean.Abroad>?
) : AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding, List<VrmapBean.Abroad>?>(
context,
list,
1
) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemEnterDestinationAdapterBinding>,
position: Int
) {
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
if(isMultipleLayout){
bgLayoutParams.width = (a.widthPixels*0.9).toInt()
}else{
if (isMultipleLayout) {
bgLayoutParams.width = (a.widthPixels * 0.9).toInt()
} else {
bgLayoutParams.width = a.widthPixels
}
list?.let { it ->
holder.binding.tvName.text = it[position].name
holder.binding.tvNumberPeople.text = "人数"
it[position].img?.let { url ->
for (index in it.indices) {
when (index) {
0 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(url[index]).setTargetView(holder.binding.image1).start()
}
1 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(url[index]).setTargetView(holder.binding.image2).start()
}
2 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(url[index]).setTargetView(holder.binding.image3).start()
override fun getItemCount() = 2
}
}
}
}
}
}
override fun getItemCount() = list?.size ?: 0
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_enter_destination_adapter
}
......@@ -22,6 +22,7 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
private var gridMapAdapter: GridMapAdapter? = null
private var enterDestinationAdapter: EnterDestinationAdapter? = null
override fun initContentView(
inflater: LayoutInflater?,
container: ViewGroup?,
......@@ -48,13 +49,17 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel
binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter
mAdapter?.addAdapter(EnterDestinationAdapter(context!! ))
}
override fun initViewObservable() {
super.initViewObservable()
viewModel.VrmapBean.observe(this, Observer<VrmapBean> {
if(enterDestinationAdapter == null){
enterDestinationAdapter = EnterDestinationAdapter(context!!,it.abroad )
mAdapter?.addAdapter(enterDestinationAdapter)
}
if (gridMapAdapter == null){
gridMapAdapter = GridMapAdapter(context!!, it.internal)
mAdapter?.addAdapter(gridMapAdapter)
......
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