Commit f488b893 authored by fengruiyu's avatar fengruiyu

谷歌和百度地图回调该gps定位功能已完成

parent 2de53ea8
......@@ -14,9 +14,11 @@ import com.fry.base.binding.setMargin
import com.mints.street.R
import com.mints.street.bean.VrmapBean
import com.mints.street.databinding.ItemGridMapAdapterBinding
import com.mints.street.main.vr.PanoramicActivity
import com.mints.street.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.RxUtils
/**
* Created by 冯瑞雨 on 2021/7/9.
......@@ -24,7 +26,6 @@ import me.goldze.mvvmhabit.utils.KLog
class GridMapAdapter(val context: Context, var list: List<VrmapBean.Internal>?) :
AbstractVLayoutBaseAdapter<ItemGridMapAdapterBinding, List<VrmapBean.Internal>>(context, list, 2) {
private var datalist: List<VrmapBean.Internal>? = list
override fun onBindViewHolder(
holder: BindingViewHolder<ItemGridMapAdapterBinding>,
position: Int
......@@ -38,23 +39,20 @@ class GridMapAdapter(val context: Context, var list: List<VrmapBean.Internal>?)
AppUtils.dp2Px(context, 20F), 0, null, null, null)
}
datalist?.let {
var databean = it[position]
list?.get(position)?.apply {
//设置图片
Glide.with(mContext).load(databean.img).into(holder.binding.image)
Glide.with(mContext).load(img).into(holder.binding.image)
//设置标题
holder.binding.tvName.text = databean.name
holder.binding.tvName.text = name
//设置点击跳转
holder.itemView.setOnClickListener {
RxUtils.onMultiClick(holder.itemView){
//页面跳转
MintsWebViewActivity.startWebView(databean.name, url = databean.url)
MintsWebViewActivity.startWebView(name, url = url)
}
holder.binding.llstart.setNumber(stars?.toInt()?:5)
}
// RxUtils.onMultiClick(holder.binding.bg) {
// PanoramicActivity.starPanoramicActivity(context, ""
// , PanoramicActivity.WGS84, lat = 39.906283536127169, lon = 116.39129554889048)
// }
}
......
......@@ -15,9 +15,11 @@ import com.fry.base.utils.ImageLoader
import com.mints.street.R
import com.mints.street.bean.DetailedBean
import com.mints.street.databinding.ItemGridVrmapAdapterBinding
import com.mints.street.main.vr.DetailedViewModel
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.RxUtils
class GridVrMapAdapter(val context: Context, var list: List<DetailedBean.DetailedItemBean>?) :
class GridVrMapAdapter(val context: Context, var list: List<DetailedBean.DetailedItemBean>?,val viewModel: DetailedViewModel) :
AbstractVLayoutBaseAdapter<ItemGridVrmapAdapterBinding, List<DetailedBean.DetailedItemBean>>(context, list, 2) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemGridVrmapAdapterBinding>,
......@@ -39,10 +41,13 @@ class GridVrMapAdapter(val context: Context, var list: List<DetailedBean.Detaile
ImageLoader.ImageBuilder.with(context)
.setUrl(it[position].img).setTargetView(holder.binding.image).start()
}
RxUtils.onMultiClick(holder.binding.bg){
viewModel.authorized(list?.get(position)?.name,list?.get(position)?.lat,list?.get(position)?.lng)
}
}
override fun getItemCount() = list!!.size
override fun getItemCount() = list?.size?:0
override fun onCreateLayoutHelper(): LayoutHelper {
val hp: GridLayoutHelper = GridLayoutHelper(2)
......
......@@ -139,7 +139,7 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
binding.click.setOnClickListener {
binding.imageLocationIcon.setOnClickListener {
initZsMap()
}
RxUtils.onMultiClick(binding.stbBgSearch) {
......@@ -213,8 +213,12 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
KLog.e("file:///android_asset/w")
}
})
viewModel.pt.observe(this, Observer {
binding.webview.callHandler("initZsMap"
,Gson().toJson(it) ) {
}
})
}
override fun onDestroy() {
super.onDestroy()
......
......@@ -27,6 +27,7 @@ import com.mints.street.R
import com.mints.street.bean.PositioningBean
import com.mints.street.databinding.FragmentHomeBinding
import com.mints.street.manager.UmengManager
import com.mints.street.utils.GPSConverterUtils
import com.mints.street.webview.MintsWebViewActivity
import com.mints.street.widget.ScrollLayout
import me.goldze.mvvmhabit.base.AppManager
......@@ -111,10 +112,11 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
}
override fun initViewObservable() {
viewModel.pt.observe(this, Observer<Map<String, Double>> {
viewModel.pt.observe(this, Observer {
if (it==null)return@Observer
// 默认 天安门
val center = LatLng(it["latitude"] ?:39.915071, it["longitude"] ?:116.403907)
val gps = GPSConverterUtils.gcj02_To_Bd09(it.lat,it.lng)
val center = LatLng(gps.lat, gps.lng)
setNewMapStatus(center)
binding.scrollLayout.toggle(ScrollLayout.STATUS_DEFAULT)
})
......
......@@ -7,10 +7,7 @@ import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.bean.AuthorizedBean
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.MapBean
import com.mints.street.bean.VipBean
import com.mints.street.bean.*
import com.mints.street.common.DeviceInfo
import com.mints.street.manager.oaid.OaidManager
import com.mints.street.model.ApiModel
......@@ -34,7 +31,7 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
var addressList = ObservableArrayList<HomeButtonItemVM?>()
var addressItemBinding = ItemBinding.of<HomeButtonItemVM>(BR.viewModel, R.layout.item_home_button)
var pt = MutableLiveData<Map<String,Double>>()
var pt = MutableLiveData<GPS>()
val authorizedBean = MutableLiveData<AuthorizedBean>()
......@@ -116,12 +113,8 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == 200 && resultCode == SearchMapActivity.REQUEST_CODE){
KLog.a("homeFragment onActivityResult")
data?.let {
val map = HashMap<String,Double>(2)
map["latitude"] = it.getDoubleExtra("latitude",0.0)
map["longitude"] = it.getDoubleExtra("longitude",0.0)
pt.value = map
pt.value = GPS(it.getDoubleExtra("latitude",0.0),it.getDoubleExtra("longitude",0.0))
}
}
}
......
......@@ -22,26 +22,10 @@ class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
*/
val onClick = BindingCommand<Any>(BindingAction {
viewModel.searchName.value = HistoryBean(name = this.name,
latitude = pt?.lat,longitude = pt?.lat)
latitude = pt?.lat,longitude = pt?.lng)
val intent = Intent()
intent.putExtra("latitude",pt?.lat)
intent.putExtra("longitude",pt?.lat)
intent.putExtra("longitude",pt?.lng)
viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
})
}
/*class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
, val address:String?,val pt: LatLng?=null) :
ItemViewModel<SearchMapViewModel>(viewModel) {
*//***
* 点击名称回调回调
*//*
val onClick = BindingCommand<Any>(BindingAction {
viewModel.searchName.value = HistoryBean(name = this.name,
latitude = pt?.latitude,longitude = pt?.longitude)
//不带参数、不跳转
// val intent = Intent()
// intent.putExtra("latitude",pt?.latitude)
// intent.putExtra("longitude",pt?.longitude)
// viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
})
}*/
\ No newline at end of file
......@@ -61,7 +61,7 @@ class DetailedActivity : BaseActivity<ActivityDetailedBinding, DetailedViewModel
super.initViewObservable()
viewModel.detailbean.observe(this, Observer {
if (gridVrMapAdapter == null){
gridVrMapAdapter = GridVrMapAdapter(this, it.list)
gridVrMapAdapter = GridVrMapAdapter(this, it.list,viewModel)
mAdapter?.addAdapter(gridVrMapAdapter)
}
gridVrMapAdapter?.list = it.list
......
......@@ -2,11 +2,14 @@ package com.mints.street.main.vr
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.mints.street.bean.AuthorizedBean
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.DetailedBean
import com.mints.street.bean.VipBean
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
......@@ -15,6 +18,7 @@ class DetailedViewModel(application: Application) : BaseViewModel(application) {
val detailbean: MutableLiveData<DetailedBean> = MutableLiveData()
fun getChooseExperienceData(name:String){
val vo = HashMap<String, Any>()
vo["area"] = name
......@@ -32,4 +36,25 @@ class DetailedViewModel(application: Application) : BaseViewModel(application) {
}
)
}
fun authorized(name:String?,lat:Double?=0.0 ,lng:Double?=0.0) {
ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@DetailedViewModel,false
) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
MintsWebViewActivity.startWebView(
name,
MintsWebViewActivity.toGoogleVR(
response.result.u,
response.result.gk,
response.result.base,
lat.toString(),
lng.toString(),
response.result.ut
)
)
}
})
}
}
......@@ -39,11 +39,21 @@ class FeaturedExperienceFragment:BaseFragment<FragmentFeaturedExperienceBinding
binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter
binding.srlMy.setOnRefreshListener {
//获取VR全景数据
viewModel.getChooseExperienceHeadData()
}
viewModel.getChooseExperienceHeadData()
}
override fun initViewObservable() {
super.initViewObservable()
viewModel.VreperienceBean.observe(this, Observer {
binding.srlMy.finishRefresh(true)
// mAdapter?.addAdapter(ItemEnterDestinationAdapter(context!!, false,it.abroad))
if (itemEnterDestinationAdapter == null){
itemEnterDestinationAdapter = ItemEnterDestinationAdapter(context!!, false, it.data)
......@@ -53,11 +63,4 @@ class FeaturedExperienceFragment:BaseFragment<FragmentFeaturedExperienceBinding
mAdapter?.notifyDataSetChanged()
})
}
override fun onResume() {
super.onResume()
// viewModel.vrPlaces()
//设置数据请求
viewModel.getChooseExperienceHeadData()
}
}
\ No newline at end of file
......@@ -13,6 +13,9 @@ import com.mints.street.adapter.EnterDestinationAdapter
import com.mints.street.adapter.GridMapAdapter
import com.mints.street.bean.VrmapBean
import com.mints.street.databinding.FragmentFreeZoneBinding
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import me.goldze.mvvmhabit.utils.KLog
/**
* Created by 冯瑞雨 on 2021/7/9.
......@@ -22,7 +25,6 @@ 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?,
......@@ -31,11 +33,6 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel
override fun initVariableId() = BR.viewModel
override fun onResume() {
super.onResume()
//获取VR全景数据
viewModel.vrPlaces()
}
override fun initData() {
super.initData()
......@@ -47,12 +44,20 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel
binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter
binding.srlMy.autoRefresh()//自动刷新
binding.srlMy.setOnRefreshListener {
//获取VR全景数据
viewModel.vrPlaces()
}
viewModel.vrPlaces()
}
override fun initViewObservable() {
super.initViewObservable()
viewModel.VrmapBean.observe(this, Observer<VrmapBean> {
binding.srlMy.finishRefresh(true)
/*if(enterDestinationAdapter == null){
enterDestinationAdapter = EnterDestinationAdapter(context!!,it.abroad )
mAdapter?.addAdapter(enterDestinationAdapter)
......
......@@ -53,6 +53,9 @@ public class RatingStar extends View {
i0 = -1;
}
public void setNumber(int number){
this.number = number;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
......
......@@ -14,19 +14,23 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:paddingBottom="40dp"
android:layout_marginBottom="40dp"
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="0dp"
/>
<Button
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/click"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:text="点击"
<ImageView
android:id="@+id/image_location_icon"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginTop="125dp"
android:layout_marginEnd="6dp"
android:src="@mipmap/location_icon"
app:layout_constraintBottom_toBottomOf="@+id/webview"
app:layout_constraintTop_toTopOf="@id/webview"
app:layout_constraintEnd_toEndOf="parent"
/>
<com.mints.street.widget.ScrollLayout
android:id="@+id/scroll_layout"
......
......@@ -39,6 +39,8 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:visibility="gone"
android:id="@+id/image_map_history"
android:layout_width="35dp"
android:layout_height="35dp"
......
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