opt
This commit is contained in:
@@ -488,4 +488,13 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
|
||||
if ( checkAMapView() ) {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
options.setPointToCenter( mapCenterX, mapCenterY );
|
||||
mMapView.setViewOptions( options );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,4 +129,11 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.setPointToCenter( mapCenterX, mapCenterY );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,4 +87,12 @@ public interface IMogoMapUIController {
|
||||
* @return
|
||||
*/
|
||||
MogoLatLng getCameraSouthWestPosition();
|
||||
|
||||
/**
|
||||
* 设置地图中心点
|
||||
*
|
||||
* @param mapCenterX x 点位置x值与地图宽度的比例
|
||||
* @param mapCenterY y 点位置x值与地图高度的比例
|
||||
*/
|
||||
void setPointToCenter( double mapCenterX, double mapCenterY );
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 15 KiB |
@@ -122,4 +122,11 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setPointToCenter( mapCenterX, mapCenterY );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
@@ -75,4 +76,9 @@ public class AppsFragmentProvider implements IMogoModuleProvider {
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
@@ -71,4 +72,9 @@ public class ExtensionsModuleProvider implements IMogoModuleProvider {
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
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;
|
||||
@@ -60,6 +64,11 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
mSearch = findViewById( R.id.module_map_id_search );
|
||||
mSearch.setOnClickListener( view -> {
|
||||
|
||||
ViewGroup group = ( ( Activity ) getContext() ).findViewById( android.R.id.content );
|
||||
final View child = new View(getContext());
|
||||
child.setBackground( new ColorDrawable( Color.RED ) );
|
||||
group.addView( child );
|
||||
} );
|
||||
|
||||
mHome = findViewById( R.id.module_map_id_home );
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
@@ -72,4 +73,9 @@ public class EntranceProvider implements IMogoModuleProvider {
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
@@ -21,6 +22,7 @@ import com.mogo.module.main.cards.MogoModulesManager;
|
||||
import com.mogo.module.main.cards.OnPageChangeListenerAdapter;
|
||||
import com.mogo.module.main.cards.OrientedViewPager;
|
||||
import com.mogo.module.main.cards.VerticalStackTransformer;
|
||||
import com.mogo.module.main.fragmentmanager.FragmentStack;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
@@ -44,6 +46,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
private IMogoMapService mMogoMapService;
|
||||
private IMogoMapUIController mMogoMapUIController;
|
||||
private MogoModulesHandler mMogoModuleHandler;
|
||||
|
||||
private IMogoSocketManager mMogoSocketManager;
|
||||
@@ -79,6 +82,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
FragmentStack.getInstance().init( this, R.id.module_main_id_search_fragment );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,12 +104,16 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mMogoMapService.getHostListenerRegister().registerMarkerClickListener( this );
|
||||
}
|
||||
|
||||
mMogoMapUIController = mMogoMapService.getMapUIController();
|
||||
|
||||
mMogoModuleHandler.loadModules();
|
||||
mMogoModuleHandler.onMapLoadedCallback( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Logger.d( TAG, "map loaded." + Thread.currentThread().getName() );
|
||||
loadModules();
|
||||
|
||||
mMogoMapUIController.setPointToCenter( 0.66145, 0.590688 );
|
||||
}
|
||||
} );
|
||||
// 加载地图,触发地图加载完毕回调,在初始化其他卡片模块,保证卡片模块可以正确获取地图相关服务。
|
||||
@@ -163,6 +172,14 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if ( getSupportFragmentManager().getBackStackEntryCount() > 0 ) {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
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.utils.logger.Logger;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* fragment 任务栈
|
||||
*/
|
||||
public class FragmentStack {
|
||||
|
||||
private static final String TAG = "FragmentStack";
|
||||
|
||||
private static volatile FragmentStack sInstance;
|
||||
|
||||
private Stack< Fragment > mFragmentStack = new Stack<>();
|
||||
private FragmentManager mFragmentManager;
|
||||
private FragmentTransaction mFragmentTransaction;
|
||||
private int mContainerId;
|
||||
private Activity mActivity;
|
||||
private Fragment mCurrentFragment;
|
||||
|
||||
private FragmentStackTransactionListener mFragmentStackTransactionListener;
|
||||
|
||||
private FragmentStack() {
|
||||
}
|
||||
|
||||
public static FragmentStack getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( FragmentStack.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new FragmentStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
public void init( AppCompatActivity activity, int containerId ) {
|
||||
mActivity = activity;
|
||||
mFragmentManager = activity.getSupportFragmentManager();
|
||||
mContainerId = containerId;
|
||||
mFragmentTransaction = mFragmentManager.beginTransaction();
|
||||
}
|
||||
|
||||
public void push( Fragment fragment, String tag ) {
|
||||
if ( fragment == null ) {
|
||||
return;
|
||||
}
|
||||
if ( mFragmentStack.contains( fragment ) ) {
|
||||
Logger.w( TAG, "fragment has already in stack." );
|
||||
return;
|
||||
}
|
||||
if ( mCurrentFragment != null ) {
|
||||
mFragmentTransaction.hide( mCurrentFragment );
|
||||
}
|
||||
mFragmentTransaction.add( mContainerId, fragment, tag );
|
||||
mFragmentTransaction.addToBackStack( null );
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
mFragmentStack.push( fragment );
|
||||
mCurrentFragment = fragment;
|
||||
|
||||
if ( getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
if ( mCurrentFragment != null ) {
|
||||
mFragmentTransaction.remove( mCurrentFragment );
|
||||
}
|
||||
if ( mFragmentStack.isEmpty() ) {
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
mCurrentFragment = null;
|
||||
} else {
|
||||
Fragment fragment = mFragmentStack.pop();
|
||||
if ( fragment != null ) {
|
||||
mFragmentTransaction.show( fragment );
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
}
|
||||
mCurrentFragment = fragment;
|
||||
}
|
||||
|
||||
if ( getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return mFragmentStack.isEmpty();
|
||||
}
|
||||
|
||||
public FragmentStackTransactionListener getFragmentStackTransactionListener() {
|
||||
return mFragmentStackTransactionListener;
|
||||
}
|
||||
|
||||
public void setFragmentStackTransactionListener( FragmentStackTransactionListener fragmentStackTransactionListener ) {
|
||||
this.mFragmentStackTransactionListener = fragmentStackTransactionListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mogo.module.main.fragmentmanager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* fragment 栈发生变化
|
||||
*/
|
||||
public interface FragmentStackTransactionListener {
|
||||
|
||||
void onTransaction();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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.IMogoFragmentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_FRAGMENT_MANAGER )
|
||||
public class MogoFragmentManager implements IMogoFragmentManager {
|
||||
|
||||
@Override
|
||||
public void push( Fragment fragment, String tag ) {
|
||||
FragmentStack.getInstance().push( fragment, tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pop() {
|
||||
FragmentStack.getInstance().pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,10 @@
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_search_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
@@ -75,4 +76,9 @@ public class MapFragmentProvider implements IMogoModuleProvider {
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
@@ -73,4 +74,9 @@ public class SearchFragmentProvider implements IMogoModuleProvider {
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ 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.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
@@ -421,4 +422,9 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
mRefreshRemainingTime += mAutoRefreshStrategy.getInterruptInterval();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
@@ -77,4 +78,8 @@ public class TanluCardViewProvider implements IMogoModuleProvider {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +65,9 @@ public class MogoServicePaths {
|
||||
* 卡片控制
|
||||
*/
|
||||
public static final String PATH_CARD_MANAGER = "/cardmanager/api";
|
||||
|
||||
/**
|
||||
* 管理 fragment
|
||||
*/
|
||||
public static final String PATH_FRAGMENT_MANAGER = "/fragmentmanager/api";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.service.fragmentmanager;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-08
|
||||
* <p>
|
||||
* fragment 管理接口
|
||||
*/
|
||||
public interface IMogoFragmentManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 显示fragment并加入回退栈
|
||||
*
|
||||
* @param fragment 需要显示的fragment
|
||||
* @param tag fragment的tag
|
||||
*/
|
||||
void push( Fragment fragment, String tag );
|
||||
|
||||
/**
|
||||
* 将当前 fragment 出栈
|
||||
*/
|
||||
void pop();
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
|
||||
/**
|
||||
@@ -80,4 +81,11 @@ public interface IMogoModuleProvider extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
IMogoLocationListener getLocationListener();
|
||||
|
||||
/**
|
||||
* marker 点击回调
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerClickListener getMarkerClickListener();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user