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

解决冲突

parent 9b237c3a
...@@ -23,15 +23,15 @@ import me.tatarka.bindingcollectionadapter2.ItemBinding ...@@ -23,15 +23,15 @@ import me.tatarka.bindingcollectionadapter2.ItemBinding
* Created by 冯瑞雨 on 2021/7/9. * Created by 冯瑞雨 on 2021/7/9.
*/ */
class EnterDestinationAdapter(val context: Context,val bean :List<VrmapBean.Abroad>?): class EnterDestinationAdapter(val context: Context,val bean :List<VrmapBean.Abroad>?):
AbstractVLayoutBaseAdapter<EnterDestinationAdapterBinding, List<VrmapBean.Abroad>?>(context,bean,1) { AbstractVLayoutBaseAdapter<EnterDestinationAdapterBinding, List<VrmapBean.Abroad>?>(context,bean,1) {
private var vLayout: VirtualLayoutManager? = null private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null private var mAdapter: DelegateAdapter? = null
override fun onBindViewHolder( override fun onBindViewHolder(
holder: BindingViewHolder<EnterDestinationAdapterBinding>, holder: BindingViewHolder<EnterDestinationAdapterBinding>,
position: Int) { position: Int) {
vLayout = VirtualLayoutManager(context, VirtualLayoutManager.HORIZONTAL) vLayout = VirtualLayoutManager(context, VirtualLayoutManager.HORIZONTAL)
mAdapter = DelegateAdapter(vLayout,false) mAdapter = DelegateAdapter(vLayout,false)
......
package com.mints.street.adapter package com.mints.street.adapter
import android.content.Context 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.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder import com.fry.base.adapter.BindingViewHolder
import com.fry.base.utils.ImageLoader
import com.mints.street.R import com.mints.street.R
import com.mints.street.bean.VrmapBean
import com.mints.street.databinding.ItemEnterDestinationAdapterBinding import com.mints.street.databinding.ItemEnterDestinationAdapterBinding
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
/** /**
* Created by 冯瑞雨 on 2021/7/9. * Created by 冯瑞雨 on 2021/7/9.
* @param isMultipleLayout 是否是多布局 * @param isMultipleLayout 是否是多布局
*/ */
class ItemEnterDestinationAdapter(val context: Context,val isMultipleLayout:Boolean) class ItemEnterDestinationAdapter(
:AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding,Any>(context,null,1) { val context: Context,
private val isMultipleLayout: Boolean,
val list: List<VrmapBean.Abroad>?
) : AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding, List<VrmapBean.Abroad>?>(
context,
list,
1
) {
override fun onBindViewHolder( override fun onBindViewHolder(
holder: BindingViewHolder<ItemEnterDestinationAdapterBinding>, holder: BindingViewHolder<ItemEnterDestinationAdapterBinding>,
position: Int position: Int
) { ) {
var a = context.resources.displayMetrics; var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams val bgLayoutParams = holder.binding.bg.layoutParams
if(isMultipleLayout){ if (isMultipleLayout) {
bgLayoutParams.width = (a.widthPixels*0.9).toInt() bgLayoutParams.width = (a.widthPixels * 0.9).toInt()
}else{ } else {
bgLayoutParams.width = a.widthPixels 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 onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_enter_destination_adapter override fun getLayoutId(viewType: Int) = R.layout.item_enter_destination_adapter
} }
...@@ -22,6 +22,7 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel ...@@ -22,6 +22,7 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel
private var vLayout: VirtualLayoutManager? = null private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null private var mAdapter: DelegateAdapter? = null
private var gridMapAdapter: GridMapAdapter? = null private var gridMapAdapter: GridMapAdapter? = null
private var enterDestinationAdapter: EnterDestinationAdapter? = null
override fun initContentView( override fun initContentView(
inflater: LayoutInflater?, inflater: LayoutInflater?,
container: ViewGroup?, container: ViewGroup?,
...@@ -48,13 +49,17 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel ...@@ -48,13 +49,17 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel
binding.listView.layoutManager = vLayout binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter binding.listView.adapter = mAdapter
mAdapter?.addAdapter(EnterDestinationAdapter(context!! ))
} }
override fun initViewObservable() { override fun initViewObservable() {
super.initViewObservable() super.initViewObservable()
viewModel.VrmapBean.observe(this, Observer<VrmapBean> { viewModel.VrmapBean.observe(this, Observer<VrmapBean> {
if(enterDestinationAdapter == null){
enterDestinationAdapter = EnterDestinationAdapter(context!!,it.abroad )
mAdapter?.addAdapter(enterDestinationAdapter)
}
if (gridMapAdapter == null){ if (gridMapAdapter == null){
gridMapAdapter = GridMapAdapter(context!!, it.internal) gridMapAdapter = GridMapAdapter(context!!, it.internal)
mAdapter?.addAdapter(gridMapAdapter) 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