Commit 133881c9 authored by 张释方's avatar 张释方

添加景点推荐弹窗、景点推荐接口

parent 59409d26
......@@ -29,7 +29,7 @@ class ItemHotViewAdapter(val context: Context, var list: List<HotViewBean.datasl
//设置名称
holder.binding.viewname.text=name
//设置距离
holder.binding.tvDistance.text= distance.toString()
// holder.binding.tvDistance.text= distance.toString()
//设置景点简介
holder.binding.tvDescribe.text=desc
//设置点击事件
......
......@@ -143,5 +143,11 @@ interface MainApi {
* 热门景点
*/
@POST("na/getAttractionsList")
fun getHotView():Observable<Response<BaseResponse<HotViewBean>>>
fun getHotView(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<HotViewBean>>>
/**
* 景点推荐
*/
@POST("na/getAttractionsList")
fun getViewRecommed(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<ViewRecommed>>>
}
\ No newline at end of file
......@@ -3,16 +3,10 @@ package com.mints.street.bean
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
......
package com.mints.street.bean
import java.io.Serializable
class ViewRecommed : Serializable {
val list: List<dataslist>? = null
inner class dataslist : Serializable {
val desc: String? = null
val img: String? = null
val lat: String? = null
val lng: String? = null
val name: String? = null
}
}
......@@ -31,6 +31,7 @@ import com.mints.street.widget.ScrollLayout
import com.mints.street.widget.dialog.DialogUtils
import com.mints.street.widget.dialog.DialogUtils.showupgradevipDialog
import com.mints.street.widget.dialog.HotViewDialog
import com.mints.street.widget.dialog.ViewRecommedDialog
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.RxUtils
......@@ -43,7 +44,7 @@ import me.goldze.mvvmhabit.utils.ToastUtils
*/
class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener {
private val hotViewDialog by lazy { HotViewDialog(requireActivity(),viewModel,this).init() }
private val viewrecommedDialog by lazy { ViewRecommedDialog(requireActivity(),viewModel,this).init() }
companion object {
val IS_FIRST_OPEN: String = "isFirstOpen"
}
......@@ -167,7 +168,6 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
override fun onMapStatusChangeStart(status: MapStatus?, reason: Int) {
KLog.a("百度map", "移动开始,两个参数")
}
override fun onMapStatusChange(status: MapStatus?) {
......
......@@ -184,11 +184,14 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
}
/**
* 获取人们景点数据
* 获取热门景点数据
*/
var hotviewData=MutableLiveData<HotViewBean>()
fun getHotView() {
ApiModel.getHotView(lifecycleProvider).safeSubscribe(
val vo = HashMap<String, Any>()
//2-景点推荐 3-热门景点
vo["type"] = 3
ApiModel.getHotView(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<HotViewBean>>(
this@HomeViewModel, true) {
......@@ -205,4 +208,30 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
)
}
/**
* 获取景点推荐数据
*/
var viewRecommed=MutableLiveData<ViewRecommed>()
fun getviewrecommend(){
val vo = HashMap<String, Any>()
//2-景点推荐 3-热门景点
vo["type"] = 2
ApiModel.getViewRecommed(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<ViewRecommed>>(
this@HomeViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<ViewRecommed>) {
viewRecommed.value = response.result
KLog.e("getmyInfo", response.result.toString())
}
override fun onError(e: Throwable) {
super.onError(e)
KLog.e("getmyInfo", "用户登录信息请求失败")
}
}
)
}
}
\ No newline at end of file
......@@ -6,7 +6,6 @@ import com.mints.street.netwrok.common.HttpManager
import com.trello.rxlifecycle2.LifecycleProvider
import io.reactivex.Observable
import retrofit2.Response
import retrofit2.http.Body
/**
* Created by 冯瑞雨 on 2021/7/2.
......@@ -147,8 +146,17 @@ object ApiModel {
return HttpManager.getInstance().execute(null,MainApi.newInstance().authorizedA())
}
/**
* 请求热门景点数据
*/
fun getHotView(lifecycleProvider: LifecycleProvider<Any>?, map: HashMap<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())
/**
* 请求景点推荐数据
*/
fun getViewRecommed(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>):Observable<Response<BaseResponse<ViewRecommed>>>{
return HttpManager.getInstance().execute(lifecycleProvider,MainApi.newInstance().getViewRecommed(map))
}
}
\ No newline at end of file
......@@ -18,7 +18,8 @@ import retrofit2.Response
* @date 2020/1/10
*/
abstract class HttpSubscribeImpl<T : BaseResponse<*>>(viewModel: BaseViewModel?, val needToast: Boolean = true) : IHttpSubscribe<T>(viewModel) {
abstract class HttpSubscribeImpl<T : BaseResponse<*>>(viewModel: BaseViewModel?, val needToast: Boolean = true) :
IHttpSubscribe<T>(viewModel) {
constructor(viewModel: BaseViewModel?) : this(viewModel, true)
......
......@@ -60,11 +60,9 @@ class HotViewDialog(context: FragmentActivity, viewModel: HomeViewModel, homeFra
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{
......
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.DividerItemDecoration
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.ItemHotViewAdapter
import com.mints.street.main.home.HomeFragment
import com.mints.street.main.home.HomeViewModel
import com.mints.street.widget.GridItemDecoration
class ViewRecommedDialog (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
init {
this.context=context
this.viewModel=viewModel
this.homeFragment=homeFragment
}
//
fun init(): ViewRecommedDialog {
//创建弹窗
if (mBottomSheetDialog!=null) return this
mBottomSheetDialog= BottomSheetDialog(context)
val view1: View = LayoutInflater.from(context).inflate(R.layout.layout_viewrecommed,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)
viewModel?.getHotView()
viewModel?.hotviewData?.observe(homeFragment!!, androidx.lifecycle.Observer {
})
iv_close.setOnClickListener{
mBottomSheetDialog!!.dismiss()
}
return this
}
/**
* 展示
*/
fun show() {
mBottomSheetDialog!!.show()
}
fun onDestroy() {
mBottomSheetDialog = null
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_dialog_bg">
<TextView
android:id="@+id/viewname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:text="景点名称"
android:textColor="@color/black"
android:textSize="18dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view"
android:layout_width="1dp"
android:layout_height="14dp"
android:layout_marginLeft="5dp"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="@+id/tv_distance"
app:layout_constraintStart_toEndOf="@+id/viewname"
app:layout_constraintTop_toTopOf="@+id/tv_distance"
tools:ignore="MissingConstraints" />
<TextView
android:id="@+id/tv_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="距离"
android:textColor="#99000000"
android:textSize="14dp"
app:layout_constraintBottom_toBottomOf="@+id/viewname"
app:layout_constraintStart_toEndOf="@+id/view"
app:layout_constraintTop_toTopOf="@+id/viewname"
tools:text="距离" />
<TextView
android:id="@+id/textView5"
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_marginEnd="10dp"
android:background="@drawable/shape_btn_friends_unenabled"
android:gravity="center"
android:text="看街景"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@+id/viewname"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/viewname"
tools:text="看街景" />
<com.mints.street.widget.XCRoundRectImageView
android:id="@+id/image1"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginTop="10dp"
android:src="@mipmap/icon_card6"
app:layout_constraintEnd_toEndOf="@+id/textView5"
app:layout_constraintStart_toStartOf="@+id/viewname"
app:layout_constraintTop_toBottomOf="@+id/viewname"
tools:src="@mipmap/icon_card6" />
<TextView
android:id="@+id/tv_describe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="景点介绍。。。"
android:maxLines="2"
android:ellipsize="end"
android:textColor="#99000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/image1"
app:layout_constraintStart_toStartOf="@+id/image1"
app:layout_constraintTop_toBottomOf="@+id/image1"
tools:text="景点介绍。。。" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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