opt
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -5,7 +5,7 @@
|
||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
@@ -10,6 +12,8 @@ import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -27,6 +31,7 @@ public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView >
|
||||
private IMogoCardManager mCardManager;
|
||||
|
||||
private AppsFragment mAppsFragment;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -52,7 +57,8 @@ public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView >
|
||||
mCardManager.switch2( "CARD_TYPE_CARS_CHATTING" );
|
||||
} );
|
||||
mApps.setOnClickListener( view -> {
|
||||
new AppsFragment().show( getChildFragmentManager(), AppsFragment.TAG );
|
||||
mAppsFragment = new AppsFragment();
|
||||
mMogoFragmentManager.push( new FragmentDescriptor.Builder().fragment( mAppsFragment ).tag( "apps" ).notifyMainModule( false ).build() );
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -62,4 +68,10 @@ public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView >
|
||||
return new Presenter< IView >( this ) {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( getContext() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.mogo.commons.mvp.MvpDialogFragment;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.utils.BitmapHelper;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,7 +18,7 @@ import java.util.List;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsFragment extends MvpDialogFragment< AppsView, AppsPresenter > implements AppsView {
|
||||
public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > implements AppsView {
|
||||
|
||||
public static final String TAG = "AppsFragment";
|
||||
|
||||
@@ -59,21 +51,6 @@ public class AppsFragment extends MvpDialogFragment< AppsView, AppsPresenter > i
|
||||
// mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
super.onStart();
|
||||
final Dialog dialog = getDialog();
|
||||
if ( dialog != null ) {
|
||||
if ( dialog.getWindow() != null ) {
|
||||
final WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
|
||||
params.width = WindowUtils.getScreenWidth( getContext() );
|
||||
params.height = WindowUtils.getScreenHeight( getContext() );
|
||||
dialog.getWindow().setAttributes( params );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected AppsPresenter createPresenter() {
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
@@ -25,6 +20,7 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
|
||||
@@ -64,35 +60,35 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
fragmentManager = (IMogoFragmentManager) ARouter.getInstance().build(MogoServicePaths.PATH_FRAGMENT_MANAGER).navigation();
|
||||
fragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation();
|
||||
|
||||
mCommonAddress = findViewById( R.id.module_map_id_common_address );
|
||||
mCommonAddress = findViewById( R.id.module_entrance_id_common_address );
|
||||
|
||||
mSearch = findViewById( R.id.module_map_id_search );
|
||||
mSearch = findViewById( R.id.module_entrance_id_search );
|
||||
|
||||
Fragment fragment = (Fragment) ARouter.getInstance().build(MogoModulePaths.PATH_FRAGMENT_SEARCH).navigation();
|
||||
Fragment fragment = ( Fragment ) ARouter.getInstance().build( MogoModulePaths.PATH_FRAGMENT_SEARCH ).navigation();
|
||||
|
||||
mSearch.setOnClickListener( view -> {
|
||||
fragmentManager.push(fragment,MogoModulePaths.PATH_FRAGMENT_SEARCH);
|
||||
fragmentManager.push( new FragmentDescriptor.Builder().fragment( fragment ).tag( MogoModulePaths.PATH_FRAGMENT_SEARCH ).notifyMainModule( true ).build() );
|
||||
} );
|
||||
|
||||
mHome = findViewById( R.id.module_map_id_home );
|
||||
mHome = findViewById( R.id.module_entrance_id_home );
|
||||
mHome.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mCompany = findViewById( R.id.module_map_id_company );
|
||||
mCompany = findViewById( R.id.module_entrance_id_company );
|
||||
mCompany.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mUploadRoadCondition = findViewById( R.id.module_map_id_upload_road_condition );
|
||||
mUploadRoadCondition = findViewById( R.id.module_entrance_id_upload_road_condition );
|
||||
mUploadRoadCondition.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mVRMode = findViewById( R.id.module_map_id_vr_mode );
|
||||
mVRMode = findViewById( R.id.module_entrance_id_vr_mode );
|
||||
mVRMode.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mMove2CurrentLocation = findViewById( R.id.module_map_id_move2_current_location );
|
||||
mMove2CurrentLocation = findViewById( R.id.module_entrance_id_move2_current_location );
|
||||
mMove2CurrentLocation.setOnClickListener( view -> {
|
||||
final MogoLocation location = mMogoLocationClient.getLastKnowLocation();
|
||||
if ( location != null ) {
|
||||
@@ -100,8 +96,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
}
|
||||
} );
|
||||
|
||||
mNaviInfo = findViewById( R.id.module_map_id_navi_info_panel );
|
||||
mExitNavi = findViewById( R.id.module_map_id_exit_navi );
|
||||
mNaviInfo = findViewById( R.id.module_entrance_id_navi_info_panel );
|
||||
mExitNavi = findViewById( R.id.module_entrance_id_exit_navi );
|
||||
mExitNavi.setOnClickListener( view -> {
|
||||
if ( mMogoNavi != null ) {
|
||||
mMogoNavi.stopNavi();
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false">
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="@dimen/dp_16" android:bottomRightRadius="@dimen/dp_16" />
|
||||
<solid android:color="#3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="@dimen/dp_16" android:bottomRightRadius="@dimen/dp_16" />
|
||||
<solid android:color="#7F3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -1,9 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<item android:state_pressed="false">
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_16" />
|
||||
<solid android:color="#3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_16" />
|
||||
<solid android:color="#cc3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false">
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="@dimen/dp_16" android:topLeftRadius="@dimen/dp_16" />
|
||||
<solid android:color="#3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="@dimen/dp_16" android:topLeftRadius="@dimen/dp_16" />
|
||||
<solid android:color="#7F3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false">
|
||||
<shape>
|
||||
<corners android:bottomRightRadius="@dimen/dp_16" android:topRightRadius="@dimen/dp_16" />
|
||||
<solid android:color="#3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<corners android:bottomRightRadius="@dimen/dp_16" android:topRightRadius="@dimen/dp_16" />
|
||||
<solid android:color="#7F3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false">
|
||||
<shape>
|
||||
<corners android:topLeftRadius="@dimen/dp_16" android:topRightRadius="@dimen/dp_16" />
|
||||
<solid android:color="#3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<corners android:topLeftRadius="@dimen/dp_16" android:topRightRadius="@dimen/dp_16" />
|
||||
<solid android:color="#7F3F4057" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -1,9 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<item android:state_pressed="false">
|
||||
<shape>
|
||||
<gradient android:angle="90" android:endColor="#5CC1FF" android:startColor="#256BFF" />
|
||||
<corners android:radius="@dimen/dp_16" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<gradient android:angle="90" android:endColor="#7F5CC1FF" android:startColor="#7F256BFF" />
|
||||
<corners android:radius="@dimen/dp_16" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -5,7 +5,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_search"
|
||||
android:id="@+id/module_entrance_id_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
@@ -24,42 +24,55 @@
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_common_address"
|
||||
android:id="@+id/module_entrance_id_common_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/dp_22"
|
||||
android:paddingTop="@dimen/dp_17"
|
||||
android:paddingRight="@dimen/dp_22"
|
||||
android:paddingBottom="@dimen/dp_17"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_map_id_search"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_entrance_id_search"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_map_id_home"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_home" />
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_entrance_id_home"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:background="@drawable/module_map_dw_left_corner_bkg">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/module_map_ic_home" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/dp_2"
|
||||
android:layout_height="@dimen/dp_54"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="#1ED8D8D8" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_entrance_id_company"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:background="@drawable/module_map_dw_right_corner_bkg"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_company" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/dp_2"
|
||||
android:layout_height="@dimen/dp_54"
|
||||
android:layout_marginLeft="@dimen/dp_21"
|
||||
android:layout_marginRight="@dimen/dp_21"
|
||||
android:background="#1ED8D8D8" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_map_id_company"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_company" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.mogo.module.extensions.navi.NaviInfoView
|
||||
android:id="@+id/module_map_id_navi_info_panel"
|
||||
android:id="@+id/module_entrance_id_navi_info_panel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
@@ -69,21 +82,21 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_operation_panel"
|
||||
android:id="@+id/module_entrance_id_operation_panel"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/dp_32"
|
||||
android:layout_marginBottom="@dimen/dp_60"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_map_id_vr_mode"
|
||||
android:id="@+id/module_entrance_id_vr_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_92"
|
||||
android:background="@drawable/module_map_dw_top_corner_bkg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@@ -104,9 +117,10 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_move2_current_location"
|
||||
android:id="@+id/module_entrance_id_move2_current_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:background="@drawable/module_map_dw_bottom_corner_bkg"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
@@ -116,9 +130,8 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_upload_road_condition"
|
||||
android:id="@+id/module_entrance_id_upload_road_condition"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginBottom="@dimen/dp_40"
|
||||
@@ -127,13 +140,13 @@
|
||||
android:text="@string/module_map_str_upload_road_condition"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/dp_24"
|
||||
app:layout_constraintBottom_toTopOf="@+id/module_map_id_operation_panel"
|
||||
app:layout_constraintRight_toRightOf="@+id/module_map_id_operation_panel"
|
||||
app:layout_constraintBottom_toTopOf="@+id/module_entrance_id_operation_panel"
|
||||
app:layout_constraintRight_toRightOf="@+id/module_entrance_id_operation_panel"
|
||||
app:layout_goneMarginBottom="@dimen/dp_32"
|
||||
app:layout_goneMarginRight="@dimen/dp_32" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_exit_navi"
|
||||
android:id="@+id/module_entrance_id_exit_navi"
|
||||
android:layout_width="@dimen/dp_200"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
|
||||
@@ -199,7 +199,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
if ( mCardModulesAdapter != null ) {
|
||||
int position = mCardModulesAdapter.getProviderPosition( cardType );
|
||||
if ( position != -1 ) {
|
||||
mCardsContainer.setCurrentItem( position, false );
|
||||
mCardsContainer.setCurrentItem( position, Math.abs( mCurrentPosition - position ) == 1 );
|
||||
} else {
|
||||
Logger.e( TAG, "Can't find type of %s's position", cardType );
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public class OrientedViewPager extends ViewGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Used internally to tag special types of child views that should be added as
|
||||
* Used internally to mTag special types of child views that should be added as
|
||||
* pager decorations by default.
|
||||
*/
|
||||
interface Decor {
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.mogo.module.main.fragmentmanager;
|
||||
import android.app.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.Stack;
|
||||
@@ -23,12 +23,12 @@ public class FragmentStack {
|
||||
|
||||
private static volatile FragmentStack sInstance;
|
||||
|
||||
private Stack< Fragment > mFragmentStack = new Stack<>();
|
||||
private Stack< FragmentDescriptor > mFragmentStack = new Stack<>();
|
||||
private FragmentManager mFragmentManager;
|
||||
private FragmentTransaction mFragmentTransaction;
|
||||
private int mContainerId;
|
||||
private Activity mActivity;
|
||||
private Fragment mCurrentFragment;
|
||||
private FragmentDescriptor mCurrentFragment;
|
||||
|
||||
private FragmentStackTransactionListener mFragmentStackTransactionListener;
|
||||
|
||||
@@ -56,11 +56,11 @@ public class FragmentStack {
|
||||
mContainerId = containerId;
|
||||
}
|
||||
|
||||
public void push( Fragment fragment, String tag ) {
|
||||
if ( fragment == null ) {
|
||||
public void push( FragmentDescriptor descriptor ) {
|
||||
if ( descriptor == null || descriptor.getFragment() == null ) {
|
||||
return;
|
||||
}
|
||||
if ( mFragmentStack.contains( fragment ) ) {
|
||||
if ( mFragmentStack.contains( descriptor ) ) {
|
||||
Logger.w( TAG, "fragment has already in stack." );
|
||||
return;
|
||||
}
|
||||
@@ -68,15 +68,15 @@ public class FragmentStack {
|
||||
mFragmentTransaction = mFragmentManager.beginTransaction();
|
||||
|
||||
if ( mCurrentFragment != null ) {
|
||||
mFragmentTransaction.hide( mCurrentFragment );
|
||||
mFragmentTransaction.hide( mCurrentFragment.getFragment() );
|
||||
}
|
||||
mFragmentTransaction.add( mContainerId, fragment );
|
||||
mFragmentTransaction.add( mContainerId, descriptor.getFragment() );
|
||||
mFragmentTransaction.addToBackStack( null );
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
mFragmentStack.push( fragment );
|
||||
mCurrentFragment = fragment;
|
||||
mFragmentStack.push( descriptor );
|
||||
mCurrentFragment = descriptor;
|
||||
|
||||
if ( getFragmentStackTransactionListener() != null ) {
|
||||
if ( descriptor.isNotifyMainModule() && getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
}
|
||||
}
|
||||
@@ -90,26 +90,26 @@ public class FragmentStack {
|
||||
|
||||
mCurrentFragment = mFragmentStack.pop();
|
||||
if ( mCurrentFragment != null ) {
|
||||
mFragmentTransaction.remove( mCurrentFragment );
|
||||
mFragmentTransaction.remove( mCurrentFragment.getFragment() );
|
||||
}
|
||||
if ( mFragmentStack.isEmpty() ) {
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
mCurrentFragment = null;
|
||||
if ( getFragmentStackTransactionListener() != null ) {
|
||||
if ( mCurrentFragment.isNotifyMainModule() && getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
}
|
||||
mCurrentFragment = null;
|
||||
return;
|
||||
}
|
||||
Fragment fragment = mFragmentStack.peek();
|
||||
FragmentDescriptor fragment = mFragmentStack.peek();
|
||||
if ( fragment != null ) {
|
||||
mFragmentTransaction.show( fragment );
|
||||
mFragmentTransaction.show( fragment.getFragment() );
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
}
|
||||
mCurrentFragment = fragment;
|
||||
|
||||
if ( getFragmentStackTransactionListener() != null ) {
|
||||
if ( mCurrentFragment.isNotifyMainModule() && getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
}
|
||||
mCurrentFragment = fragment;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
|
||||
@@ -2,10 +2,9 @@ package com.mogo.module.main.fragmentmanager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
|
||||
/**
|
||||
@@ -18,8 +17,8 @@ import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
public class MogoFragmentManager implements IMogoFragmentManager {
|
||||
|
||||
@Override
|
||||
public void push( Fragment fragment, String tag ) {
|
||||
FragmentStack.getInstance().push( fragment, tag );
|
||||
public void push( FragmentDescriptor descriptor ) {
|
||||
FragmentStack.getInstance().push( descriptor );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -207,7 +207,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.USER_INTERACTED, this );
|
||||
|
||||
//TODO 初始化地图地图绘制大而全的Marker
|
||||
MarkerServiceHandler.init(mContext);
|
||||
MarkerServiceHandler.init( mContext );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -418,8 +418,8 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
if ( descriptor == StatusDescriptor.USER_INTERACTED && isTrue ) {
|
||||
Logger.i( TAG, "用户状态改变,自动刷新时间延时" );
|
||||
mRefreshRemainingTime += mAutoRefreshStrategy.getInterruptInterval();
|
||||
Logger.i( TAG, "用户状态改变,自动刷新时间延时,%s ms后自动刷新", mRefreshRemainingTime );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mogo.service.fragmentmanager;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* 加入栈中的fragment
|
||||
*/
|
||||
public class FragmentDescriptor {
|
||||
|
||||
private Fragment mFragment;
|
||||
|
||||
private String mTag;
|
||||
/**
|
||||
* 是否需要主页面的UI联动
|
||||
*/
|
||||
private boolean mNotifyMainModule = true;
|
||||
|
||||
public FragmentDescriptor() {
|
||||
}
|
||||
|
||||
public Fragment getFragment() {
|
||||
return mFragment;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return mTag;
|
||||
}
|
||||
|
||||
public boolean isNotifyMainModule() {
|
||||
return mNotifyMainModule;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private FragmentDescriptor descriptor;
|
||||
|
||||
public Builder() {
|
||||
descriptor = new FragmentDescriptor();
|
||||
}
|
||||
|
||||
public Builder fragment( Fragment fragment ) {
|
||||
descriptor.mFragment = fragment;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder tag( String tag ) {
|
||||
descriptor.mTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder notifyMainModule( boolean notify ) {
|
||||
descriptor.mNotifyMainModule = notify;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FragmentDescriptor build() {
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,9 @@ public interface IMogoFragmentManager extends IProvider {
|
||||
/**
|
||||
* 显示fragment并加入回退栈
|
||||
*
|
||||
* @param fragment 需要显示的fragment
|
||||
* @param tag fragment的tag
|
||||
* @param descriptor fragment描述
|
||||
*/
|
||||
void push( Fragment fragment, String tag );
|
||||
void push( FragmentDescriptor descriptor );
|
||||
|
||||
/**
|
||||
* 将当前 fragment 出栈
|
||||
|
||||
Reference in New Issue
Block a user