回家,去公司的问题
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 60 KiB |
@@ -7,6 +7,7 @@ import com.mogo.module.navi.bean.EntityConvertUtils
|
||||
import com.mogo.module.navi.bean.SearchPoi
|
||||
import com.mogo.module.navi.constants.DataConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.cp.AddressHelper
|
||||
import com.mogo.module.navi.dao.SearchPoiDao
|
||||
import com.mogo.module.navi.database.AppDataBase
|
||||
import com.mogo.module.navi.ui.search.ChoosePathFragment
|
||||
@@ -114,20 +115,28 @@ object AddressManager {
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteHome(){
|
||||
fun deleteHome(context: Context){
|
||||
Observable.create(
|
||||
ObservableOnSubscribe<String> {
|
||||
poiDao.delete(homeAddress)
|
||||
homeAddress?.name=""
|
||||
AddressHelper.notifyAddressChanged(context, homeAddress!!)
|
||||
|
||||
homeAddress=null
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun deleteCompany(){
|
||||
fun deleteCompany(context: Context){
|
||||
Observable.create(
|
||||
ObservableOnSubscribe<String> {
|
||||
poiDao.delete(companyAddress)
|
||||
companyAddress?.name=""
|
||||
AddressHelper.notifyAddressChanged(context, companyAddress!!)
|
||||
|
||||
companyAddress=null
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@@ -197,12 +197,12 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
|
||||
|
||||
|
||||
tv_navi_clear_home_address.setOnClickListener {
|
||||
AddressManager.deleteHome()
|
||||
AddressManager.deleteHome(context!!)
|
||||
clearHome()
|
||||
}
|
||||
|
||||
tv_navi_clear_company_address.setOnClickListener {
|
||||
AddressManager.deleteCompany()
|
||||
AddressManager.deleteCompany(context!!)
|
||||
clearCompany()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.navi.ui.setting
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
@@ -43,8 +44,15 @@ import kotlinx.android.synthetic.main.fragment_setting_address.tv_set_as_home
|
||||
class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
override fun onRegeocodeSearched(regeocodeResult: MogoRegeocodeResult?) {
|
||||
et_navi_search.setText(regeocodeResult?.regeocodeAddress?.formatAddress)
|
||||
selectPoi?.address=regeocodeResult?.regeocodeAddress?.formatAddress
|
||||
selectPoi?.name=regeocodeResult?.regeocodeAddress?.building
|
||||
var formatAddress = regeocodeResult?.regeocodeAddress?.formatAddress
|
||||
selectPoi?.address = formatAddress
|
||||
|
||||
var neighborhood = regeocodeResult?.regeocodeAddress?.neighborhood
|
||||
if (!TextUtils.isEmpty(neighborhood)) {
|
||||
selectPoi?.name = neighborhood
|
||||
}else{
|
||||
selectPoi?.name = formatAddress
|
||||
}
|
||||
}
|
||||
|
||||
override fun onGeocodeSearched(geocodeResult: MogoGeocodeResult?) {
|
||||
@@ -55,7 +63,7 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
private var style: Int = DataConstants.TYPE_HOME_ADDRESS
|
||||
var addMarker: IMogoMarker? = null
|
||||
|
||||
private var selectPoi: SearchPoi?=null
|
||||
private var selectPoi: SearchPoi? = null
|
||||
private var mapListener: IMogoMapListener = object : MogoMapListenerAdapter() {
|
||||
override fun onMapChanged(
|
||||
latLng: MogoLatLng?,
|
||||
@@ -64,20 +72,23 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
bearing: Float
|
||||
) {
|
||||
super.onMapChanged(latLng, zoom, tilt, bearing)
|
||||
selectPoi=EntityConvertUtils.geoToPoi(latLng?.lat?:0.0,latLng?.lng?:0.0,style)
|
||||
selectPoi = EntityConvertUtils.geoToPoi(latLng?.lat ?: 0.0, latLng?.lng ?: 0.0, style)
|
||||
|
||||
var mogoRegeocodeQuery = MogoRegeocodeQuery()
|
||||
mogoRegeocodeQuery.point = latLng
|
||||
SearchServiceHolder.getGeoSearcher().getFromLocationAsyn(mogoRegeocodeQuery)
|
||||
SearchServiceHolder.getGeoSearcher()
|
||||
.getFromLocationAsyn(mogoRegeocodeQuery)
|
||||
addMarker?.apply {
|
||||
SearchServiceHolder.getMapUIController().startJumpAnimation(this,
|
||||
150f,{input ->
|
||||
if (input <= 0.5) {
|
||||
(0.5f - 2.0 * (0.5 - input) * (0.5 - input)).toFloat()
|
||||
} else {
|
||||
(0.5f - Math.sqrt(((input - 0.5f) * (1.5f - input)).toDouble())).toFloat()
|
||||
}
|
||||
}, 600)
|
||||
SearchServiceHolder.getMapUIController()
|
||||
.startJumpAnimation(this,
|
||||
150f, { input ->
|
||||
if (input <= 0.5) {
|
||||
(0.5f - 2.0 * (0.5 - input) * (0.5 - input)).toFloat()
|
||||
} else {
|
||||
(0.5f - Math.sqrt(((input - 0.5f) * (1.5f - input)).toDouble())).toFloat()
|
||||
}
|
||||
}, 600
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,9 +107,11 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
.setGeoSearchListener(this)
|
||||
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, true)
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, true
|
||||
)
|
||||
|
||||
SearchServiceHolder.getMarkerManger().removeMarkers()
|
||||
SearchServiceHolder.getMarkerManger()
|
||||
.removeMarkers()
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
@@ -131,7 +144,8 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
}
|
||||
tv_set_as_home.setOnClickListener {
|
||||
if (selectPoi == null) {
|
||||
Toast.makeText(context,"请选择",Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, "请选择", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
insert(selectPoi!!)
|
||||
@@ -146,16 +160,16 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
UiThreadHandler.postDelayed({
|
||||
var decodeResource = BitmapFactory.decodeResource(resources, R.mipmap.icon_choose_position2)
|
||||
val options = MogoMarkerOptions()
|
||||
.icon(decodeResource)
|
||||
.latitude(location?.lat ?: 0.0)
|
||||
.owner(TAG)
|
||||
.anchor(0.5f, 1f)
|
||||
.longitude(location?.lng ?: 0.0)
|
||||
.icon(decodeResource)
|
||||
.latitude(location?.lat ?: 0.0)
|
||||
.owner(TAG)
|
||||
.anchor(0.5f, 1f)
|
||||
.longitude(location?.lng ?: 0.0)
|
||||
addMarker = SearchServiceHolder.getMarkerManger()
|
||||
.addMarker(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, options)
|
||||
.addMarker(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, options)
|
||||
|
||||
var locationPointInScreen = SearchServiceHolder.getMapUIController()
|
||||
.getLocationPointInScreen(location)
|
||||
.getLocationPointInScreen(location)
|
||||
addMarker?.setPositionByPixels(locationPointInScreen)
|
||||
}, 500L)
|
||||
}
|
||||
@@ -173,7 +187,7 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
.subscribe()
|
||||
|
||||
|
||||
AddressHelper.notifyAddressChanged(context,searchPoi)
|
||||
AddressHelper.notifyAddressChanged(context, searchPoi)
|
||||
|
||||
}
|
||||
|
||||
@@ -188,12 +202,14 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
addMarker?.destroy()
|
||||
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, false)
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, false
|
||||
)
|
||||
|
||||
if (SearchServiceHolder.fragmentManager.stackSize == 0) {
|
||||
moveMapToRight()
|
||||
SearchServiceHolder.getMapUIController().showMyLocation(true)
|
||||
}
|
||||
if (SearchServiceHolder.fragmentManager.stackSize == 0) {
|
||||
moveMapToRight()
|
||||
SearchServiceHolder.getMapUIController()
|
||||
.showMyLocation(true)
|
||||
}
|
||||
|
||||
// moveMapToRight()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user