diff --git a/app/build.gradle b/app/build.gradle index e40891f0bf..6c342f9507 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,8 +61,8 @@ dependencies { // implementation rootProject.ext.dependencies.moduledemo // implementation rootProject.ext.dependencies.moduledemo2 -// implementation rootProject.ext.dependencies.modulechattingprovider -// implementation rootProject.ext.dependencies.modulechatting + implementation rootProject.ext.dependencies.modulechattingprovider + implementation rootProject.ext.dependencies.modulechatting implementation rootProject.ext.dependencies.moduleonlinecar diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index d2f1206eb8..9bf35c4d79 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -6,10 +6,11 @@ import androidx.multidex.MultiDex; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.debug.DebugConfig; +import com.mogo.module.carchatting.CallChatConstant; import com.mogo.module.common.MogoModule; import com.mogo.module.common.MogoModulePaths; import com.mogo.module.onlinecar.OnLineCarConstants; -import com.mogo.tanlu.constant.TanluConstants; +import com.mogo.module.tanlu.constant.TanluConstants; /** * @author congtaowang @@ -27,8 +28,7 @@ public class MogoApplication extends AbsMogoApplication { DebugConfig.setNetMode( DebugConfig.NET_MODE_QA ); MogoModulePaths.addModule(new MogoModule(OnLineCarConstants.TAG, "CARD_TYPE_ROAD_ONLINECAR")); MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, "CARD_TYPE_ROAD_CODITION" ) ); - MogoModulePaths.addModule(new MogoModule( OnLineCarConstants.TAG, "CARD_TYPE_ROAD_ONLINECAR")); -// MogoModulePaths.addModule(new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME)); + MogoModulePaths.addModule(new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME)); } @Override diff --git a/foudations/mogo-connection/src/main/java/com/mogo/connection/socket/SocketManager.java b/foudations/mogo-connection/src/main/java/com/mogo/connection/socket/SocketManager.java index e5fe7f1b36..53dac19903 100644 --- a/foudations/mogo-connection/src/main/java/com/mogo/connection/socket/SocketManager.java +++ b/foudations/mogo-connection/src/main/java/com/mogo/connection/socket/SocketManager.java @@ -88,7 +88,7 @@ public class SocketManager implements IMogoSocketManager, OnSocketReceiveCallbac listener.onMsgReceived( GsonUtil.objectFromJson( payload.getPayload().toStringUtf8(), listener.target() ) ); } } catch ( InvalidProtocolBufferException e ) { - Logger.e( TAG, "parse msg error.", e ); + Logger.e( TAG, e, "parse msg error." ); } } diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java index d0dcbdfe6a..42ef51dff1 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java @@ -34,6 +34,8 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme private View mExit; private IMogoFragmentManager mMogoFragmentManager; + private View mLoadingView; + @Override protected int getLayoutId() { return R.layout.module_apps_fragment_apps; @@ -62,6 +64,8 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme // } // } ); // mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED ); + mLoadingView = findViewById( R.id.module_apps_id_loading ); + mLoadingView.setVisibility( View.VISIBLE ); } @NonNull @@ -78,6 +82,7 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme @Override public void renderApps( Map< Integer, List< AppInfo > > appInfos ) { + mLoadingView.setVisibility( View.GONE ); if ( mAppsPagerAdapter == null ) { mAppsPagerAdapter = new AppsPagerAdapter( appInfos ); mAppsPager.setAdapter( mAppsPagerAdapter ); @@ -88,5 +93,6 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme } else { mAppsPagerAdapter.setPagedApps( appInfos ); } + mLoadingView.setVisibility( View.GONE ); } } diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java index 9aade9ba5d..cf5ff4e31b 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java @@ -1,26 +1,16 @@ package com.mogo.module.apps; import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.graphics.drawable.Drawable; import androidx.annotation.NonNull; import androidx.lifecycle.LifecycleOwner; -import androidx.lifecycle.Observer; import com.mogo.commons.mvp.Presenter; import com.mogo.module.apps.model.AppInfo; +import com.mogo.module.apps.model.AppsModel; import com.mogo.utils.ThreadPoolService; import com.mogo.utils.TipToast; import com.mogo.utils.UiThreadHandler; -import com.mogo.utils.logger.Logger; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; /** * @author congtaowang @@ -32,13 +22,8 @@ public class AppsPresenter extends Presenter< AppsView > { private static final String TAG = "AppsPresenter"; - private AppFilter mAppFilter; - public AppsPresenter( AppsView view ) { super( view ); - RefreshAppsListLiveData.getInstance().observeForever( s -> { - renderAppsList(); - } ); } @Override @@ -49,45 +34,17 @@ public class AppsPresenter extends Presenter< AppsView > { private void renderAppsList() { ThreadPoolService.execute( () -> { - final Map< Integer, List< AppInfo > > appInfoList = loadAppsList(); - UiThreadHandler.post( () -> { - if ( mView != null ) { - mView.renderApps( appInfoList ); - } + AppsModel.getInstance( getContext() ).load( appInfoList -> { + UiThreadHandler.post( () -> { + if ( mView != null ) { + mView.renderApps( appInfoList ); + } + } ); } ); + } ); } - private Map< Integer, List< AppInfo > > loadAppsList() { - Logger.i( TAG, "load apps list." ); - if ( mAppFilter == null ) { - mAppFilter = new AppFilterImpl( getContext() ); - } - - final Map< Integer, List< AppInfo > > pagedApps = new HashMap<>(); - final PackageManager packageManager = getContext().getPackageManager(); - List< PackageInfo > packages = packageManager.getInstalledPackages( 0 ); - int counter = 0; - for ( int i = 0; i < packages.size(); ++i ) { - PackageInfo packageInfo = packages.get( i ); - if ( mAppFilter.filter( packageInfo ) ) { - continue; - } - int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE; - if ( !pagedApps.containsKey( page ) ) { - pagedApps.put( page, new ArrayList<>() ); - } - String appName = packageInfo.applicationInfo.loadLabel( packageManager ).toString(); - String packageName = packageInfo.packageName; - String versionName = packageInfo.versionName; - int versionCode = packageInfo.versionCode; - Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager ); - AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon ); - pagedApps.get( page ).add( appInfo ); - } - return pagedApps; - } - public void launch( AppInfo appInfo ) { if ( appInfo == null ) { return; diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/RefreshAppsListLiveData.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/RefreshAppsListLiveData.java deleted file mode 100644 index 47ca92529a..0000000000 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/RefreshAppsListLiveData.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mogo.module.apps; - -import androidx.lifecycle.MutableLiveData; - -/** - * @author congtaowang - * @since 2019-12-30 - *

- * 刷新app列表 - */ -public class RefreshAppsListLiveData extends MutableLiveData< String > { - - private static volatile RefreshAppsListLiveData sInstance; - - private RefreshAppsListLiveData() { - } - - public static RefreshAppsListLiveData getInstance() { - if ( sInstance == null ) { - synchronized ( RefreshAppsListLiveData.class ) { - if ( sInstance == null ) { - sInstance = new RefreshAppsListLiveData(); - } - } - } - return sInstance; - } - - public synchronized void release() { - sInstance = null; - } -} diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppLoadCallback.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppLoadCallback.java new file mode 100644 index 0000000000..af16816210 --- /dev/null +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppLoadCallback.java @@ -0,0 +1,15 @@ +package com.mogo.module.apps.model; + +import java.util.List; +import java.util.Map; + +/** + * @author congtaowang + * @since 2020-01-09 + *

+ * 描述 + */ +public interface AppLoadCallback { + + void onLoaded( Map< Integer, List< AppInfo > > appInfos ); +} diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java new file mode 100644 index 0000000000..e637c40733 --- /dev/null +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java @@ -0,0 +1,185 @@ +package com.mogo.module.apps.model; + +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.graphics.drawable.Drawable; +import android.text.TextUtils; + +import com.mogo.module.apps.AppFilter; +import com.mogo.module.apps.AppFilterImpl; +import com.mogo.module.apps.AppsConst; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * @author congtaowang + * @since 2020-01-09 + *

+ * 加载并保存 app 列表 + */ +public class AppsModel { + + private static volatile AppsModel sInstance; + private final Context mContext; + + private AppFilter mAppFilter; + + private Map< Integer, List< AppInfo > > mPagedApps = new HashMap<>(); + + private AppsModel( Context context ) { + mContext = context; + mAppFilter = new AppFilterImpl( context ); + } + + public static AppsModel getInstance( Context context ) { + if ( sInstance == null ) { + synchronized ( AppsModel.class ) { + if ( sInstance == null ) { + sInstance = new AppsModel( context ); + } + } + } + return sInstance; + } + + + private AtomicBoolean mIsLoaded = new AtomicBoolean( false ); + + public synchronized void release() { + sInstance = null; + } + + public void load( AppLoadCallback callback ) { + if ( !mPagedApps.isEmpty() ) { + if ( callback != null ) { + callback.onLoaded( mPagedApps ); + } + return; + } + final PackageManager packageManager = mContext.getPackageManager(); + List< PackageInfo > packages = packageManager.getInstalledPackages( 0 ); + int counter = 0; + for ( int i = 0; i < packages.size(); ++i ) { + PackageInfo packageInfo = packages.get( i ); + if ( mAppFilter.filter( packageInfo ) ) { + continue; + } + int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE; + if ( !mPagedApps.containsKey( page ) ) { + mPagedApps.put( page, new ArrayList<>() ); + } + String appName = packageInfo.applicationInfo.loadLabel( packageManager ).toString(); + String packageName = packageInfo.packageName; + String versionName = packageInfo.versionName; + int versionCode = packageInfo.versionCode; + Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager ); + AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon ); + mPagedApps.get( page ).add( appInfo ); + } + if ( callback != null ) { + callback.onLoaded( mPagedApps ); + } + mIsLoaded.set( true ); + } + + public void appAdded( String packageName ) { + if ( !mIsLoaded.get() ) { + return; + } + if ( TextUtils.isEmpty( packageName ) ) { + return; + } + if ( mPagedApps.isEmpty() ) { + return; + } + try { + final PackageManager packageManager = mContext.getPackageManager(); + PackageInfo packageInfo = packageManager.getPackageInfo( packageName, 0 ); + if ( !mAppFilter.filter( packageInfo ) ) { + String appName = packageInfo.applicationInfo.loadLabel( packageManager ).toString(); + String versionName = packageInfo.versionName; + int versionCode = packageInfo.versionCode; + Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager ); + AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon ); + int pageIndex = getPageIndex( packageName, true ); + if ( !mPagedApps.containsKey( pageIndex ) ) { + mPagedApps.put( pageIndex, new ArrayList<>() ); + } + mPagedApps.get( pageIndex ).add( appInfo ); + } + } catch ( PackageManager.NameNotFoundException e ) { + e.printStackTrace(); + } + } + + private int getPageIndex( String packageName, boolean add ) { + int totalPages = mPagedApps.size(); + if ( add ) { + if ( totalPages == 0 ) { + return 0; + } else { + if ( mPagedApps.get( totalPages - 1 ).size() == AppsConst.TOTAL_SIZE_EACH_PAGE ) { + return totalPages + 1; + } else { + return totalPages; + } + } + } else { + if ( totalPages == 0 ) { + return -1; + } + int pageIndex = -1; + for ( int i = 0; i < totalPages; i++ ) { + for ( AppInfo appInfo : mPagedApps.get( i ) ) { + if ( TextUtils.equals( appInfo.getPackageName(), packageName ) ) { + pageIndex = i; + } + } + } + return pageIndex; + } + } + + public void appRemoved( String packageName ) { + if ( !mIsLoaded.get() ) { + return; + } + if ( TextUtils.isEmpty( packageName ) ) { + return; + } + try { + final PackageManager packageManager = mContext.getPackageManager(); + PackageInfo packageInfo = packageManager.getPackageInfo( packageName, 0 ); + if ( !mAppFilter.filter( packageInfo ) ) { + int pageIndex = getPageIndex( packageName, false ); + if ( pageIndex == -1 ) { + return; + } + int totalPages = mPagedApps.size(); + List< AppInfo > dynamicAppsList = new ArrayList<>(); + for ( int i = pageIndex; i < totalPages; i++ ) { + dynamicAppsList.addAll( mPagedApps.remove( i ) ); + } + int counter = 0; + for ( int i = 0; i < dynamicAppsList.size(); i++ ) { + AppInfo appInfo = dynamicAppsList.get( i ); + if ( TextUtils.equals( appInfo.getPackageName(), packageName ) ) { + continue; + } + int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE + pageIndex; + if ( !mPagedApps.containsKey( page ) ) { + mPagedApps.put( page, new ArrayList<>() ); + } + mPagedApps.get( page ).add( appInfo ); + } + } + } catch ( PackageManager.NameNotFoundException e ) { + e.printStackTrace(); + } + } +} diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java index 218704c86a..e3e599243f 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/receiver/AppInstallReceiver.java @@ -4,9 +4,8 @@ package com.mogo.module.apps.receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; -import com.mogo.module.apps.RefreshAppsListLiveData; +import com.mogo.module.apps.model.AppsModel; public class AppInstallReceiver extends BroadcastReceiver { @@ -14,31 +13,23 @@ public class AppInstallReceiver extends BroadcastReceiver { public void onReceive( Context context, Intent intent ) { if ( intent.getAction().equals( Intent.ACTION_PACKAGE_ADDED ) ) { String packageName = intent.getData().getSchemeSpecificPart(); - notifyRefreshAppsList( packageName ); + AppsModel.getInstance( context ).appAdded( packageName ); } if ( intent.getAction().equals( Intent.ACTION_PACKAGE_REMOVED ) ) { String packageName = intent.getData().getSchemeSpecificPart(); - notifyRefreshAppsList( packageName ); + AppsModel.getInstance( context ).appRemoved( packageName ); } if ( intent.getAction().equals( Intent.ACTION_PACKAGE_REPLACED ) ) { String packageName = intent.getData().getSchemeSpecificPart(); - notifyRefreshAppsList( packageName ); } if ( intent.getAction().equals( Intent.ACTION_PACKAGE_CHANGED ) ) { String packageName = intent.getData().getSchemeSpecificPart(); - notifyRefreshAppsList( packageName ); } if ( intent.getAction().equals( Intent.ACTION_PACKAGE_RESTARTED ) ) { String packageName = intent.getData().getSchemeSpecificPart(); - notifyRefreshAppsList( packageName ); } if ( intent.getAction().equals( Intent.ACTION_PACKAGE_DATA_CLEARED ) ) { String packageName = intent.getData().getSchemeSpecificPart(); - notifyRefreshAppsList( packageName ); } } - - private void notifyRefreshAppsList( String packageName ) { - RefreshAppsListLiveData.getInstance().postValue( packageName ); - } } \ No newline at end of file diff --git a/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml b/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml index 85340fa44d..86f95931b2 100644 --- a/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml +++ b/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml @@ -30,4 +30,10 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="@dimen/dp_210" /> + + \ No newline at end of file diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModule.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModule.java index 5a4f67162a..45e1e0bfc8 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModule.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModule.java @@ -18,6 +18,11 @@ public class MogoModule { */ private String mName; + /** + * 语音指令通过广播传递数据 action. + */ + private String mVoiceAction; + /** * @param path 模块加载路径 * @param name 模块名称 @@ -32,15 +37,26 @@ public class MogoModule { return mPath; } - public void setPath( String path ) { + public MogoModule setPath( String path ) { this.mPath = path; + return this; } public String getName() { return mName; } - public void setName( String name ) { + public MogoModule setName( String name ) { this.mName = name; + return this; + } + + public String getVoiceAction() { + return mVoiceAction; + } + + public MogoModule setVoiceAction( String voiceAction ) { + this.mVoiceAction = voiceAction; + return this; } } diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java index c668d6baf8..2eb363ccd7 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java @@ -45,7 +45,7 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements try { refreshTimeAndDate(); } catch ( Exception e ) { - Logger.e( TAG, "error. ", e ); + Logger.e( TAG, e, "error. " ); } } }; diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/weather/WeatherModel.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/weather/WeatherModel.java index 587bc387f0..389aff46a2 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/weather/WeatherModel.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/weather/WeatherModel.java @@ -57,14 +57,14 @@ public class WeatherModel { try { queryWeatherInformation(); } catch ( Exception e ) { - Logger.e( TAG, "error. ", e ); + Logger.e( TAG, e, "error. " ); } } }; try { mContentResolver.registerContentObserver( mWeatherUri, false, mContentObserver ); } catch ( Exception e ) { - Logger.e( TAG, "error when query weather info.", e ); + Logger.e( TAG, e, "error when query weather info." ); } } diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml index 2d54723c23..be17991ae9 100644 --- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml +++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml @@ -97,7 +97,8 @@ android:layout_width="match_parent" android:layout_height="@dimen/dp_92" android:background="@drawable/module_map_dw_top_corner_bkg" - android:orientation="vertical"> + android:orientation="vertical" + android:visibility="gone"> impleme super.onCreate( savedInstanceState ); MogoModulePaths.addModule( new MogoModule( MogoModulePaths.PATH_MODULE_APPS, MogoModulePaths.PATH_MODULE_APPS ) ); - MogoModulePaths.addModule( new MogoModule( MogoModulePaths.PATH_MODULE_MAP, MogoModulePaths.PATH_MODULE_MAP ) ); + MogoModulePaths.addModule( new MogoModule( MogoModulePaths.PATH_MODULE_MAP, MogoModulePaths.PATH_MODULE_MAP ).setVoiceAction( VoiceConstants.ACTION_GAODE_SDK_NAVI_RECV ) ); MogoModulePaths.addModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) ); MogoModulePaths.addModule( new MogoModule( ExtensionsModuleConst.PATH_EXTENSION, ExtensionsModuleConst.TYPE ) ); MogoModulePaths.addModule( new MogoModule( ExtensionsModuleConst.PATH_ENTRANCE, ExtensionsModuleConst.TYPE_ENTRANCE ) ); diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java index 24e6b114d6..231b29f3ae 100644 --- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java +++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragment.java @@ -5,10 +5,14 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.mvp.MvpFragment; import com.mogo.map.IMogoMap; import com.mogo.map.IMogoUiSettings; import com.mogo.map.MogoMapView; +import com.mogo.map.uicontroller.IMogoMapUIController; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.voice.IMogoVoiceManager; /** * @author congtaowang @@ -23,6 +27,8 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements private MogoMapView mMogoMapView; private IMogoMap mMogoMap; + private IMogoVoiceManager mMogoVoiceManager; + @Override protected int getLayoutId() { return R.layout.module_map_fragment_map; @@ -48,6 +54,8 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements mMogoMapView.onCreate( savedInstanceState ); } initMapView(); + mMogoVoiceManager = ( IMogoVoiceManager ) ARouter.getInstance().build( MogoServicePaths.PATH_VOICE_MANAGER ).navigation( getContext() ); + mMogoVoiceManager.registerIntentListener( VoiceConstants.ACTION_GAODE_SDK_NAVI_RECV, mPresenter ); } @Override @@ -66,14 +74,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements } } - @Override - public void onDestroyView() { - super.onDestroyView(); - if ( mMogoMapView != null ) { - mMogoMapView.onDestroy(); - } - } - @Override public void onLowMemory() { super.onLowMemory(); @@ -109,4 +109,20 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements } } } + + @Override + public IMogoMapUIController getUIController() { + return mMogoMap.getUIController(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if ( mMogoMapView != null ) { + mMogoMapView.onDestroy(); + } + if ( mMogoVoiceManager != null ) { + mMogoVoiceManager.unregisterIntentListener( VoiceConstants.ACTION_GAODE_SDK_NAVI_RECV ); + } + } } diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java index 55c045ca9f..a7964b911b 100644 --- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java +++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java @@ -1,6 +1,17 @@ package com.mogo.module.map; +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; + +import androidx.annotation.NonNull; +import androidx.lifecycle.LifecycleOwner; + import com.mogo.commons.mvp.Presenter; +import com.mogo.commons.voice.AIAssist; +import com.mogo.commons.voice.IMogoVoiceCmdCallBack; +import com.mogo.map.uicontroller.EnumMapUI; +import com.mogo.service.voice.IMogoVoiceListener; /** * @author congtaowang @@ -8,11 +19,185 @@ import com.mogo.commons.mvp.Presenter; *

* 描述 */ -public class MapPresenter extends Presenter< MapView > { +public class MapPresenter extends Presenter< MapView > implements IMogoVoiceListener, IMogoVoiceCmdCallBack { + public MapPresenter( MapView view ) { super( view ); } + @Override + public void onCreate( @NonNull LifecycleOwner owner ) { + super.onCreate( owner ); + registerUnWakeupCmd(); + } + private void registerUnWakeupCmd() { + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_ZOOM_IN, VoiceConstants.CMD_MAP_ZOOM_IN_WAKE_UP_WORDS, this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_ZOOM_OUT, VoiceConstants.CMD_MAP_ZOOM_OUT_WAKE_UP_WORDS, this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_2D, VoiceConstants.CMD_MAP_2D_WAKE_UP_WORDS, this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_3D, VoiceConstants.CMD_MAP_3D_WAKE_UP_WORDS, this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_LIGHT_MODE, VoiceConstants.CMD_MAP_LIGHT_MODE_WAKE_UP_WORDS, this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_NIGHT_MODE, VoiceConstants.CMD_MAP_NIGHT_MODE_WAKE_UP_WORDS, this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_TRAFFIC_MODE, VoiceConstants.CMD_MAP_TRAFFIC_MODE_WAKE_UP_WORDS, this ); + AIAssist.getInstance( getContext() ).registerUnWakeupCommand( VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE, VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE_WAKE_UP_WORDS, this ); + } + + @Override + public void onIntentReceived( String action, Intent intent ) { + if ( !TextUtils.equals( action, VoiceConstants.ACTION_GAODE_SDK_NAVI_RECV ) ) { + return; + } + int type = intent.getExtras().getInt( VoiceConstants.EXTRA_KEY_TYPE ); + Bundle data = intent.getExtras(); + switch ( type ) { + case VoiceConstants.TYPE_START_NAVI: +// actions.onStartNavi(); + break; + case VoiceConstants.TYPE_STOP_NAVI: +// actions.onStopNavi(); + break; + case VoiceConstants.TYPE_NAVI_GUIDE_INFO: +// actions.onSpeakNaviGuideInfo(); + break; + case VoiceConstants.TYPE_MAP_UI_SETTING: + final int actionType = data.getInt( VoiceConstants.EXTRA_TYPE, 0 ); + final int operateAction = data.getInt( VoiceConstants.EXTRA_OPERA, 0 ); + onMapUISetting( actionType, operateAction ); + break; + case VoiceConstants.TYPE_NAVI_STRATEGY: +// actions.onNaviStrategySetting( data.getInt( VoiceConstants.EXTRA_M, 1 ) ); + break; + case VoiceConstants.TYPE_NAVI_OVERVIEW: + final int overview = data.getInt( VoiceConstants.EXTRA_IS_SHOW, -1 ); +// if ( overview == 0 ) { +// actions.onNaviOverview(); +// } else { +// actions.onNaviContinue(); +// } + break; + case VoiceConstants.TYPE_NAVI_SPEAK: +// actions.onNaviSpeak( data.getInt( VoiceConstants.EXTRA_MUTE, 0 ) ); + break; + case VoiceConstants.TYPE_COMMON_ADDRESS_SETTING: +// actions.onAddressSetting(); + break; + case VoiceConstants.TYPE_COMMON_ADDRESS_CHANGED: +// actions.onAddressUpdate(); + break; + case VoiceConstants.TYPE_NAVI_ADD_POINT: +// final int updateType = intent.getIntExtra( "TYPE", -1 ); +// final String name = intent.getStringExtra( "POINAME" ); +// final String address = intent.getStringExtra( "ADDRESS" ); +// final double lat = intent.getDoubleExtra( "LAT", 0.0 ); +// final double lng = intent.getDoubleExtra( "LON", 0.0 ); +// actions.onUpdateNaviPoint( updateType, name, address, lat, lng ); + break; + case VoiceConstants.TYPE_SPEAK_NAVI_INFO: +// actions.onSpeakPathRetainDistanceInfo(); + break; + case VoiceConstants.TYPE_SPEAK_SPEED_LIMIT_INFO: +// actions.onSpeakSpeedLimitInfo(); + break; + + } + } + + /** + * @param actionType 0 - 实时路况 + * 1 - 地图缩放 + * 2 - 视图模式 + * 3 - 夜间模式 + * @param action actionType = 0 -> 0 - 开、1 - 关 + * actionType = 1 -> 0 - 放大地图、1 - 缩小地图 + * actionType = 2 -> 0 - 切换到2D车头朝上、1 - 切换2D正北模式、2 - 切换3D车头朝上 + * actionType = 3 -> 0 - 黑夜、1 - 正常 + */ + public void onMapUISetting( int actionType, int action ) { + switch ( actionType ) { + case 0: + if ( action == 0 ) { + mView.getUIController().setTrafficEnabled( true ); + } else if ( action == 1 ) { + mView.getUIController().setTrafficEnabled( false ); + } + break; + case 1: + if ( action == 0 ) { + mView.getUIController().changeZoom( true ); + } else if ( action == 1 ) { + mView.getUIController().changeZoom( false ); + } + break; + case 2: + if ( action == 0 ) { + // 车头朝上,2D + mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D ); + } else if ( action == 1 ) { + // 北朝上,2D + mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D ); + } else if ( action == 2 ) { + // 车头朝上,3D + mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D ); + } + break; + case 3: + if ( action == 0 ) { + mView.getUIController().changeMapMode( EnumMapUI.Type_Night ); + } else if ( action == 1 ) { + mView.getUIController().changeMapMode( EnumMapUI.Type_Light ); + } + break; + } + } + + @Override + public void onCmdSelected( String cmd ) { + switch ( cmd ) { + case VoiceConstants.CMD_MAP_TRAFFIC_MODE: + onMapUISetting( 0, 0 ); + break; + case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE: + onMapUISetting( 0, 1 ); + break; + case VoiceConstants.CMD_MAP_ZOOM_IN: + onMapUISetting( 1, 0 ); + break; + case VoiceConstants.CMD_MAP_ZOOM_OUT: + onMapUISetting( 1, 1 ); + break; + case VoiceConstants.CMD_MAP_2D: + onMapUISetting( 2, 1 ); + break; + case VoiceConstants.CMD_MAP_3D: + onMapUISetting( 2, 2 ); + break; + case VoiceConstants.CMD_MAP_LIGHT_MODE: + onMapUISetting( 3, 1 ); + break; + case VoiceConstants.CMD_MAP_NIGHT_MODE: + onMapUISetting( 3, 0 ); + break; + } + } + + @Override + public void onCmdAction( String speakText ) { + + } + + @Override + public void onCmdCancel( String speakText ) { + + } + + @Override + public void onSpeakEnd( String speakText ) { + + } + + @Override + public void onSpeakSelectTimeOut( String speakText ) { + + } } diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapView.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapView.java index 52acc523c2..8bb8ae2a88 100644 --- a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapView.java +++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapView.java @@ -1,6 +1,7 @@ package com.mogo.module.map; import com.mogo.commons.mvp.IView; +import com.mogo.map.uicontroller.IMogoMapUIController; /** * @author congtaowang @@ -9,4 +10,11 @@ import com.mogo.commons.mvp.IView; * 地图view */ public interface MapView extends IView { + + /** + * 地图控制接口 + * + * @return + */ + IMogoMapUIController getUIController(); } diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/VoiceConstants.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/VoiceConstants.java new file mode 100644 index 0000000000..2a34dd679f --- /dev/null +++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/VoiceConstants.java @@ -0,0 +1,133 @@ +package com.mogo.module.map; + +/** + * @author congtaowang + * @since 2020-01-09 + *

+ * 描述 + */ +public class VoiceConstants { + + // 同行者Adapter接受action + public static final String ACTION_GAODE_SDK_NAVI_RECV = "ACTION_GAODE_SDK_NAVI_RECV"; + // 同行者Adapter发送action + public static final String ACTION_GAODE_SDK_NAVI_SEND = "ACTION_GAODE_SDK_NAVI_SEND"; + + public static final String EXTRA_KEY_TYPE = "KEY_TYPE"; + public static final String EXTRA_TYPE = "EXTRA_TYPE";//操作地图 + public static final String EXTRA_OPERA = "EXTRA_OPERA";//操作地图 + public static final String EXTRA_MUTE = "EXTRA_MUTE"; + public static final String EXTRA_IS_SHOW = "EXTRA_IS_SHOW";//预览全路径还是继续导航 + public static final String EXTRA_M = "EXTRA_M";// 导航策略:1(避免收费) 3(不走高速) 4(躲避拥堵) 20 (高速优先) + + /** + * 直接导航 + */ + public static final int TYPE_START_NAVI = 110009; + + /** + * 导航预览or继续导航 + */ + public static final int TYPE_NAVI_OVERVIEW = 110006; + + /** + * 地图控制:缩放、路况、车头、2/3D + */ + public static final int TYPE_MAP_UI_SETTING = 110027; + + /** + * 重新计算导航策略 + */ + public static final int TYPE_NAVI_STRATEGY = 110032; + + /** + * 提箱前方路线方案 + *

+ * 未实现 + */ + public static final int TYPE_NAVI_GUIDE_INFO = 120004; + + /** + * 播放当前剩余里程和时间 + *

+ * 未实现 + */ + public static final int TYPE_SPEAK_NAVI_INFO = 120001; + + /** + * 播放当前限速信息 + *

+ * 未实现 + */ + public static final int TYPE_SPEAK_SPEED_LIMIT_INFO = 120002; + + /** + * 停止导航,但是不退出地图 + */ + public static final int TYPE_STOP_NAVI = 110010; + + /** + * 退出地图应用 + */ + @Deprecated + public static final int TYPE_EXIT_NAVI = 120003; + + /** + * 插入途经点 + */ + public static final int TYPE_NAVI_ADD_POINT = 210009; + + public static final int TYPE_NAVI_SPEAK = 10011; + public static final int TYPE_COMMON_ADDRESS_SETTING = 10007; + public static final int TYPE_COMMON_ADDRESS_CHANGED = 10008; + public static final int TYPE_NAVI_TO = 110027; + + // 地图免唤醒语音注册 + /** + * 放大地图 + */ + public static final String CMD_MAP_ZOOM_IN = "CMD_MAP_ZOOM_IN"; + public static final String[] CMD_MAP_ZOOM_IN_WAKE_UP_WORDS = {"放大地图"}; + + /** + * 缩小地图 + */ + public static final String CMD_MAP_ZOOM_OUT = "CMD_MAP_ZOOM_OUT"; + public static final String[] CMD_MAP_ZOOM_OUT_WAKE_UP_WORDS = {"缩小地图"}; + + /** + * 2D模式 + */ + public static final String CMD_MAP_2D = "CMD_MAP_2D"; + public static final String[] CMD_MAP_2D_WAKE_UP_WORDS = {"2D模式"}; + /** + * 3D模式 + */ + public static final String CMD_MAP_3D = "CMD_MAP_3D"; + public static final String[] CMD_MAP_3D_WAKE_UP_WORDS = {"3D模式"}; + + /** + * 白天模式 + */ + public static final String CMD_MAP_LIGHT_MODE = "CMD_MAP_LIGHT_MODE"; + public static final String[] CMD_MAP_LIGHT_MODE_WAKE_UP_WORDS = {"白天模式"}; + + /** + * 黑夜模式 + */ + public static final String CMD_MAP_NIGHT_MODE = "CMD_MAP_NIGHT_MODE"; + public static final String[] CMD_MAP_NIGHT_MODE_WAKE_UP_WORDS = {"黑夜模式"}; + + /** + * 查看路况 + */ + public static final String CMD_MAP_TRAFFIC_MODE = "CMD_MAP_TRAFFIC_MODE"; + public static final String[] CMD_MAP_TRAFFIC_MODE_WAKE_UP_WORDS = {"查看路况"}; + /** + * 关闭路况 + */ + public static final String CMD_MAP_UN_TRAFFIC_MODE = "CMD_MAP_UN_TRAFFIC_MODE"; + public static final String[] CMD_MAP_UN_TRAFFIC_MODE_WAKE_UP_WORDS = {"关闭路况"}; + + +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java index 785f51bde4..943c415cc4 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java @@ -2,10 +2,12 @@ package com.mogo.module.service; import android.content.Context; +import android.content.IntentFilter; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.text.TextUtils; import android.view.MotionEvent; import android.view.View; @@ -25,8 +27,13 @@ import com.mogo.map.navi.IMogoNaviListener; import com.mogo.map.navi.MogoNaviInfo; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; +import com.mogo.module.common.MogoModule; +import com.mogo.module.common.MogoModulePaths; import com.mogo.module.service.network.RefreshCallback; import com.mogo.module.service.network.RefreshModel; +import com.mogo.module.service.receiver.AIAssistReceiver; +import com.mogo.module.service.refresh.AutoRefreshStrategy; +import com.mogo.module.service.refresh.CustomRefreshStrategy; import com.mogo.service.MogoServicePaths; import com.mogo.service.map.IMogoMapService; import com.mogo.service.module.IMogoModuleLifecycle; @@ -37,6 +44,8 @@ import com.mogo.service.statusmanager.IMogoStatusManager; import com.mogo.service.statusmanager.StatusDescriptor; import com.mogo.utils.logger.Logger; +import java.util.List; + /** * @author congtaowang * @since 2020-01-03 @@ -71,6 +80,8 @@ public class MogoServiceProvider implements IMogoModuleProvider, */ boolean mIsVertical = false; + private AIAssistReceiver mAIAssistReceiver; + /** * 手动刷新策略 */ @@ -208,6 +219,31 @@ public class MogoServiceProvider implements IMogoModuleProvider, //TODO 初始化地图地图绘制大而全的Marker MarkerServiceHandler.init( mContext ); + registerAIReceiver( context ); + } + + private void registerAIReceiver( Context context ) { + if ( context == null ) { + return; + } + List< MogoModule > modules = MogoModulePaths.getModules(); + if ( modules.isEmpty() || modules == null ) { + return; + } + mAIAssistReceiver = new AIAssistReceiver( context ); + IntentFilter filter = new IntentFilter(); + for ( MogoModule module : modules ) { + String action = module.getVoiceAction(); + if ( !TextUtils.isEmpty( action ) ) { + filter.addAction( action ); + } + } + try { + context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter ); + Logger.i( TAG, "register voice receiver." ); + } catch ( Exception e ) { + Logger.e( TAG, e, "error. " ); + } } @Override @@ -331,7 +367,6 @@ public class MogoServiceProvider implements IMogoModuleProvider, mLastCustomRefreshCenterLocation = latLng; } } - Logger.d( TAG, "current map status: %s, zoom = %f, tilt = %f, bearing = %f", latLng, zoom, tilt, bearing ); } private int getQueryRadius() { diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/AIAssistReceiver.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/AIAssistReceiver.java new file mode 100644 index 0000000000..00376fdf83 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/AIAssistReceiver.java @@ -0,0 +1,37 @@ +package com.mogo.module.service.receiver; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; + +import com.alibaba.android.arouter.launcher.ARouter; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.voice.IMogoVoiceManager; +import com.mogo.utils.logger.Logger; + +/** + * @author congtaowang + * @since 2019-10-03 + *

+ * 语音助手广播接收者 + */ +public class AIAssistReceiver extends BroadcastReceiver { + + private static final String TAG = "AIAssistReceiver"; + + + private IMogoVoiceManager mMogoVoiceManager; + + public AIAssistReceiver( Context context ) { + mMogoVoiceManager = ( IMogoVoiceManager ) ARouter.getInstance().build( MogoServicePaths.PATH_VOICE_MANAGER ).navigation( context ); + } + + @Override + public void onReceive( Context context, Intent intent ) { + Logger.i( TAG, "receive ai assist intent" ); + final String action = intent.getAction(); + mMogoVoiceManager.invoke( action, intent ); + } +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/AutoRefreshStrategy.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/refresh/AutoRefreshStrategy.java similarity index 95% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/AutoRefreshStrategy.java rename to modules/mogo-module-service/src/main/java/com/mogo/module/service/refresh/AutoRefreshStrategy.java index 3a107c335d..d620f20586 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/AutoRefreshStrategy.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/refresh/AutoRefreshStrategy.java @@ -1,4 +1,4 @@ -package com.mogo.module.service; +package com.mogo.module.service.refresh; /** * @author congtaowang diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/CustomRefreshStrategy.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/refresh/CustomRefreshStrategy.java similarity index 86% rename from modules/mogo-module-service/src/main/java/com/mogo/module/service/CustomRefreshStrategy.java rename to modules/mogo-module-service/src/main/java/com/mogo/module/service/refresh/CustomRefreshStrategy.java index 90005b3c5d..1a5187e86b 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/CustomRefreshStrategy.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/refresh/CustomRefreshStrategy.java @@ -1,4 +1,4 @@ -package com.mogo.module.service; +package com.mogo.module.service.refresh; /** * @author congtaowang diff --git a/modules/mogo-module-tanlu/src/main/AndroidManifest.xml b/modules/mogo-module-tanlu/src/main/AndroidManifest.xml index ec531bc01c..a238192807 100644 --- a/modules/mogo-module-tanlu/src/main/AndroidManifest.xml +++ b/modules/mogo-module-tanlu/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.mogo.module.tanlu"> > int id = view.getId(); if (id == R.id.tv_previous_res) { //上一个 //判断是图片还是视频,第一个时,上一个不可点击 - Logger.d(TAG, " tv_previous_res --1-> currentPosition =" + currentPosition); + Logger.d(TAG, " tv_previous_res --1-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size()); if (currentPosition < 0) { return; } currentPosition--; - Logger.d(TAG, " tv_previous_res --2-> currentPosition =" + currentPosition); - if (markerExploreWayList.size() > currentPosition) { + Logger.d(TAG, " tv_previous_res --2-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size()); + if (markerExploreWayList.size() > currentPosition && currentPosition >= 0) { handleData(markerExploreWayList.get(currentPosition)); } } else if (id == R.id.tv_next_res) { //下一个 //判断是图片还是视频,最后一个时,下一个不可点击 - Logger.d(TAG, " tv_next_res --1-> currentPosition =" + currentPosition); - if (currentPosition > markerExploreWayList.size()) { //TODO >= + Logger.d(TAG, " tv_next_res --1-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size()); + if (currentPosition > markerExploreWayList.size()) { return; } currentPosition++; - Logger.d(TAG, " tv_next_res --2-> currentPosition =" + currentPosition); + Logger.d(TAG, " tv_next_res --2-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size()); if (markerExploreWayList.size() > currentPosition) { handleData(markerExploreWayList.get(currentPosition)); } diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluCardViewProvider.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java similarity index 95% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluCardViewProvider.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java index b804bd33e0..21f29c8c4d 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluCardViewProvider.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.fragment; +package com.mogo.module.tanlu.fragment; import android.content.Context; import android.os.Bundle; @@ -14,7 +14,7 @@ import com.mogo.map.navi.IMogoNaviListener; import com.mogo.service.module.IMogoModuleLifecycle; import com.mogo.service.module.IMogoModuleProvider; import com.mogo.service.module.ModuleType; -import com.mogo.tanlu.constant.TanluConstants; +import com.mogo.module.tanlu.constant.TanluConstants; import com.mogo.utils.logger.Logger; /** diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluServiceHandler.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceHandler.java similarity index 98% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluServiceHandler.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceHandler.java index 1128cd336b..c066dbb319 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluServiceHandler.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceHandler.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.fragment; +package com.mogo.module.tanlu.fragment; import android.content.Context; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/AMapUtil.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/AMapUtil.java similarity index 99% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/AMapUtil.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/AMapUtil.java index 45f188e363..427a20d0a8 100755 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/AMapUtil.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/AMapUtil.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.map; +package com.mogo.module.tanlu.map; import android.text.Html; import android.text.Spanned; @@ -10,7 +10,7 @@ import com.amap.api.services.route.BusPath; import com.amap.api.services.route.BusStep; import com.amap.api.services.route.RouteBusLineItem; import com.amap.api.services.route.RouteRailwayItem; -import com.mogo.tanlu.R; +import com.mogo.module.tanlu.R; import java.text.DecimalFormat; import java.text.SimpleDateFormat; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/ChString.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/ChString.java similarity index 97% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/ChString.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/ChString.java index 8a1b3bc67c..1f32432da7 100755 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/ChString.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/ChString.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.map; +package com.mogo.module.tanlu.map; public class ChString { public static final String Kilometer = "\u516c\u91cc";// "公里"; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/DrivingRouteOverlay.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/DrivingRouteOverlay.java similarity index 99% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/DrivingRouteOverlay.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/DrivingRouteOverlay.java index bb1fc2df84..8e95c5fde3 100755 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/DrivingRouteOverlay.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/DrivingRouteOverlay.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.map; +package com.mogo.module.tanlu.map; import android.content.Context; import android.graphics.Color; @@ -15,7 +15,7 @@ import com.amap.api.services.core.LatLonPoint; import com.amap.api.services.route.DrivePath; import com.amap.api.services.route.DriveStep; import com.amap.api.services.route.TMC; -import com.mogo.tanlu.R; +import com.mogo.module.tanlu.R; import java.util.ArrayList; import java.util.List; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/RouteOverlay.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/RouteOverlay.java similarity index 99% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/RouteOverlay.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/RouteOverlay.java index af1b169592..47a63582b5 100755 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/map/RouteOverlay.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/map/RouteOverlay.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.map; +package com.mogo.module.tanlu.map; import android.content.Context; import android.graphics.Bitmap; @@ -14,7 +14,7 @@ import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.Polyline; import com.amap.api.maps.model.PolylineOptions; -import com.mogo.tanlu.R; +import com.mogo.module.tanlu.R; import java.util.ArrayList; import java.util.List; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/CarsLive.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/CarsLive.kt new file mode 100644 index 0000000000..aeacd5025c --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/CarsLive.kt @@ -0,0 +1,17 @@ +package com.mogo.module.tanlu.model + +class CarsLive { + var sn: String + var lat: Double + var lon: Double + var direction: Int + var canLive: Int + + constructor(sn: String, lat: Double, lon: Double, direction: Int, canLive: Int) { + this.sn = sn + this.lat = lat + this.lon = lon + this.direction = direction + this.canLive = canLive + } +} \ No newline at end of file diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Center.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Center.kt new file mode 100644 index 0000000000..b5c5a909c8 --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Center.kt @@ -0,0 +1,12 @@ +package com.mogo.module.tanlu.model + +/** + * @description + * + * @author lixiaopeng + * @since 2019-10-24 + */ +data class Center ( + val lat: Double,//weidu + val lon: Double +) diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Information.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Information.java similarity index 93% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Information.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Information.java index a65ca8b47f..5e196a1cd8 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Information.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Information.java @@ -1,8 +1,10 @@ -package com.mogo.tanlu.model; +package com.mogo.module.tanlu.model; import android.os.Parcel; import android.os.Parcelable; +import com.mogo.commons.data.BaseData; + import java.util.ArrayList; /** @@ -10,7 +12,7 @@ import java.util.ArrayList; * @description 列表数据 * @since 2020-01-05 */ -public class Information implements Parcelable { +public class Information extends BaseData implements Parcelable { private int type; private Double lon; private Double lat; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/InformationAndLiveCarResult.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/InformationAndLiveCarResult.kt new file mode 100644 index 0000000000..24bc41b302 --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/InformationAndLiveCarResult.kt @@ -0,0 +1,18 @@ +package com.mogo.module.tanlu.model + +/** + * @author congtaowang + * @since 2019-11-20 + * + * 根据范围请求情报+在线车机结果 + */ +data class InformationAndLiveCarResult( + var onTheWayData: Result, + var infoMationResult: Result, + var snResult: Sns +) { + fun getInformation(): Result = if (onTheWayData == null + || onTheWayData.informations == null + || onTheWayData.informations.isEmpty() + ) infoMationResult else onTheWayData +} \ No newline at end of file diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Items.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Items.kt similarity index 95% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Items.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Items.kt index d7f75dc33e..444c53b240 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Items.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Items.kt @@ -1,4 +1,4 @@ -package com.mogo.tanlu.model +package com.mogo.module.tanlu.model import android.os.Parcel import android.os.Parcelable diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/PathLineResult.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/PathLineResult.java new file mode 100644 index 0000000000..5c9ad18e34 --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/PathLineResult.java @@ -0,0 +1,30 @@ +package com.mogo.module.tanlu.model; + +import com.mogo.commons.data.BaseData; +import java.util.List; + +/** + * @author lixiaopeng + * @description 通勤族划线 + * @since 2020-01-08 + */ +public class PathLineResult extends BaseData { + private List informations; + private List

pointList; + + public List getInformations() { + return informations; + } + + public void setInformations(List informations) { + this.informations = informations; + } + + public List
getPointList() { + return pointList; + } + + public void setPointList(List
pointList) { + this.pointList = pointList; + } +} diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Result.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Result.java new file mode 100644 index 0000000000..4c3f4aeabd --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Result.java @@ -0,0 +1,22 @@ +package com.mogo.module.tanlu.model; + +import com.mogo.commons.data.BaseData; + +import java.util.List; + +/** + * @author lixiaopeng + * @description + * @since 2020-01-08 + */ +public class Result extends BaseData { + public List informations; + + public List getInformations() { + return informations; + } + + public void setInformations(List informations) { + this.informations = informations; + } +} diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Sns.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Sns.kt new file mode 100644 index 0000000000..f075745c2b --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/Sns.kt @@ -0,0 +1,13 @@ +package com.mogo.module.tanlu.model + + +class Sns { + + var sns: List + var localUserId: String + + constructor(sns: List, localUserId: String) { + this.sns = sns + this.localUserId = localUserId + } +} \ No newline at end of file diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/VoiceSearchResult.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/VoiceSearchResult.java new file mode 100644 index 0000000000..a4ed3c5f26 --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/VoiceSearchResult.java @@ -0,0 +1,39 @@ +package com.mogo.module.tanlu.model; + +import com.mogo.commons.data.BaseData; +import java.util.List; + +/** + * @author lixiaopeng + * @description 声音控制接口 + * @since 2020-01-08 + */ +public class VoiceSearchResult extends BaseData { + private List informations; + private String description; + private Sns snResult; + + public List getInformations() { + return informations; + } + + public void setInformations(List informations) { + this.informations = informations; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Sns getSnResult() { + return snResult; + } + + public void setSnResult(Sns snResult) { + this.snResult = snResult; + } +} diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/event/MarkerInfo.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/MarkerInfo.java similarity index 91% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/event/MarkerInfo.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/MarkerInfo.java index 2676f0cd80..f5a6ba68a0 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/event/MarkerInfo.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/MarkerInfo.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.model.event; +package com.mogo.module.tanlu.model.event; import java.io.Serializable; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/event/VoiceRoadInfo.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/VoiceRoadInfo.java similarity index 88% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/event/VoiceRoadInfo.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/VoiceRoadInfo.java index c37f423836..8b93c1ca2e 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/event/VoiceRoadInfo.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/VoiceRoadInfo.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.model.event; +package com.mogo.module.tanlu.model.event; import java.io.Serializable; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/global/GlobalSharedInformation.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/global/GlobalSharedInformation.kt similarity index 74% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/global/GlobalSharedInformation.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/global/GlobalSharedInformation.kt index 31fe2a771b..280a81b536 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/global/GlobalSharedInformation.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/global/GlobalSharedInformation.kt @@ -1,6 +1,6 @@ -package com.mogo.tanlu.model.global +package com.mogo.module.tanlu.model.global -import com.mogo.tanlu.model.Information +import com.mogo.module.tanlu.model.Information import java.util.ArrayList /** diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/net/TanluApiService.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/net/TanluApiService.java new file mode 100644 index 0000000000..f2157fa456 --- /dev/null +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/net/TanluApiService.java @@ -0,0 +1,47 @@ +package com.mogo.module.tanlu.net; + +import com.mogo.module.tanlu.model.InformationAndLiveCarResult; +import com.mogo.module.tanlu.model.PathLineResult; +import com.mogo.module.tanlu.model.VoiceSearchResult; + +import java.util.Map; + +import io.reactivex.Observable; +import retrofit2.http.FieldMap; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * @author lixiaopeng + * @description 探路相关接口定义 + * @since 2020-01-07 + */ +public interface TanluApiService { + + /** + * 探路沿途数据 + * + * @return + */ + @FormUrlEncoded + @POST("deva/car/path/no/getOnTheWayDataAndSn/v1") + Observable requestInformationAlongTheWay(@Query("sn") String sn, @FieldMap Map parameters); + + /** + * 获取上班族路线的坐标集 + */ + @FormUrlEncoded + @POST("yycp-travel-condition/travelDetail/info/no/commuter/v1") + Observable getRoadLineInfo(@FieldMap Map infoBody); + + + /** + * 基于地理信息词缀的空间情报检索 + */ + @FormUrlEncoded + @POST("deva/car/search/no/searchInforationByAddress/v1") + Observable searchOnLineInformation(@FieldMap Map infoBody); + + +} diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/receiver/MarkerInfoReceiver.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt similarity index 89% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/receiver/MarkerInfoReceiver.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt index 8ea58db2d3..bfcb102fb6 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/receiver/MarkerInfoReceiver.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt @@ -1,10 +1,10 @@ -package com.mogo.tanlu.receiver +package com.mogo.module.tanlu.receiver import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.util.Log -import com.mogo.tanlu.model.event.MarkerInfo +import com.mogo.module.tanlu.model.event.MarkerInfo import org.greenrobot.eventbus.EventBus /** diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/receiver/RoadInfoReceiver.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/RoadInfoReceiver.kt similarity index 78% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/receiver/RoadInfoReceiver.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/RoadInfoReceiver.kt index a10985e5ec..3899359ea2 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/receiver/RoadInfoReceiver.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/RoadInfoReceiver.kt @@ -1,14 +1,14 @@ -package com.mogo.tanlu.receiver +package com.mogo.module.tanlu.receiver import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.util.Log -import com.mogo.tanlu.model.event.VoiceRoadInfo +import com.mogo.module.tanlu.model.event.VoiceRoadInfo import org.greenrobot.eventbus.EventBus /** - * xx堵不堵,接收关键字 + * xx堵不堵,接收关键字,应该在哪里接收关键字请求接口? */ class RoadInfoReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/DoubleCheckUtil.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/DoubleCheckUtil.kt similarity index 94% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/DoubleCheckUtil.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/DoubleCheckUtil.kt index b0582d8da9..a3a1bf645e 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/DoubleCheckUtil.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/DoubleCheckUtil.kt @@ -1,5 +1,4 @@ -package com.mogo.tanlu.util - +package com.mogo.module.tanlu.util const val SPACE_TIME = 1000 diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/HideControl.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/HideControl.kt similarity index 98% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/HideControl.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/HideControl.kt index 0307d5c53e..d11c954451 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/HideControl.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/HideControl.kt @@ -1,4 +1,4 @@ -package com.mogo.tanlu.util +package com.mogo.module.tanlu.util import android.os.Message import android.view.View diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/StringUitl.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/StringUitl.kt similarity index 95% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/StringUitl.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/StringUitl.kt index aee8d3240a..bc4ceace53 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/StringUitl.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/StringUitl.kt @@ -1,4 +1,4 @@ -package com.mogo.tanlu.util +package com.mogo.module.tanlu.util import android.text.format.DateFormat import java.text.DecimalFormat diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/Utils.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/Utils.java similarity index 93% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/Utils.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/Utils.java index 90165434f2..afb74a6fac 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/util/Utils.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/util/Utils.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.util; +package com.mogo.module.tanlu.util; import java.text.DecimalFormat; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/FullMediaActivity.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/FullMediaActivity.kt similarity index 96% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/FullMediaActivity.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/FullMediaActivity.kt index 76164cfe92..181f684f32 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/FullMediaActivity.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/FullMediaActivity.kt @@ -1,14 +1,13 @@ -package com.mogo.tanlu.video +package com.mogo.module.tanlu.video import android.app.Activity import android.content.Intent import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity -import com.mogo.tanlu.R -import com.mogo.tanlu.model.Informations -import com.mogo.tanlu.util.HideControl -import com.mogo.tanlu.util.formatDate +import com.mogo.module.tanlu.R +import com.mogo.module.tanlu.util.HideControl +import com.mogo.module.tanlu.util.formatDate import com.mogo.utils.logger.Logger import com.shuyu.gsyvideoplayer.GSYVideoManager import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/MediaCoverVideoPlayer.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt similarity index 98% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/MediaCoverVideoPlayer.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt index c71fc8d361..a02fc9653c 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/MediaCoverVideoPlayer.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt @@ -1,4 +1,4 @@ -package com.mogo.tanlu.video +package com.mogo.module.tanlu.video import android.content.Context import android.util.AttributeSet @@ -6,7 +6,7 @@ import android.util.Log import android.view.View import android.widget.ImageView import com.bumptech.glide.Glide -import com.mogo.tanlu.R +import com.mogo.module.tanlu.R import com.shuyu.gsyvideoplayer.GSYVideoManager import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer import com.shuyu.gsyvideoplayer.video.base.GSYVideoView diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/SimpleCoverVideoPlayer.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt similarity index 98% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/SimpleCoverVideoPlayer.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt index 7093db9c1c..8643ae7cfd 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/SimpleCoverVideoPlayer.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt @@ -1,4 +1,4 @@ -package com.mogo.tanlu.video +package com.mogo.module.tanlu.video import android.content.Context import android.util.AttributeSet @@ -6,7 +6,7 @@ import android.view.Surface import android.view.View import android.widget.ImageView import com.bumptech.glide.Glide -import com.mogo.tanlu.R +import com.mogo.module.tanlu.R import com.shuyu.gsyvideoplayer.GSYVideoManager import com.shuyu.gsyvideoplayer.utils.GSYVideoType import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/VideoInit.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/VideoInit.kt similarity index 96% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/VideoInit.kt rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/VideoInit.kt index 8d9ee59d98..6b98b7c203 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/video/VideoInit.kt +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/VideoInit.kt @@ -1,4 +1,4 @@ -package com.mogo.tanlu.video +package com.mogo.module.tanlu.video import com.shuyu.gsyvideoplayer.GSYVideoManager import com.shuyu.gsyvideoplayer.cache.CacheFactory diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/view/AutoZoomInImageView.java similarity index 99% rename from modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.java rename to modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/view/AutoZoomInImageView.java index 102d772568..20737ab449 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/view/AutoZoomInImageView.java @@ -1,4 +1,4 @@ -package com.mogo.tanlu.view; +package com.mogo.module.tanlu.view; import com.mogo.service.imageloader.MogoImageView; diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Informations.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Informations.kt deleted file mode 100644 index 6793083965..0000000000 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/model/Informations.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.mogo.tanlu.model - -import android.os.Parcel -import android.os.Parcelable -import com.amap.api.maps.model.LatLng - -fun Informations.toLatLng(): LatLng { - return LatLng(lat, lon) -} - -class Informations( - var type: Int, - var lon: Double, - var lat: Double, - var addr: String?, - var generateTime: Long, - var cityName: String?, -// var items: ArrayList, - var distance: Int, - var nickName: String?, - var headImgUrl: String? -) : - Parcelable { - - var position = 0 - - constructor(parcel: Parcel) : this( - parcel.readInt(), - parcel.readDouble(), - parcel.readDouble(), - parcel.readString(), - parcel.readLong(), - parcel.readString(), -// parcel.readArrayList(Items::class.java.classLoader) as ArrayList, - parcel.readInt(), - parcel.readString(), - parcel.readString() - ) - - override fun writeToParcel(parcel: Parcel, flags: Int) { - parcel.writeInt(type) - parcel.writeDouble(lon) - parcel.writeDouble(lat) - parcel.writeString(addr) - parcel.writeLong(generateTime) - parcel.writeString(cityName) -// parcel.writeList(items) - parcel.writeInt(distance) - parcel.writeString(nickName) - parcel.writeString(headImgUrl) - } - - override fun describeContents(): Int { - return 0 - } - - companion object CREATOR : Parcelable.Creator { - override fun createFromParcel(parcel: Parcel): Informations { - return Informations(parcel) - } - - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } - -} diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/net/TanluApiService.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/net/TanluApiService.java deleted file mode 100644 index 1af02b5e43..0000000000 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/net/TanluApiService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mogo.tanlu.net; - -import com.mogo.commons.data.BaseData; - -import java.util.Map; - -import io.reactivex.Observable; -import retrofit2.http.FieldMap; -import retrofit2.http.FormUrlEncoded; -import retrofit2.http.POST; -import retrofit2.http.QueryMap; - -/** - * @author lixiaopeng - * @description 探路相关接口定义 - * @since 2020-01-07 - */ -public interface TanluApiService { - - @FormUrlEncoded - @POST( "" ) - Observable refreshData(@QueryMap Map< String, Object > params, - @FieldMap Map< String, Object > parameters ); - -} diff --git a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_activity_media_full.xml b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_activity_media_full.xml index a90d871523..995db5a607 100644 --- a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_activity_media_full.xml +++ b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_activity_media_full.xml @@ -8,7 +8,7 @@ tools:context=".video.FullMediaActivity"> - - - - - diff --git a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_photo_recycler.xml b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_photo_recycler.xml index 5e12cbfff3..fe8427ad57 100644 --- a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_photo_recycler.xml +++ b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_photo_recycler.xml @@ -28,7 +28,7 @@ android:layout_marginBottom="14dp" android:textSize="20dp" /> - + * 免唤醒语音监听 + */ +public interface IMogoVoiceListener { + + /** + * 回调语音意图 + * + * @param action 广播 action + * @param intent 意图 + */ + void onIntentReceived( String action, Intent intent ); +} diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/voice/IMogoVoiceManager.java b/services/mogo-service-api/src/main/java/com/mogo/service/voice/IMogoVoiceManager.java new file mode 100644 index 0000000000..35f5c7b342 --- /dev/null +++ b/services/mogo-service-api/src/main/java/com/mogo/service/voice/IMogoVoiceManager.java @@ -0,0 +1,36 @@ +package com.mogo.service.voice; + +import android.content.Intent; + +import com.alibaba.android.arouter.facade.template.IProvider; + +/** + * @author congtaowang + * @since 2020-01-09 + *

+ * 免唤醒语音控制 + */ +public interface IMogoVoiceManager extends IProvider { + + /** + * 注册意图接收者 + * + * @param action + */ + void registerIntentListener( String action, IMogoVoiceListener listener ); + + /** + * 注册意图接收者 + * + * @param action + */ + void unregisterIntentListener( String action ); + + /** + * 触发意图回调,各业务不用关心 + * + * @param action + * @param intent + */ + void invoke( String action, Intent intent ); +} diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/voice/MogoVoiceManager.java b/services/mogo-service/src/main/java/com/mogo/service/impl/voice/MogoVoiceManager.java new file mode 100644 index 0000000000..f1b7cd8b5b --- /dev/null +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/voice/MogoVoiceManager.java @@ -0,0 +1,42 @@ +package com.mogo.service.impl.voice; + +import android.content.Context; +import android.content.Intent; + +import androidx.viewpager.widget.ViewPager; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.voice.IMogoVoiceListener; +import com.mogo.service.voice.IMogoVoiceManager; +import com.zhidao.auto.platform.voice.VoiceClient; + +/** + * @author congtaowang + * @since 2020-01-09 + *

+ * 描述 + */ +@Route( path = MogoServicePaths.PATH_VOICE_MANAGER ) +public class MogoVoiceManager implements IMogoVoiceManager { + + @Override + public void registerIntentListener( String action, IMogoVoiceListener listener ) { + VoiceManager.getInstance().registerIntentListener( action, listener ); + } + + @Override + public void unregisterIntentListener( String action ) { + VoiceManager.getInstance().unregisterIntentListener( action ); + } + + @Override + public void invoke( String action, Intent intent ) { + VoiceManager.getInstance().invoke( action, intent ); + } + + @Override + public void init( Context context ) { + VoiceManager.getInstance().init( context ); + } +} diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/voice/VoiceManager.java b/services/mogo-service/src/main/java/com/mogo/service/impl/voice/VoiceManager.java new file mode 100644 index 0000000000..f77b16a0eb --- /dev/null +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/voice/VoiceManager.java @@ -0,0 +1,76 @@ +package com.mogo.service.impl.voice; + +import android.content.Context; +import android.content.Intent; + +import com.mogo.service.voice.IMogoVoiceListener; +import com.mogo.service.voice.IMogoVoiceManager; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author congtaowang + * @since 2020-01-09 + *

+ * 描述 + */ +public class VoiceManager implements IMogoVoiceManager { + + private static volatile VoiceManager sInstance; + + private VoiceManager() { + } + + public static VoiceManager getInstance() { + if ( sInstance == null ) { + synchronized ( VoiceManager.class ) { + if ( sInstance == null ) { + sInstance = new VoiceManager(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + + private Map< String, List< IMogoVoiceListener > > mListeners = new HashMap<>(); + + @Override + public void registerIntentListener( String action, IMogoVoiceListener listener ) { + if ( listener == null || action == null ) { + return; + } + if ( !mListeners.containsKey( action ) ) { + mListeners.put( action, new ArrayList<>() ); + } + mListeners.get( action ).add( listener ); + + } + + @Override + public void unregisterIntentListener( String action ) { + mListeners.remove( action ); + } + + @Override + public void init( Context context ) { + + } + + @Override + public void invoke( String action, Intent intent ) { + List< IMogoVoiceListener > listeners = mListeners.get( action ); + if ( listeners != null && !listeners.isEmpty() ) { + for ( IMogoVoiceListener listener : listeners ) { + listener.onIntentReceived( action, intent ); + } + } + } +} diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/windowview/WindowViewHandler.java b/services/mogo-service/src/main/java/com/mogo/service/impl/windowview/WindowViewHandler.java index 8c511e1da7..9e782f3a4e 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/windowview/WindowViewHandler.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/windowview/WindowViewHandler.java @@ -47,7 +47,7 @@ public class WindowViewHandler { try { sWindowManager = ( WindowManager ) view.getContext().getApplicationContext().getSystemService( Context.WINDOW_SERVICE ); } catch ( Exception e ) { - Logger.e( TAG, "error. ", e ); + Logger.e( TAG, e, "error. " ); return; } }