Commit 59409d26 authored by 张释方's avatar 张释方

热门景点对接后端数据

parent 8797c2a5
package com.mints.street.adapter
import android.content.Context
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.blankj.utilcode.util.ActivityUtils.startActivity
import com.bumptech.glide.Glide
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.street.R
import com.mints.street.bean.HotViewBean
import com.mints.street.databinding.ItemHotViewAdapterBinding
import com.mints.street.main.my.OpenvipActivity
import com.mints.street.manager.UserManager
import com.mints.street.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.utils.RxUtils
class ItemHotViewAdapter(val context: Context, var list: List<String>?) :
AbstractVLayoutBaseAdapter<ItemHotViewAdapterBinding, List<String>?>(
class ItemHotViewAdapter(val context: Context, var list: List<HotViewBean.dataslist>?) :
AbstractVLayoutBaseAdapter<ItemHotViewAdapterBinding, List<HotViewBean.dataslist>?>(
context,list,1
) {
override fun onBindViewHolder(holder: BindingViewHolder<ItemHotViewAdapterBinding>, position: Int) {
......@@ -22,6 +23,16 @@ class ItemHotViewAdapter(val context: Context, var list: List<String>?) :
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
bgLayoutParams.width = a.widthPixels
list?.get(position)?.apply {
//设置图片
Glide.with(mContext).load(img).into(holder.binding.image1)
//设置名称
holder.binding.viewname.text=name
//设置距离
holder.binding.tvDistance.text= distance.toString()
//设置景点简介
holder.binding.tvDescribe.text=desc
//设置点击事件
RxUtils.onMultiClick(holder.itemView){
//判断是否当前是否是会员,
if (!UserManager.INSTANCE.userIsLogin()){
......@@ -31,6 +42,8 @@ class ItemHotViewAdapter(val context: Context, var list: List<String>?) :
//是-继续浏览,
}
}
}
}
override fun getItemCount() = list?.size?: 0
......
......@@ -142,6 +142,6 @@ interface MainApi {
/**
* 热门景点
*/
@POST("xx/xxx")
fun getHotView(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<HotViewBean>>>
@POST("na/getAttractionsList")
fun getHotView():Observable<Response<BaseResponse<HotViewBean>>>
}
\ No newline at end of file
package com.mints.street.bean
class HotViewBean {
import java.io.Serializable
class HotViewBean : Serializable {
val list: List<dataslist>? = null
inner class dataslist : Serializable {
//景点简介
val desc: String? = null
//距离
val distance: Double? = null
val id: String? = null
val img: String? = null
val lat: String? = null
val lng: String? = null
val name: String? = null
}
}
......@@ -188,9 +188,7 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
*/
var hotviewData=MutableLiveData<HotViewBean>()
fun getHotView() {
val vo = java.util.HashMap<String, Any>()
vo["status"] = 1
ApiModel.getHotView(lifecycleProvider,vo).safeSubscribe(
ApiModel.getHotView(lifecycleProvider).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<HotViewBean>>(
this@HomeViewModel, true) {
......
......@@ -73,7 +73,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
bt_try.setOnClickListener(this)
ly_payfirst.setOnClickListener(this)
ly_paysecond.setOnClickListener(this)
loginDialog.setListener(object : WxLoginDialog.WxLoginListener {
override fun loginSuc(wxInfo: String) {
viewModel.wechatlogin(wxInfo)
......@@ -158,7 +157,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
binding.listview.adapter = mAdapter
binding.listview.layoutManager = vLayout
}
//添加page点击
......@@ -215,13 +213,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
tv_ly_paysecond.setText("微信支付")
ly_paysecond.visibility = View.VISIBLE
}
/*if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "WEIXIN"
}
ly_payfirst.visibility = View.VISIBLE
if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "WEIXIN"
}*/
}
if (str.equals("ALIPAY")) {
//第一个位置是否展示
......@@ -235,13 +226,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
tv_ly_paysecond.setText("支付宝支付")
ly_paysecond.visibility = View.VISIBLE
}
/*if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "ALIPAY"
}
ly_second.visibility = View.VISIBLE
if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "ALIPAY"
}*/
}
//设置 默认支付方式 (根据返回参数的第一个值)
setOnChecked(1, tv_ly_payfirst.text)
......
......@@ -148,7 +148,7 @@ object ApiModel {
}
fun getHotView(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>):Observable<Response<BaseResponse<HotViewBean>>>{
return HttpManager.getInstance().execute(lifecycleProvider,MainApi.newInstance().getHotView(map))
fun getHotView(lifecycleProvider: LifecycleProvider<Any>?):Observable<Response<BaseResponse<HotViewBean>>>{
return HttpManager.getInstance().execute(lifecycleProvider,MainApi.newInstance().getHotView())
}
}
\ No newline at end of file
......@@ -11,9 +11,7 @@ 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
import com.mints.street.widget.GridItemDecoration
......@@ -54,20 +52,21 @@ class HotViewDialog(context: FragmentActivity, viewModel: HomeViewModel, homeFra
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)
// itemHotViewAdapter = ItemHotViewAdapter(context!!, listOf("1","3","1","3","1","3","1","3"))
// mAdapter?.addAdapter(itemHotViewAdapter)
// }
// itemHotViewAdapter?.list = it?.data!!
// mAdapter?.notifyDataSetChanged()
// })
// itemHotViewAdapter!!.list=listOf("1","3","1","3","1","3","1","3")
viewModel?.getHotView()
viewModel?.hotviewData?.observe(homeFragment!!, androidx.lifecycle.Observer {
if (itemHotViewAdapter == null){
// itemHotViewAdapter = ItemEnterDestinationAdapter(context!!, false,it?.data)
itemHotViewAdapter = ItemHotViewAdapter(context!!, it.list)
mAdapter?.addAdapter(itemHotViewAdapter)
}
itemHotViewAdapter?.list = it?.list!!
mAdapter?.notifyDataSetChanged()
})
iv_close.setOnClickListener{
mBottomSheetDialog!!.dismiss()
}
......
......@@ -39,7 +39,7 @@
app:layout_constraintGuide_percent="0.4" />
<TextView
android:id="@+id/textView2"
android:id="@+id/viewname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
......@@ -54,14 +54,14 @@
android:layout_width="1dp"
android:layout_height="14dp"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="@+id/textView3"
app:layout_constraintBottom_toBottomOf="@+id/tv_distance"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="@+id/textView3"
app:layout_constraintStart_toEndOf="@+id/viewname"
app:layout_constraintTop_toTopOf="@+id/tv_distance"
tools:ignore="MissingConstraints" />
<TextView
android:id="@+id/textView3"
android:id="@+id/tv_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
......@@ -69,18 +69,18 @@
android:textColor="#99000000"
android:textSize="14dp"
app:layout_constraintStart_toEndOf="@+id/view"
app:layout_constraintTop_toTopOf="@+id/textView2"
app:layout_constraintTop_toTopOf="@+id/viewname"
tools:text="距离" />
<TextView
android:id="@+id/textView4"
android:id="@+id/tv_describe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="景点介绍。。。"
android:textColor="#99000000"
app:layout_constraintStart_toEndOf="@+id/image1"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/viewname"
tools:text="景点介绍。。。" />
<TextView
......
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