适配导航模块的UI

This commit is contained in:
zhangyuanzhen
2020-01-18 15:24:05 +08:00
parent 4284867495
commit a02cd2363e
15 changed files with 451 additions and 251 deletions

View File

@@ -30,6 +30,7 @@ import com.mogo.module.main.assist.MapBroadCastHelper;
import com.mogo.module.main.registercenter.MogoRegisterCenterHandler;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
@@ -49,9 +50,9 @@ import java.util.Map;
* 卡片加载
*/
public class MogoModulesManager implements MogoModulesHandler,
IMogoMapListener,
IMogoNaviListener,
IMogoLocationListener {
IMogoMapListener,
IMogoNaviListener,
IMogoLocationListener {
private static final String TAG = "MogoModulesManager";
@@ -59,21 +60,26 @@ public class MogoModulesManager implements MogoModulesHandler,
private Map<MogoModule, IMogoModuleProvider> mModuleProviders = new HashMap<>();
private IMogoAnalytics mTrackManager;
private IMogoMapService mapService;
private String mEnableModuleName = null;
private Runnable mMapLoadedCallback;
private BroadcastReceiver mReceiver;
public MogoModulesManager( MainActivity activity ) {
if ( activity == null ) {
throw new NullPointerException( "activity can't be null." );
public MogoModulesManager(MainActivity activity) {
if (activity == null) {
throw new NullPointerException("activity can't be null.");
}
this.mActivity = activity;
mTrackManager = (IMogoAnalytics) ARouter.getInstance()
.build(MogoServicePaths.PATH_UTILS_ANALYTICS)
.navigation();
mapService = (IMogoMapService) ARouter.getInstance().build(
MogoServicePaths.PATH_SERVICES_MAP
).navigation();
registerReceiver();
}
@@ -87,124 +93,140 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void loadModules() {
final List< MogoModule > modules = MogoModulePaths.getModules();
if ( modules != null && !modules.isEmpty() ) {
for ( MogoModule module : modules ) {
IMogoModuleProvider provider = load( module.getPath() );
if ( provider != null ) {
mModuleProviders.put( module, provider );
final List<MogoModule> modules = MogoModulePaths.getModules();
if (modules != null && !modules.isEmpty()) {
for (MogoModule module : modules) {
IMogoModuleProvider provider = load(module.getPath());
if (provider != null) {
mModuleProviders.put(module, provider);
}
}
}
}
@Override
public void setMapLoadedCallback( Runnable callback ) {
public void setMapLoadedCallback(Runnable callback) {
mMapLoadedCallback = callback;
}
@Override
public List< IMogoModuleProvider > loadCardsModule() {
final List< MogoModule > modules = MogoModulePaths.getModules();
final ArrayList< IMogoModuleProvider > providers = new ArrayList<>();
for ( MogoModule module : modules ) {
IMogoModuleProvider provider = mModuleProviders.get( module );
if ( provider.getType() == ModuleType.TYPE_CARD_FRAGMENT ) {
if ( mEnableModuleName == null ) {
public List<IMogoModuleProvider> loadCardsModule() {
final List<MogoModule> modules = MogoModulePaths.getModules();
final ArrayList<IMogoModuleProvider> providers = new ArrayList<>();
for (MogoModule module : modules) {
IMogoModuleProvider provider = mModuleProviders.get(module);
if (provider.getType() == ModuleType.TYPE_CARD_FRAGMENT) {
if (mEnableModuleName == null) {
mEnableModuleName = provider.getModuleName();
}
providers.add( provider );
providers.add(provider);
}
}
return providers;
}
@Override
public void loadMapModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance().build( MogoModulePaths.PATH_MODULE_MAP ).navigation( getContext() );
addFragment( provider, containerId );
public void loadMapModule(int containerId) {
IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
.build(MogoModulePaths.PATH_MODULE_MAP)
.navigation(getContext());
addFragment(provider, containerId);
}
@Override
public void loadAppsListModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance().build( MogoModulePaths.PATH_MODULE_APPS ).navigation( getContext() );
addFragment( provider, containerId );
public void loadAppsListModule(int containerId) {
IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
.build(MogoModulePaths.PATH_MODULE_APPS)
.navigation(getContext());
addFragment(provider, containerId);
}
@Override
public void loadExtensionsModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance().build( ExtensionsModuleConst.PATH_EXTENSION ).navigation( getContext() );
addFragment( provider, containerId );
public void loadExtensionsModule(int containerId) {
IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
.build(ExtensionsModuleConst.PATH_EXTENSION)
.navigation(getContext());
addFragment(provider, containerId);
}
@Override
public void loadEntrancesModule( int containerId ) {
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance().build( ExtensionsModuleConst.PATH_ENTRANCE ).navigation( getContext() );
addFragment( provider, containerId );
public void loadEntrancesModule(int containerId) {
IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
.build(ExtensionsModuleConst.PATH_ENTRANCE)
.navigation(getContext());
addFragment(provider, containerId);
}
private IMogoModuleProvider load( String path ) {
return ( IMogoModuleProvider ) ARouter.getInstance().build( path ).navigation( getContext() );
private IMogoModuleProvider load(String path) {
return (IMogoModuleProvider) ARouter.getInstance().build(path).navigation(getContext());
}
private void addFragment( IMogoModuleProvider provider, int containerId ) {
if ( provider == null ) {
Logger.e( TAG, "add fragment fail cause provider == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
private void addFragment(IMogoModuleProvider provider, int containerId) {
if (provider == null) {
Logger.e(TAG, "add fragment fail cause provider == null, container is %s",
ResourcesHelper.getResNameById(getApplicationContext(), containerId));
return;
}
final Fragment fragment = provider.createFragment( getContext(), null );
if ( fragment == null ) {
Logger.e( TAG, "add fragment fail cause fragment == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
final Fragment fragment = provider.createFragment(getContext(), null);
if (fragment == null) {
Logger.e(TAG, "add fragment fail cause fragment == null, container is %s",
ResourcesHelper.getResNameById(getApplicationContext(), containerId));
return;
}
mActivity.getSupportFragmentManager().beginTransaction()
.add( containerId, fragment, provider.getModuleName() )
.commitAllowingStateLoss();
.add(containerId, fragment, provider.getModuleName())
.commitAllowingStateLoss();
}
@Override
public void setModuleEnable( String module ) {
public void setModuleEnable(String module) {
// 仅操作上一个模块和当前模块
Iterator< IMogoModuleProvider > iterator = mModuleProviders.values().iterator();
Iterator<IMogoModuleProvider> iterator = mModuleProviders.values().iterator();
int counter = 0;
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoModuleProvider provider = iterator.next();
if ( provider == null ) {
if (provider == null) {
continue;
}
if ( provider.getType() != ModuleType.TYPE_CARD_FRAGMENT ) {
if (provider.getType() != ModuleType.TYPE_CARD_FRAGMENT) {
continue;
}
if ( TextUtils.equals( mEnableModuleName, provider.getModuleName() ) ) {
final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( mEnableModuleName );
if ( lifecycle != null ) {
if (TextUtils.equals(mEnableModuleName, provider.getModuleName())) {
final IMogoModuleLifecycle lifecycle =
MogoRegisterCenterHandler.getInstance().getLifecycleListener(mEnableModuleName);
if (lifecycle != null) {
try {
final long start = System.currentTimeMillis();
lifecycle.onDisable();
Logger.i(TAG, "set %s module disable event cost " + (System.currentTimeMillis() - start) + "ms", mEnableModuleName);
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
Logger.i(TAG,
"set %s module disable event cost " + (System.currentTimeMillis()
- start) + "ms", mEnableModuleName);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
counter++;
continue;
}
if ( TextUtils.equals( module, provider.getModuleName() ) ) {
final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( module );
if ( lifecycle != null ) {
if (TextUtils.equals(module, provider.getModuleName())) {
final IMogoModuleLifecycle lifecycle =
MogoRegisterCenterHandler.getInstance().getLifecycleListener(module);
if (lifecycle != null) {
try {
final long start = System.currentTimeMillis();
lifecycle.onPerform();
Logger.i(TAG, "set %s module perform event cost " + (System.currentTimeMillis() - start) + "ms", module);
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
Logger.i(TAG,
"set %s module perform event cost " + (System.currentTimeMillis()
- start) + "ms", module);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
counter++;
continue;
}
if ( counter == 2 ) {
if (counter == 2) {
break;
}
}
@@ -214,115 +236,121 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onMapLoaded() {
if ( mMapLoadedCallback != null ) {
if (mMapLoadedCallback != null) {
mMapLoadedCallback.run();
mMapLoadedCallback = null;
}
}
@Override
public void onTouch( MotionEvent motionEvent ) {
Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
if ( iterator == null ) {
public void onTouch(MotionEvent motionEvent) {
Iterator<IMogoMapListener> iterator =
MogoRegisterCenterHandler.getInstance().getMapListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoMapListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onTouch( motionEvent );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onTouch(motionEvent);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
}
@Override
public void onPOIClick( MogoPoi poi ) {
Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
if ( iterator == null ) {
public void onPOIClick(MogoPoi poi) {
Iterator<IMogoMapListener> iterator =
MogoRegisterCenterHandler.getInstance().getMapListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoMapListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onPOIClick( poi );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onPOIClick(poi);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
}
@Override
public void onMapClick( MogoLatLng latLng ) {
Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
if ( iterator == null ) {
public void onMapClick(MogoLatLng latLng) {
Iterator<IMogoMapListener> iterator =
MogoRegisterCenterHandler.getInstance().getMapListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoMapListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onMapClick( latLng );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onMapClick(latLng);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
}
@Override
public void onLockMap( boolean isLock ) {
Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
if ( iterator == null ) {
public void onLockMap(boolean isLock) {
Iterator<IMogoMapListener> iterator =
MogoRegisterCenterHandler.getInstance().getMapListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoMapListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onLockMap( isLock );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onLockMap(isLock);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
}
@Override
public void onMapModeChanged( EnumMapUI ui ) {
Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
if ( iterator == null ) {
public void onMapModeChanged(EnumMapUI ui) {
Iterator<IMogoMapListener> iterator =
MogoRegisterCenterHandler.getInstance().getMapListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoMapListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onMapModeChanged( ui );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onMapModeChanged(ui);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
}
@Override
public void onMapChanged( MogoLatLng location, float zoom, float tilt, float bearing ) {
Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
if ( iterator == null ) {
public void onMapChanged(MogoLatLng location, float zoom, float tilt, float bearing) {
Iterator<IMogoMapListener> iterator =
MogoRegisterCenterHandler.getInstance().getMapListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoMapListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onMapChanged( location, zoom, tilt, bearing );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onMapChanged(location, zoom, tilt, bearing);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -330,17 +358,18 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onInitNaviFailure() {
Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
if ( iterator == null ) {
Iterator<IMogoNaviListener> iterator =
MogoRegisterCenterHandler.getInstance().getNaviListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onInitNaviFailure();
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -348,17 +377,18 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onInitNaviSuccess() {
Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
if ( iterator == null ) {
Iterator<IMogoNaviListener> iterator =
MogoRegisterCenterHandler.getInstance().getNaviListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onInitNaviSuccess();
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -373,13 +403,13 @@ public class MogoModulesManager implements MogoModulesHandler,
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onNaviInfoUpdate( naviinfo );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onNaviInfoUpdate(naviinfo);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -395,13 +425,13 @@ public class MogoModulesManager implements MogoModulesHandler,
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onStartNavi();
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -416,13 +446,13 @@ public class MogoModulesManager implements MogoModulesHandler,
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onStopNavi();
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -430,17 +460,18 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onCalculateSuccess() {
Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
if ( iterator == null ) {
Iterator<IMogoNaviListener> iterator =
MogoRegisterCenterHandler.getInstance().getNaviListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onCalculateSuccess();
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -448,53 +479,56 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onoCalculateFailed() {
Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
if ( iterator == null ) {
Iterator<IMogoNaviListener> iterator =
MogoRegisterCenterHandler.getInstance().getNaviListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onoCalculateFailed();
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
}
@Override
public void onUpdateTraffic( MogoTraffic traffic ) {
Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
if ( iterator == null ) {
public void onUpdateTraffic(MogoTraffic traffic) {
Iterator<IMogoNaviListener> iterator =
MogoRegisterCenterHandler.getInstance().getNaviListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoNaviListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onUpdateTraffic( traffic );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onUpdateTraffic(traffic);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
}
@Override
public void onLocationChanged( MogoLocation location ) {
Iterator< IMogoLocationListener > iterator = MogoRegisterCenterHandler.getInstance().getLocationListeners();
if ( iterator == null ) {
public void onLocationChanged(MogoLocation location) {
Iterator<IMogoLocationListener> iterator =
MogoRegisterCenterHandler.getInstance().getLocationListeners();
if (iterator == null) {
return;
}
while ( iterator.hasNext() ) {
while (iterator.hasNext()) {
IMogoLocationListener listener = iterator.next();
if ( listener != null ) {
if (listener != null) {
try {
listener.onLocationChanged( location );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
listener.onLocationChanged(location);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -503,37 +537,37 @@ public class MogoModulesManager implements MogoModulesHandler,
public void registerReceiver() {
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive( Context context, Intent intent ) {
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if ( TextUtils.equals( action, Intent.ACTION_POWER_CONNECTED ) ) {
Iterator< IMogoModuleLifecycle > iterator = MogoRegisterCenterHandler.getInstance().getLifecycleListeners();
if ( iterator.hasNext() ) {
if (TextUtils.equals(action, Intent.ACTION_POWER_CONNECTED)) {
Iterator<IMogoModuleLifecycle> iterator =
MogoRegisterCenterHandler.getInstance().getLifecycleListeners();
if (iterator.hasNext()) {
iterator.next().accOn();
}
}
if ( TextUtils.equals( action, Intent.ACTION_POWER_DISCONNECTED ) ) {
} else if (TextUtils.equals(action, Intent.ACTION_POWER_DISCONNECTED)) {
}
}
};
IntentFilter inputFilter = new IntentFilter();
inputFilter.addAction( Intent.ACTION_POWER_CONNECTED );
inputFilter.addAction( Intent.ACTION_POWER_DISCONNECTED );
getApplicationContext().registerReceiver( mReceiver, inputFilter );
inputFilter.addAction(Intent.ACTION_POWER_CONNECTED);
inputFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
getApplicationContext().registerReceiver(mReceiver, inputFilter);
}
@Override
public void destroy() {
if ( mReceiver != null ) {
if (mReceiver != null) {
try {
getApplicationContext().unregisterReceiver( mReceiver );
} catch ( Exception e ) {
getApplicationContext().unregisterReceiver(mReceiver);
} catch (Exception e) {
e.printStackTrace();
}
}
mReceiver = null;
mActivity = null;
if ( mModuleProviders != null ) {
if (mModuleProviders != null) {
mModuleProviders.clear();
}
mModuleProviders = null;
@@ -542,13 +576,14 @@ public class MogoModulesManager implements MogoModulesHandler,
}
@Override
public boolean onMarkerClicked( IMogoMarker marker ) {
IMogoMarkerClickListener listener = MogoRegisterCenterHandler.getInstance().getMarkerListener( marker.getOwner() );
if ( listener != null ) {
public boolean onMarkerClicked(IMogoMarker marker) {
IMogoMarkerClickListener listener =
MogoRegisterCenterHandler.getInstance().getMarkerListener(marker.getOwner());
if (listener != null) {
try {
return listener.onMarkerClicked( marker );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
return listener.onMarkerClicked(marker);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
return false;

View File

@@ -24,5 +24,6 @@ public class MogoAddressManager implements IMogoAddressManager {
AddressManager.INSTANCE.init(context);
SearchServiceHolder.INSTANCE.init(context);
SettingManager.INSTANCE.init(context);
NaviManager.INSTANCE.init(context);
}
}

View File

@@ -0,0 +1,50 @@
package com.mogo.module.navi.manager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.text.TextUtils
import com.mogo.map.MogoLatLng
import com.mogo.module.common.MogoModulePaths
import com.mogo.module.navi.constants.SearchServiceHolder
import com.mogo.module.navi.ui.search.ChoosePathFragment
/**
*@author zyz
* 2020-01-18.
*/
object NaviManager {
private lateinit var mReceiver:BroadcastReceiver
private val AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV"
fun init(context: Context){
mReceiver = object : BroadcastReceiver() {
override fun onReceive(
context: Context,
intent: Intent
) {
val action = intent.action
if (TextUtils.equals(action, AUTONAVI_STANDARD_BROADCAST_RECV)) {
val key_type = intent.getIntExtra("KEY_TYPE", 0)
if (key_type == 10038) {
val lat = intent.getDoubleExtra("LAT", 0.0)
val lon = intent.getDoubleExtra("LON", 0.0)
var newInstance =
ChoosePathFragment.newInstance(
MogoLatLng(lat,lon)
)
SearchServiceHolder.push(
newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
)
}
}
}
}
val inputFilter = IntentFilter()
inputFilter.addAction(AUTONAVI_STANDARD_BROADCAST_RECV)
context.registerReceiver(mReceiver, inputFilter)
}
}

View File

@@ -40,6 +40,10 @@ public class CalculatePathAdapter extends RecycleBaseAdapter<MogoCalculatePath>
View mName = holder.getView(R.id.amap_calculate_item_strategy_name);
holder.setText(R.id.amap_calculate_item_strategy_name, item.getStrategyName());
mName.setBackgroundResource(getStrategyNameBkgResId(holder.getLayoutPosition()));
if (holder.getLayoutPosition()>=2) {
mName.setVisibility(View.GONE);
}
holder.setText(R.id.amap_calculate_item_strategy_time, item.getTime());
holder.setText(R.id.amap_calculate_item_strategy_distance, item.getDistance());
holder.setText(R.id.amap_calculate_item_strategy_desc, item.getDesc());

View File

@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#5B6CFF" />
<solid android:color="#FF8D32" />
<corners android:radius="5dp" />
</shape>
</item>

View File

@@ -44,21 +44,21 @@
<ScrollView
android:layout_width="match_parent"
android:paddingRight="@dimen/dp_160"
android:paddingLeft="@dimen/dp_160"
android:paddingRight="@dimen/module_search_dp_160"
android:paddingLeft="@dimen/module_search_dp_160"
app:layout_constraintTop_toBottomOf="@+id/rl_navi_setting_title"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:paddingBottom="@dimen/dp_150"
android:paddingBottom="@dimen/module_search_dp_150"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="180dp"
android:layout_height="@dimen/dp_120"
android:layout_marginTop="@dimen/dp_12"
android:layout_width="@dimen/module_search_180dp"
android:layout_height="@dimen/module_search_dp_120"
android:layout_marginTop="@dimen/dp_24"
android:background="@drawable/shape_round_gray"
android:orientation="horizontal"
android:gravity="center_vertical"
@@ -188,11 +188,11 @@
<TextView
android:id="@+id/tv_navi_sound"
android:layout_width="400px"
android:layout_height="45px"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:layout_marginTop="@dimen/dp_32"
android:text="@string/navi_setting_sound"
android:textColor="@color/white"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_navi_path"
@@ -201,11 +201,11 @@
<TextView
android:id="@+id/tv_navi_prefer"
android:layout_width="400px"
android:layout_height="45px"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:layout_marginTop="@dimen/dp_40"
android:text="@string/preference_navi"
android:textColor="@color/white"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
@@ -215,11 +215,11 @@
<TextView
android:id="@+id/tv_navi_sound_type"
android:layout_width="400px"
android:layout_height="45px"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:layout_marginTop="@dimen/dp_40"
android:text="@string/preference_navi_sound_type"
android:textColor="@color/white"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_navi_sound"
@@ -262,11 +262,11 @@
<TextView
android:id="@+id/tv_navi_day_night"
android:layout_width="400px"
android:layout_height="45px"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:layout_marginTop="@dimen/dp_40"
android:text="@string/preference_navi_sound_type"
android:textColor="@color/white"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rg_navi_sound_type"
@@ -315,11 +315,11 @@
<TextView
android:id="@+id/tv_navi_address"
android:layout_width="400px"
android:layout_height="45px"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_search_txt_setting_width"
android:layout_marginTop="@dimen/dp_40"
android:text="@string/preference_navi_address"
android:textColor="@color/white"
android:textColor="@color/white_80"
android:textSize="@dimen/txt_normal"
app:layout_constraintTop_toBottomOf="@id/rg_navi_day_night"
app:layout_constraintLeft_toLeftOf="parent"

View File

@@ -4,10 +4,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/dp_60"
android:paddingLeft="@dimen/dp_60"
android:paddingRight="@dimen/dp_60"
android:paddingTop="@dimen/dp_40"
android:paddingBottom="@dimen/moudle_search_fragment_padding"
android:paddingLeft="@dimen/moudle_search_fragment_padding"
android:paddingRight="@dimen/moudle_search_fragment_padding"
android:paddingTop="@dimen/moudle_search_fragment_padding_top"
android:clickable="true"
tools:context=".ui.search.SearchFragment"
style="@style/amap_fragment_container_padding_style"
@@ -17,26 +17,26 @@
<TextView
android:layout_width="@dimen/dp_266"
android:layout_width="@dimen/module_search_btn_width"
android:text="@string/search_action"
android:layout_marginRight="@dimen/dp_8"
android:layout_marginRight="@dimen/module_search_btn_right_margin"
android:gravity="center"
android:id="@+id/tv_navi_search"
android:textColor="@color/white"
android:textSize="@dimen/sp_40"
android:textSize="@dimen/module_search_txt_big"
android:background="@drawable/shape_round_blue_grident"
app:layout_constraintRight_toRightOf="@+id/ll_navi_search"
app:layout_constraintTop_toTopOf="@+id/ll_navi_search"
app:layout_constraintBottom_toBottomOf="@+id/ll_navi_search"
android:layout_height="@dimen/dp_104"/>
android:layout_height="@dimen/module_search_btn_height"/>
<LinearLayout
android:id="@+id/ll_navi_home"
android:layout_width="@dimen/dp_568"
android:layout_height="@dimen/dp_120"
android:layout_width="@dimen/module_search_navi_home_width"
android:layout_height="@dimen/module_search_navi_home_height"
android:background="@drawable/shape_round_gray"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_32"
android:layout_marginLeft="@dimen/module_search_navi_home_margin_left"
android:orientation="horizontal"
app:layout_constraintLeft_toRightOf="@id/ll_navi_search"
app:layout_constraintTop_toTopOf="parent"
@@ -47,7 +47,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="@dimen/txt_normal"
android:paddingLeft="@dimen/dp_75"
android:paddingLeft="@dimen/module_search_navi_home_padding_left"
android:id="@+id/tv_navi_home"
android:gravity="center_vertical"
android:drawableLeft="@mipmap/icon_navi_home"
@@ -57,7 +57,7 @@
<View
android:layout_width="1dp"
android:layout_height="@dimen/dp_72"
android:layout_height="@dimen/module_search_dp_72"
android:background="#17D8D8D8"
/>
@@ -65,7 +65,7 @@
android:layout_width="0dp"
android:textSize="@dimen/txt_normal"
android:text="@string/navi_company"
android:paddingLeft="@dimen/dp_75"
android:paddingLeft="@dimen/module_search_navi_home_padding_left"
android:id="@+id/tv_navi_company"
android:gravity="center_vertical"
android:drawableLeft="@mipmap/icon_navi_company"
@@ -77,11 +77,11 @@
</LinearLayout>
<RelativeLayout
android:id="@+id/rl_navi_history"
android:layout_width="600dp"
android:layout_height="@dimen/dp_778"
android:layout_marginTop="@dimen/dp_32"
android:layout_width="@dimen/module_search_dp_1200"
android:layout_height="@dimen/module_search_dp_778"
android:layout_marginTop="@dimen/module_search_dp_32"
android:background="@drawable/shape_round_gray"
android:padding="@dimen/dp_40"
android:padding="@dimen/module_search_dp_40"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_navi_search"
>
@@ -111,7 +111,7 @@
android:layout_width="match_parent"
android:id="@+id/rv_navi_history"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_60"
android:layout_marginTop="@dimen/module_search_dp_60"
/>
</RelativeLayout>
@@ -120,8 +120,8 @@
<androidx.recyclerview.widget.RecyclerView
android:visibility="gone"
android:layout_marginTop="@dimen/dp_32"
android:padding="@dimen/dp_37"
android:layout_width="600dp"
android:padding="@dimen/module_search_dp_37"
android:layout_width="@dimen/module_search_dp_1200"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@id/tv_navi_wash"
android:background="@drawable/shape_round_gray"
@@ -133,7 +133,7 @@
<TextView
android:visibility="gone"
android:layout_marginTop="@dimen/dp_32"
android:layout_width="600dp"
android:layout_width="@dimen/module_search_dp_1200"
android:layout_height="0dp"
android:gravity="center"
android:textColor="@color/white"

View File

@@ -12,8 +12,9 @@
<androidx.cardview.widget.CardView
android:id="@+id/cv_search_result"
android:layout_width="@dimen/dp_838"
android:layout_height="@dimen/dp_778"
android:layout_width="@dimen/module_search_dp_838"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="@dimen/dp_32"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_navi_search"
@@ -24,17 +25,33 @@
android:id="@+id/rv_search_result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/dp_100"
android:layout_marginBottom="@dimen/module_search_category_margin_bottom"
/>
<View
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:background="#3F4057"
android:layout_height="@dimen/module_search_category_margin_bottom"/>
<View
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:background="@color/white_10"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/module_search_category_margin_bottom"/>
<TextView
android:id="@+id/tv_navi_navi"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_margin="@dimen/dp_40"
android:text="@string/navi_to_there"
android:layout_height="@dimen/dp_104"
android:layout_height="@dimen/module_search_dp_104"
style="@style/txt_btn"
/>
</androidx.cardview.widget.CardView>

View File

@@ -12,18 +12,18 @@
<include layout="@layout/include_search_bar" />
<TextView
android:layout_width="@dimen/dp_266"
android:layout_width="@dimen/module_search_btn_width"
android:text="@string/set_as_home_navi"
android:layout_marginRight="@dimen/dp_8"
android:layout_marginRight="@dimen/module_search_btn_right_margin"
android:gravity="center"
android:id="@+id/tv_set_as_home"
android:textColor="@color/white"
android:textSize="@dimen/sp_40"
android:textSize="@dimen/module_search_txt_big"
android:background="@drawable/shape_round_blue_grident"
app:layout_constraintRight_toRightOf="@+id/ll_navi_search"
app:layout_constraintTop_toTopOf="@+id/ll_navi_search"
app:layout_constraintBottom_toBottomOf="@+id/ll_navi_search"
android:layout_height="@dimen/dp_104"/>
android:layout_height="@dimen/module_search_btn_height"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -3,8 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll_navi_search"
android:layout_width="600dp"
android:layout_height="@dimen/dp_120"
android:layout_width="@dimen/moudle_search_et_width"
android:layout_height="@dimen/moudle_search_et_hight"
android:background="@drawable/shape_round_gray"
android:gravity="center_vertical"
android:orientation="horizontal"
@@ -13,22 +13,23 @@
tools:showIn="@layout/fragment_search"
>
<ImageView
android:layout_width="@dimen/dp_80"
android:layout_width="@dimen/moudle_search_iv_back_hight"
android:id="@+id/iv_navi_back"
android:layout_height="@dimen/dp_80"
android:layout_marginLeft="@dimen/dp_24"
android:layout_marginRight="@dimen/dp_20"
android:layout_height="@dimen/moudle_search_iv_back_hight"
android:layout_marginLeft="@dimen/moudle_search_iv_back_margin_left"
android:layout_marginRight="@dimen/moudle_search_iv_back_margin_right"
android:src="@mipmap/icon_back"
/>
<EditText
android:layout_width="0dp"
android:singleLine="true"
android:layout_marginRight="@dimen/dp_50"
android:layout_marginRight="@dimen/module_search_et_margin_right"
android:id="@+id/et_navi_search"
android:background="@null"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:textSize="@dimen/module_search_et_text_size"
android:imeOptions="actionDone"
android:hint="@string/hint_map_search"
android:textColor="@color/white"

View File

@@ -3,13 +3,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_180"
android:layout_height="@dimen/module_search_dp_180"
>
<ImageView
android:id="@+id/iv_position"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
android:layout_width="@dimen/module_search_dp_80"
android:layout_height="@dimen/module_search_dp_80"
android:src="@mipmap/icon_navi_position"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
@@ -19,12 +19,12 @@
<TextView
android:id="@+id/tv_position"
android:layout_width="0dp"
android:layout_height="@dimen/dp_70"
android:layout_height="@dimen/module_search_dp_70"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_30"
android:gravity="center_vertical"
android:textColor="@color/white"
android:textSize="25sp"
android:textSize="@dimen/module_search_25sp"
app:layout_constraintLeft_toRightOf="@id/iv_position"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
@@ -34,7 +34,7 @@
<TextView
android:id="@+id/tv_position_des"
android:layout_width="0dp"
android:layout_height="@dimen/dp_42"
android:layout_height="@dimen/module_search_dp_42"
android:layout_marginTop="@dimen/dp_8"
android:ellipsize="marquee"
android:singleLine="true"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- module_main_activity_main.xml-->
<dimen name="moudle_search_fragment_padding" >32px</dimen>
<dimen name="moudle_search_fragment_padding_top">32px</dimen>
<dimen name="moudle_search_et_width">640px</dimen>
<dimen name="moudle_search_et_hight">64px</dimen>
<dimen name="moudle_search_iv_back_hight">42px</dimen>
<dimen name="moudle_search_iv_back_margin_left">12px</dimen>
<dimen name="moudle_search_iv_back_margin_right">10px</dimen>
<dimen name="module_search_et_margin_right">30px</dimen>
<dimen name="module_search_et_text_size">22px</dimen>
<dimen name="module_search_btn_width">142px</dimen>
<dimen name="module_search_btn_right_margin">4px</dimen>
<dimen name="module_search_txt_big">22px</dimen>
<dimen name="module_search_btn_height">55.5px</dimen>
<dimen name="module_search_navi_home_width">304px</dimen>
<dimen name="module_search_navi_home_height">64px</dimen>
<dimen name="module_search_navi_home_margin_left">16px</dimen>
<dimen name="txt_normal">18px</dimen>
<dimen name="module_search_dp_72">38px</dimen>
<dimen name="module_search_dp_75">75px</dimen>
<dimen name="module_search_navi_home_padding_left">40px</dimen>
<dimen name="module_search_dp_778">410px</dimen>
<dimen name="module_search_dp_1200">640px</dimen>
<dimen name="module_search_dp_32">16px</dimen>
<dimen name="module_search_dp_40">20px</dimen>
<dimen name="module_search_dp_60">30px</dimen>
<dimen name="module_search_dp_37">20px</dimen>
<dimen name="txt_large">28px</dimen>
<dimen name="module_search_dp_268">144px</dimen>
<dimen name="module_search_dp_236">126px</dimen>
<dimen name="module_search_dp_180">96px</dimen>
<dimen name="module_search_dp_80">42px</dimen>
<dimen name="module_search_dp_70">38px</dimen>
<dimen name="module_search_25sp">28px</dimen>
<dimen name="module_search_dp_42">23px</dimen>
<dimen name="module_search_dp_160">96px</dimen>
<dimen name="module_search_dp_150">69px</dimen>
<dimen name="module_search_180dp">192px</dimen>
<dimen name="module_search_dp_120">64px</dimen>
<dimen name="module_search_txt_setting_width">24px</dimen>
<dimen name="module_search_dp_838">446px</dimen>
<dimen name="module_search_category_margin_bottom">96px</dimen>
<dimen name="module_search_dp_104">56px</dimen>
<dimen name="module_search_strategy_name_width" >100px</dimen>
</resources>

View File

@@ -4,4 +4,47 @@
<dimen name="fragment_left_margin">@dimen/dp_60</dimen>
<dimen name="txt_title">@dimen/sp_40</dimen>
<dimen name="txt_large">25sp</dimen>
<dimen name="moudle_search_fragment_padding" >@dimen/dp_60</dimen>
<dimen name="moudle_search_fragment_padding_top">@dimen/dp_40</dimen>
<dimen name="moudle_search_et_width">600dp</dimen>
<dimen name="moudle_search_et_hight">@dimen/dp_120</dimen>
<dimen name="moudle_search_iv_back_hight">@dimen/dp_80</dimen>
<dimen name="moudle_search_iv_back_margin_left">@dimen/dp_24</dimen>
<dimen name="moudle_search_iv_back_margin_right">@dimen/dp_20</dimen>
<dimen name="module_search_et_margin_right">@dimen/dp_50</dimen>
<dimen name="module_search_et_text_size">40px</dimen>
<dimen name="module_search_btn_width">266px</dimen>
<dimen name="module_search_btn_right_margin">8px</dimen>
<dimen name="module_search_txt_big">40px</dimen>
<dimen name="module_search_btn_height">104px</dimen>
<dimen name="module_search_navi_home_width">568px</dimen>
<dimen name="module_search_navi_home_height">120px</dimen>
<dimen name="module_search_navi_home_margin_left">32px</dimen>
<dimen name="module_search_navi_home_padding_left">75px</dimen>
<dimen name="module_search_dp_72">72px</dimen>
<dimen name="module_search_dp_75">75px</dimen>
<dimen name="module_search_dp_778">778px</dimen>
<dimen name="module_search_dp_1200">1200px</dimen>
<dimen name="module_search_dp_32">32px</dimen>
<dimen name="module_search_dp_40">40px</dimen>
<dimen name="module_search_dp_60">60px</dimen>
<dimen name="module_search_dp_37">37px</dimen>
<dimen name="module_search_dp_268">268px</dimen>
<dimen name="module_search_dp_236">236px</dimen>
<dimen name="module_search_dp_180">180px</dimen>
<dimen name="module_search_dp_80">80px</dimen>
<dimen name="module_search_dp_70">70px</dimen>
<dimen name="module_search_25sp">25sp</dimen>
<dimen name="module_search_dp_42">42px</dimen>
<dimen name="module_search_dp_160">160px</dimen>
<dimen name="module_search_dp_150">150px</dimen>
<dimen name="module_search_180dp">180dp</dimen>
<dimen name="module_search_dp_120">120px</dimen>
<dimen name="module_search_txt_setting_width">45px</dimen>
<dimen name="module_search_dp_838">838px</dimen>
<dimen name="module_search_category_margin_bottom">184px</dimen>
<dimen name="module_search_dp_104">104px</dimen>
<dimen name="module_search_strategy_name_width" >154px</dimen>
</resources>

View File

@@ -17,23 +17,23 @@
</style>
<style name="txt_navi_style">
<item name="android:layout_width">@dimen/dp_268</item>
<item name="android:layout_width">@dimen/module_search_dp_268</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:textSize">@dimen/txt_normal</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/shape_round_gray</item>
<item name="android:layout_height">@dimen/dp_236</item>
<item name="android:layout_height">@dimen/module_search_dp_236</item>
<item name="android:paddingTop">@dimen/dp_44</item>
</style>
<style name="rb_setting">
<item name="android:layout_width">180dp</item>
<item name="android:layout_width">@dimen/module_search_180dp</item>
<item name="android:button">@null</item>
<item name="android:gravity">center</item>
<item name="android:textSize">@dimen/sp_40</item>
<item name="android:textColor">@color/selector_white_gray</item>
<item name="android:layout_height">@dimen/dp_120</item>
<item name="android:layout_height">@dimen/module_search_dp_120</item>
<item name="android:background">@drawable/selector_setting_bg</item>
</style>