设置家和公司
This commit is contained in:
@@ -178,6 +178,9 @@ public class NaviClient implements IMogoNavi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void updateNaviConfig() {
|
||||
}
|
||||
|
||||
// -- end
|
||||
|
||||
private boolean checkAMapNavi() {
|
||||
|
||||
@@ -104,4 +104,7 @@ public interface IMogoNavi {
|
||||
*/
|
||||
void setCalculatePathDisplayBounds( Rect bounds );
|
||||
|
||||
|
||||
void updateNaviConfig();
|
||||
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ public class MogoNavi implements IMogoNavi {
|
||||
|
||||
private static volatile MogoNavi sInstance;
|
||||
|
||||
private MogoNavi( Context context ) {
|
||||
mDelegate = NaviClient.getInstance( context );
|
||||
private MogoNavi(Context context) {
|
||||
mDelegate = NaviClient.getInstance(context);
|
||||
}
|
||||
|
||||
public static MogoNavi getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoNavi.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MogoNavi( context );
|
||||
public static MogoNavi getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoNavi.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoNavi(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,65 +43,65 @@ public class MogoNavi implements IMogoNavi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.naviTo( endPoint );
|
||||
public void naviTo(MogoLatLng endPoint) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.naviTo(endPoint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, MogoNaviConfig config ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.naviTo( endPoint, config );
|
||||
public void naviTo(MogoLatLng endPoint, MogoNaviConfig config) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.naviTo(endPoint, config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.naviTo( endPoint, wayPoints );
|
||||
public void naviTo(MogoLatLng endPoint, List<MogoLatLng> wayPoints) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.naviTo(endPoint, wayPoints);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.naviTo( endPoint, wayPoints, config );
|
||||
public void naviTo(MogoLatLng endPoint, List<MogoLatLng> wayPoints, MogoNaviConfig config) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.naviTo(endPoint, wayPoints, config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reCalculateRoute( MogoNaviConfig config ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.reCalculateRoute( config );
|
||||
public void reCalculateRoute(MogoNaviConfig config) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.reCalculateRoute(config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopNavi() {
|
||||
if ( mDelegate != null ) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.stopNavi();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startNavi( boolean isRealNavi ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.startNavi( isRealNavi );
|
||||
public void startNavi(boolean isRealNavi) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.startNavi(isRealNavi);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNaviing() {
|
||||
if ( mDelegate != null ) {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.isNaviing();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< MogoCalculatePath > getCalculatedStrategies() {
|
||||
if ( mDelegate != null ) {
|
||||
public List<MogoCalculatePath> getCalculatedStrategies() {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getCalculatedStrategies();
|
||||
}
|
||||
return null;
|
||||
@@ -109,30 +109,36 @@ public class MogoNavi implements IMogoNavi {
|
||||
|
||||
@Override
|
||||
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
|
||||
if ( mDelegate != null ) {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getItemClickInteraction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineClickInteraction( OnCalculatePathItemClickInteraction itemClickInteraction ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setLineClickInteraction( itemClickInteraction );
|
||||
public void setLineClickInteraction(OnCalculatePathItemClickInteraction itemClickInteraction) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.setLineClickInteraction(itemClickInteraction);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCalculatePaths() {
|
||||
if ( mDelegate != null ) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.clearCalculatePaths();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCalculatePathDisplayBounds( Rect bounds ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setCalculatePathDisplayBounds( bounds );
|
||||
public void setCalculatePathDisplayBounds(Rect bounds) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.setCalculatePathDisplayBounds(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void updateNaviConfig() {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.updateNaviConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.windowview.IMogoWindowManager;
|
||||
@@ -68,6 +69,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
private IMogoLocationClient mMogoLocationClient;
|
||||
private IMogoNavi mMogoNavi;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
private IMogoAddressManager mMogoAddressManager;
|
||||
private IMogoMarkerManager mMogoMarkerManager;
|
||||
|
||||
private IMogoRegisterCenter mMogoRegisterCenter;
|
||||
@@ -86,6 +88,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation();
|
||||
mMogoAddressManager = (IMogoAddressManager) ARouter.getInstance().build( MogoServicePaths.PATH_ADDRESS_MANAGER ).navigation();
|
||||
mCommonAddress = findViewById( R.id.module_entrance_id_common_address );
|
||||
|
||||
mSearch = findViewById( R.id.module_entrance_id_search );
|
||||
@@ -98,12 +101,14 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
mHome = findViewById( R.id.module_entrance_id_home );
|
||||
mHome.setOnClickListener( view -> {
|
||||
mMogoAddressManager.goHome();
|
||||
} );
|
||||
|
||||
mCompany = findViewById( R.id.module_entrance_id_company );
|
||||
mCompany.setOnClickListener( view -> {
|
||||
mMogoMarkerManager.addMarker( "tag", new MogoMarkerOptions().owner( "tag" )
|
||||
.latitude( 39.000 ).longitude( 136.000 ).icon( BitmapFactory.decodeResource( getResources(), R.drawable.module_ext_ic_voice ) ).anchor( 0.5f, 0.5f ) );
|
||||
mMogoAddressManager.goCompany();
|
||||
//mMogoMarkerManager.addMarker( "tag", new MogoMarkerOptions().owner( "tag" )
|
||||
// .latitude( 39.000 ).longitude( 136.000 ).icon( BitmapFactory.decodeResource( getResources(), R.drawable.module_ext_ic_voice ) ).anchor( 0.5f, 0.5f ) );
|
||||
} );
|
||||
|
||||
mUploadRoadCondition = findViewById( R.id.module_entrance_id_upload_road_condition );
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.navi.bean;
|
||||
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.services.geocoder.RegeocodeAddress;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import java.util.ArrayList;
|
||||
@@ -78,17 +80,32 @@ public class EntityConvertUtils {
|
||||
// location.getCoordType() );
|
||||
//}
|
||||
|
||||
//public static SearchPoi geocodeAddress2Poi( RegeocodeAddress address, CameraPosition position ) {
|
||||
// if ( address == null || position == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// return new SearchPoi( System.currentTimeMillis() + "",
|
||||
// address.getFormatAddress(),
|
||||
// address.getFormatAddress(),
|
||||
// position.target.latitude,
|
||||
// position.target.longitude,
|
||||
// address.getDistrict(),
|
||||
// address.getAdCode(),
|
||||
// "" );
|
||||
//}
|
||||
public static SearchPoi geocodeAddress2Poi( RegeocodeAddress address, CameraPosition position ) {
|
||||
if ( address == null || position == null ) {
|
||||
return null;
|
||||
}
|
||||
return new SearchPoi( System.currentTimeMillis() + "",
|
||||
address.getFormatAddress(),
|
||||
address.getFormatAddress(),
|
||||
position.target.latitude,
|
||||
position.target.longitude,
|
||||
address.getDistrict(),
|
||||
address.getAdCode(),
|
||||
"" );
|
||||
}
|
||||
|
||||
|
||||
public static SearchPoi geoToPoi(double latitude,double longitude,int type) {
|
||||
SearchPoi searchPoi = new SearchPoi(System.currentTimeMillis() + "",
|
||||
null,
|
||||
null,
|
||||
latitude,
|
||||
longitude,
|
||||
null,
|
||||
null,
|
||||
"");
|
||||
searchPoi.setType(type);
|
||||
return searchPoi;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.mogo.module.navi.constants;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-12
|
||||
* <p>
|
||||
* 自定义地图样式
|
||||
*/
|
||||
public class CustomMapStyle {
|
||||
|
||||
public static final String STYLE_ID = "e3e33a3423230b219494b40c4d71d93a";
|
||||
|
||||
public static final String ASSET_STYLE_DATA = "style.data";
|
||||
|
||||
public static final String ASSET_STYLE_EXTRA_DATA = "style_extra.data";
|
||||
}
|
||||
@@ -4,12 +4,15 @@ import android.annotation.SuppressLint
|
||||
import android.app.StatusBarManager
|
||||
import android.content.Context
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.amap.api.services.interfaces.IGeocodeSearch
|
||||
import com.mogo.map.marker.IMogoMarkerManager
|
||||
import com.mogo.map.navi.IMogoNavi
|
||||
import com.mogo.map.search.geo.IMogoGeoSearch
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController
|
||||
import com.mogo.module.navi.manager.MogoSettingManager
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager
|
||||
@@ -23,7 +26,7 @@ import kotlin.isInitialized as isInitialized1
|
||||
* 2020-01-08.
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object SearchServiceHolder {
|
||||
object SearchServiceHolder{
|
||||
// 单例对象,要使用Application Context
|
||||
private lateinit var context: Context
|
||||
val fragmentManager: IMogoFragmentManager = ARouter.getInstance().build(
|
||||
@@ -38,10 +41,12 @@ object SearchServiceHolder {
|
||||
val statusManager: IMogoStatusManager = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_STATUS_MANAGER
|
||||
).navigation() as IMogoStatusManager
|
||||
|
||||
val settingManager: MogoSettingManager = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_ADDRESS_MANAGER
|
||||
).navigation() as MogoSettingManager
|
||||
var geoSearch: IMogoGeoSearch? = null
|
||||
|
||||
fun init(context: Context) {
|
||||
fun init(context: Context) {
|
||||
this.context = context
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.mogo.module.navi.manager
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
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.database.AppDataBase
|
||||
import com.mogo.module.navi.ui.search.ChoosePathFragment
|
||||
import com.mogo.module.navi.ui.setting.SettingAddressFragment
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-12.
|
||||
*/
|
||||
object AddressManager {
|
||||
private var homeAddress: SearchPoi? = null
|
||||
private var companyAddress: SearchPoi? = null
|
||||
fun goHome() {
|
||||
if (homeAddress == null) {
|
||||
pushSettingAddress(
|
||||
DataConstants.TYPE_HOME_ADDRESS
|
||||
)
|
||||
} else {
|
||||
var newInstance = ChoosePathFragment.newInstance(EntityConvertUtils.poi2MogoTip(
|
||||
homeAddress
|
||||
))
|
||||
SearchServiceHolder.push(
|
||||
newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun goCompany() {
|
||||
if (companyAddress == null) {
|
||||
pushSettingAddress(
|
||||
DataConstants.TYPE_COMPANY_ADDRESS
|
||||
)
|
||||
} else {
|
||||
var newInstance =
|
||||
ChoosePathFragment.newInstance(EntityConvertUtils.poi2MogoTip(
|
||||
companyAddress
|
||||
))
|
||||
SearchServiceHolder.push(
|
||||
newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun pushSettingAddress(type: Int) {
|
||||
|
||||
val builder = FragmentDescriptor.Builder()
|
||||
builder.fragment(SettingAddressFragment.newInstance(type))
|
||||
val build = builder.tag(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME)
|
||||
.build()
|
||||
SearchServiceHolder.fragmentManager.push(build)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult") fun init(context: Context) {
|
||||
AppDataBase.getDatabase(context)
|
||||
.poiDao()
|
||||
.companyAddress
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (t1.size > 0) {
|
||||
companyAddress = t1[0]
|
||||
}
|
||||
}
|
||||
AppDataBase.getDatabase(context)
|
||||
.poiDao()
|
||||
.homeAddress
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (t1.size > 0) {
|
||||
homeAddress = t1[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun insert(searchPoi: SearchPoi) {
|
||||
if (searchPoi.type == DataConstants.TYPE_COMPANY_ADDRESS) {
|
||||
companyAddress = searchPoi
|
||||
} else {
|
||||
homeAddress = searchPoi
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.navi.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-12.
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_ADDRESS_MANAGER )
|
||||
public class MogoAddressManager implements IMogoAddressManager {
|
||||
@Override public void goHome() {
|
||||
AddressManager.INSTANCE.goHome();
|
||||
}
|
||||
|
||||
@Override public void goCompany() {
|
||||
AddressManager.INSTANCE.goCompany();
|
||||
}
|
||||
|
||||
@Override public void init(Context context) {
|
||||
AddressManager.INSTANCE.init(context);
|
||||
SearchServiceHolder.INSTANCE.init(context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mogo.module.navi.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.module.IMogoSettingManager;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-12.
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_SETTING_MANAGER)
|
||||
public class MogoSettingManager implements IMogoSettingManager {
|
||||
|
||||
private static final String KEY_PAHT_PREFER="keyPath";
|
||||
private static final String KEY_VOLUME="keyVolume";
|
||||
private static final String KEY_VOICE_STYLE="keyVoice";
|
||||
private static final String KEY_MAP_TYPE="keyMapType";
|
||||
private SharedPreferences settings;
|
||||
|
||||
@Override public int getPathPrefer() {
|
||||
return settings.getInt(KEY_PAHT_PREFER,0);
|
||||
}
|
||||
|
||||
@Override public int getVolume() {
|
||||
return settings.getInt(KEY_VOLUME,0);
|
||||
}
|
||||
|
||||
@Override public int getVoiceStyle() {
|
||||
return settings.getInt(KEY_VOICE_STYLE,0);
|
||||
}
|
||||
|
||||
@Override public int getMapType() {
|
||||
return settings.getInt(KEY_MAP_TYPE,0);
|
||||
}
|
||||
|
||||
public void setPathPrefer(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
}
|
||||
|
||||
public void setVolume(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
}
|
||||
|
||||
public void setVoiceStyle(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
}
|
||||
|
||||
public void setMapType(int type) {
|
||||
settings.edit().putInt(KEY_PAHT_PREFER,type).apply();
|
||||
}
|
||||
|
||||
@Override public void init(Context context) {
|
||||
settings = context.getSharedPreferences("settings", Context.MODE_PRIVATE);
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,7 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener {
|
||||
tv_navi_navi.setOnClickListener {
|
||||
SearchServiceHolder.getNavi()
|
||||
.startNavi(false)
|
||||
SearchServiceHolder.fragmentManager.clearAll()
|
||||
}
|
||||
|
||||
SearchServiceHolder.getNavi()
|
||||
|
||||
@@ -15,19 +15,16 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.constants.AMapConstants;
|
||||
import com.mogo.module.navi.manager.AddressManager;
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder;
|
||||
import com.mogo.module.navi.ui.adapter.HistoryPoiAdapter;
|
||||
import com.mogo.module.navi.ui.adapter.SearchPoiAdapter;
|
||||
import com.mogo.module.navi.ui.base.UiController;
|
||||
import com.mogo.module.navi.ui.setting.NaviSettingFragment;
|
||||
import com.mogo.module.navi.ui.setting.SettingAddressFragment;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
|
||||
/**
|
||||
* 搜索页面
|
||||
* <p>
|
||||
@@ -83,7 +80,6 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
SearchServiceHolder.INSTANCE.init(getActivity().getApplicationContext());
|
||||
SearchServiceHolder.INSTANCE.getMarkerManger().removeMarkers();
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation( false );
|
||||
moveMapToCenter();
|
||||
@@ -149,13 +145,13 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
|
||||
findViewById(R.id.tv_navi_company).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
pupSettingAddress(1);
|
||||
AddressManager.INSTANCE.goCompany();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.tv_navi_home).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
pupSettingAddress(0);
|
||||
AddressManager.INSTANCE.goHome();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -174,14 +170,7 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager().push(build);
|
||||
}
|
||||
|
||||
private void pupSettingAddress(int type) {
|
||||
|
||||
FragmentDescriptor.Builder builder = new FragmentDescriptor.Builder();
|
||||
builder.fragment(SettingAddressFragment.Companion.newInstance(type));
|
||||
FragmentDescriptor build =
|
||||
builder.tag(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME).build();
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager().push(build);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示我的位置,并且可设置为家
|
||||
|
||||
@@ -5,11 +5,8 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.amap.api.col.n3.it
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.map.listener.IMogoMapListener
|
||||
import com.mogo.map.location.IMogoLocationListener
|
||||
import com.mogo.map.location.MogoLocation
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.marker.MogoMarkerOptions
|
||||
import com.mogo.map.search.geo.IMogoGeoSearchListener
|
||||
@@ -20,9 +17,17 @@ import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.common.adapter.MogoMapListenerAdapter
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.R.string
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils
|
||||
import com.mogo.module.navi.bean.SearchPoi
|
||||
import com.mogo.module.navi.constants.AMapConstants
|
||||
import com.mogo.module.navi.manager.AddressManager
|
||||
import com.mogo.module.navi.constants.DataConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.database.AppDataBase
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.fragment_setting_address.tv_set_as_home
|
||||
import kotlinx.android.synthetic.main.include_search_bar.et_navi_search
|
||||
import kotlinx.android.synthetic.main.include_search_bar.iv_navi_back
|
||||
@@ -43,9 +48,10 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
}
|
||||
|
||||
private val TAG: String = "SettingAddressFragment"
|
||||
private var style: Int = 0
|
||||
private var style: Int = DataConstants.TYPE_HOME_ADDRESS
|
||||
var addMarker: IMogoMarker? = null
|
||||
|
||||
private var selectPoi: MogoLatLng?=null
|
||||
private var mapListener: IMogoMapListener = object : MogoMapListenerAdapter() {
|
||||
override fun onMapChanged(
|
||||
latLng: MogoLatLng?,
|
||||
@@ -54,6 +60,7 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
bearing: Float
|
||||
) {
|
||||
super.onMapChanged(latLng, zoom, tilt, bearing)
|
||||
selectPoi=latLng
|
||||
var mogoRegeocodeQuery = MogoRegeocodeQuery()
|
||||
mogoRegeocodeQuery.point = latLng
|
||||
SearchServiceHolder.getGeoSearcher().getFromLocationAsyn(mogoRegeocodeQuery)
|
||||
@@ -72,7 +79,7 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
style = arguments?.getInt(AMapConstants.KEY_SET_HOME_COMPONY) ?: 0
|
||||
style = arguments?.getInt(AMapConstants.KEY_SET_HOME_COMPONY) ?: DataConstants.TYPE_HOME_ADDRESS
|
||||
setMarkerStatus(true)
|
||||
SearchServiceHolder.listenerCenter.registerMogoMapListener(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, mapListener
|
||||
@@ -91,11 +98,11 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
}
|
||||
|
||||
fun isHome(): Boolean {
|
||||
return style == 0
|
||||
return style == DataConstants.TYPE_HOME_ADDRESS
|
||||
}
|
||||
|
||||
fun isCompony(): Boolean {
|
||||
return style == 1
|
||||
return style == DataConstants.TYPE_COMPANY_ADDRESS
|
||||
}
|
||||
|
||||
override fun onViewCreated(
|
||||
@@ -114,11 +121,18 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
iv_navi_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
tv_set_as_home.setOnClickListener {
|
||||
|
||||
var geoToPoi =
|
||||
EntityConvertUtils.geoToPoi(selectPoi?.lat ?: 0.0, selectPoi?.lng ?: 0.0, style)
|
||||
insert(geoToPoi)
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
|
||||
et_navi_search.isEnabled = false
|
||||
et_navi_search.setText(getString(string.drag_map_to_choose))
|
||||
var location = SearchServiceHolder.getMapUIController()
|
||||
.windowCenterLocation
|
||||
.windowCenterLocation
|
||||
if (addMarker == null) {
|
||||
var decodeResource = BitmapFactory.decodeResource(resources, R.mipmap.icon_choose_position2)
|
||||
val options = MogoMarkerOptions()
|
||||
@@ -128,12 +142,26 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
.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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun insert(searchPoi: SearchPoi) {
|
||||
|
||||
AddressManager.insert(searchPoi)
|
||||
Observable.create(
|
||||
ObservableOnSubscribe<String> {
|
||||
AppDataBase.getDatabase(context)
|
||||
.poiDao()
|
||||
.insert(searchPoi)
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
@@ -149,7 +177,7 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(type: Int = 0): Fragment {
|
||||
fun newInstance(type: Int = DataConstants.TYPE_HOME_ADDRESS): Fragment {
|
||||
var settingAddressFragment = SettingAddressFragment()
|
||||
val bundle = Bundle()
|
||||
bundle.putInt(AMapConstants.KEY_SET_HOME_COMPONY, type)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
android:gravity="center"
|
||||
android:id="@+id/tv_set_as_home"
|
||||
android:textColor="@color/white"
|
||||
android:visibility="gone"
|
||||
android:textSize="@dimen/sp_40"
|
||||
android:background="@drawable/shape_round_blue_grident"
|
||||
app:layout_constraintRight_toRightOf="@+id/ll_navi_search"
|
||||
|
||||
@@ -22,10 +22,12 @@
|
||||
/>
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:maxLines="1"
|
||||
android:id="@+id/et_navi_search"
|
||||
android:background="@null"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:imeOptions="actionDone"
|
||||
android:hint="@string/hint_map_search"
|
||||
android:textColor="@color/white"
|
||||
|
||||
@@ -81,5 +81,22 @@ public class MogoServicePaths {
|
||||
*/
|
||||
public static final String PATH_REGISTER_CENTER = "/registercenter/api";
|
||||
|
||||
/**
|
||||
* 基础家和公司管理
|
||||
*/
|
||||
public static final String PATH_ADDRESS_MANAGER = "/addressmanager/api";
|
||||
|
||||
|
||||
/**
|
||||
* 基础设置参数管理
|
||||
*/
|
||||
public static final String PATH_SETTING_MANAGER = "/settingmanager/api";
|
||||
|
||||
|
||||
/**
|
||||
* 搜索module管理中心
|
||||
*/
|
||||
public static final String PATH_SERACH_CENTER = "/searchcenter/api";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.service.module;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-12.
|
||||
*/
|
||||
public interface IMogoAddressManager extends IProvider {
|
||||
|
||||
void goHome();
|
||||
void goCompany();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.service.module;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-12.
|
||||
*/
|
||||
public interface IMogoSettingManager extends IProvider {
|
||||
|
||||
int getPathPrefer();
|
||||
int getVolume();
|
||||
int getVoiceStyle();
|
||||
int getMapType();
|
||||
}
|
||||
Reference in New Issue
Block a user