Merge branch 'qa' into dev
This commit is contained in:
@@ -25,22 +25,12 @@ public class AppsAdapter extends BaseAdapter {
|
||||
private List< AppInfo > mAppInfos;
|
||||
|
||||
public AppsAdapter( List< AppInfo > appInfos ) {
|
||||
List< AppInfo > newList = new ArrayList<>( appInfos );
|
||||
this.mAppInfos = new ArrayList<>();
|
||||
if ( newList != null && !newList.isEmpty() ) {
|
||||
for ( AppInfo appInfo : newList ) {
|
||||
if ( mAppInfos.contains( appInfo ) ) {
|
||||
continue;
|
||||
}
|
||||
mAppInfos.add( appInfo );
|
||||
}
|
||||
}
|
||||
this.mAppInfos = new ArrayList<>( appInfos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
int size = mAppInfos == null ? 0 : mAppInfos.size();
|
||||
size = size > AppsConst.TOTAL_SIZE_EACH_PAGE ? AppsConst.TOTAL_SIZE_EACH_PAGE : size;
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.sql.ClientInfoStatus;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -80,9 +81,10 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
|
||||
Logger.d( TAG, "apps: %s", appInfoList );
|
||||
final Map< Integer, List< AppInfo > > result = addOthersEntrances( appInfoList );
|
||||
final Map< Integer, List< AppInfo > > newResult = rePutInOrderAppList( result );
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mView != null ) {
|
||||
mView.renderApps( result );
|
||||
mView.renderApps( newResult );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
@@ -172,6 +174,39 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
}
|
||||
}
|
||||
|
||||
private Map< Integer, List< AppInfo > > rePutInOrderAppList( Map< Integer, List< AppInfo > > target ) {
|
||||
if ( target == null || target.isEmpty() ) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Map< Integer, List< AppInfo > > result = new HashMap<>();
|
||||
synchronized ( target ) {
|
||||
List< AppInfo > list = new ArrayList<>();
|
||||
for ( List< AppInfo > value : target.values() ) {
|
||||
for ( AppInfo appInfo : value ) {
|
||||
if ( list.contains( appInfo ) ) {
|
||||
continue;
|
||||
}
|
||||
list.add( appInfo );
|
||||
}
|
||||
}
|
||||
int page = 0;
|
||||
int counter = 0;
|
||||
for ( AppInfo appInfo : list ) {
|
||||
if ( counter < AppsConst.TOTAL_SIZE_EACH_PAGE ) {
|
||||
counter++;
|
||||
} else {
|
||||
page++;
|
||||
counter = 0;
|
||||
}
|
||||
if ( !result.containsKey( page ) ) {
|
||||
result.put( page, new ArrayList<>() );
|
||||
}
|
||||
result.get( page ).add( appInfo );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void launch( AppInfo appInfo ) {
|
||||
if ( appInfo == null ) {
|
||||
return;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.main;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
@@ -26,6 +27,7 @@ import com.mogo.module.main.windowview.FloatingViewHandler;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.obu.IMogoObuManager;
|
||||
@@ -43,7 +45,8 @@ import java.util.List;
|
||||
*/
|
||||
public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView,
|
||||
IMogoLocationListener,
|
||||
IMogoMarkerClickListener {
|
||||
IMogoMarkerClickListener,
|
||||
IMogoIntentListener {
|
||||
|
||||
protected static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
@@ -59,6 +62,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
protected FrameLayout mFloatingLayout;
|
||||
protected FrameLayout mCoverUpLayout;
|
||||
protected View mLeftShadowFrame;
|
||||
private boolean mIsHomeKeyDown = false;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -222,6 +226,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
if ( mCoverUpLayout.getVisibility() != View.VISIBLE ) {
|
||||
mServiceApis.getAdasControllerApi().showADAS();
|
||||
}
|
||||
getApis().getIntentManagerApi().registerIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,7 +234,16 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
super.onPause();
|
||||
mMogoStatusManager.setMainPageResumeStatus( TAG, false );
|
||||
mMogoStatusManager.setMainPageLaunchedStatus( TAG, false );
|
||||
mServiceApis.getAdasControllerApi().closeADAS();
|
||||
if ( !mIsHomeKeyDown ) {
|
||||
mServiceApis.getAdasControllerApi().closeADAS();
|
||||
}
|
||||
mIsHomeKeyDown = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
getApis().getIntentManagerApi().unregisterIntentListener( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,6 +275,13 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
return mServiceApis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
if ( TextUtils.equals( Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentStr ) ) {
|
||||
mIsHomeKeyDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -405,6 +405,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
filter.addAction( MogoReceiver.ACTION_ADAS_STATUS );
|
||||
filter.addAction( MogoReceiver.ACTION_VOICE_READY );
|
||||
filter.addAction( MogoReceiver.ACTION_MOCK );
|
||||
filter.addAction( Intent.ACTION_CLOSE_SYSTEM_DIALOGS );
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
Logger.i( TAG, "register voice receiver." );
|
||||
|
||||
Reference in New Issue
Block a user