This commit is contained in:
wangcongtao
2020-01-12 15:30:43 +08:00
parent 590ef1fc1f
commit 246f2471a1
115 changed files with 354 additions and 143 deletions

View File

@@ -23,7 +23,7 @@ import com.mogo.service.module.IMogoModuleProvider;
* <p>
* 描述
*/
public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView > > implements IView {
public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavigatorPresenter > implements AppNavigatorView {
private View mNavigation;
private View mMediaCenter;
@@ -62,16 +62,14 @@ public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView >
mCarSettings.setOnClickListener( view -> {
} );
mApps.setOnClickListener( view -> {
mAppsFragment = new AppsFragment();
mMogoFragmentManager.push( new FragmentDescriptor.Builder().fragment( mAppsFragment ).tag( "apps" ).notifyMainModule( false ).build() );
openAppsPanel();
} );
}
@NonNull
@Override
protected Presenter< IView > createPresenter() {
return new Presenter< IView >( this ) {
};
protected AppNavigatorPresenter createPresenter() {
return new AppNavigatorPresenter( this );
}
@Override
@@ -79,4 +77,17 @@ public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView >
super.onActivityCreated( savedInstanceState );
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( getContext() );
}
@Override
public void openAppsPanel() {
mAppsFragment = new AppsFragment();
mMogoFragmentManager.push( new FragmentDescriptor.Builder().hasTransition( true ).fragment( mAppsFragment ).tag( "apps" ).notifyMainModule( false ).build() );
}
@Override
public void closeAppsPanel() {
if ( getActivity() != null ) {
getActivity().onBackPressed();
}
}
}

View File

@@ -0,0 +1,70 @@
package com.mogo.module.apps;
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;
/**
* @author congtaowang
* @since 2020-01-12
* <p>
* 描述
*/
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoVoiceCmdCallBack {
public AppNavigatorPresenter( AppNavigatorView view ) {
super( view );
}
@Override
public void onCreate( @NonNull LifecycleOwner owner ) {
super.onCreate( owner );
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_OPEN_APPS_PANEL, AppsConst.CMD_OPEN_APPS_PANEL_UN_WAKEUP_WORDS, this );
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_CLOSE_APPS_PANEL, AppsConst.CMD_CLOSE_APPS_PANEL_UN_WAKEUP_WORDS, this );
}
@Override
public void onCmdSelected( String cmd ) {
if ( mView == null ) {
return;
}
switch ( cmd ) {
case AppsConst.CMD_OPEN_APPS_PANEL:
mView.openAppsPanel();
break;
case AppsConst.CMD_CLOSE_APPS_PANEL:
mView.closeAppsPanel();
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 ) {
}
@Override
public void onDestroy( @NonNull LifecycleOwner owner ) {
super.onDestroy( owner );
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_OPEN_APPS_PANEL );
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_CLOSE_APPS_PANEL );
}
}

View File

@@ -0,0 +1,23 @@
package com.mogo.module.apps;
import com.mogo.commons.mvp.IView;
/**
* @author congtaowang
* @since 2020-01-12
* <p>
* 描述
*/
public interface AppNavigatorView extends IView {
/**
* 打开全部应用
*/
void openAppsPanel();
/**
* 关闭全部应用
*/
void closeAppsPanel();
}

View File

@@ -8,5 +8,14 @@ package com.mogo.module.apps;
*/
public class AppsConst {
/**
* 每页显示多少个app
*/
public static final int TOTAL_SIZE_EACH_PAGE = 12;
public static final String CMD_OPEN_APPS_PANEL = "CMD_OPEN_APPS_PANEL";
public static final String[] CMD_OPEN_APPS_PANEL_UN_WAKEUP_WORDS = {"第一个"};
public static final String CMD_CLOSE_APPS_PANEL = "CMD_CLOSE_APPS_PANEL";
public static final String[] CMD_CLOSE_APPS_PANEL_UN_WAKEUP_WORDS = {"第二个"};
}

View File

@@ -2,12 +2,16 @@ package com.mogo.module.apps;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.ViewPager;
import com.alibaba.android.arouter.launcher.ARouter;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.module.apps.model.AppInfo;
import com.mogo.module.apps.view.LinePageIndicator;
@@ -28,7 +32,7 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
public static final String TAG = "AppsFragment";
// private BottomSheetBehavior mBottomSheetBehavior;
private BottomSheetBehavior mBottomSheetBehavior;
private ViewPager mAppsPager;
private AppsPagerAdapter mAppsPagerAdapter;
@@ -48,24 +52,28 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
mAppsPager = findViewById( R.id.module_apps_id_apps_pager );
mExit = findViewById( R.id.module_apps_id_apps_exit );
mExit.setOnClickListener( view -> {
mMogoFragmentManager.pop();
if ( getActivity() != null ) {
getActivity().onBackPressed();
}
} );
// mAppsList = findViewById( R.id.module_apps_id_apps );
// mAppsList.setLayoutManager( new GridLayoutManager( getContext(), 8 ) );
// mBottomSheetBehavior = BottomSheetBehavior.from( mAppsList );
// mBottomSheetBehavior.setSkipCollapsed( true );
// mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
// @Override
// public void onStateChanged( @NonNull View bottomSheet, int newState ) {
//
// }
//
// @Override
// public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
//
// }
// } );
// mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED );
mBottomSheetBehavior = BottomSheetBehavior.from( findViewById( R.id.module_apps_id_apps_container ) );
mBottomSheetBehavior.setSkipCollapsed( true );
mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged( @NonNull View bottomSheet, int newState ) {
if ( newState == BottomSheetBehavior.STATE_COLLAPSED ) {
mMogoFragmentManager.pop();
}
}
@Override
public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
}
} );
mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_EXPANDED );
mLoadingView = findViewById( R.id.module_apps_id_loading );
mLoadingView.setVisibility( View.VISIBLE );
mIndicator = findViewById( R.id.module_apps_id_indicator );
@@ -100,6 +108,34 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
mLoadingView.setVisibility( View.GONE );
}
@Override
public Animation onCreateAnimation( int transit, boolean enter, int nextAnim ) {
TranslateAnimation animation = null;
if ( transit == FragmentTransaction.TRANSIT_FRAGMENT_OPEN ) {
if ( enter ) {
animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0 );
} else {
animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0 );
}
} else if ( FragmentTransaction.TRANSIT_FRAGMENT_CLOSE == transit ) {
if ( enter ) {
animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0 );
} else {
animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0 );
}
}
if ( animation == null ) {
animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1 );
}
animation.setDuration( 300 );
return animation;
}
@Override
public void onDestroyView() {
super.onDestroyView();