调整搜索页面
This commit is contained in:
@@ -44,6 +44,10 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility 1.8
|
||||
targetCompatibility 1.8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -68,5 +72,6 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':modules:mogo-module-common')
|
||||
implementation project(':modules:mogo-module-tanlu')
|
||||
implementation project(':modules:mogo-module-navi')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,13 @@ public class MogoModulePaths {
|
||||
@Keep
|
||||
public static final String PATH_MODULE_SEARCH= "navi/search/ui";
|
||||
|
||||
/**
|
||||
* 搜索页面Activity实例化路径
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_MODULE_NAV_ACTIVITY= "/navi/search/ui/activity";
|
||||
|
||||
|
||||
/**
|
||||
* 添加卡片模块
|
||||
*
|
||||
|
||||
@@ -2,13 +2,16 @@ package com.mogo.module.map;
|
||||
|
||||
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.MvpFragment;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
import com.mogo.map.MogoMapView;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
|
||||
/**
|
||||
@@ -34,6 +37,11 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
mMogoMapView = findViewById( R.id.module_map_id_map );
|
||||
mMogoMap = mMogoMapView.getMap();
|
||||
mMogoMap.getUIController().showMyLocation( true );
|
||||
findViewById(R.id.module_map_id_search).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
ARouter.getInstance().build(MogoModulePaths.PATH_MODULE_NAV_ACTIVITY).navigation(getActivity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
@@ -8,17 +10,22 @@ android {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
versionName getValueFromRootProperties(
|
||||
"${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -28,10 +35,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -41,31 +45,34 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.room
|
||||
annotationProcessor rootProject.ext.dependencies.roomAnnotationProcessor
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
kapt rootProject.ext.dependencies.roomAnnotationProcessor
|
||||
implementation rootProject.ext.dependencies.roomRxjava
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||
implementation rootProject.ext.dependencies.jetbrainsannotationsjava5
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
// implementation rootProject.ext.dependencies.jetbrainsannotationsjava5
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
// api project(path: ':modules:mogo-module-common')
|
||||
// api project(path: ':foudations:mogo-utils')
|
||||
// api project(path: ':modules:mogo-module-map')
|
||||
// api project(path: ':modules:mogo-module-common')
|
||||
// api project(path: ':foudations:mogo-utils')
|
||||
// api project(path: ':modules:mogo-module-map')
|
||||
|
||||
if( Boolean.valueOf(RELEASE) ){
|
||||
// implementation rootProject.ext.dependencies.mogomap
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
// implementation rootProject.ext.dependencies.mogomap
|
||||
implementation rootProject.ext.dependencies.mogomapapi
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
// implementation rootProject.ext.dependencies.modulemap
|
||||
// implementation rootProject.ext.dependencies.modulemap
|
||||
} else {
|
||||
// implementation project(":libraries:mogo-map")
|
||||
// implementation project(":libraries:mogo-map")
|
||||
implementation project(":libraries:mogo-map-api")
|
||||
implementation project(":foudations:mogo-utils")
|
||||
api project(":foudations:mogo-commons")
|
||||
api project(':services:mogo-service-api')
|
||||
api project(':modules:mogo-module-common')
|
||||
// implementation project(':modules:mogo-module-map')
|
||||
// implementation project(':modules:mogo-module-map')
|
||||
}
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
}
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.navi" />
|
||||
package="com.mogo.module.navi">
|
||||
|
||||
<application>
|
||||
<activity android:name=".ui.NaviActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.module.navi.ui
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.R
|
||||
|
||||
@Route(path = MogoModulePaths.PATH_MODULE_NAV_ACTIVITY)
|
||||
class NaviActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_navi)
|
||||
var fragment = ARouter.getInstance()
|
||||
.build("/navi/search")
|
||||
.navigation() as Fragment
|
||||
supportFragmentManager.beginTransaction().replace(R.id.fl_container,fragment).commitNow()
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mogo.module.navi.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.ui.adapter.base.RecycleBaseAdapter;
|
||||
import com.mogo.module.navi.ui.adapter.base.RecycleViewHolder;
|
||||
import com.mogo.utils.OnItemClickedListener;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2019-08-13.
|
||||
*/
|
||||
public class HistoryPoiAdapter extends RecycleBaseAdapter<SearchPoi> {
|
||||
/**
|
||||
* @param context
|
||||
* @param list
|
||||
*/
|
||||
public HistoryPoiAdapter(Context context, List<SearchPoi> list) {
|
||||
super(context, list, R.layout.item_search_poi);
|
||||
}
|
||||
private boolean mShowDelete = false;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecycleViewHolder holder, SearchPoi tip) {
|
||||
|
||||
holder.setText(R.id.tv_position, tip.getName());
|
||||
holder.setText(R.id.tv_position_des, tip.getAddress());
|
||||
|
||||
holder.itemView.setTag(R.id.tag_position, tip);
|
||||
holder.itemView.setOnClickListener(onClickListener);
|
||||
|
||||
}
|
||||
|
||||
public void setOnClickListener(View.OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
public void setShowDelete( boolean showDelete ) {
|
||||
this.mShowDelete = showDelete;
|
||||
}
|
||||
public void refresh( List< SearchPoi > datums, boolean showDelete ) {
|
||||
//this.da = datums;
|
||||
setShowDelete( showDelete );
|
||||
setDatas(datums);
|
||||
//notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -36,9 +37,8 @@ import java.util.List;
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_COMPANY}
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
|
||||
*/
|
||||
@Route( path = "/amap/search" )
|
||||
public class SearchFragment extends BaseFragment implements SearchView
|
||||
{
|
||||
@Route(path = "/navi/search")
|
||||
public class SearchFragment extends BaseFragment implements SearchView {
|
||||
|
||||
public static final String TAG = "search";
|
||||
|
||||
@@ -61,25 +61,17 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
*/
|
||||
private TextView mActionButton;
|
||||
|
||||
private UiController mUiController;
|
||||
|
||||
private Bitmap mSearchBoxRightDrawableBitmap = null;
|
||||
|
||||
/**
|
||||
* 地址设置是否完成
|
||||
*/
|
||||
private boolean mActionSuccess = false;
|
||||
|
||||
/**
|
||||
* 当前UI的样式(具体是哪个操作)
|
||||
*/
|
||||
private int mUiMode = SearchConstants.UI_MODE_COMMON;
|
||||
|
||||
@Override
|
||||
public void onAttach( Context context ) {
|
||||
super.onAttach( context );
|
||||
if ( context instanceof UiController) {
|
||||
mUiController = ( ( UiController ) context );
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof UiController) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,70 +81,15 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
getLifecycle().addObserver( mSearchPresenter = new SearchPresenter( this ) );
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getLifecycle().addObserver(mSearchPresenter = new SearchPresenter(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通搜索UI:不显示我的位置、地图选点、我的定位
|
||||
*/
|
||||
private void commonSearchUI() {
|
||||
mUiMode = SearchConstants.UI_MODE_COMMON;
|
||||
mSearchBox.setEnabled( true );
|
||||
mMyLocation.setVisibility( View.GONE );
|
||||
mChoicePoint.setVisibility( View.GONE );
|
||||
mCurrentLocation.setVisibility( View.GONE );
|
||||
mActionButton.setVisibility( View.INVISIBLE );
|
||||
mSearchResult.setVisibility( View.GONE );
|
||||
if ( mSearchBox.getCompoundDrawables()[2] == null ) {
|
||||
Drawable rightDrawable = null;
|
||||
if ( mSearchBoxRightDrawableBitmap == null ) {
|
||||
mSearchBoxRightDrawableBitmap = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_unshadow );
|
||||
}
|
||||
rightDrawable = new BitmapDrawable( getResources(), mSearchBoxRightDrawableBitmap );
|
||||
mSearchBox.setCompoundDrawables( null, null, rightDrawable, null );
|
||||
rightDrawable.setBounds( 0, 0, rightDrawable.getIntrinsicWidth(), rightDrawable.getIntrinsicHeight() );
|
||||
}
|
||||
//removeChoicePointMarker();
|
||||
mSearchBox.setTag( null );
|
||||
if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
params.removeRule( RelativeLayout.LEFT_OF );
|
||||
mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 0 ), 0 );
|
||||
mSearchBox.setLayoutParams( params );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 多项搜索:显示我的位置、地图选点、我的定位
|
||||
*/
|
||||
private void multiSearchUI() {
|
||||
mUiMode = SearchConstants.UI_MODE_MULTI;
|
||||
mSearchBox.setText( "" );
|
||||
mSearchBox.setEnabled( true );
|
||||
mMyLocation.setVisibility( View.VISIBLE );
|
||||
mChoicePoint.setVisibility( View.VISIBLE );
|
||||
mCurrentLocation.setVisibility( View.VISIBLE );
|
||||
mSearchResult.setVisibility( View.GONE );
|
||||
if ( mSearchBox.getCompoundDrawables()[2] == null ) {
|
||||
Drawable rightDrawable = null;
|
||||
if ( mSearchBoxRightDrawableBitmap == null ) {
|
||||
mSearchBoxRightDrawableBitmap = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_unshadow );
|
||||
}
|
||||
rightDrawable = new BitmapDrawable( getResources(), mSearchBoxRightDrawableBitmap );
|
||||
rightDrawable.setBounds( 0, 0, rightDrawable.getIntrinsicWidth(), rightDrawable.getIntrinsicHeight() );
|
||||
mSearchBox.setCompoundDrawables( null, null, rightDrawable, null );
|
||||
}
|
||||
mActionButton.setVisibility( View.INVISIBLE );
|
||||
//removeChoicePointMarker();
|
||||
mSearchBox.setTag( null );
|
||||
if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
params.removeRule( RelativeLayout.LEFT_OF );
|
||||
mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 0 ), 0 );
|
||||
mSearchBox.setLayoutParams( params );
|
||||
}
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +136,6 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
// mSearchBox.setLayoutParams( params );
|
||||
// }
|
||||
//}
|
||||
|
||||
private void saveCurrentLocationAsCommonAddress() {
|
||||
//if ( mLastAMapLocation == null ) {
|
||||
// shortToast( "定位失败,请重试" );
|
||||
@@ -234,7 +170,6 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// view interface
|
||||
|
||||
@Override
|
||||
@@ -243,55 +178,55 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSearchPoiResult( List<MogoTip> datums, boolean showDelete ) {
|
||||
public void renderSearchPoiResult(List<MogoTip> datums, boolean showDelete) {
|
||||
|
||||
if ( datums == null || datums.isEmpty() ) {
|
||||
mSearchResult.setVisibility( View.GONE );
|
||||
if (datums == null || datums.isEmpty()) {
|
||||
mSearchResult.setVisibility(View.GONE);
|
||||
} else {
|
||||
mSearchResult.setVisibility( View.VISIBLE );
|
||||
mSearchResult.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if ( mPoiAdapter == null ) {
|
||||
mPoiAdapter = new SearchPoiAdapter(getContext(), datums );
|
||||
mPoiAdapter.setOnItemClickedListener( item -> {
|
||||
if ( mSearchType == SearchConstants.SEARCH_TYPE_COMMON ) {
|
||||
final Disposable disposable = mSearchPresenter.cacheSelectPoiItem( item ).subscribe( output -> {
|
||||
navi2Location( EntityConvertUtils.tipToPoi( item ) );
|
||||
} );
|
||||
mSearchPresenter.addDisposable( disposable );
|
||||
if (mPoiAdapter == null) {
|
||||
mPoiAdapter = new SearchPoiAdapter(getContext(), datums);
|
||||
mPoiAdapter.setOnItemClickedListener(item -> {
|
||||
if (mSearchType == SearchConstants.SEARCH_TYPE_COMMON) {
|
||||
final Disposable disposable =
|
||||
mSearchPresenter.cacheSelectPoiItem(item).subscribe(output -> {
|
||||
navi2Location(EntityConvertUtils.tipToPoi(item));
|
||||
});
|
||||
mSearchPresenter.addDisposable(disposable);
|
||||
} else {
|
||||
// do nothing.
|
||||
}
|
||||
} );
|
||||
mPoiAdapter.setOnDeleteAllClickedListener( NULL -> {
|
||||
});
|
||||
mPoiAdapter.setOnDeleteAllClickedListener(NULL -> {
|
||||
mSearchPresenter.deleteAllCachedPoi();
|
||||
} );
|
||||
});
|
||||
|
||||
mPoiAdapter.setShowDelete( showDelete );
|
||||
mSearchResult.setAdapter( mPoiAdapter );
|
||||
mPoiAdapter.setShowDelete(showDelete);
|
||||
mSearchResult.setAdapter(mPoiAdapter);
|
||||
} else {
|
||||
if ( datums != null && !datums.isEmpty() ) {
|
||||
mSearchResult.scrollToPosition( 0 );
|
||||
if (datums != null && !datums.isEmpty()) {
|
||||
mSearchResult.scrollToPosition(0);
|
||||
}
|
||||
mPoiAdapter.refresh( datums, showDelete );
|
||||
mPoiAdapter.refresh(datums, showDelete);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void showHistory(List<SearchPoi> datums) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSearchType() {
|
||||
return mSearchType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUiMode() {
|
||||
return mUiMode;
|
||||
@Override public void startJumpAnimation() {
|
||||
|
||||
}
|
||||
|
||||
@Override public void startJumpAnimation() {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
//@Override
|
||||
//public void renderChoicePointResult( RegeocodeAddress address ) {
|
||||
// if ( address == null ) {
|
||||
// mSearchBox.setTag( null );
|
||||
@@ -355,10 +290,10 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
/**
|
||||
* @param searchPoi 导航目的地
|
||||
*/
|
||||
private void navi2Location( SearchPoi searchPoi ) {
|
||||
private void navi2Location(SearchPoi searchPoi) {
|
||||
|
||||
if ( searchPoi == null || searchPoi == SearchPoi.NULL ) {
|
||||
Toast.makeText( mContext, "未设置", Toast.LENGTH_SHORT ).show();
|
||||
if (searchPoi == null || searchPoi == SearchPoi.NULL) {
|
||||
Toast.makeText(mContext, "未设置", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
//SearchPoiLiveData.getInstance().postValue( searchPoi );
|
||||
@@ -370,29 +305,14 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
*/
|
||||
private void exitSearch() {
|
||||
|
||||
switch ( mSearchType ) {
|
||||
switch (mSearchType) {
|
||||
case SearchConstants.SEARCH_TYPE_COMMON:
|
||||
try {
|
||||
mUiController.popBackStackImmediate();
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_HOME:
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_COMPANY:
|
||||
if ( !mActionSuccess ) {
|
||||
// 通过搜索框搜索,在设置成功之前点击返回按钮,返回到未搜索状态
|
||||
if ( mUiMode != SearchConstants.UI_MODE_MULTI || mSearchResult.getVisibility() == View.VISIBLE ) {
|
||||
multiSearchUI();
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
mUiController.popBackStackImmediate();
|
||||
mUiController.onSettingsMode();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -400,24 +320,17 @@ public class SearchFragment extends BaseFragment implements SearchView
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if ( mSearchPresenter != null ) {
|
||||
mSearchPresenter.onDestroy( getViewLifecycleOwner() );
|
||||
getLifecycle().removeObserver( mSearchPresenter );
|
||||
if (mSearchPresenter != null) {
|
||||
mSearchPresenter.onDestroy(getViewLifecycleOwner());
|
||||
getLifecycle().removeObserver(mSearchPresenter);
|
||||
mSearchPresenter = null;
|
||||
}
|
||||
mSearchBox.setTag( null );
|
||||
mUiController = null;
|
||||
if ( mSearchBoxRightDrawableBitmap != null ) {
|
||||
try {
|
||||
mSearchBoxRightDrawableBitmap.recycle();
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
if ( mPoiAdapter != null ) {
|
||||
mSearchBox.setTag(null);
|
||||
|
||||
if (mPoiAdapter != null) {
|
||||
mPoiAdapter.clear();
|
||||
}
|
||||
mPoiAdapter = null;
|
||||
mSearchBoxRightDrawableBitmap = null;
|
||||
//removeChoicePointMarker();
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -55,7 +56,7 @@ public class SearchFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return IMogoModuleProvider.TYPE_FRAGMENT;
|
||||
return ModuleType.TYPE_CARD_FRAGMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.EditText;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.search.inputtips.IMogoInputtipsListener;
|
||||
import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
|
||||
import com.mogo.module.common.TextWatcherAdapter;
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.constants.DataConstants;
|
||||
import com.mogo.module.navi.database.AppDataBase;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleEmitter;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,8 +39,9 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
|
||||
|
||||
private CompositeDisposable mCompositeDisposable;
|
||||
private IMogoMapService mMapService;
|
||||
|
||||
public SearchPresenter( SearchView view ) {
|
||||
public SearchPresenter( SearchView view ) {
|
||||
super( view );
|
||||
mCompositeDisposable = new CompositeDisposable();
|
||||
}
|
||||
@@ -43,16 +50,25 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
attachSearchBoxTextWatcher( mView.getSearchBox() );
|
||||
switch ( mView.getSearchType() ) {
|
||||
case SearchConstants.SEARCH_TYPE_COMMON:
|
||||
loadHistories();
|
||||
break;
|
||||
mMapService = (IMogoMapService) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
||||
loadHistories();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadHistories() {
|
||||
}
|
||||
Disposable subscribe =
|
||||
AppDataBase.getDatabase(getContext())
|
||||
.poiDao()
|
||||
.getAll()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<List<SearchPoi>>() {
|
||||
@Override public void accept(List<SearchPoi> searchPois) throws Exception {
|
||||
mView.showHistory(searchPois);
|
||||
}
|
||||
});
|
||||
|
||||
addDisposable(subscribe);
|
||||
}
|
||||
|
||||
private void attachSearchBoxTextWatcher( EditText editText ) {
|
||||
if ( editText == null ) {
|
||||
@@ -71,25 +87,16 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
};
|
||||
|
||||
private void startSearchPoiByInput( String keyword ) {
|
||||
switch ( mView.getUiMode() ) {
|
||||
// 如果是普通搜索,清空搜索内容后需要加载缓存历史,否则不需要
|
||||
case SearchConstants.UI_MODE_COMMON:
|
||||
if ( TextUtils.isEmpty( keyword ) ) {
|
||||
loadHistories();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SearchConstants.UI_MODE_MULTI_CHOICE_POINT:
|
||||
case SearchConstants.UI_MODE_MULTI_MY_LOCATION:
|
||||
return;
|
||||
case SearchConstants.UI_MODE_MULTI:
|
||||
if ( TextUtils.isEmpty( keyword ) ) {
|
||||
mView.renderSearchPoiResult( null, false );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
MogoInputtipsQuery mogoInputtipsQuery = new MogoInputtipsQuery();
|
||||
mogoInputtipsQuery.setKeyword(keyword);
|
||||
IMogoInputtipsSearch inputtipsSearch =
|
||||
mMapService.getInputtipsSearch(getContext(), mogoInputtipsQuery);
|
||||
|
||||
inputtipsSearch.setInputtipsListener(new IMogoInputtipsListener() {
|
||||
@Override public void onGetInputtips(List<MogoTip> result) {
|
||||
mView.renderSearchPoiResult(result,false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.module.navi.ui.search;
|
||||
import android.widget.EditText;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,14 +22,12 @@ public interface SearchView extends IView {
|
||||
*/
|
||||
void renderSearchPoiResult(List<MogoTip> datums, boolean showDelete);
|
||||
|
||||
|
||||
void showHistory(List<SearchPoi> datums);
|
||||
|
||||
int getSearchType();
|
||||
|
||||
/**
|
||||
* 当前是哪一个操作
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getUiMode();
|
||||
|
||||
|
||||
///**
|
||||
// * 显示逆地理位置编码结果
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.mogo.module.navi.wrapper;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.amap.api.navi.model.AMapCalcRouteResult;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-09-27
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AMapCalcRouteResultWrapper implements Parcelable {
|
||||
|
||||
private final int errorCode;
|
||||
private final int[] routeId;
|
||||
private final int calcRouteType;
|
||||
private final String errorDetail;
|
||||
|
||||
public AMapCalcRouteResultWrapper( AMapCalcRouteResult result ) {
|
||||
errorCode = result.getErrorCode();
|
||||
routeId = result.getRouteid();
|
||||
calcRouteType = result.getCalcRouteType();
|
||||
errorDetail = result.getErrorDetail();
|
||||
}
|
||||
|
||||
public AMapCalcRouteResult parse() {
|
||||
final AMapCalcRouteResult inst = new AMapCalcRouteResult();
|
||||
inst.setErrorCode( getErrorCode() );
|
||||
inst.setRouteid( getRouteId() );
|
||||
inst.setCalcRouteType( getCalcRouteType() );
|
||||
inst.setErrorDetail( getErrorDetail() );
|
||||
return inst;
|
||||
}
|
||||
|
||||
public int getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public int[] getRouteId() {
|
||||
return routeId;
|
||||
}
|
||||
|
||||
public int getCalcRouteType() {
|
||||
return calcRouteType;
|
||||
}
|
||||
|
||||
public String getErrorDetail() {
|
||||
return errorDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeInt( this.errorCode );
|
||||
dest.writeIntArray( this.routeId );
|
||||
dest.writeInt( this.calcRouteType );
|
||||
dest.writeString( this.errorDetail );
|
||||
}
|
||||
|
||||
protected AMapCalcRouteResultWrapper( Parcel in ) {
|
||||
this.errorCode = in.readInt();
|
||||
this.routeId = in.createIntArray();
|
||||
this.calcRouteType = in.readInt();
|
||||
this.errorDetail = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator< AMapCalcRouteResultWrapper > CREATOR = new Creator< AMapCalcRouteResultWrapper >() {
|
||||
@Override
|
||||
public AMapCalcRouteResultWrapper createFromParcel( Parcel source ) {
|
||||
return new AMapCalcRouteResultWrapper( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AMapCalcRouteResultWrapper[] newArray( int size ) {
|
||||
return new AMapCalcRouteResultWrapper[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.mogo.module.navi.wrapper;
|
||||
|
||||
import com.amap.api.navi.model.AMapNaviCameraInfo;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AMapNaviCameraInfoWrapper {
|
||||
|
||||
private int cameraDistance;
|
||||
private double x;
|
||||
private double y;
|
||||
/**
|
||||
* {@link AMapNaviCameraInfo#getCameraType()}
|
||||
* {@link com.amap.api.navi.enums.CameraType#SPEED} 测速摄像
|
||||
* {@link com.amap.api.navi.enums.CameraType#SURVEILLANCE}监控摄像
|
||||
* {@link com.amap.api.navi.enums.CameraType#TRAFFICLIGHT} 闯红灯拍照
|
||||
* {@link com.amap.api.navi.enums.CameraType#BREAKRULE} 违章拍照
|
||||
* {@link com.amap.api.navi.enums.CameraType#BUSWAY} 公交专用道摄像头
|
||||
* {@link com.amap.api.navi.enums.CameraType#EMERGENCY}应急车道拍照
|
||||
* {@link com.amap.api.navi.enums.CameraType#BICYCLE}非机动车道(暂未使用)
|
||||
* {@link com.amap.api.navi.enums.CameraType#INTERVALVELOCITYSTART}区间测速起始
|
||||
* {@link com.amap.api.navi.enums.CameraType#INTERVALVELOCITYEND}区间测速解除
|
||||
*/
|
||||
private int cameraType;
|
||||
private int cameraSpeed;
|
||||
private int averageSpeed;
|
||||
private int reasonableSpeedInRemainDist;
|
||||
private int distance;
|
||||
private int[] speed;
|
||||
|
||||
public AMapNaviCameraInfoWrapper( AMapNaviCameraInfo info ) {
|
||||
if ( info != null ) {
|
||||
cameraDistance = info.getCameraDistance();
|
||||
x = info.getX();
|
||||
y = info.getY();
|
||||
cameraType = info.getCameraType();
|
||||
cameraSpeed = info.getCameraSpeed();
|
||||
averageSpeed = info.getAverageSpeed();
|
||||
reasonableSpeedInRemainDist = info.getReasonableSpeedInRemainDist();
|
||||
distance = info.getDistance();
|
||||
speed = info.getSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append( "cameraDistance" ).append( "=" ).append( cameraDistance ).append( "\n" );
|
||||
builder.append( "cameraType" ).append( "=" ).append( cameraType ).append( "\n" );
|
||||
builder.append( "cameraSpeed" ).append( "=" ).append( cameraSpeed ).append( "\n" );
|
||||
builder.append( "averageSpeed" ).append( "=" ).append( averageSpeed ).append( "\n" );
|
||||
builder.append( "reasonableSpeedInRemainDist" ).append( "=" ).append( reasonableSpeedInRemainDist ).append( "\n" );
|
||||
builder.append( "distance" ).append( "=" ).append( distance ).append( "\n" );
|
||||
if ( speed != null ) {
|
||||
builder.append( "speed" ).append( "=" ).append( speed ).append( "\n" );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public int getCameraDistance() {
|
||||
return cameraDistance;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getCameraType() {
|
||||
return cameraType;
|
||||
}
|
||||
|
||||
public int getCameraSpeed() {
|
||||
return cameraSpeed;
|
||||
}
|
||||
|
||||
public int getAverageSpeed() {
|
||||
return averageSpeed;
|
||||
}
|
||||
|
||||
public int getReasonableSpeedInRemainDist() {
|
||||
return reasonableSpeedInRemainDist;
|
||||
}
|
||||
|
||||
public int getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public int[] getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package com.mogo.module.navi.wrapper;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.amap.api.navi.model.AMapNaviLocation;
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-09-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AMapNaviLocationWrapper implements Parcelable {
|
||||
|
||||
private final float accuracy;
|
||||
private final double altitude;
|
||||
private final float bearing;
|
||||
private final float speed;
|
||||
private final long time;
|
||||
private final int matchStatus;
|
||||
private final NaviLatLng coord;
|
||||
private final int curStepIndex;
|
||||
private final int curLinkIndex;
|
||||
private final int curPointIndex;
|
||||
private final int type;
|
||||
|
||||
public AMapNaviLocationWrapper( AMapNaviLocation aMapNaviLocation ) {
|
||||
this.accuracy = aMapNaviLocation.getAccuracy();
|
||||
this.altitude = aMapNaviLocation.getAltitude();
|
||||
this.bearing = aMapNaviLocation.getBearing();
|
||||
this.speed = aMapNaviLocation.getSpeed();
|
||||
this.time = aMapNaviLocation.getTime();
|
||||
this.matchStatus = aMapNaviLocation.getMatchStatus();
|
||||
this.coord = aMapNaviLocation.getCoord();
|
||||
this.curStepIndex = aMapNaviLocation.getCurStepIndex();
|
||||
this.curLinkIndex = aMapNaviLocation.getCurLinkIndex();
|
||||
this.curPointIndex = aMapNaviLocation.getCurPointIndex();
|
||||
this.type = aMapNaviLocation.getType();
|
||||
}
|
||||
|
||||
public AMapNaviLocation parse() {
|
||||
final AMapNaviLocation inst = new AMapNaviLocation();
|
||||
inst.setAccuracy( getAccuracy() );
|
||||
inst.setAltitude( getAltitude() );
|
||||
inst.setBearing( getBearing() );
|
||||
inst.setSpeed( getSpeed() );
|
||||
inst.setTime( getTime() );
|
||||
inst.setMatchStatus( getMatchStatus() );
|
||||
inst.setCoord( getCoord() );
|
||||
inst.setCurStepIndex( getCurStepIndex() );
|
||||
inst.setCurLinkIndex( getCurLinkIndex() );
|
||||
inst.setCurPointIndex( getCurPointIndex() );
|
||||
inst.setType( getType() );
|
||||
return inst;
|
||||
}
|
||||
|
||||
public float getAccuracy() {
|
||||
return accuracy;
|
||||
}
|
||||
|
||||
public double getAltitude() {
|
||||
return altitude;
|
||||
}
|
||||
|
||||
public float getBearing() {
|
||||
return bearing;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public int getMatchStatus() {
|
||||
return matchStatus;
|
||||
}
|
||||
|
||||
public NaviLatLng getCoord() {
|
||||
return coord;
|
||||
}
|
||||
|
||||
public int getCurStepIndex() {
|
||||
return curStepIndex;
|
||||
}
|
||||
|
||||
public int getCurLinkIndex() {
|
||||
return curLinkIndex;
|
||||
}
|
||||
|
||||
public int getCurPointIndex() {
|
||||
return curPointIndex;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeFloat( this.accuracy );
|
||||
dest.writeDouble( this.altitude );
|
||||
dest.writeFloat( this.bearing );
|
||||
dest.writeFloat( this.speed );
|
||||
dest.writeLong( this.time );
|
||||
dest.writeInt( this.matchStatus );
|
||||
dest.writeParcelable( this.coord, flags );
|
||||
dest.writeInt( this.curStepIndex );
|
||||
dest.writeInt( this.curLinkIndex );
|
||||
dest.writeInt( this.curPointIndex );
|
||||
dest.writeInt( this.type );
|
||||
}
|
||||
|
||||
protected AMapNaviLocationWrapper( Parcel in ) {
|
||||
this.accuracy = in.readFloat();
|
||||
this.altitude = in.readDouble();
|
||||
this.bearing = in.readFloat();
|
||||
this.speed = in.readFloat();
|
||||
this.time = in.readLong();
|
||||
this.matchStatus = in.readInt();
|
||||
this.coord = in.readParcelable( NaviLatLng.class.getClassLoader() );
|
||||
this.curStepIndex = in.readInt();
|
||||
this.curLinkIndex = in.readInt();
|
||||
this.curPointIndex = in.readInt();
|
||||
this.type = in.readInt();
|
||||
}
|
||||
|
||||
public static final Creator< AMapNaviLocationWrapper >
|
||||
CREATOR = new Parcelable.Creator< AMapNaviLocationWrapper >() {
|
||||
@Override
|
||||
public AMapNaviLocationWrapper createFromParcel( Parcel source ) {
|
||||
return new AMapNaviLocationWrapper( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AMapNaviLocationWrapper[] newArray( int size ) {
|
||||
return new AMapNaviLocationWrapper[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.mogo.module.navi.wrapper;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.navi.model.AMapNaviLocation;
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-09-26
|
||||
* <p>
|
||||
* 经纬度
|
||||
*/
|
||||
public class LatLngWrapper implements Parcelable {
|
||||
|
||||
private final double lat;
|
||||
private final double lng;
|
||||
|
||||
public LatLngWrapper( double lat, double lng ) {
|
||||
this.lat = lat;
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeDouble( this.lat );
|
||||
dest.writeDouble( this.lng );
|
||||
}
|
||||
|
||||
protected LatLngWrapper( Parcel in ) {
|
||||
this.lat = in.readDouble();
|
||||
this.lng = in.readDouble();
|
||||
}
|
||||
|
||||
public static final Creator< LatLngWrapper > CREATOR = new Creator< LatLngWrapper >() {
|
||||
@Override
|
||||
public LatLngWrapper createFromParcel( Parcel source ) {
|
||||
return new LatLngWrapper( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLngWrapper[] newArray( int size ) {
|
||||
return new LatLngWrapper[size];
|
||||
}
|
||||
};
|
||||
|
||||
public static LatLngWrapper from( LatLng latlng ) {
|
||||
return new LatLngWrapper( latlng.latitude, latlng.longitude );
|
||||
}
|
||||
|
||||
public static LatLngWrapper from( NaviLatLng latlng ) {
|
||||
return new LatLngWrapper( latlng.getLatitude(), latlng.getLongitude() );
|
||||
}
|
||||
|
||||
public static LatLngWrapper from( AMapNaviLocation latlng ) {
|
||||
return from( latlng.getCoord() );
|
||||
}
|
||||
|
||||
public LatLng parseLatLngInst() {
|
||||
return new LatLng( getLat(), getLng() );
|
||||
}
|
||||
|
||||
public static LatLng parse( NaviLatLng latLng ) {
|
||||
if ( latLng == null ) {
|
||||
return null;
|
||||
}
|
||||
return new LatLng( latLng.getLatitude(), latLng.getLongitude() );
|
||||
}
|
||||
|
||||
public static LatLng parse( Location location ) {
|
||||
if ( location == null ) {
|
||||
return null;
|
||||
}
|
||||
return new LatLng( location.getLatitude(), location.getLongitude() );
|
||||
}
|
||||
|
||||
public static LatLng parse( double lat, double lng ) {
|
||||
if ( isRightLatLng( lat, lng ) ) {
|
||||
return new LatLng( lat, lng );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isRightLatLng( double lat, double lng ) {
|
||||
return lat > 0 && lat < 90 && lng > 0 && lng < 180;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package com.mogo.module.navi.wrapper;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.amap.api.navi.model.NaviInfo;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-09-29
|
||||
* <p>
|
||||
* 导航信息对象
|
||||
*/
|
||||
public class NaviInfoWrapper implements Parcelable {
|
||||
|
||||
private static final NaviInfoWrapper INST = new NaviInfoWrapper();
|
||||
|
||||
private int nextIconType;
|
||||
private int nextDistance;
|
||||
private String nextRoad;
|
||||
private int surplusDistance;
|
||||
private int surplusTime;
|
||||
private int currentSpeed;
|
||||
|
||||
private NaviInfoWrapper() {
|
||||
|
||||
}
|
||||
|
||||
public static NaviInfoWrapper getInst() {
|
||||
return INST;
|
||||
}
|
||||
|
||||
public synchronized NaviInfoWrapper fillWith( NaviInfo naviInfo ) {
|
||||
INST.nextIconType = naviInfo.getIconType();
|
||||
INST.nextDistance = naviInfo.getCurStepRetainDistance();
|
||||
INST.nextRoad = naviInfo.getNextRoadName();
|
||||
INST.surplusDistance = naviInfo.getPathRetainDistance();
|
||||
INST.surplusTime = naviInfo.getPathRetainTime();
|
||||
INST.currentSpeed = naviInfo.getCurrentSpeed();
|
||||
return INST;
|
||||
}
|
||||
|
||||
public NaviInfoWrapper( NaviInfo naviInfo ) {
|
||||
this.nextIconType = naviInfo.getIconType();
|
||||
this.nextDistance = naviInfo.getCurStepRetainDistance();
|
||||
this.nextRoad = naviInfo.getNextRoadName();
|
||||
this.surplusDistance = naviInfo.getPathRetainDistance();
|
||||
this.surplusTime = naviInfo.getPathRetainTime();
|
||||
this.currentSpeed = naviInfo.getCurrentSpeed();
|
||||
}
|
||||
|
||||
public synchronized int getNextIconType() {
|
||||
return nextIconType;
|
||||
}
|
||||
|
||||
public synchronized int getNextDistance() {
|
||||
return nextDistance;
|
||||
}
|
||||
|
||||
public synchronized String getNextRoad() {
|
||||
return nextRoad;
|
||||
}
|
||||
|
||||
public synchronized int getSurplusDistance() {
|
||||
return surplusDistance;
|
||||
}
|
||||
|
||||
public synchronized int getSurplusTime() {
|
||||
return surplusTime;
|
||||
}
|
||||
|
||||
public synchronized int getCurrentSpeed() {
|
||||
return currentSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeInt( getNextIconType() );
|
||||
dest.writeInt( getNextDistance() );
|
||||
dest.writeString( getNextRoad() );
|
||||
dest.writeInt( getSurplusDistance() );
|
||||
dest.writeInt( getSurplusTime() );
|
||||
dest.writeInt( getCurrentSpeed() );
|
||||
}
|
||||
|
||||
protected NaviInfoWrapper( Parcel in ) {
|
||||
this.nextIconType = in.readInt();
|
||||
this.nextDistance = in.readInt();
|
||||
this.nextRoad = in.readString();
|
||||
this.surplusDistance = in.readInt();
|
||||
this.surplusTime = in.readInt();
|
||||
this.currentSpeed = in.readInt();
|
||||
}
|
||||
|
||||
public static final Creator< NaviInfoWrapper > CREATOR = new Parcelable.Creator< NaviInfoWrapper >() {
|
||||
@Override
|
||||
public NaviInfoWrapper createFromParcel( Parcel source ) {
|
||||
return new NaviInfoWrapper( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NaviInfoWrapper[] newArray( int size ) {
|
||||
return new NaviInfoWrapper[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.NaviActivity"
|
||||
>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -4,18 +4,18 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/dp_30"
|
||||
android:paddingLeft="@dimen/dp_30"
|
||||
android:paddingRight="@dimen/dp_30"
|
||||
android:paddingTop="@dimen/dp_20"
|
||||
android:paddingBottom="@dimen/dp_60"
|
||||
android:paddingLeft="@dimen/dp_60"
|
||||
android:paddingRight="@dimen/dp_60"
|
||||
android:paddingTop="@dimen/dp_40"
|
||||
tools:context=".ui.search.SearchFragment"
|
||||
style="@style/amap_fragment_container_padding_style"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_navi_search"
|
||||
android:layout_width="@dimen/dp_600"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
android:layout_width="600dp"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:background="@drawable/shape_round_gray"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
@@ -25,18 +25,20 @@
|
||||
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:id="@+id/et_navi_search"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:imeOptions="actionDone"
|
||||
android:hint="@string/hint_map_search"
|
||||
android:textColor="@color/white"
|
||||
android:textColorHint="@color/white_60"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_40"
|
||||
android:layout_height="@dimen/dp_40"
|
||||
android:layout_marginLeft="@dimen/dp_12"
|
||||
android:layout_marginRight="@dimen/dp_10"
|
||||
android:layout_width="@dimen/dp_80"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_marginLeft="@dimen/dp_24"
|
||||
android:layout_marginRight="@dimen/dp_20"
|
||||
android:src="@mipmap/icon_back"
|
||||
/>
|
||||
|
||||
@@ -45,11 +47,11 @@
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_navi_home"
|
||||
android:layout_width="@dimen/dp_284"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
android:layout_width="@dimen/dp_568"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:background="@drawable/shape_round_gray"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/dp_16"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintLeft_toRightOf="@id/ll_navi_search"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
@@ -60,6 +62,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:textSize="@dimen/txt_normal"
|
||||
android:paddingLeft="@dimen/dp_75"
|
||||
android:gravity="center_vertical"
|
||||
android:drawableLeft="@mipmap/icon_navi_home"
|
||||
android:text="@string/navi_home"
|
||||
@@ -68,7 +71,7 @@
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="@dimen/dp_36"
|
||||
android:layout_height="@dimen/dp_72"
|
||||
android:background="#17D8D8D8"
|
||||
/>
|
||||
|
||||
@@ -76,6 +79,8 @@
|
||||
android:layout_width="0dp"
|
||||
android:textSize="@dimen/txt_normal"
|
||||
android:text="@string/navi_company"
|
||||
android:paddingLeft="@dimen/dp_75"
|
||||
|
||||
android:gravity="center_vertical"
|
||||
android:drawableLeft="@mipmap/icon_navi_company"
|
||||
android:layout_height="match_parent"
|
||||
@@ -86,11 +91,11 @@
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_navi_history"
|
||||
android:layout_width="@dimen/dp_600"
|
||||
android:layout_height="@dimen/dp_389"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_width="600dp"
|
||||
android:layout_height="@dimen/dp_778"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
android:background="@drawable/shape_round_gray"
|
||||
android:padding="@dimen/dp_20"
|
||||
android:padding="@dimen/dp_40"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_navi_search"
|
||||
>
|
||||
@@ -101,7 +106,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/history_search"
|
||||
android:textColor="@color/white_60"
|
||||
android:textSize="@dimen/sp_16"
|
||||
android:textSize="@dimen/txt_normal"
|
||||
/>
|
||||
|
||||
|
||||
@@ -113,25 +118,35 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/history_search"
|
||||
android:textColor="@color/txt_blue"
|
||||
android:textSize="@dimen/sp_16"
|
||||
android:textSize="@dimen/txt_normal"
|
||||
/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/rv_navi_history"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:layout_marginTop="@dimen/dp_120"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="600dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@id/ll_navi_search"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:id="@+id/rv_navi_search"
|
||||
android:layout_height="match_parent"/>
|
||||
<TextView
|
||||
android:drawableTop="@mipmap/icon_navi_restrant"
|
||||
app:layout_constraintTop_toTopOf="@id/rl_navi_history"
|
||||
app:layout_constraintLeft_toRightOf="@id/rl_navi_history"
|
||||
android:text="@string/navi_restrant"
|
||||
android:id="@+id/tv_navi_restaurant"
|
||||
android:layout_marginLeft="@dimen/dp_16"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
style="@style/txt_navi_style"
|
||||
/>
|
||||
|
||||
@@ -141,7 +156,7 @@
|
||||
app:layout_constraintTop_toTopOf="@id/tv_navi_restaurant"
|
||||
app:layout_constraintLeft_toRightOf="@id/tv_navi_restaurant"
|
||||
android:text="@string/navi_restrant"
|
||||
android:layout_marginLeft="@dimen/dp_16"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
style="@style/txt_navi_style"
|
||||
/>
|
||||
|
||||
@@ -152,7 +167,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_navi_restaurant"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tv_navi_restaurant"
|
||||
android:text="@string/navi_restrant"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
style="@style/txt_navi_style"
|
||||
/>
|
||||
|
||||
@@ -163,7 +178,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_navi_toilet"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tv_navi_restaurant"
|
||||
android:text="@string/navi_restrant"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
|
||||
style="@style/txt_navi_style"
|
||||
/>
|
||||
@@ -174,7 +189,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_navi_gas"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tv_navi_gas"
|
||||
android:text="@string/navi_restrant"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
|
||||
style="@style/txt_navi_style"
|
||||
/>
|
||||
@@ -185,7 +200,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_navi_park"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tv_navi_gas"
|
||||
android:text="@string/navi_restrant"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
|
||||
style="@style/txt_navi_style"
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="txt_normal">@dimen/sp_16</dimen>
|
||||
<dimen name="txt_normal">@dimen/sp_32</dimen>
|
||||
</resources>
|
||||
@@ -17,12 +17,13 @@
|
||||
</style>
|
||||
|
||||
<style name="txt_navi_style">
|
||||
<item name="android:layout_width">@dimen/dp_134</item>
|
||||
<item name="android:layout_width">@dimen/dp_268</item>
|
||||
<item name="android:gravity">center_horizontal</item>
|
||||
<item name="android:textSize">@dimen/txt_normal</item>
|
||||
<item name="android:textColor">@color/white</item>
|
||||
<item name="android:background">@drawable/shape_round_gray</item>
|
||||
<item name="android:layout_height">@dimen/dp_118</item>
|
||||
<item name="android:layout_height">@dimen/dp_236</item>
|
||||
<item name="android:paddingTop">@dimen/dp_44</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user