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

热门景点对接后端数据

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