opt
This commit is contained in:
@@ -22,5 +22,16 @@
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<activity
|
||||
android:name=".AppsListActivity"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:resizeableActivity="true"
|
||||
android:resumeWhilePausing="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:stateNotNeeded="true"
|
||||
android:theme="@style/AppsList"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -105,8 +105,7 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
|
||||
@Override
|
||||
public void openAppsPanel() {
|
||||
mAppsFragment = new AppsFragment();
|
||||
mMogoFragmentManager.push( new FragmentDescriptor.Builder().hasTransition( true ).fragment( mAppsFragment ).tag( "apps" ).notifyMainModule( false ).build() );
|
||||
AppsListActivity.start( getActivity() );
|
||||
}
|
||||
|
||||
private void trackNavigatorClickEvent( int type ) {
|
||||
@@ -117,9 +116,6 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
|
||||
@Override
|
||||
public void closeAppsPanel() {
|
||||
if ( getActivity() != null ) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,12 +7,11 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.module.apps.utils.LaunchUtils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.TipToast;
|
||||
|
||||
import org.json.JSONException;
|
||||
@@ -26,7 +25,10 @@ import org.json.JSONObject;
|
||||
*/
|
||||
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener {
|
||||
|
||||
private static final String TAG = "AppNavigatorPresenter";
|
||||
|
||||
IMogoIntentManager mIntentManager;
|
||||
IMogoStatusManager mMogoStatusManager;
|
||||
|
||||
public AppNavigatorPresenter( AppNavigatorView view ) {
|
||||
super( view );
|
||||
@@ -36,20 +38,10 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation( getContext() );
|
||||
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
if ( !AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
|
||||
@@ -62,8 +54,6 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_OPEN.equals( operation ) ) {
|
||||
mView.openAppsPanel();
|
||||
} else if ( AppsConst.OPERATION_CLOSE.equals( operation ) ) {
|
||||
mView.closeAppsPanel();
|
||||
}
|
||||
} else if ( AppsConst.OBJECT_FAST_SETTINGS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_OPEN.equals( operation ) ) {
|
||||
@@ -82,7 +72,7 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
if ( mIntentManager != null ) {
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION );
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
}
|
||||
super.onDestroy( owner );
|
||||
}
|
||||
|
||||
@@ -2,24 +2,19 @@ package com.mogo.module.apps;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
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.GridViewPagerScroller;
|
||||
import com.mogo.module.apps.view.PagerSlidingTabStripV2;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -33,16 +28,16 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
|
||||
public static final String TAG = "AppsFragment";
|
||||
|
||||
private BottomSheetBehavior mBottomSheetBehavior;
|
||||
private ViewPager mAppsPager;
|
||||
private AppsPagerAdapter mAppsPagerAdapter;
|
||||
|
||||
private View mExit;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
private View mLoadingView;
|
||||
private PagerSlidingTabStripV2 mIndicator;
|
||||
|
||||
private GridViewPagerScroller mScroller;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_apps_fragment_apps;
|
||||
@@ -54,31 +49,30 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
mExit = findViewById( R.id.module_apps_id_apps_exit );
|
||||
mExit.setOnClickListener( view -> {
|
||||
if ( getActivity() != null ) {
|
||||
getActivity().onBackPressed();
|
||||
getActivity().finish();
|
||||
getActivity().overridePendingTransition( R.anim.module_apps_anim_enter, R.anim.module_apps_anim_exit);
|
||||
}
|
||||
} );
|
||||
// mAppsList = findViewById( R.id.module_apps_id_apps );
|
||||
// mAppsList.setLayoutManager( new GridLayoutManager( getContext(), 8 ) );
|
||||
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 );
|
||||
mIndicator.setOpenPadding( true );
|
||||
|
||||
try {
|
||||
Field mField = ViewPager.class.getDeclaredField("mScroller");
|
||||
mField.setAccessible(true);
|
||||
mScroller = new GridViewPagerScroller(getContext(), new DecelerateInterpolator());
|
||||
mField.set(mAppsPager, mScroller);
|
||||
mScroller.setDuration(160);
|
||||
|
||||
Field field = ViewPager.class.getDeclaredField("mTouchSlop");
|
||||
field.setAccessible(true);
|
||||
field.setInt(mAppsPager, 4);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -90,7 +84,6 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,33 +111,33 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
}
|
||||
}
|
||||
|
||||
@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 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() {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.mogo.commons.mvp.MvpActivity;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-28
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsListActivity extends MvpActivity< AppsListView, AppsListPresenter > implements AppsListView, FragmentStackTransactionListener {
|
||||
|
||||
private BottomSheetBehavior mBottomSheetBehavior;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
public static void start( Activity context ) {
|
||||
Intent starter = new Intent( context, AppsListActivity.class );
|
||||
context.startActivity( starter );
|
||||
context.overridePendingTransition( R.anim.module_apps_anim_enter, R.anim.module_apps_anim_exit);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_apps_activiity_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add( R.id.module_apps_id_container, new AppsFragment() )
|
||||
.commitAllowingStateLoss();
|
||||
|
||||
mBottomSheetBehavior = BottomSheetBehavior.from( findViewById( R.id.module_apps_id_container ) );
|
||||
mBottomSheetBehavior.setSkipCollapsed( true );
|
||||
mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged( @NonNull View bottomSheet, int newState ) {
|
||||
if ( newState == BottomSheetBehavior.STATE_COLLAPSED ) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
|
||||
|
||||
}
|
||||
} );
|
||||
mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_EXPANDED );
|
||||
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( this );
|
||||
mMogoFragmentManager.addMainFragmentStackTransactionListener( this );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected AppsListPresenter createPresenter() {
|
||||
return new AppsListPresenter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransaction( int size ) {
|
||||
if ( size == 0 ) {
|
||||
closeAppsPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAppsPanel() {
|
||||
finish();
|
||||
overridePendingTransition( R.anim.module_apps_anim_enter, R.anim.module_apps_anim_exit);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMogoFragmentManager.removeMainFragmentStackTransactionListener( this );
|
||||
mMogoFragmentManager = null;
|
||||
mBottomSheetBehavior = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.apps.utils.LaunchUtils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.utils.TipToast;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-28
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsListPresenter extends Presenter< AppsListView > implements IMogoIntentListener {
|
||||
|
||||
private static final String TAG = "AppsListPresenter";
|
||||
|
||||
private IMogoIntentManager mIntentManager;
|
||||
|
||||
public AppsListPresenter( AppsListView view ) {
|
||||
super( view );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
|
||||
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
if ( !AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_CLOSE.equals( operation ) ) {
|
||||
mView.closeAppsPanel();
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-28
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface AppsListView extends IView {
|
||||
|
||||
void closeAppsPanel();
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.mogo.module.apps.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* Created by zeu on 2017/11/14.
|
||||
*/
|
||||
|
||||
public class GridAverageView extends ViewGroup {
|
||||
int mColumnCount = 1;
|
||||
int mRowCount = 1;
|
||||
|
||||
/**
|
||||
* 网格均等分布
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public GridAverageView( Context context ) {
|
||||
super( context );
|
||||
}
|
||||
|
||||
public GridAverageView( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public GridAverageView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
public void setColumnCount( int mColumnCount ) {
|
||||
this.mColumnCount = mColumnCount;
|
||||
}
|
||||
|
||||
public void setRowCount( int mRowCount ) {
|
||||
this.mRowCount = mRowCount;
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return mColumnCount;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return mRowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
|
||||
int averageWidth = MeasureSpec.getSize( widthMeasureSpec ) / getColumnCount();
|
||||
int averageHeight = MeasureSpec.getSize( heightMeasureSpec ) / getRowCount();
|
||||
for ( int i = 0; i < getChildCount(); i++ ) {
|
||||
View child = this.getChildAt( i );
|
||||
child.measure( MeasureSpec.makeMeasureSpec( averageWidth, MeasureSpec.EXACTLY ), MeasureSpec.makeMeasureSpec( averageHeight, MeasureSpec.EXACTLY ) );
|
||||
}
|
||||
setMeasuredDimension( widthMeasureSpec, heightMeasureSpec );
|
||||
super.onMeasure( widthMeasureSpec, heightMeasureSpec );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout( boolean changed, int l, int t, int r, int b ) {
|
||||
int width = r - l - getPaddingLeft() - getPaddingRight();
|
||||
int height = b - t - getPaddingBottom() - getPaddingTop();
|
||||
int childWidth = width / getColumnCount();
|
||||
int childHeight = height / getRowCount();
|
||||
|
||||
int size = getChildCount();
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
View child = getChildAt( i );
|
||||
int row = i / getColumnCount();
|
||||
int col = i % getColumnCount();
|
||||
int cl = 0 + childWidth * col;
|
||||
int cr = cl + childWidth;
|
||||
|
||||
int ct = 0 + childHeight * row;
|
||||
int cb = ct + childHeight;
|
||||
child.layout( cl, ct, cr, cb );
|
||||
}
|
||||
}
|
||||
|
||||
public void setAdapter( BaseAdapter adapter ) {
|
||||
if ( adapter == null ) {
|
||||
return;
|
||||
}
|
||||
final int size = adapter.getCount();
|
||||
if ( size <= 0 ) {
|
||||
return;
|
||||
}
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
View childView = adapter.getView( i, null, this );
|
||||
addView( childView );
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.module.apps.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.Scroller;
|
||||
|
||||
public class GridViewPagerScroller extends Scroller {
|
||||
private int duration;
|
||||
|
||||
public GridViewPagerScroller( Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public GridViewPagerScroller( Context context, Interpolator interpolator) {
|
||||
super(context, interpolator);
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScroll(int startX, int startY, int dx, int dy) {
|
||||
super.startScroll(startX, startY, dx, dy,this.duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
|
||||
super.startScroll(startX, startY, dx, dy, this.duration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="250">
|
||||
<translate
|
||||
android:fromXDelta="0"
|
||||
android:fromYDelta="100%"
|
||||
android:toXDelta="0"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:toYDelta="0" />
|
||||
</set>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="250">
|
||||
<translate
|
||||
android:fromXDelta="0"
|
||||
android:fromYDelta="0"
|
||||
android:toXDelta="0"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:toYDelta="100%" />
|
||||
</set>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_apps_id_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:behavior_hideable="false"
|
||||
app:behavior_peekHeight="0dp"
|
||||
app:layout_behavior="@string/bottom_sheet_behavior">
|
||||
|
||||
</FrameLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -1,58 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
|
||||
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent">-->
|
||||
|
||||
<!-- <androidx.recyclerview.widget.RecyclerView-->
|
||||
<!-- android:id="@+id/module_apps_id_apps"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- app:behavior_hideable="false"-->
|
||||
<!-- app:behavior_peekHeight="76dp"-->
|
||||
<!-- app:layout_behavior="@string/bottom_sheet_behavior" />-->
|
||||
<!--</androidx.coordinatorlayout.widget.CoordinatorLayout>-->
|
||||
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/module_apps_id_apps_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="#0C0C0C">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_apps_id_apps_container"
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_apps_exit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/module_apps_ic_retract" />
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/module_apps_id_apps_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#0C0C0C"
|
||||
app:behavior_hideable="false"
|
||||
app:behavior_peekHeight="0dp"
|
||||
app:layout_behavior="@string/bottom_sheet_behavior">
|
||||
android:layout_marginTop="@dimen/module_apps_pager_marginTop"
|
||||
android:overScrollMode="never" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_apps_exit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/module_apps_ic_retract" />
|
||||
<com.mogo.module.apps.view.PagerSlidingTabStripV2
|
||||
android:id="@+id/module_apps_id_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginBottom="@dimen/module_apps_indicator_marginBottom"
|
||||
app:pstsV2TabPaddingLeftRight="@dimen/module_apps_indicator_interval" />
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/module_apps_id_apps_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/module_apps_pager_marginTop"
|
||||
android:overScrollMode="never" />
|
||||
|
||||
<com.mogo.module.apps.view.PagerSlidingTabStripV2
|
||||
android:id="@+id/module_apps_id_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginBottom="@dimen/module_apps_indicator_marginBottom"
|
||||
app:pstsV2TabPaddingLeftRight="@dimen/module_apps_indicator_interval" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/module_apps_id_loading"
|
||||
android:layout_width="@dimen/dp_75"
|
||||
android:layout_height="@dimen/dp_75"
|
||||
android:layout_gravity="center" />
|
||||
</FrameLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
<ProgressBar
|
||||
android:id="@+id/module_apps_id_loading"
|
||||
android:layout_width="@dimen/dp_75"
|
||||
android:layout_height="@dimen/dp_75"
|
||||
android:layout_gravity="center" />
|
||||
</FrameLayout>
|
||||
29
modules/mogo-module-apps/src/main/res/values/styles.xml
Normal file
29
modules/mogo-module-apps/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="AppsList" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="android:windowTranslucentStatus">false</item>
|
||||
<item name="android:windowEnterAnimation">@null</item>
|
||||
<item name="android:windowExitAnimation">@null</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowTranslucentNavigation">false</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:windowAnimationStyle">@style/AppsListAnimation</item>
|
||||
<!--设置窗口的背景是否为半透明,设置透明背景必须要设置此项-->
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppsListAnimation">
|
||||
<item name="android:activityOpenEnterAnimation">@anim/module_apps_anim_enter</item>
|
||||
<item name="android:activityOpenExitAnimation">@anim/module_apps_anim_exit</item>
|
||||
<item name="android:activityCloseEnterAnimation">@anim/module_apps_anim_enter</item>
|
||||
<item name="android:activityCloseExitAnimation">@anim/module_apps_anim_exit</item>
|
||||
<item name="android:taskOpenEnterAnimation">@null</item>
|
||||
<item name="android:taskOpenExitAnimation">@null</item>
|
||||
<item name="android:taskCloseEnterAnimation">@null</item>
|
||||
<item name="android:taskCloseExitAnimation">@null</item>
|
||||
<item name="android:taskToFrontEnterAnimation">@null</item>
|
||||
<item name="android:taskToFrontExitAnimation">@null</item>
|
||||
<item name="android:taskToBackEnterAnimation">@null</item>
|
||||
<item name="android:taskToBackExitAnimation">@null</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user