Commit 4fb3c46b authored by fengruiyu's avatar fengruiyu

Merge branch 'branche_zsf' of http://39.97.65.143:81/android/android_street into fry_dev

 Conflicts:
	app/src/main/java/com/mints/street/main/home/HomeViewModel.kt
解决冲突
parents f3c1651d a36b1330
package com.mints.street.main.home package com.mints.street.main.home
import android.app.Dialog
import android.content.Context.SENSOR_SERVICE import android.content.Context.SENSOR_SERVICE
import android.hardware.Sensor import android.hardware.Sensor
import android.hardware.SensorEvent import android.hardware.SensorEvent
...@@ -9,7 +8,6 @@ import android.hardware.SensorManager ...@@ -9,7 +8,6 @@ import android.hardware.SensorManager
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.baidu.location.BDLocation import com.baidu.location.BDLocation
...@@ -28,7 +26,6 @@ import com.mints.street.databinding.FragmentHomeBinding ...@@ -28,7 +26,6 @@ import com.mints.street.databinding.FragmentHomeBinding
import com.mints.street.manager.UmengManager import com.mints.street.manager.UmengManager
import com.mints.street.utils.GPSConverterUtils import com.mints.street.utils.GPSConverterUtils
import com.mints.street.widget.ScrollLayout import com.mints.street.widget.ScrollLayout
import com.mints.street.widget.dialog.DialogListener
import com.mints.street.widget.dialog.DialogUtils import com.mints.street.widget.dialog.DialogUtils
import me.goldze.mvvmhabit.base.AppManager import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
...@@ -41,6 +38,10 @@ import me.goldze.mvvmhabit.utils.SPUtils ...@@ -41,6 +38,10 @@ import me.goldze.mvvmhabit.utils.SPUtils
*/ */
class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener { class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener {
companion object {
val IS_FIRST_OPEN: String = "isFirstOpen"
}
private var mBaiduMap: BaiduMap? = null private var mBaiduMap: BaiduMap? = null
// 定位相关 // 定位相关
...@@ -122,7 +123,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -122,7 +123,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
}) })
viewModel.mapbeanData.observe(this, Observer<MapBean> { viewModel.mapbeanData.observe(this, Observer<MapBean> {
DialogUtils.showbennfitsDialog(context!!,viewModel,it.innerPlaces?.places) DialogUtils.showbennfitsDialog(context!!, viewModel, it.innerPlaces?.places)
}) })
} }
......
...@@ -9,7 +9,6 @@ import com.mints.street.BR ...@@ -9,7 +9,6 @@ import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.bean.* import com.mints.street.bean.*
import com.mints.street.common.DeviceInfo import com.mints.street.common.DeviceInfo
import com.mints.street.db.ScenicSpotBean
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.manager.oaid.OaidManager import com.mints.street.manager.oaid.OaidManager
...@@ -31,7 +30,8 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -31,7 +30,8 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
var addressList = ObservableArrayList<HomeButtonItemVM?>() var addressList = ObservableArrayList<HomeButtonItemVM?>()
var addressItemBinding = ItemBinding.of<HomeButtonItemVM>(BR.viewModel, R.layout.item_home_button) var addressItemBinding =
ItemBinding.of<HomeButtonItemVM>(BR.viewModel, R.layout.item_home_button)
var pt = MutableLiveData<GPS>() var pt = MutableLiveData<GPS>()
val authorizedBean = MutableLiveData<AuthorizedBean>() val authorizedBean = MutableLiveData<AuthorizedBean>()
...@@ -40,10 +40,10 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -40,10 +40,10 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
fun authorized() { fun authorized() {
ApiModel.authorized().safeSubscribe(object ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>( : HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
null,false null, false
) { ) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) { override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
if(Gson().toJson(response.result).equals(Gson().toJson(authorizedBean.value))){ if (Gson().toJson(response.result).equals(Gson().toJson(authorizedBean.value))) {
return return
} }
authorizedBean.value = response.result authorizedBean.value = response.result
...@@ -51,64 +51,72 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -51,64 +51,72 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}) })
} }
fun authorized(name:String?=null,lat:String?,lng:String?,isLook:Boolean) {
if (isLook){ fun authorized(name: String? = null, lat: String?, lng: String?, isLook: Boolean) {
if (isLook) {
ApiModel.authorizedA().safeSubscribe(object ApiModel.authorizedA().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>( : HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@HomeViewModel,false this@HomeViewModel, false
) { ) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) { override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
if(!Gson().toJson(response.result).equals(Gson().toJson(authorizedBean.value))){ if (!Gson().toJson(response.result)
.equals(Gson().toJson(authorizedBean.value))
) {
authorizedBean.value = response.result authorizedBean.value = response.result
} }
MintsWebViewActivity.startWebView(name, MintsWebViewActivity.startWebView(
MintsWebViewActivity.toBaduVR(lat,lng,response.result?.bk)) name,
MintsWebViewActivity.toBaduVR(lat, lng, response.result?.bk)
)
} }
}) })
}else{ } else {
if((!UserManager.INSTANCE.userIsLogin() && !UserManager.INSTANCE.getVipFlag())){ if ((!UserManager.INSTANCE.userIsLogin() && !UserManager.INSTANCE.getVipFlag())) {
startActivity(OpenvipActivity::class.java) startActivity(OpenvipActivity::class.java)
return return
} }
ApiModel.authorized().safeSubscribe(object ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>( : HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@HomeViewModel,false this@HomeViewModel, false
) { ) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) { override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
if(!Gson().toJson(response.result).equals(Gson().toJson(authorizedBean.value))){ if (!Gson().toJson(response.result)
.equals(Gson().toJson(authorizedBean.value))
) {
authorizedBean.value = response.result authorizedBean.value = response.result
} }
MintsWebViewActivity.startWebView(name, MintsWebViewActivity.startWebView(
MintsWebViewActivity.toBaduVR(lat,lng,response.result?.bk)) name,
MintsWebViewActivity.toBaduVR(lat, lng, response.result?.bk)
)
} }
}) })
} }
} }
var mapbeanData=MutableLiveData<MapBean>() var mapbeanData = MutableLiveData<MapBean>()
fun getMapBean() { fun getMapBean() {
val assets = AppManager.getAppManager().currentActivity.assets val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder() val stringBuilder = StringBuilder()
var mapBean:MapBean?=null var mapBean: MapBean? = null
try { try {
//通过管理器打开文件并读取 //通过管理器打开文件并读取
val bf = BufferedReader( val bf = BufferedReader(
InputStreamReader( InputStreamReader(
assets.open("map.json")) assets.open("map.json")
)
) )
var line: String? var line: String?
while (bf.readLine().also { line = it } != null) { while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line) stringBuilder.append(line)
} }
mapbeanData.value= Gson().fromJson(stringBuilder.toString(), MapBean::class.java) mapbeanData.value = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
mapBean = Gson().fromJson(stringBuilder.toString(), MapBean::class.java) mapBean = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e: Exception) { } catch (e: Exception) {
...@@ -116,13 +124,21 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -116,13 +124,21 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
} }
val bean = mapBean?.homePlaces?.places val bean = mapBean?.homePlaces?.places
bean?.iterator()?.forEach { item -> bean?.iterator()?.forEach { item ->
if (item.images==null || item.images?.size!!<3){ if (item.images == null || item.images?.size!! < 3) {
return return
} }
addressList.add(HomeButtonItemVM(this, item.name addressList.add(
, item.images!![0],item.images!![1],item.images!![2] HomeButtonItemVM(
,latitude = item.latitude.toString(),longitude = item.longitude.toString(),isLook = true this,
)) item.name,
item.images!![0],
item.images!![1],
item.images!![2],
latitude = item.latitude.toString(),
longitude = item.longitude.toString(),
isLook = true
)
)
} }
} }
...@@ -148,7 +164,8 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -148,7 +164,8 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
ApiModel.comSaveTerminalInfo(lifecycleProvider, vo).safeSubscribe( ApiModel.comSaveTerminalInfo(lifecycleProvider, vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>( object : HttpSubscribeImpl<BaseResponse<Any>>(
this@HomeViewModel, true) { this@HomeViewModel, true
) {
override fun onBusinessSuccess(response: BaseResponse<Any>) { override fun onBusinessSuccess(response: BaseResponse<Any>) {
} }
...@@ -158,10 +175,13 @@ class HomeViewModel(application: Application) : BaseViewModel(application) { ...@@ -158,10 +175,13 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == 200 && resultCode == SearchMapActivity.REQUEST_CODE){ if (requestCode == 200 && resultCode == SearchMapActivity.REQUEST_CODE) {
data?.let { data?.let {
pt.value = GPS(it.getDoubleExtra("latitude",0.0),it.getDoubleExtra("longitude",0.0)) pt.value = GPS(
it.getDoubleExtra("latitude", 0.0), it.getDoubleExtra("longitude", 0.0)
)
} }
} }
} }
} }
\ 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