diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java index ba34b7889d..50493f61fa 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java @@ -14,7 +14,6 @@ import com.mogo.commons.network.ParamsUtil; import com.mogo.commons.network.X509TrustManagerImpl; import com.mogo.commons.storage.SpStorage; import com.mogo.utils.TipToast; -import com.mogo.utils.glide.GlideApp; import com.mogo.utils.logger.Logger; import com.mogo.utils.network.NetConfig; import com.zhidao.account.sdk.AccountClientManager; diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java index 0f6bce5c93..65e430a6b3 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java @@ -52,13 +52,27 @@ public class MogoModulePaths { /** - * 管理 fragment + * 搜索 fragment */ @Keep public static final String PATH_FRAGMENT_SEARCH = "/navi/search"; + /** + * 设置 fragment + */ + @Keep + public static final String PATH_FRAGMENT_SETTING = "/navi/setting"; + + + /** + * 设置家和公司 fragment + */ + @Keep + public static final String PATH_FRAGMENT_SETTING_HOME = "/navi/setting/home"; + + /** * 添加卡片模块 diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java index ead25df897..d516520fcc 100644 --- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java +++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java @@ -66,9 +66,9 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent mSearch = findViewById( R.id.module_entrance_id_search ); - Fragment fragment = ( Fragment ) ARouter.getInstance().build( MogoModulePaths.PATH_FRAGMENT_SEARCH ).navigation(); mSearch.setOnClickListener( view -> { + Fragment fragment = ( Fragment ) ARouter.getInstance().build( MogoModulePaths.PATH_FRAGMENT_SEARCH ).navigation(); mMogoFragmentManager.push( new FragmentDescriptor.Builder().fragment( fragment ).tag( MogoModulePaths.PATH_FRAGMENT_SEARCH ).notifyMainModule( true ).build() ); } ); diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/constants/SearchServiceHolder.kt b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/constants/SearchServiceHolder.kt new file mode 100644 index 0000000000..e0465d19a6 --- /dev/null +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/constants/SearchServiceHolder.kt @@ -0,0 +1,19 @@ +package com.mogo.module.navi.constants + +import com.alibaba.android.arouter.launcher.ARouter +import com.mogo.service.MogoServicePaths +import com.mogo.service.fragmentmanager.IMogoFragmentManager + +/** + *@author zyz + * 2020-01-08. + */ +object SearchServiceHolder { + + val fragmentManager:IMogoFragmentManager = ARouter.getInstance().build( + MogoServicePaths.PATH_FRAGMENT_MANAGER + ).navigation() as IMogoFragmentManager + + + +} \ No newline at end of file diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/BaseSearchFragment.java b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/BaseSearchFragment.java new file mode 100644 index 0000000000..9b0edd0b1f --- /dev/null +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/BaseSearchFragment.java @@ -0,0 +1,280 @@ +package com.mogo.module.navi.ui.search; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import com.alibaba.android.arouter.facade.annotation.Route; +import com.alibaba.android.arouter.launcher.ARouter; +import com.mogo.map.search.inputtips.MogoTip; +import com.mogo.module.common.MogoModulePaths; +import com.mogo.module.navi.R; +import com.mogo.module.navi.bean.EntityConvertUtils; +import com.mogo.module.navi.bean.SearchPoi; +import com.mogo.module.navi.ui.adapter.HistoryPoiAdapter; +import com.mogo.module.navi.ui.adapter.SearchPoiAdapter; +import com.mogo.module.navi.ui.base.BaseFragment; +import com.mogo.module.navi.ui.base.UiController; +import com.mogo.module.navi.ui.setting.NaviSettingFragment; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.fragmentmanager.FragmentDescriptor; +import com.mogo.service.fragmentmanager.IMogoFragmentManager; +import java.util.ArrayList; +import java.util.List; + +/** + * 搜索页面 + *
+ * 普通搜索:从首页点击搜索按钮进入:包含:仅输入搜索(列表不包含设置按钮) + * {@link SearchConstants#SEARCH_TYPE_COMMON} + *
+ * 地址设置搜索:设置家、公司、其他的地址:包含当前位置、选点、搜索列表(列表包含设置按钮)、普通页面
+ * {@link SearchConstants#SEARCH_TYPE_MULTI_COMPANY}
+ * {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
+ */
+public abstract class BaseSearchFragment extends BaseFragment implements SearchView {
+
+
+ public int mSearchType;
+
+ protected SearchPresenter mSearchPresenter;
+
+ private View mClose;
+ private EditText mSearchBox;
+
+
+
+ /**
+ * 设置常用地址(我的位置、选点)时的设置按钮
+ */
+ private TextView mActionButton;
+
+ /**
+ * 地址设置是否完成
+ */
+ private boolean mActionSuccess = false;
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ if (context instanceof UiController) {
+ }
+ }
+
+ @Override public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_search;
+ }
+
+ @Override
+ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getLifecycle().addObserver(mSearchPresenter = new SearchPresenter(this));
+ }
+
+ @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ mSearchBox = view.findViewById(R.id.et_navi_search);
+ }
+
+ /**
+ * 显示我的位置,并且可设置为家
+ */
+ //private void multiSearchMyLocationUI() {
+ // mUiMode = SearchConstants.UI_MODE_MULTI_MY_LOCATION;
+ // mSearchBox.setEnabled( false );
+ // mMyLocation.setVisibility( View.GONE );
+ // mChoicePoint.setVisibility( View.GONE );
+ // mCurrentLocation.setVisibility( View.GONE );
+ // mSearchResult.setVisibility( View.GONE );
+ // mActionButton.setVisibility( View.VISIBLE );
+ // mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
+ // mSearchBox.setCompoundDrawables( null, null, null, null );
+ // //removeChoicePointMarker();
+ // mSearchBox.setTag( null );
+ // if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
+ // final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
+ // params.addRule( RelativeLayout.LEFT_OF, R.id.amap_search_action_setting );
+ // mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 15 ), 0 );
+ // mSearchBox.setLayoutParams( params );
+ // }
+ //}
+
+ /**
+ * 显示我的位置,并且可设置为家
+ */
+ //private void multiSearchChoicePointUI() {
+ // mUiMode = SearchConstants.UI_MODE_MULTI_CHOICE_POINT;
+ // mSearchBox.setEnabled( false );
+ // mMyLocation.setVisibility( View.GONE );
+ // mChoicePoint.setVisibility( View.GONE );
+ // mCurrentLocation.setVisibility( View.GONE );
+ // mSearchResult.setVisibility( View.GONE );
+ // mActionButton.setVisibility( View.VISIBLE );
+ // mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
+ // mSearchBox.setCompoundDrawables( null, null, null, null );
+ // mSearchBox.setTag( null );
+ // if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
+ // final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
+ // params.addRule( RelativeLayout.LEFT_OF, R.id.amap_search_action_setting );
+ // mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 15 ), 0 );
+ // mSearchBox.setLayoutParams( params );
+ // }
+ //}
+ private void saveCurrentLocationAsCommonAddress() {
+ //if ( mLastAMapLocation == null ) {
+ // shortToast( "定位失败,请重试" );
+ // return;
+ //}
+ //final Disposable disposable = mSearchPresenter.cacheCommonAddressPoi( mLastAMapLocation ).subscribe( output -> {
+ // Toast.makeText( mContext, "设置成功!", Toast.LENGTH_SHORT ).show();
+ // mActionSuccess = true;
+ //}, error -> {
+ // if ( error instanceof Exception) {
+ // Toast.makeText( mContext, ( (Exception) error ).getMessage(), Toast.LENGTH_SHORT ).show();
+ // mActionSuccess = false;
+ // }
+ //} );
+ //mSearchPresenter.addDisposable( disposable );
+ }
+
+ private void saveRegeoAddressAsCommonAddress() {
+ //if ( mSearchBox.getTag() instanceof RegeocodeAddress ) {
+ // final Disposable disposable = mSearchPresenter.cacheCommonAddressPoi( ( ( RegeocodeAddress ) mSearchBox.getTag() ) ).subscribe( output -> {
+ // Toast.makeText( mContext, "设置成功!", Toast.LENGTH_SHORT ).show();
+ // mActionSuccess = true;
+ // }, error -> {
+ // if ( error instanceof Exception) {
+ // Toast.makeText( mContext, ( (Exception) error ).getMessage(), Toast.LENGTH_SHORT ).show();
+ // mActionSuccess = false;
+ // }
+ // } );
+ // mSearchPresenter.addDisposable( disposable );
+ //} else {
+ // Toast.makeText( mContext, "请选择位置", Toast.LENGTH_SHORT ).show();
+ //}
+ }
+
+ // view interface
+
+ @Override
+ public EditText getSearchBox() {
+ return mSearchBox;
+ }
+
+
+ @Override
+ public int getSearchType() {
+ return mSearchType;
+ }
+
+ @Override public void startJumpAnimation() {
+
+ }
+
+ //@Override
+ //public void renderChoicePointResult( RegeocodeAddress address ) {
+ // if ( address == null ) {
+ // mSearchBox.setTag( null );
+ // mSearchBox.setText( "" );
+ // return;
+ // }
+ // mSearchBox.setTag( address );
+ // mSearchBox.setText( address.getFormatAddress() );
+ //}
+ //
+ //@Override
+ //public void renderErrorView() {
+ //
+ //}
+ //
+ //@Override
+ //public void renderContentView() {
+ //
+ //}
+
+ // view interface end
+
+ ///**
+ // * 屏幕中心marker 跳动
+ // */
+ //@Override
+ //public void startJumpAnimation() {
+ //
+ // final AMap aMap = mUiController.getAMapServiceVisitor().getMap();
+ //
+ // if ( mChoicePointMaker != null ) {
+ // //根据屏幕距离计算需要移动的目标点
+ // final LatLng latLng = mChoicePointMaker.getPosition();
+ // Point point = aMap.getProjection().toScreenLocation( latLng );
+ // point.y -= WindowUtils.dip2px( mContext, 125 );
+ // LatLng target = aMap.getProjection()
+ // .fromScreenLocation( point );
+ // //使用TranslateAnimation,填写一个需要移动的目标点
+ // Animation animation = new TranslateAnimation( target );
+ // animation.setInterpolator( new Interpolator() {
+ // @Override
+ // public float getInterpolation( float input ) {
+ // // 模拟重加速度的interpolator
+ // if ( input <= 0.5 ) {
+ // return ( float ) ( 0.5f - 2 * ( 0.5 - input ) * ( 0.5 - input ) );
+ // } else {
+ // return ( float ) ( 0.5f - Math.sqrt( ( input - 0.5f ) * ( 1.5f - input ) ) );
+ // }
+ // }
+ // } );
+ // //整个移动所需要的时间
+ // animation.setDuration( 600 );
+ // //设置动画
+ // mChoicePointMaker.setAnimation( animation );
+ // //开始动画
+ // mChoicePointMaker.startAnimation();
+ //
+ // }
+ //}
+
+
+ private void navi2Location(SearchPoi searchPoi) {
+
+
+ }
+
+ /**
+ * 退出搜索,进行清理
+ */
+ private void exitSearch() {
+
+ switch (mSearchType) {
+ case SearchConstants.SEARCH_TYPE_COMMON:
+ try {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ break;
+ case SearchConstants.SEARCH_TYPE_MULTI_HOME:
+ break;
+ }
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ if (mSearchPresenter != null) {
+ mSearchPresenter.onDestroy(getViewLifecycleOwner());
+ getLifecycle().removeObserver(mSearchPresenter);
+ mSearchPresenter = null;
+ }
+ mSearchBox.setTag(null);
+ //removeChoicePointMarker();
+ }
+}
diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java
index 98d63bbf4f..c1cdbcc1d6 100644
--- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java
+++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java
@@ -27,7 +27,9 @@ import com.mogo.module.navi.ui.adapter.HistoryPoiAdapter;
import com.mogo.module.navi.ui.adapter.SearchPoiAdapter;
import com.mogo.module.navi.ui.base.BaseFragment;
import com.mogo.module.navi.ui.base.UiController;
+import com.mogo.module.navi.ui.setting.NaviSettingFragment;
import com.mogo.service.MogoServicePaths;
+import com.mogo.service.fragmentmanager.FragmentDescriptor;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.utils.WindowUtils;
import io.reactivex.disposables.Disposable;
@@ -45,16 +47,14 @@ import java.util.List;
* {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
*/
@Route(path = MogoModulePaths.PATH_FRAGMENT_SEARCH)
-public class SearchFragment extends BaseFragment implements SearchView {
+public class SearchFragment extends BaseSearchFragment implements SearchView {
public static final String TAG = "search";
public int mSearchType;
- private SearchPresenter mSearchPresenter;
private View mClose;
- private EditText mSearchBox;
private RecyclerView mSearchResult;
private RecyclerView rvHistory;
@@ -96,12 +96,10 @@ public class SearchFragment extends BaseFragment implements SearchView {
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- getLifecycle().addObserver(mSearchPresenter = new SearchPresenter(this));
}
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mSearchBox = view.findViewById(R.id.et_navi_search);
mSearchResult = view.findViewById(R.id.rv_navi_search);
rvHistory = view.findViewById(R.id.rv_navi_history);
rlHistory = view.findViewById(R.id.rl_navi_history);
@@ -148,6 +146,16 @@ public class SearchFragment extends BaseFragment implements SearchView {
}
});
+ findViewById(R.id.tv_navi_setting).setOnClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v) {
+ FragmentDescriptor.Builder builder = new FragmentDescriptor.Builder();
+ builder.fragment(new NaviSettingFragment());
+ FragmentDescriptor build =
+ builder.tag(MogoModulePaths.PATH_FRAGMENT_SETTING).build();
+ fragmentManager.push(build);
+ }
+ });
+
}
/**
@@ -228,12 +236,6 @@ public class SearchFragment extends BaseFragment implements SearchView {
//}
}
- // view interface
-
- @Override
- public EditText getSearchBox() {
- return mSearchBox;
- }
@Override
public void renderSearchPoiResult(List