opt
This commit is contained in:
@@ -40,7 +40,7 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
AppServiceHandler.getApis().getRegisterCenterApi().registerMogoNaviListener( TAG, this );
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
// 预加载应用列表,空间换时间
|
||||
// AppsModel.getInstance( getContext() ).load( null );
|
||||
AppsModel.getInstance( getContext() ).load( null );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,6 @@ public class AppsListActivity extends MvpActivity< AppsListView, AppsListPresent
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
AppsModel.getInstance( this ).release();
|
||||
AppServiceHandler.getApis().getStatusManagerApi().setAppListUIShow( TAG, false );
|
||||
mMogoFragmentManager.removeMainFragmentStackTransactionListener( this );
|
||||
mMogoFragmentManager = null;
|
||||
|
||||
@@ -80,6 +80,11 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
|
||||
Logger.d( TAG, "apps: %s", appInfoList );
|
||||
final Map< Integer, List< AppInfo > > result = addOthersEntrances( appInfoList );
|
||||
try {
|
||||
filterSamePackage( result );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mView != null ) {
|
||||
mView.renderApps( result );
|
||||
@@ -143,7 +148,7 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
}
|
||||
}
|
||||
}
|
||||
// growthCapacity( result );
|
||||
// growthCapacity( result )
|
||||
// // 添加介绍入口
|
||||
// result.get( result.size() - 1 ).add( new AppInfo( GuideShowLauncher.APP_INFO_NAME_GUIDE_SHOW, getContext().getPackageName(), null, 0, null, R.drawable.module_apps_ic_guide_show ) );
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
@@ -154,6 +159,30 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void filterSamePackage( Map< Integer, List< AppInfo > > appInfoMap ) {
|
||||
if ( appInfoMap == null || appInfoMap.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
for ( Map.Entry< Integer, List< AppInfo > > integerListEntry : appInfoMap.entrySet() ) {
|
||||
if ( integerListEntry == null ) {
|
||||
continue;
|
||||
}
|
||||
List< AppInfo > oldList = integerListEntry.getValue();
|
||||
if ( oldList == null
|
||||
|| oldList.size() > AppsConst.TOTAL_SIZE_EACH_PAGE ) {
|
||||
return;
|
||||
}
|
||||
List< AppInfo > appInfos = new ArrayList<>();
|
||||
for ( AppInfo appInfo : oldList ) {
|
||||
if ( appInfos.contains( appInfo ) ) {
|
||||
continue;
|
||||
}
|
||||
appInfos.add( appInfo );
|
||||
}
|
||||
integerListEntry.setValue( appInfos );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩容
|
||||
*
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -29,7 +32,7 @@ public class AppInfo {
|
||||
}
|
||||
|
||||
public AppInfo( String mName, String mPackageName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId ) {
|
||||
this(mName, mPackageName, mVersionName, mVersionCode, mIcon, mIconResId, 0);
|
||||
this( mName, mPackageName, mVersionName, mVersionCode, mIcon, mIconResId, 0 );
|
||||
}
|
||||
|
||||
public int getIconResId() {
|
||||
@@ -60,6 +63,19 @@ public class AppInfo {
|
||||
return mTrackType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o ) {
|
||||
if ( this == o ) return true;
|
||||
if ( o == null || getClass() != o.getClass() ) return false;
|
||||
AppInfo appInfo = ( AppInfo ) o;
|
||||
return TextUtils.equals( mPackageName, appInfo.mPackageName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( mPackageName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AppInfo{" +
|
||||
|
||||
@@ -63,16 +63,15 @@ public class AppsModel {
|
||||
}
|
||||
|
||||
public void load( AppLoadCallback callback ) {
|
||||
// if ( !mPagedApps.isEmpty() ) {
|
||||
// if ( callback != null ) {
|
||||
// callback.onLoaded( mPagedApps );
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
if ( !mPagedApps.isEmpty() ) {
|
||||
if ( callback != null ) {
|
||||
callback.onLoaded( mPagedApps );
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( mAppFilter == null ) {
|
||||
mAppFilter = new AppFilterImpl( mContext );
|
||||
}
|
||||
mPagedApps.clear();
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
List< PackageInfo > packages = packageManager.getInstalledPackages( 0 );
|
||||
int counter = 0;
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/module_service_marker_bubble_icon_width"
|
||||
android:layout_height="@dimen/module_service_marker_bubble_icon_height"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="@dimen/module_service_marker_bubble_icon_marginBottom"
|
||||
tools:src="@drawable/icon_map_marker_road_block_up" />
|
||||
tools:src="@drawable/icon_map_marker_road_block_up2" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/module_service_marker_bubble_icon_width"
|
||||
android:layout_height="@dimen/module_service_marker_bubble_icon_height"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/dp_15"
|
||||
android:visibility="invisible"
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<dimen name="module_service_marker_dot_marginTop">8dp</dimen>
|
||||
<dimen name="module_service_marker_bubble_width">100px</dimen>
|
||||
<dimen name="module_service_marker_bubble_height">117px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_width">50px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_height">50px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_width">60px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_height">60px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_marginBottom">8px</dimen>
|
||||
|
||||
<!-- 导航查看全程显示范围-->
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<dimen name="module_service_marker_dot_marginTop">4dp</dimen>
|
||||
<dimen name="module_service_marker_bubble_width">56px</dimen>
|
||||
<dimen name="module_service_marker_bubble_height">65px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_width">27px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_height">27px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_width">35px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_height">35px</dimen>
|
||||
<dimen name="module_service_marker_bubble_icon_marginBottom">4px</dimen>
|
||||
|
||||
<dimen name="module_service_marker_bounds_leftMargin">550px</dimen>
|
||||
|
||||
Reference in New Issue
Block a user