删除无用类
优化地图中心点按照productFlavor来进行选择
This commit is contained in:
@@ -3,15 +3,10 @@ package com.mogo.module.main;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.main.livedata.CardInfo;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -19,42 +14,35 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 卡片控制
|
||||
*/
|
||||
@Deprecated
|
||||
@Route( path = MogoServicePaths.PATH_CARD_MANAGER )
|
||||
public class MogoCardManager implements IMogoCardManager {
|
||||
|
||||
private static final Map< String, IMogoCardChangedListener > sListeners = new HashMap<>();
|
||||
private static final String TAG = "MogoCardManager";
|
||||
|
||||
@Override
|
||||
public void switch2( String cardType ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( cardType, false ) );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCardChangedListener( String tag, IMogoCardChangedListener listener ) {
|
||||
sListeners.put( tag, listener );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterCardChangedListener( String tag ) {
|
||||
sListeners.remove( tag );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( int position, String moduleName ) {
|
||||
if ( sListeners != null && !sListeners.isEmpty() ) {
|
||||
Iterator< IMogoCardChangedListener > iterator = sListeners.values().iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoCardChangedListener listener = iterator.next();
|
||||
if ( listener != null ) {
|
||||
listener.onSwitched( position, moduleName );
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switch2( String cardType, boolean lockCar ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( cardType, lockCar ) );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,9 +6,6 @@ import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.main.livedata.CardInfo;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -57,12 +54,13 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
|
||||
private static volatile SchemeIntent sInstance;
|
||||
|
||||
private SchemeIntent(){}
|
||||
private SchemeIntent() {
|
||||
}
|
||||
|
||||
public static SchemeIntent getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( SchemeIntent.class ) {
|
||||
if( sInstance == null ){
|
||||
public static SchemeIntent getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SchemeIntent.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SchemeIntent();
|
||||
}
|
||||
}
|
||||
@@ -70,7 +68,7 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@@ -80,7 +78,7 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
mApis.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
public void clear() {
|
||||
mApis.getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
mContext = null;
|
||||
mApis = null;
|
||||
@@ -141,14 +139,6 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
return;
|
||||
}
|
||||
switch ( type ) {
|
||||
case ModuleNames.CARD_TYPE_BUSINESS_OPERATION:
|
||||
case ModuleNames.CARD_TYPE_CARS_CHATTING:
|
||||
case ModuleNames.CARD_TYPE_NOVELTY:
|
||||
case ModuleNames.CARD_TYPE_ROAD_CONDITION:
|
||||
case ModuleNames.CARD_TYPE_SHARE_MUSIC:
|
||||
case ModuleNames.CARD_TYPE_USER_DATA:
|
||||
handleSwitchCardIntent( type );
|
||||
break;
|
||||
case TYPE_NAVI:
|
||||
handleNaviIntent( target );
|
||||
break;
|
||||
@@ -175,10 +165,6 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
target.getQueryParameter( "keywords" ) );
|
||||
}
|
||||
|
||||
private void handleSwitchCardIntent( String type ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( type, true ) );
|
||||
}
|
||||
|
||||
private void handleNaviIntent( Uri naviUri ) {
|
||||
if ( mApis == null ) {
|
||||
return;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-27
|
||||
* <p>
|
||||
* 卡片播报配置
|
||||
*/
|
||||
public class CardIntroduceConfig {
|
||||
|
||||
public String cardType;
|
||||
public String broadcastWords;
|
||||
public int broadcastAmount;
|
||||
|
||||
public CardIntroduceConfig( String cardType, String broadcastWords, int broadcastAmount ) {
|
||||
this.cardType = cardType;
|
||||
this.broadcastWords = broadcastWords;
|
||||
this.broadcastAmount = broadcastAmount;
|
||||
}
|
||||
|
||||
public CardIntroduceConfig() {
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.VoicePreemptType;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-27
|
||||
* <p>
|
||||
* 卡片播报配置
|
||||
*/
|
||||
public class CardIntroduceConfigs {
|
||||
|
||||
private static final String TAG = "CardIntroduceConfigs";
|
||||
|
||||
public static final String KEY_VOICE_BROADCAST_CONFIG = "voice_broadcast_";
|
||||
public static String sBroadcastConfigKey;
|
||||
|
||||
public static Map< String, CardIntroduceConfig > sConfigs = new HashMap<>();
|
||||
private static IMogoStatusManager sStatusManager;
|
||||
private static IMogoNavi sNaiv;
|
||||
|
||||
static {
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, new CardIntroduceConfig( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, "", 3 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_SHARE_MUSIC, new CardIntroduceConfig( ModuleNames.CARD_TYPE_SHARE_MUSIC, "音乐新闻听书,海量资源随你选", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_CARS_CHATTING, new CardIntroduceConfig( ModuleNames.CARD_TYPE_CARS_CHATTING, "开车无聊,就用车聊聊", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_ROAD_CONDITION, new CardIntroduceConfig( ModuleNames.CARD_TYPE_ROAD_CONDITION, "随时查看路况,可以对我说某某地点堵不堵", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_USER_DATA, new CardIntroduceConfig( ModuleNames.CARD_TYPE_USER_DATA, "在线车辆,邀你在地图上发现万千有趣的车友", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_NOVELTY, new CardIntroduceConfig( ModuleNames.CARD_TYPE_NOVELTY, "新鲜事,邀你给同城车友分享沿途封路、拥堵消息", 0 ) );
|
||||
}
|
||||
|
||||
public static void init( Context context, IMogoServiceApis apis ) {
|
||||
sStatusManager = apis.getStatusManagerApi();
|
||||
sNaiv = apis.getMapServiceApi().getNavi( context );
|
||||
WorkThreadHandler.getInstance().post( () -> {
|
||||
sBroadcastConfigKey = KEY_VOICE_BROADCAST_CONFIG + CommonUtils.getVersionCode( context );
|
||||
String configsStr = SharedPrefsMgr.getInstance( context ).getString( sBroadcastConfigKey );
|
||||
List< CardIntroduceConfig > configs = GsonUtil.arrayFromJson( configsStr, CardIntroduceConfig.class );
|
||||
if ( configs == null ) {
|
||||
return;
|
||||
}
|
||||
for ( CardIntroduceConfig config : configs ) {
|
||||
if ( config == null ) {
|
||||
return;
|
||||
}
|
||||
sConfigs.put( config.cardType, config );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public static void broadcastCardIntroduce( Context context, String type ) {
|
||||
if ( sConfigs.get( type ) == null ) {
|
||||
Logger.d( TAG, "un support %s", type );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( sConfigs.get( type ).broadcastAmount >= 3 ) {
|
||||
Logger.d( TAG, "do not broadcastCardIntroduce %s cast amount = %s", type, type );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( sStatusManager != null ) {
|
||||
if ( !sStatusManager.isAIAssistReady() ) {
|
||||
Logger.w( TAG, "ai assist not ready: %s", type );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( sNaiv.isNaviing() ) {
|
||||
Logger.d( TAG, "do not broadcastCardIntroduce cause naving" );
|
||||
return;
|
||||
}
|
||||
|
||||
CardIntroduceConfig config = sConfigs.get( type );
|
||||
config.broadcastAmount++;
|
||||
|
||||
Logger.d( TAG, "speak card introduce: %s", config.broadcastWords );
|
||||
AIAssist.getInstance( context ).speakTTSVoice( config.broadcastWords, VoicePreemptType.PREEMPT_TYPE_IMMEADIATELY, null );
|
||||
}
|
||||
|
||||
public static void flush( Context context ) {
|
||||
if ( sBroadcastConfigKey == null || sConfigs.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
WorkThreadHandler.getInstance().post( () -> {
|
||||
synchronized ( sConfigs ) {
|
||||
ArrayList configs = new ArrayList( sConfigs.entrySet() );
|
||||
SharedPrefsMgr.getInstance( context ).putString( sBroadcastConfigKey, GsonUtil.jsonFromObject( configs ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private static final String TAG = "CardModulesAdapter";
|
||||
|
||||
private final MainActivity mActivity;
|
||||
private List< IMogoModuleProvider > mProviders;
|
||||
|
||||
public CardModulesAdapter( @NonNull MainActivity fragmentActivity, List< IMogoModuleProvider > providers ) {
|
||||
super( fragmentActivity.getSupportFragmentManager() );
|
||||
mActivity = fragmentActivity;
|
||||
this.mProviders = new ArrayList<>( providers );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem( int position ) {
|
||||
Logger.i( TAG, "current position: %d", position );
|
||||
int factPosition = getFactPosition( position );
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt( "position", factPosition );
|
||||
final Fragment f = mProviders.get( factPosition ).createFragment( mActivity, bundle );
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mProviders.size();
|
||||
// return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public IMogoModuleProvider getProvider( int position ) {
|
||||
return mProviders.get( getFactPosition( position ) );
|
||||
}
|
||||
|
||||
public int getFactPosition( int position ) {
|
||||
return position % mProviders.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemPosition( Object object ) {
|
||||
return POSITION_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应卡片类型在列表中的位置
|
||||
*
|
||||
* @param tag 卡片类型
|
||||
* @return 列表中的位置
|
||||
*/
|
||||
public int getProviderPosition( String tag ) {
|
||||
if ( mProviders != null ) {
|
||||
for ( int i = 0; i < mProviders.size(); i++ ) {
|
||||
IMogoModuleProvider provider = mProviders.get( i );
|
||||
if ( provider != null ) {
|
||||
if ( TextUtils.equals( provider.getModuleName(), tag ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/**
|
||||
* Created by Nate on 2016/7/22.
|
||||
*/
|
||||
public abstract class HorizentalBaseTransformer implements ViewPager.PageTransformer {
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected abstract void onTransform(View page, float position);
|
||||
|
||||
/**
|
||||
* Apply a property transformation to the given page. For most use cases, this method should not be overridden.
|
||||
* Instead use {@link #transformPage(View, float)} to perform typical transformations.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
@Override
|
||||
public void transformPage(View page, float position) {
|
||||
onPreTransform(page, position);
|
||||
onTransform(page, position);
|
||||
onPostTransform(page, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the position offset of a fragment is less than negative one or greater than one, returning true will set the
|
||||
* fragment alpha to 0f. Otherwise fragment alpha is always defaulted to 1f.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean hideOffscreenPages() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the default animations of the view pager should be used.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean isPagingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
|
||||
* <p/>
|
||||
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
|
||||
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
|
||||
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
|
||||
* alpha.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPreTransform(View page, float position) {
|
||||
final float width = page.getWidth();
|
||||
//final float height = page.getHeight();
|
||||
|
||||
page.setRotationX(0);
|
||||
page.setRotationY(0);
|
||||
page.setRotation(0);
|
||||
page.setScaleX(1);
|
||||
page.setScaleY(1);
|
||||
page.setPivotX(0);
|
||||
page.setPivotY(0);
|
||||
page.setTranslationY(0);
|
||||
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
|
||||
|
||||
if (hideOffscreenPages()) {
|
||||
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
|
||||
} else {
|
||||
page.setAlpha(1f);
|
||||
}
|
||||
|
||||
/*final float normalizedposition = Math.abs(Math.abs(position) - 1);
|
||||
page.setAlpha(normalizedposition);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} after {@link #onTransform(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPostTransform(View page, float position) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Math#min(double, double)} without double casting, zero closest to infinity handling, or NaN support.
|
||||
*
|
||||
* @param val
|
||||
* @param min
|
||||
* @return
|
||||
*/
|
||||
protected static final float min(float val, float min) {
|
||||
return val < min ? min : val;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import com.mogo.module.main.R;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class HorizentalStackTransformer extends HorizentalBaseTransformer {
|
||||
|
||||
private Context context;
|
||||
private int spaceBetweenFirAndSecWith;//第一张卡片和第二张卡片宽度差
|
||||
private int spaceBetweenFirAndSecHeight;//第一张卡片和第二张卡片高度差
|
||||
private float offsetScroll = 0.0f;//ViewPager滑动时变化幅度
|
||||
|
||||
public HorizentalStackTransformer( Context context ) {
|
||||
this.context = context;
|
||||
spaceBetweenFirAndSecHeight = 0;
|
||||
spaceBetweenFirAndSecWith = context.getResources().getDimensionPixelSize( R.dimen.module_main_card_card_shadow_width_div );
|
||||
}
|
||||
|
||||
public HorizentalStackTransformer( Context context, int spaceBetweenFirAndSecWith, int spaceBetweenFirAndSecHeight ) {
|
||||
this.context = context;
|
||||
this.spaceBetweenFirAndSecWith = spaceBetweenFirAndSecWith;
|
||||
this.spaceBetweenFirAndSecHeight = spaceBetweenFirAndSecHeight;
|
||||
}
|
||||
|
||||
public void offsetScrollChanged(float offset){
|
||||
if(offset ==0){
|
||||
return;
|
||||
}
|
||||
offsetScroll = offset;
|
||||
}
|
||||
|
||||
public void resetOffsetScroll(){
|
||||
offsetScroll = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTransform( View page, float position ) {
|
||||
if ( position == 0.0f ) {
|
||||
page.setAlpha( 1.0f );
|
||||
page.setTranslationX( 0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( true );
|
||||
} else if(position>0){
|
||||
float scale = ( float ) ( page.getWidth() - spaceBetweenFirAndSecWith * position ) / ( float ) ( page.getWidth() );
|
||||
Logger.d("VerticalStackTransformer","scale :" + scale);
|
||||
//控制下面卡片的可见度
|
||||
page.setAlpha( 1.0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( false );
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setScaleX( scale );
|
||||
page.setScaleY( scale );
|
||||
page.setTranslationX( -page.getHeight() * position + ( page.getHeight() * 0.5f ) * ( 1 - scale ) + spaceBetweenFirAndSecHeight * position );
|
||||
}else{
|
||||
float currentPage;
|
||||
if(offsetScroll > 0.1f){
|
||||
currentPage = 0.1f;
|
||||
}else{
|
||||
currentPage = offsetScroll;
|
||||
}
|
||||
page.setAlpha( 1 );
|
||||
page.setScaleX(1-currentPage);
|
||||
page.setScaleY(1-currentPage);
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setTranslationX( 0f );
|
||||
page.setClickable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class OnPageChangeListenerAdapter implements ViewPager.OnPageChangeListener {
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected( int position ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,112 +0,0 @@
|
||||
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Nate on 2016/7/22.
|
||||
*/
|
||||
public abstract class VerticalBaseTransformer implements ViewPager.PageTransformer {
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected abstract void onTransform(View page, float position);
|
||||
|
||||
/**
|
||||
* Apply a property transformation to the given page. For most use cases, this method should not be overridden.
|
||||
* Instead use {@link #transformPage(View, float)} to perform typical transformations.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
@Override
|
||||
public void transformPage(View page, float position) {
|
||||
onPreTransform(page, position);
|
||||
onTransform(page, position);
|
||||
onPostTransform(page, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the position offset of a fragment is less than negative one or greater than one, returning true will set the
|
||||
* fragment alpha to 0f. Otherwise fragment alpha is always defaulted to 1f.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean hideOffscreenPages() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the default animations of the view pager should be used.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean isPagingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
|
||||
* <p/>
|
||||
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
|
||||
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
|
||||
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
|
||||
* alpha.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPreTransform(View page, float position) {
|
||||
final float width = page.getWidth();
|
||||
final float height = page.getHeight();
|
||||
|
||||
page.setRotationX(0);
|
||||
page.setRotationY(0);
|
||||
page.setRotation(0);
|
||||
page.setScaleX(1);
|
||||
page.setScaleY(1);
|
||||
page.setPivotX(0);
|
||||
page.setPivotY(0);
|
||||
page.setTranslationX(0);
|
||||
page.setTranslationY(isPagingEnabled() ? 0f : -height * position);
|
||||
|
||||
if (hideOffscreenPages()) {
|
||||
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
|
||||
} else {
|
||||
page.setAlpha(1f);
|
||||
}
|
||||
|
||||
/*final float normalizedposition = Math.abs(Math.abs(position) - 1);
|
||||
page.setAlpha(normalizedposition);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} after {@link #onTransform(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPostTransform(View page, float position) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Math#min(double, double)} without double casting, zero closest to infinity handling, or NaN support.
|
||||
*
|
||||
* @param val
|
||||
* @param min
|
||||
* @return
|
||||
*/
|
||||
protected static final float min(float val, float min) {
|
||||
return val < min ? min : val;
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.module.main.R;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class VerticalStackTransformer extends VerticalBaseTransformer {
|
||||
|
||||
private Context context;
|
||||
private int spaceBetweenFirAndSecWith;//第一张卡片和第二张卡片宽度差
|
||||
private int spaceBetweenFirAndSecHeight;//第一张卡片和第二张卡片高度差
|
||||
private float offsetScroll = 0.0f;//ViewPager滑动时变化幅度
|
||||
|
||||
public VerticalStackTransformer( Context context ) {
|
||||
this.context = context;
|
||||
spaceBetweenFirAndSecHeight = 0;
|
||||
spaceBetweenFirAndSecWith = context.getResources().getDimensionPixelSize( R.dimen.module_main_card_card_shadow_width_div );
|
||||
}
|
||||
|
||||
public VerticalStackTransformer( Context context, int spaceBetweenFirAndSecWith, int spaceBetweenFirAndSecHeight ) {
|
||||
this.context = context;
|
||||
this.spaceBetweenFirAndSecWith = spaceBetweenFirAndSecWith;
|
||||
this.spaceBetweenFirAndSecHeight = spaceBetweenFirAndSecHeight;
|
||||
}
|
||||
|
||||
public void offsetScrollChanged(float offset){
|
||||
if(offset ==0){
|
||||
return;
|
||||
}
|
||||
offsetScroll = offset;
|
||||
}
|
||||
|
||||
public void resetOffsetScroll(){
|
||||
offsetScroll = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTransform( View page, float position ) {
|
||||
if ( position == 0.0f ) {
|
||||
page.setAlpha( 1.0f );
|
||||
page.setTranslationY( 0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( true );
|
||||
} else if(position>0){
|
||||
float scale = ( float ) ( page.getWidth() - spaceBetweenFirAndSecWith * position ) / ( float ) ( page.getWidth() );
|
||||
Logger.d("VerticalStackTransformer","scale :" + scale);
|
||||
//控制下面卡片的可见度
|
||||
page.setAlpha( 1.0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( false );
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setScaleX( scale );
|
||||
page.setScaleY( scale );
|
||||
page.setTranslationY( -page.getHeight() * position + ( page.getHeight() * 0.5f ) * ( 1 - scale ) + spaceBetweenFirAndSecHeight * position );
|
||||
}else{
|
||||
float currentPage;
|
||||
if(offsetScroll > 0.2f){
|
||||
currentPage = 0.2f;
|
||||
}else{
|
||||
currentPage = offsetScroll;
|
||||
}
|
||||
page.setAlpha( 1 );
|
||||
page.setScaleX(1-currentPage);
|
||||
page.setScaleY(1-currentPage);
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setTranslationY( 0f );
|
||||
page.setClickable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.mogo.module.main.constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-03-02.
|
||||
*/
|
||||
public class VoiceConstants {
|
||||
/**
|
||||
* 切换上一张卡片
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_SWITCHCARD_PREVIOUS = "com.zhidao.desk.switchCard.previous";
|
||||
/**
|
||||
* 切换下一张卡片
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_SWITCHCARD_NEXT = "com.zhidao.desk.switchCard.next";
|
||||
/**
|
||||
* 查看多媒体卡片、探路卡片
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_SWITCHCARD = "com.zhidao.desk.switchCard";
|
||||
|
||||
|
||||
|
||||
public static ArrayList<String> sCmds=new ArrayList<>();
|
||||
|
||||
static {
|
||||
sCmds.add(COMMAND_ZHIDAO_SWITCHCARD_PREVIOUS);
|
||||
sCmds.add(COMMAND_ZHIDAO_SWITCHCARD_NEXT);
|
||||
sCmds.add(COMMAND_ZHIDAO_SWITCHCARD);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.mogo.module.main.livedata;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class CardInfo implements Parcelable {
|
||||
|
||||
public String mCardName;
|
||||
public boolean mLockCar;
|
||||
|
||||
public CardInfo( String cardName, boolean lockCar ) {
|
||||
this.mCardName = cardName;
|
||||
this.mLockCar = lockCar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeString( this.mCardName );
|
||||
dest.writeByte( this.mLockCar ? ( byte ) 1 : ( byte ) 0 );
|
||||
}
|
||||
|
||||
protected CardInfo( Parcel in ) {
|
||||
this.mCardName = in.readString();
|
||||
this.mLockCar = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator< CardInfo > CREATOR = new Parcelable.Creator< CardInfo >() {
|
||||
@Override
|
||||
public CardInfo createFromParcel( Parcel source ) {
|
||||
return new CardInfo( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardInfo[] newArray( int size ) {
|
||||
return new CardInfo[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.mogo.module.main.livedata;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 切换卡片
|
||||
*/
|
||||
public class CardSwitchLiveData extends MutableLiveData< CardInfo > {
|
||||
|
||||
private CardSwitchLiveData() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final CardSwitchLiveData INSTANCE = new CardSwitchLiveData();
|
||||
}
|
||||
|
||||
public static CardSwitchLiveData getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.module.main.windowview;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* 用来处理主屏上方1/2屏的view
|
||||
*/
|
||||
public class TopViewHolder {
|
||||
public void init(){
|
||||
|
||||
}
|
||||
public void addView(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user