opt
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
package com.mogo.module.common;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
@@ -10,26 +16,27 @@ import androidx.annotation.Keep;
|
||||
*/
|
||||
public class MogoModulePaths {
|
||||
|
||||
private static List< String > mModulesPath = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 地图模块 fragment 路径
|
||||
*/
|
||||
public static final String PATH_MODULE_MAP = "/map/ui";
|
||||
|
||||
/**
|
||||
* 测试模块
|
||||
*/
|
||||
public static final String PATH_MODULE_DEMO = "/demo/ui";
|
||||
|
||||
/**
|
||||
* 测试模块
|
||||
*/
|
||||
public static final String PATH_MODULE_DEMO2 = "/demo2/ui";
|
||||
|
||||
/**
|
||||
* app列表模块实例化路径
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_MODULE_APPS = "/appslist/ui";
|
||||
|
||||
public static void addModule( String path ) {
|
||||
if ( TextUtils.isEmpty( path.replace( " ", "" ) ) ) {
|
||||
throw new IllegalArgumentException( "module path can't be empty or null or blank" );
|
||||
}
|
||||
mModulesPath.add( path );
|
||||
}
|
||||
|
||||
public static List< String > getModulesPath() {
|
||||
return mModulesPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.modulemap
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.mogoservice
|
||||
implementation rootProject.ext.dependencies.moduledemo
|
||||
implementation rootProject.ext.dependencies.moduleapps
|
||||
} else {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
@@ -51,7 +50,6 @@ dependencies {
|
||||
implementation project(':modules:mogo-module-map')
|
||||
implementation project(':services:mogo-service-api')
|
||||
implementation project(':services:mogo-service')
|
||||
implementation project(':demo:demo-module-map')
|
||||
implementation project(':modules:mogo-module-apps')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -11,6 +12,8 @@ import com.mogo.commons.mvp.MvpActivity;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.module.main.cards.CardModulesAdapter;
|
||||
import com.mogo.module.main.cards.MogoModulesHandler;
|
||||
import com.mogo.module.main.cards.MogoModulesManager;
|
||||
@@ -19,6 +22,7 @@ import com.mogo.module.main.cards.VerticalStackTransformer;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,7 +33,10 @@ import java.util.List;
|
||||
* 描述
|
||||
*/
|
||||
public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView,
|
||||
IMogoLocationListener {
|
||||
IMogoLocationListener,
|
||||
IMogoMarkerClickListener {
|
||||
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
private IMogoMapService mMogoMapService;
|
||||
private MogoModulesHandler mMogoModuleHandler;
|
||||
@@ -42,6 +49,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
*/
|
||||
private IMogoLocationClient mLocationClient;
|
||||
|
||||
private int mCurrentPosition = 1;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_main_activity_main;
|
||||
@@ -54,14 +63,23 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
mCardsContainer.setOnPageChangeListener( new ViewPager.OnPageChangeListener() {
|
||||
|
||||
private int mLastPosition = -1;
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||
|
||||
Logger.i( TAG, "position = " + position );
|
||||
if ( mLastPosition != position ) {
|
||||
if ( mCardModulesAdapter != null ) {
|
||||
mCardModulesAdapter.render( position );
|
||||
}
|
||||
mLastPosition = position;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected( int position ) {
|
||||
try {
|
||||
mCurrentPosition = position;
|
||||
mMogoModuleHandler.setEnable( mCardModulesAdapter.getProvider( position ).getModuleName() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
@@ -71,37 +89,66 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
||||
if ( mCurrentPosition == 0 ) {
|
||||
mCurrentPosition = mCardModulesAdapter.getCount() - 3;
|
||||
mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
||||
} else if ( mCurrentPosition == mCardModulesAdapter.getCount() - 2 ) {
|
||||
mCurrentPosition = 1;
|
||||
mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public int getCurrentPosition() {
|
||||
return mCurrentPosition;
|
||||
}
|
||||
|
||||
public OrientedViewPager getCardsContainer() {
|
||||
return mCardsContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
|
||||
mMogoModuleHandler = new MogoModulesManager( this );
|
||||
mMogoModuleHandler.onMapLoadedCallback( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Logger.d( TAG, "map loaded." + Thread.currentThread().getName() );
|
||||
loadModules();
|
||||
}
|
||||
} );
|
||||
|
||||
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation();
|
||||
if ( mMogoMapService != null ) {
|
||||
mMogoMapService.getHostListenerRegister().registerHostMapListener( mMogoModuleHandler );
|
||||
mMogoMapService.getHostListenerRegister().registerHostNaviListener( mMogoModuleHandler );
|
||||
mMogoMapService.getHostListenerRegister().registerMarkerClickListener( mMogoModuleHandler );
|
||||
mMogoMapService.getHostListenerRegister().registerMarkerClickListener( this );
|
||||
}
|
||||
|
||||
// 加载地图,触发地图加载完毕回调,在初始化其他卡片模块,保证卡片模块可以正确获取地图相关服务。
|
||||
mMogoModuleHandler.loadMap( R.id.module_main_id_map_fragment_container );
|
||||
mMogoModuleHandler.loadAppsList( R.id.module_main_id_fragment_container );
|
||||
|
||||
mLocationClient = mMogoMapService.getSingletonLocationClient( getApplicationContext() );
|
||||
mLocationClient.addLocationListener( this );
|
||||
mLocationClient.start();
|
||||
|
||||
mMogoModuleHandler.loadAppsList( R.id.module_main_id_fragment_container );
|
||||
}
|
||||
|
||||
private void loadModules() {
|
||||
|
||||
List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCards();
|
||||
mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
||||
mCardsContainer.setOffscreenPageLimit( providers.size() );
|
||||
mCardsContainer.setOffscreenPageLimit( providers.size() + 2 );
|
||||
mCardsContainer.setPageTransformer( true, new VerticalStackTransformer( this ) );
|
||||
mCardsContainer.setAdapter( mCardModulesAdapter );
|
||||
mCardsContainer.setCurrentItem( 0 );
|
||||
mCardsContainer.setCurrentItem( mCurrentPosition );
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected MainPresenter createPresenter() {
|
||||
@@ -115,6 +162,13 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
// int mappedCardPosition = mCardModulesAdapter.getNextCardPosition( marker.getOwner(), mCurrentPosition );
|
||||
// mCardsContainer.setCurrentItem( mappedCardPosition, true );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.mogo.module.main.MainActivity;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,26 +27,43 @@ public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private static final String TAG = "CardModulesAdapter";
|
||||
|
||||
private final FragmentActivity mActivity;
|
||||
private final MainActivity mActivity;
|
||||
private List< IMogoModuleProvider > mProviders;
|
||||
|
||||
private PlaceholderFragmentProvider mLastPH;
|
||||
private PlaceholderFragmentProvider mFirstPH;
|
||||
private PlaceholderFragmentProvider mPH;
|
||||
|
||||
|
||||
public CardModulesAdapter( @NonNull MainActivity fragmentActivity, List< IMogoModuleProvider > providers ) {
|
||||
super( fragmentActivity.getSupportFragmentManager() );
|
||||
mActivity = fragmentActivity;
|
||||
this.mProviders = new ArrayList<>( providers );
|
||||
this.mProviders.add( 0, mLastPH = new PlaceholderFragmentProvider() );
|
||||
this.mProviders.add( mFirstPH = new PlaceholderFragmentProvider() );
|
||||
this.mProviders.add( mPH = new PlaceholderFragmentProvider() );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem( int position ) {
|
||||
int factPosition = getFactPosition( position );
|
||||
Log.i( TAG, "factPosition=" + factPosition );
|
||||
return mProviders.get( factPosition ).createFragment( mActivity, null );
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt( "position", factPosition );
|
||||
Logger.d( TAG, "here" );
|
||||
final Fragment f = mProviders.get( factPosition ).createFragment( mActivity, bundle );
|
||||
if ( position == 0 ) {
|
||||
mLastPH.setCopyTarget( f );
|
||||
} else if ( position == getCount() - 2 ) {
|
||||
mFirstPH.setCopyTarget( f );
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public CardModulesAdapter( @NonNull FragmentActivity fragmentActivity, List< IMogoModuleProvider > providers ) {
|
||||
super( fragmentActivity.getSupportFragmentManager() );
|
||||
mActivity = fragmentActivity;
|
||||
this.mProviders = providers;
|
||||
return mProviders.size();
|
||||
// return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public IMogoModuleProvider getProvider( int position ) {
|
||||
@@ -57,4 +79,50 @@ public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
||||
return POSITION_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* marker、卡片、语音等通过 launcher 切换到其他卡片。
|
||||
*
|
||||
* @param providerTag 卡片类型
|
||||
* @param currentPosition 当前卡片位置
|
||||
* @return 需要跳转到的卡片实际位置
|
||||
*/
|
||||
public int getNextCardPosition( String providerTag, int currentPosition ) {
|
||||
int position = 0;
|
||||
int currentFactPosition = getFactPosition( currentPosition );
|
||||
for ( IMogoModuleProvider provider : mProviders ) {
|
||||
if ( TextUtils.equals( providerTag, provider.getModuleName() ) ) {
|
||||
break;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
int offset = 0;
|
||||
if ( currentFactPosition > position ) {
|
||||
// 下一个卡片在当前卡片前面
|
||||
offset = position - mProviders.size();
|
||||
} else if ( currentFactPosition < position ) {
|
||||
// 下一个卡片在当前卡片后面
|
||||
offset = mProviders.size() - position;
|
||||
}
|
||||
return currentPosition + offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem( @NonNull ViewGroup container, int position, @NonNull Object object ) {
|
||||
// super.destroyItem( container, position, object );
|
||||
// Logger.d( TAG, "destroy " + object );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void finishUpdate( @NonNull ViewGroup container ) {
|
||||
super.finishUpdate( container );
|
||||
}
|
||||
|
||||
public void render( int position ) {
|
||||
if ( position == 1 ) {
|
||||
mLastPH.renderTargetUI();
|
||||
} else if ( position == getCount() - 2 ) {
|
||||
mFirstPH.renderTargetUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.mogo.service.module.IMogoModuleProvider;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.security.auth.callback.Callback;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
@@ -17,7 +19,10 @@ import java.util.List;
|
||||
* 卡片管理
|
||||
*/
|
||||
public interface MogoModulesHandler extends IMogoMapListener,
|
||||
IMogoNaviListener, IMogoLocationListener, IMogoMarkerClickListener {
|
||||
IMogoNaviListener,
|
||||
IMogoLocationListener {
|
||||
|
||||
void onMapLoadedCallback( Runnable callback );
|
||||
|
||||
/**
|
||||
* 加载卡片
|
||||
@@ -61,5 +66,8 @@ public interface MogoModulesHandler extends IMogoMapListener,
|
||||
*/
|
||||
void setEnable( String module );
|
||||
|
||||
/**
|
||||
* 销毁
|
||||
*/
|
||||
void destroy();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
@@ -47,6 +46,7 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
private IMogoModuleProvider mMapProvider;
|
||||
private IMogoModuleProvider mAppsListProvider;
|
||||
private String mEnableModuleName = null;
|
||||
private Runnable mMapLoadedCallback;
|
||||
|
||||
public MogoModulesManager( MainActivity activity ) {
|
||||
if ( activity == null ) {
|
||||
@@ -63,13 +63,23 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
return mActivity.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLoadedCallback( Runnable callback ) {
|
||||
mMapLoadedCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< IMogoModuleProvider > loadCards() {
|
||||
IMogoModuleProvider demo = load( MogoModulePaths.PATH_MODULE_DEMO );
|
||||
IMogoModuleProvider demo2 = load( MogoModulePaths.PATH_MODULE_DEMO2 );
|
||||
mCardProviders.put( demo.getModuleName(), demo );
|
||||
mCardProviders.put( demo2.getModuleName(), demo2 );
|
||||
return new ArrayList<>( mCardProviders.values() );
|
||||
final List< String > modulePaths = MogoModulePaths.getModulesPath();
|
||||
final ArrayList< IMogoModuleProvider > providers = new ArrayList<>();
|
||||
if ( modulePaths != null && !modulePaths.isEmpty() ) {
|
||||
for ( String modulePath : modulePaths ) {
|
||||
IMogoModuleProvider provider = load( modulePath );
|
||||
providers.add( provider );
|
||||
mCardProviders.put( provider.getModuleName(), provider );
|
||||
}
|
||||
}
|
||||
return providers;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,6 +150,12 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
|
||||
if ( mMapLoadedCallback != null ) {
|
||||
mMapLoadedCallback.run();
|
||||
mMapLoadedCallback = null;
|
||||
}
|
||||
|
||||
if ( mEnableModuleName != null ) {
|
||||
IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
|
||||
if ( provider != null && provider.getMapListener() != null ) {
|
||||
@@ -260,12 +276,6 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
marker.setAlpha( 0.5f );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.main.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class PlaceholderFragment extends UnDestroyedViewFragment {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_main_fragement_placeholder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.main.R;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class PlaceholderFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
private Fragment mCopyTarget;
|
||||
private PlaceholderFragment mUi;
|
||||
|
||||
public void setCopyTarget( Fragment mUICopyTarget ) {
|
||||
this.mCopyTarget = mUICopyTarget;
|
||||
}
|
||||
|
||||
public void renderTargetUI() {
|
||||
if ( mCopyTarget == null ) {
|
||||
return;
|
||||
}
|
||||
final View target = mCopyTarget.getView();
|
||||
if ( target == null ) {
|
||||
return;
|
||||
}
|
||||
target.setDrawingCacheEnabled( true );
|
||||
Bitmap result = target.getDrawingCache();
|
||||
result = target.getDrawingCache() != null ? result.copy( Bitmap.Config.ARGB_8888, false ) : null;
|
||||
if ( mUi.getView() != null ) {
|
||||
mUi.getView().setBackgroundDrawable( new BitmapDrawable( result ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
mUi = new PlaceholderFragment();
|
||||
return mUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return "placeholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE_FRAGMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.main.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public abstract class UnDestroyedViewFragment extends MvpFragment< IView, Presenter< IView > > implements IView {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView( @NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState ) {
|
||||
if ( mRootView == null ) {
|
||||
return super.onCreateView( inflater, container, savedInstanceState );
|
||||
}
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Presenter< IView > createPresenter() {
|
||||
return new Presenter< IView >( this ) {
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,10 @@ public class VerticalStackTransformer extends VerticalBaseTransformer {
|
||||
protected void onTransform( View page, float position ) {
|
||||
if ( position <= 0.0f ) {
|
||||
page.setAlpha( 1.0f );
|
||||
Log.e( "onTransform", "position <= 0.0f ==>" + position );
|
||||
page.setTranslationY( 0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( true );
|
||||
} else if ( position <= 3.0f ) {
|
||||
Log.e( "onTransform", "position <= 3.0f ==>" + position );
|
||||
float scale = ( float ) ( page.getWidth() - WindowUtils.dip2px( context, spaceBetweenFirAndSecWith * position ) ) / ( float ) ( page.getWidth() );
|
||||
//控制下面卡片的可见度
|
||||
page.setAlpha( 1.0f );
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
android:background="#f00">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user