fix bug and add guideShow icon

This commit is contained in:
unknown
2020-03-30 12:18:05 +08:00
parent f6310008b1
commit 07440d45cd
9 changed files with 137 additions and 55 deletions

View File

@@ -8,6 +8,8 @@ import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.guideshow.provider.GuideShowProviderConstant;
import com.mogo.module.guideshow.provider.IGuideShowProvider;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
@@ -30,12 +32,14 @@ public class AppServiceHandler {
private static IMogoServiceApis mApis;
private static IMogoCardManager mMogoCardManager;
private static IMogoAnalytics mMogoAnalytics;
private static IGuideShowProvider mMogoGuideShow;
public static void init( final Context context ) {
mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( context );
mMogoCardManager = mApis.getCardManagerApi();
mMogoAnalytics = mApis.getAnalyticsApi();
mMogoGuideShow = (IGuideShowProvider) ARouter.getInstance().build(GuideShowProviderConstant.GUIDE_SHOW_PROVIDER).navigation(context);
}
public static IMogoCardManager getMogoCardManager() {
@@ -44,4 +48,8 @@ public class AppServiceHandler {
public static IMogoAnalytics getMogoAnalytics() {
return mMogoAnalytics;
}
public static IGuideShowProvider getMogoGuideShow() {
return mMogoGuideShow;
}
}

View File

@@ -8,6 +8,7 @@ import com.mogo.commons.mvp.Presenter;
import com.mogo.module.apps.applaunch.AppLaunchFilter;
import com.mogo.module.apps.applaunch.AppLauncher;
import com.mogo.module.apps.applaunch.CardAppLauncher;
import com.mogo.module.apps.applaunch.GuideShowLauncher111;
import com.mogo.module.apps.model.AppInfo;
import com.mogo.module.apps.model.AppsModel;
import com.mogo.service.MogoServicePaths;
@@ -18,16 +19,19 @@ import com.mogo.utils.ThreadPoolService;
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
* @since 2019-12-30
* <p>
* 描述
*/
public class AppsPresenter extends Presenter< AppsView > {
public class AppsPresenter extends Presenter<AppsView> {
private static final String TAG = "AppsPresenter";
@@ -37,81 +41,102 @@ public class AppsPresenter extends Presenter< AppsView > {
private IMogoCardManager mCardManager;
private IMogoStatusManager mMogoStatusManager;
public AppsPresenter( AppsView view ) {
super( view );
mCardManager = ( IMogoCardManager ) ARouter.getInstance().build( MogoServicePaths.PATH_CARD_MANAGER ).navigation( getContext() );
CardAppLauncher cardAppLauncher = new CardAppLauncher( this, mCardManager );
cardAppLauncher.setNext( new AppLauncher() );
public AppsPresenter(AppsView view) {
super(view);
mCardManager = (IMogoCardManager) ARouter.getInstance().build(MogoServicePaths.PATH_CARD_MANAGER).navigation(getContext());
CardAppLauncher cardAppLauncher = new CardAppLauncher(this, mCardManager);
cardAppLauncher.setNext(new GuideShowLauncher111());
cardAppLauncher.setNext(new AppLauncher());
mLauncher = cardAppLauncher;
}
@Override
public void onCreate( @NonNull LifecycleOwner owner ) {
super.onCreate( owner );
public void onCreate(@NonNull LifecycleOwner owner) {
super.onCreate(owner);
renderAppsList();
AppsListChangedLiveData.getInstance().observeForever( bool -> {
if ( mView != null ) {
AppsListChangedLiveData.getInstance().observeForever(bool -> {
if (mView != null) {
renderAppsList();
}
} );
});
mAnalytics = ( IMogoAnalytics ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_ANALYTICS ).navigation( getContext() );
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation();
mMogoStatusManager.setAppListUIShow( TAG, true );
mAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation(getContext());
mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation();
mMogoStatusManager.setAppListUIShow(TAG, true);
}
private void renderAppsList() {
ThreadPoolService.execute( () -> {
AppsModel.getInstance( getContext() ).load( appInfoList -> {
ThreadPoolService.execute(() -> {
AppsModel.getInstance(getContext()).load(appInfoList -> {
Logger.d( TAG, "apps: %s", appInfoList );
UiThreadHandler.post( () -> {
if ( mView != null ) {
mView.renderApps( appInfoList );
Logger.d(TAG, "apps: %s", appInfoList);
UiThreadHandler.post(() -> {
if (mView != null) {
mView.renderApps(addGuideAppEntrance(appInfoList));
}
} );
} );
});
});
} );
});
}
public void launch( AppInfo appInfo ) {
if ( appInfo == null ) {
private Map<Integer, List<AppInfo>> addGuideAppEntrance(Map<Integer, List<AppInfo>> appInfoMap) {
Map<Integer, List<AppInfo>> result;
if (appInfoMap == null) {
result = new HashMap<>();
} else {
result = new HashMap<>();
result.putAll(appInfoMap);
}
if (result.isEmpty()) {
result.put(0, new ArrayList<>());
} else if (result.get(result.size() - 1) == null) {
result.put(result.size() - 1, new ArrayList<>());
} else if (result.get(result.size() - 1).size() == AppsConst.TOTAL_SIZE_EACH_PAGE) {
result.put(result.size(), new ArrayList<>());
}
// 添加逻辑
result.get(result.size() - 1).add(new AppInfo(GuideShowLauncher111.Companion.getAPP_INFO_NAME_GUIDE_SHOW(), getContext().getPackageName(), null, 0, null, R.drawable.module_apps_ic_guide_show));
return result;
}
public void launch(AppInfo appInfo) {
if (appInfo == null) {
return;
}
trackAppClicked( appInfo );
trackAppClicked(appInfo);
try {
mLauncher.launch( getContext(), appInfo );
} catch ( Exception e ) {
mLauncher.launch(getContext(), appInfo);
} catch (Exception e) {
}
}
private void trackAppClicked( AppInfo appInfo ) {
if ( appInfo == null ) {
private void trackAppClicked(AppInfo appInfo) {
if (appInfo == null) {
return;
}
Map< String, Object > properties = new HashMap<>();
properties.put( "appname", appInfo.getName() );
properties.put( "packagename", appInfo.getPackageName() );
properties.put( "appversion", appInfo.getVersionName() );
properties.put( "from", 1 );
mAnalytics.track( "appenterfront", properties );
Map<String, Object> properties = new HashMap<>();
properties.put("appname", appInfo.getName());
properties.put("packagename", appInfo.getPackageName());
properties.put("appversion", appInfo.getVersionName());
properties.put("from", 1);
mAnalytics.track("appenterfront", properties);
}
@Override
public void onDestroy( @NonNull LifecycleOwner owner ) {
super.onDestroy( owner );
mMogoStatusManager.setAppListUIShow( TAG, false );
public void onDestroy(@NonNull LifecycleOwner owner) {
super.onDestroy(owner);
mMogoStatusManager.setAppListUIShow(TAG, false);
AppsListChangedLiveData.getInstance().release();
mView = null;
mLauncher.destroy();
}
public void exit() {
if ( mView != null ) {
if (mView != null) {
mView.exit();
}
}

View File

@@ -0,0 +1,26 @@
package com.mogo.module.apps.applaunch;
import android.content.Context;
import com.mogo.module.apps.model.AppInfo;
public class GuideShowLauncher extends BaseAppLauncher {
public static final String TAG = "GuideShowLauncher";
public static final String APP_INFO_NAME_GUIDE_SHOW = "APP_INFO_NAME_GUIDE_SHOW";
@Override
public void launch(Context context, AppInfo appInfo) {
if (appInfo != null && APP_INFO_NAME_GUIDE_SHOW.equals(appInfo.getName())) {
// AppServiceHandler.getMogoGuideShow().playGuideVideo(s -> );
}
}
@Override
public void destroy() {
if (getNext() != null) {
getNext().destroy();
setNext(null);
}
}
}

View File

@@ -1,15 +0,0 @@
package com.mogo.module.apps.applaunch
import android.content.Context
import com.mogo.module.apps.model.AppInfo
class GuideShowLauncher : BaseAppLauncher() {
override fun launch(context: Context, appInfo: AppInfo) {
}
override fun destroy() {
}
}

View File

@@ -0,0 +1,36 @@
package com.mogo.module.apps.applaunch
import android.content.Context
import com.mogo.module.apps.AppServiceHandler
import com.mogo.module.apps.R
import com.mogo.module.apps.model.AppInfo
import com.mogo.utils.TipToast
import com.mogo.utils.logger.Logger
class GuideShowLauncher111 : BaseAppLauncher() {
companion object {
const val TAG = "GuideShowLauncher111"
val APP_INFO_NAME_GUIDE_SHOW = "APP_INFO_NAME_GUIDE_SHOW"
}
override fun launch(context: Context, appInfo: AppInfo) {
if (appInfo != null && APP_INFO_NAME_GUIDE_SHOW == appInfo.name) {
try {
AppServiceHandler.getMogoGuideShow().playGuideVideo {
Logger.e(TAG, it)
}
} catch (e: Exception) {
Logger.e(TAG, e, "error.")
TipToast.shortTip(R.string.module_apps_str_no_guide_show)
}
}
}
override fun destroy() {
if (next != null) {
next.destroy()
next = null
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -1,6 +1,7 @@
<resources>
<string name="app_name">mogo-module-apps</string>
<string name="module_apps_str_no_app">APP 未安装</string>
<string name="module_apps_str_no_guide_show">新手引导服务未加载</string>
<string-array name="module_apps_array_filter_packages">
<item>com.mogo.launcher</item>
</string-array>

View File

@@ -86,6 +86,7 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
Logger.d(TAG, "onDestroy invokeTag : $invokeTag")
closeAuthorizeView()
invokeTag?.let {
MogoAuthorizeRegisterHandler.getAuthorizeContentListener(it)?.requestContentFailed("user exit authorize by back press")
MogoAuthorizeRegisterHandler.getAuthorizeListener(it)?.authorizeFailed("user exit authorize by back press")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

After

Width:  |  Height:  |  Size: 323 KiB