调整搜索页面
This commit is contained in:
@@ -19,6 +19,14 @@ public class MogoLatLng implements Parcelable {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
||||
@@ -26,6 +26,7 @@ public class AppsAdapter extends RecyclerView.Adapter< AppsAdapter.AppsViewHolde
|
||||
public AppsAdapter( List< AppInfo > appInfos ) {
|
||||
this.mAppInfos = appInfos;
|
||||
}
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
public void refreshAppInfos( List< AppInfo > mAppInfos ) {
|
||||
this.mAppInfos = mAppInfos;
|
||||
@@ -43,6 +44,8 @@ public class AppsAdapter extends RecyclerView.Adapter< AppsAdapter.AppsViewHolde
|
||||
final AppInfo appInfo = mAppInfos.get( position );
|
||||
holder.mIcon.setImageDrawable( appInfo.getIcon() );
|
||||
holder.mName.setText( appInfo.getName() );
|
||||
holder.itemView.setTag(appInfo);
|
||||
holder.itemView.setOnClickListener(onClickListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,4 +64,8 @@ public class AppsAdapter extends RecyclerView.Adapter< AppsAdapter.AppsViewHolde
|
||||
mName = itemView.findViewById( R.id.module_apps_id_app_name );
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnClickListener(View.OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,18 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
if ( mAppsAdapter == null ) {
|
||||
mAppsAdapter = new AppsAdapter( appInfos );
|
||||
mAppsList.setAdapter( mAppsAdapter );
|
||||
bindListener();
|
||||
} else {
|
||||
mAppsAdapter.refreshAppInfos( appInfos );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindListener() {
|
||||
mAppsAdapter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
AppInfo tag = (AppInfo) v.getTag();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,15 @@ public class MogoModulePaths {
|
||||
@Keep
|
||||
public static final String PATH_MODULE_APPS = "/appslist/ui";
|
||||
|
||||
|
||||
/**
|
||||
* 搜索页面模块实例化路径
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_MODULE_SEARCH= "navi/search/ui";
|
||||
|
||||
|
||||
|
||||
public static void addModule( String path ) {
|
||||
if ( TextUtils.isEmpty( path.replace( " ", "" ) ) ) {
|
||||
throw new IllegalArgumentException( "module path can't be empty or null or blank" );
|
||||
|
||||
@@ -52,20 +52,20 @@ dependencies {
|
||||
// api project(path: ':modules:mogo-module-map')
|
||||
|
||||
if( Boolean.valueOf(RELEASE) ){
|
||||
implementation rootProject.ext.dependencies.mogomap
|
||||
// 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')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.mogo.module.navi.bean;
|
||||
|
||||
import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.services.core.LatLonPoint;
|
||||
import com.amap.api.services.geocoder.RegeocodeAddress;
|
||||
import com.amap.api.services.help.Tip;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,80 +13,82 @@ import java.util.List;
|
||||
*/
|
||||
public class EntityConvertUtils {
|
||||
|
||||
public static List< Tip > pois2Tips( List< SearchPoi > datums ) {
|
||||
final List< Tip > output = new ArrayList<>();
|
||||
public static List<MogoTip> pois2MogoTips( List< SearchPoi > datums ) {
|
||||
final List< MogoTip > output = new ArrayList<>();
|
||||
if ( datums == null || datums.isEmpty() ) {
|
||||
return output;
|
||||
}
|
||||
for ( SearchPoi poi : datums ) {
|
||||
Tip tip = poi2Tip( poi );
|
||||
if ( tip != null ) {
|
||||
output.add( tip );
|
||||
MogoTip MogoTip = poi2MogoTip( poi );
|
||||
if ( MogoTip != null ) {
|
||||
output.add( MogoTip );
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static Tip poi2Tip( SearchPoi poi ) {
|
||||
public static MogoTip poi2MogoTip( SearchPoi poi ) {
|
||||
if ( poi == null ) {
|
||||
return null;
|
||||
}
|
||||
Tip tip = new Tip();
|
||||
tip.setID( poi.pId );
|
||||
tip.setAdcode( poi.getAdCode() );
|
||||
tip.setAddress( poi.getAddress() );
|
||||
tip.setDistrict( poi.getDistrict() );
|
||||
tip.setName( poi.getName() );
|
||||
tip.setTypeCode( poi.getTypeCode() );
|
||||
tip.setPostion( new LatLonPoint( poi.getLat(), poi.getLng() ) );
|
||||
return tip;
|
||||
MogoTip MogoTip = new MogoTip();
|
||||
MogoTip.setPoiID( poi.pId );
|
||||
MogoTip.setAdCode( poi.getAdCode() );
|
||||
MogoTip.setAddress( poi.getAddress() );
|
||||
MogoTip.setDistrict( poi.getDistrict() );
|
||||
MogoTip.setName( poi.getName() );
|
||||
MogoTip.setTypeCode( poi.getTypeCode() );
|
||||
MogoTip.setPoint( new MogoLatLng( poi.getLat(), poi.getLng() ) );
|
||||
return MogoTip;
|
||||
}
|
||||
|
||||
public static SearchPoi tipToPoi( Tip tip ) {
|
||||
if ( tip == null ) {
|
||||
public static SearchPoi tipToPoi( MogoTip MogoTip ) {
|
||||
if ( MogoTip == null ) {
|
||||
return null;
|
||||
}
|
||||
double lat = 0.0;
|
||||
double lng = 0.0;
|
||||
if ( tip.getPoint() != null ) {
|
||||
lat = tip.getPoint().getLatitude();
|
||||
lng = tip.getPoint().getLongitude();
|
||||
if ( MogoTip.getPoint() != null ) {
|
||||
lat = MogoTip.getPoint().getLat();
|
||||
lng = MogoTip.getPoint().getLng();
|
||||
}
|
||||
return new SearchPoi( tip.getPoiID(),
|
||||
tip.getName(),
|
||||
tip.getAddress(),
|
||||
return new SearchPoi( MogoTip.getPoiID(),
|
||||
MogoTip.getName(),
|
||||
MogoTip.getAddress(),
|
||||
lat,
|
||||
lng,
|
||||
tip.getDistrict(),
|
||||
tip.getAdcode(),
|
||||
tip.getTypeCode() );
|
||||
MogoTip.getDistrict(),
|
||||
MogoTip.getAdCode(),
|
||||
MogoTip.getTypeCode() );
|
||||
}
|
||||
|
||||
public static SearchPoi aMapLocation2Poi( AMapLocation location ) {
|
||||
if ( location == null || location.getErrorCode() != AMapLocation.LOCATION_SUCCESS ) {
|
||||
return null;
|
||||
}
|
||||
return new SearchPoi( System.currentTimeMillis() + "",
|
||||
location.getPoiName(),
|
||||
location.getAddress(),
|
||||
location.getLatitude(),
|
||||
location.getLongitude(),
|
||||
location.getDistrict(),
|
||||
location.getAdCode(),
|
||||
location.getCoordType() );
|
||||
}
|
||||
|
||||
public static SearchPoi geocodeAddress2Poi( RegeocodeAddress address, CameraPosition position ) {
|
||||
if ( address == null || position == null ) {
|
||||
return null;
|
||||
}
|
||||
return new SearchPoi( System.currentTimeMillis() + "",
|
||||
address.getFormatAddress(),
|
||||
address.getFormatAddress(),
|
||||
position.target.latitude,
|
||||
position.target.longitude,
|
||||
address.getDistrict(),
|
||||
address.getAdCode(),
|
||||
"" );
|
||||
}
|
||||
|
||||
//public static SearchPoi aMapLocation2Poi( AMapLocation location ) {
|
||||
// if ( location == null || location.getErrorCode() != AMapLocation.LOCATION_SUCCESS ) {
|
||||
// return null;
|
||||
// }
|
||||
// return new SearchPoi( System.currentTimeMillis() + "",
|
||||
// location.getPoiName(),
|
||||
// location.getAddress(),
|
||||
// location.getLatitude(),
|
||||
// location.getLongitude(),
|
||||
// location.getDistrict(),
|
||||
// location.getAdCode(),
|
||||
// location.getCoordType() );
|
||||
//}
|
||||
|
||||
//public static SearchPoi geocodeAddress2Poi( RegeocodeAddress address, CameraPosition position ) {
|
||||
// if ( address == null || position == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// return new SearchPoi( System.currentTimeMillis() + "",
|
||||
// address.getFormatAddress(),
|
||||
// address.getFormatAddress(),
|
||||
// position.target.latitude,
|
||||
// position.target.longitude,
|
||||
// address.getDistrict(),
|
||||
// address.getAdCode(),
|
||||
// "" );
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.module.navi.constants;
|
||||
|
||||
import com.amap.api.navi.enums.PathPlanningStrategy;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -22,8 +21,6 @@ public class AMapConstants {
|
||||
|
||||
public static final float AMPA_BEARING = 0.0f;
|
||||
|
||||
public static final int DEFAULT_ROUTE_STRATEGY = PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT;
|
||||
|
||||
public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED = 1f;
|
||||
public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED = 0.3f;
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.mogo.module.navi.lib;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.navi.AMapNaviListener;
|
||||
import com.amap.api.navi.AMapNaviViewListener;
|
||||
import com.mogo.module.navi.database.wrapper.NaviInfoWrapper;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-09-27
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface AMapNaviStatusChangedListener extends AMapNaviListener,
|
||||
AMapNaviViewListener,
|
||||
AMap.OnCameraChangeListener {
|
||||
|
||||
void onNaviInfoUpdate(NaviInfoWrapper wrapper);
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
package com.mogo.module.navi.lib;
|
||||
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.navi.model.AMapCalcRouteResult;
|
||||
import com.amap.api.navi.model.AMapLaneInfo;
|
||||
import com.amap.api.navi.model.AMapModelCross;
|
||||
import com.amap.api.navi.model.AMapNaviCameraInfo;
|
||||
import com.amap.api.navi.model.AMapNaviCross;
|
||||
import com.amap.api.navi.model.AMapNaviInfo;
|
||||
import com.amap.api.navi.model.AMapNaviLocation;
|
||||
import com.amap.api.navi.model.AMapNaviRouteNotifyData;
|
||||
import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo;
|
||||
import com.amap.api.navi.model.AMapServiceAreaInfo;
|
||||
import com.amap.api.navi.model.AimLessModeCongestionInfo;
|
||||
import com.amap.api.navi.model.AimLessModeStat;
|
||||
import com.amap.api.navi.model.NaviInfo;
|
||||
import com.autonavi.tbt.TrafficFacilityInfo;
|
||||
import com.mogo.module.navi.database.wrapper.NaviInfoWrapper;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-01
|
||||
* <p>
|
||||
*/
|
||||
public abstract class AMapNaviStatusChangedListenerDefault implements AMapNaviStatusChangedListener {
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( NaviInfoWrapper wrapper ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange( CameraPosition cameraPosition ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish( CameraPosition cameraPosition ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi( int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrafficStatusUpdate() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChange( AMapNaviLocation aMapNaviLocation ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetNavigationText( int i, String s ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetNavigationText( String s ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndEmulatorNavi() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArriveDestination() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateRouteFailure( int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReCalculateRouteForYaw() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReCalculateRouteForTrafficJam() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArrivedWayPoint( int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGpsOpenStatus( boolean b ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( NaviInfo naviInfo ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdated( AMapNaviInfo aMapNaviInfo ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCameraInfo( AMapNaviCameraInfo[] aMapNaviCameraInfos ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIntervalCameraInfo( AMapNaviCameraInfo aMapNaviCameraInfo, AMapNaviCameraInfo aMapNaviCameraInfo1, int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceAreaUpdate( AMapServiceAreaInfo[] aMapServiceAreaInfos ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCross( AMapNaviCross aMapNaviCross ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideCross() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showModeCross( AMapModelCross aMapModelCross ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideModeCross() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLaneInfo( AMapLaneInfo[] aMapLaneInfos, byte[] bytes, byte[] bytes1 ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLaneInfo( AMapLaneInfo aMapLaneInfo ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLaneInfo() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateRouteSuccess( int[] ints ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyParallelRoad( int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdateTrafficFacility( AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdateTrafficFacility( AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdateTrafficFacility( TrafficFacilityInfo trafficFacilityInfo ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAimlessModeStatistics( AimLessModeStat aimLessModeStat ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAimlessModeCongestionInfo( AimLessModeCongestionInfo aimLessModeCongestionInfo ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayRing( int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateRouteSuccess( AMapCalcRouteResult aMapCalcRouteResult ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateRouteFailure( AMapCalcRouteResult aMapCalcRouteResult ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviRouteNotify( AMapNaviRouteNotifyData aMapNaviRouteNotifyData ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviSetting() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNaviBackClick() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviMapMode( int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviTurnClick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNextRoadClick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanViewButtonClick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap( boolean b ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviViewLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapTypeChanged( int i ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviViewShowMode( int i ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.mogo.module.navi.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import com.amap.api.services.help.Tip;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.ui.adapter.base.RecycleBaseAdapter;
|
||||
import com.mogo.module.navi.ui.adapter.base.RecycleViewHolder;
|
||||
@@ -13,23 +13,23 @@ import java.util.List;
|
||||
* @author zyz
|
||||
* 2019-08-13.
|
||||
*/
|
||||
public class SearchPoiAdapter extends RecycleBaseAdapter<Tip> {
|
||||
public class SearchPoiAdapter extends RecycleBaseAdapter<MogoTip> {
|
||||
/**
|
||||
* @param context
|
||||
* @param list
|
||||
*/
|
||||
public SearchPoiAdapter(Context context, List<Tip> list) {
|
||||
public SearchPoiAdapter(Context context, List<MogoTip> list) {
|
||||
super(context, list, R.layout.item_search_poi);
|
||||
}
|
||||
private OnItemClickedListener< Tip > mOnItemClickedListener;
|
||||
private OnItemClickedListener< Tip > mOnDeleteAllClickedListener;
|
||||
private OnItemClickedListener< Tip > mOnActionButtonClickedListener;
|
||||
private OnItemClickedListener< MogoTip > mOnItemClickedListener;
|
||||
private OnItemClickedListener< MogoTip > mOnDeleteAllClickedListener;
|
||||
private OnItemClickedListener< MogoTip > mOnActionButtonClickedListener;
|
||||
private boolean mShowDelete = false;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecycleViewHolder holder, Tip tip) {
|
||||
public void onBindViewHolder(RecycleViewHolder holder, MogoTip tip) {
|
||||
|
||||
holder.setText(R.id.tv_position, tip.getName());
|
||||
holder.setText(R.id.tv_position_des, tip.getAddress());
|
||||
@@ -42,21 +42,21 @@ public class SearchPoiAdapter extends RecycleBaseAdapter<Tip> {
|
||||
public void setOnClickListener(View.OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
public void setOnItemClickedListener( OnItemClickedListener< Tip > onItemClickedListener ) {
|
||||
public void setOnItemClickedListener( OnItemClickedListener< MogoTip > onItemClickedListener ) {
|
||||
this.mOnItemClickedListener = onItemClickedListener;
|
||||
}
|
||||
|
||||
public void setOnDeleteAllClickedListener( OnItemClickedListener< Tip > onDeleteAllClickedListener ) {
|
||||
public void setOnDeleteAllClickedListener( OnItemClickedListener< MogoTip > onDeleteAllClickedListener ) {
|
||||
this.mOnDeleteAllClickedListener = onDeleteAllClickedListener;
|
||||
}
|
||||
|
||||
public void setOnActionButtonClickedListener( OnItemClickedListener< Tip > onActionButtonClickedListener ) {
|
||||
public void setOnActionButtonClickedListener( OnItemClickedListener< MogoTip > onActionButtonClickedListener ) {
|
||||
this.mOnActionButtonClickedListener = onActionButtonClickedListener;
|
||||
}
|
||||
public void setShowDelete( boolean showDelete ) {
|
||||
this.mShowDelete = showDelete;
|
||||
}
|
||||
public void refresh( List< Tip > datums, boolean showDelete ) {
|
||||
public void refresh( List< MogoTip > datums, boolean showDelete ) {
|
||||
//this.da = datums;
|
||||
setShowDelete( showDelete );
|
||||
setDatas(datums);
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.annotation.Nullable;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public abstract class AMapBaseFragment extends com.mogo.module.navi.database.ui.base.BaseFragment {
|
||||
public abstract class AMapBaseFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = "amap.AMapBaseFragment";
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.mogo.module.navi.ui.base;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.navi.AMapNavi;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.amap.api.navi.model.AMapNaviPath;
|
||||
import com.mogo.module.navi.lib.AMapNaviStatusChangedListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-01
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface AMapServiceVisitor {
|
||||
|
||||
AMapNaviView getNaviView();
|
||||
|
||||
AMap getMap();
|
||||
|
||||
AMapNavi getAMapNavi();
|
||||
|
||||
void registerNaviListener(AMapNaviStatusChangedListener listener);
|
||||
|
||||
/**
|
||||
* 是否正在导航
|
||||
*/
|
||||
boolean isNaving();
|
||||
|
||||
void stopNavi();
|
||||
|
||||
void setHost(String host);
|
||||
|
||||
/**
|
||||
* 将导航路线发送给launcher
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
void pushNaviPathToLauncher(AMapNaviPath path);
|
||||
|
||||
/**
|
||||
* 将导航路线发送给launcher
|
||||
*
|
||||
* @param path 导航路线
|
||||
* @param directly 是否直接发送
|
||||
*/
|
||||
void pushNaviPathToLauncher(AMapNaviPath path, boolean directly);
|
||||
}
|
||||
@@ -1,430 +0,0 @@
|
||||
package com.mogo.module.navi.ui.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.MyLocationStyle;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.amap.api.navi.AMapNaviViewOptions;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.constants.AMapConstants;
|
||||
import com.mogo.module.navi.constants.CustomMapStyle;
|
||||
import com.mogo.utils.AssetsUtils;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-27
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MapUIController {
|
||||
|
||||
private static final String TAG = "MapUIController";
|
||||
|
||||
private static volatile MapUIController sInstance;
|
||||
private int mLastZoomLevel;
|
||||
|
||||
private MapUIController() {
|
||||
}
|
||||
|
||||
public static MapUIController getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MapUIController.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MapUIController();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
mContext = null;
|
||||
mMapView = null;
|
||||
mAMap = null;
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
private AMapNaviView mMapView;
|
||||
private AMap mAMap;
|
||||
|
||||
public synchronized void init( Context context, AMapNaviView mapView, AMap aMap ) {
|
||||
this.mContext = context;
|
||||
this.mMapView = mapView;
|
||||
this.mAMap = aMap;
|
||||
initMap();
|
||||
changeMyLocationVisibility( true );
|
||||
}
|
||||
|
||||
private boolean checkAMap() {
|
||||
return mAMap != null;
|
||||
}
|
||||
|
||||
private boolean checkAMapView() {
|
||||
return mMapView != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除所有导航mapView的默认UI
|
||||
*/
|
||||
private void initMap() {
|
||||
if ( mMapView != null ) {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
options.setAutoNaviViewNightMode( false );
|
||||
// 设置6秒后是否自动锁车
|
||||
options.setAutoLockCar( true );
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
options.setCameraBubbleShow( true );
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setCarBitmap( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.ic_amap_navi_cursor ) );
|
||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||
options.setCompassEnabled( false );
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficBarEnabled( false );
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficLayerEnabled( false );
|
||||
// 设置导航界面是否显示路线全览按钮。
|
||||
options.setRouteListButtonShow( false );
|
||||
// 设置起点位图,须在画路前设置
|
||||
options.setStartPointBitmap( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.ic_current_location_cursor ) );
|
||||
// 设置终点位图,须在画路前设置
|
||||
options.setEndPointBitmap( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.ic_search_choice_point ) );
|
||||
// 设置导航状态下屏幕是否一直开启。
|
||||
options.setScreenAlwaysBright( true );
|
||||
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficInfoUpdateEnabled( true );
|
||||
// 设置摄像头播报是否打开(只适用于驾车导航)。
|
||||
options.setCameraInfoUpdateEnabled( true );
|
||||
// 设置菜单按钮是否在导航界面显示。
|
||||
options.setSettingMenuEnabled( false );
|
||||
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
|
||||
options.setTrafficLine( true );
|
||||
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
|
||||
options.setLeaderLineEnabled( -1 );
|
||||
// 设置导航界面UI是否显示。
|
||||
options.setLayoutVisible( false );
|
||||
// 设置是否自动画路
|
||||
options.setAutoDrawRoute( false );
|
||||
// 设置是否显示路口放大图(实景图)
|
||||
options.setRealCrossDisplayShow( false );
|
||||
// 设置是否显示路口放大图(路口模型图)
|
||||
options.setModeCrossDisplayShow( false );
|
||||
// 设置是否显示道路信息view
|
||||
options.setLaneInfoShow( false );
|
||||
// 设置是否自动改变缩放等级
|
||||
options.setAutoChangeZoom( false );
|
||||
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
options.setAutoDisplayOverview( false );
|
||||
// 设置路线转向箭头隐藏和显示
|
||||
options.setNaviArrowVisible( false );
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
options.setAfterRouteAutoGray( true );
|
||||
options.setPointToCenter( 0.5D, 0.5D );
|
||||
mMapView.setViewOptions( options );
|
||||
}
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
}
|
||||
|
||||
if ( mAMap != null ) {
|
||||
|
||||
mAMap.setTrafficEnabled( true );
|
||||
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
if ( uiSettings != null ) {
|
||||
//设置所有手势是否可用
|
||||
uiSettings.setAllGesturesEnabled( true );
|
||||
//设置指南针是否可见。
|
||||
uiSettings.setCompassEnabled( false );
|
||||
//设置是否以地图中心点缩放
|
||||
uiSettings.setGestureScaleByMapCenter( true );
|
||||
//设置室内地图楼层切换控件是否可见。
|
||||
uiSettings.setIndoorSwitchEnabled( true );
|
||||
//设置定位按钮是否可见。
|
||||
uiSettings.setMyLocationButtonEnabled( false );
|
||||
//设置旋转手势是否可用。
|
||||
uiSettings.setRotateGesturesEnabled( false );
|
||||
//设置比例尺控件是否可见
|
||||
uiSettings.setScaleControlsEnabled( false );
|
||||
//设置拖拽手势是否可用。
|
||||
uiSettings.setScrollGesturesEnabled( true );
|
||||
//设置倾斜手势是否可用。
|
||||
uiSettings.setTiltGesturesEnabled( true );
|
||||
//设置缩放按钮是否可见。
|
||||
uiSettings.setZoomControlsEnabled( false );
|
||||
//设置双指缩放手势是否可用。
|
||||
uiSettings.setZoomGesturesEnabled( true );
|
||||
}
|
||||
mAMap.setCustomMapStyle( new CustomMapStyleOptions()
|
||||
.setEnable( true )
|
||||
.setStyleId( CustomMapStyle.STYLE_ID )
|
||||
.setStyleData( AssetsUtils.read( mContext, CustomMapStyle.ASSET_STYLE_DATA ) )
|
||||
.setStyleExtraData( AssetsUtils.read( mContext, CustomMapStyle.ASSET_STYLE_EXTRA_DATA ) )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制我的位置图层及定位回调能力
|
||||
*
|
||||
* @param visibility
|
||||
*/
|
||||
public void changeMyLocationVisibility( boolean visibility ) {
|
||||
if ( mAMap == null ) {
|
||||
return;
|
||||
}
|
||||
mAMap.setMyLocationEnabled( visibility );
|
||||
Log.d( TAG, visibility ? "开启定位" : "关闭定位" );
|
||||
if ( visibility ) {
|
||||
MyLocationStyle style = mAMap.getMyLocationStyle();
|
||||
if ( style == null ) {
|
||||
style = new MyLocationStyle();
|
||||
}
|
||||
style.myLocationType( MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER )
|
||||
.strokeWidth( 0 )
|
||||
.interval( 2_000L )
|
||||
.showMyLocation( visibility )
|
||||
.myLocationIcon( BitmapDescriptorFactory.fromResource( R.drawable.ic_current_location_cursor ) )
|
||||
.radiusFillColor( Color.TRANSPARENT );
|
||||
mAMap.setMyLocationStyle( style );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航模式:中心点偏下
|
||||
*/
|
||||
public void showNaviUI() {
|
||||
changeMyLocationVisibility( false );
|
||||
changeCarOverlayVisibility( true );
|
||||
changeRouteOverlayVisibility( false );
|
||||
if ( mMapView != null ) {
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
mMapView.post( () -> {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
Log.d( TAG, "中心点切换到页面偏下" );
|
||||
options.setPointToCenter( 0.5D, 0.6666666666666666D );
|
||||
mMapView.setViewOptions( options );
|
||||
if ( checkAMap() ) {
|
||||
mAMap.moveCamera( CameraUpdateFactory.zoomBy( 15 ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常地图模式:中心点居中
|
||||
*/
|
||||
public void showMapUI() {
|
||||
changeMyLocationVisibility( true );
|
||||
changeCarOverlayVisibility( false );
|
||||
changeRouteOverlayVisibility( false );
|
||||
if ( mMapView != null ) {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
Log.d( TAG, "中心点切换到页面中心" );
|
||||
options.setPointToCenter( 0.5D, 0.5D );
|
||||
mMapView.setViewOptions( options );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示规划UI样式:中心点右移
|
||||
*/
|
||||
public void showCalculateUI() {
|
||||
changeMyLocationVisibility( false );
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制自车marker
|
||||
*
|
||||
* @param visibility
|
||||
*/
|
||||
public void changeCarOverlayVisibility( boolean visibility ) {
|
||||
try {
|
||||
mMapView.setCarOverlayVisible( visibility );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制导航路线图层
|
||||
*
|
||||
* @param visibility
|
||||
*/
|
||||
public void changeRouteOverlayVisibility( boolean visibility ) {
|
||||
try {
|
||||
mMapView.setRouteOverlayVisible( visibility );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将地图移动到中心点,正北方向
|
||||
*
|
||||
* @param latlng
|
||||
*/
|
||||
public void moveCurrentPositionToCenter( LatLng latlng ) {
|
||||
if ( checkAMap() ) {
|
||||
mAMap.animateCamera( CameraUpdateFactory.newCameraPosition( new CameraPosition.Builder()
|
||||
.tilt( mMapView.getLockTilt() )
|
||||
.zoom( mMapView.getLockZoom() )
|
||||
.target( latlng )
|
||||
.bearing( AMapConstants.AMPA_BEARING )
|
||||
.build() ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变地图缩放级别
|
||||
*
|
||||
* @param level
|
||||
*/
|
||||
public void changeCameraZoomLevel( float level, boolean animate ) {
|
||||
if ( checkAMap() ) {
|
||||
if ( animate ) {
|
||||
mAMap.animateCamera( CameraUpdateFactory.zoomTo( level ) );
|
||||
} else {
|
||||
mAMap.moveCamera( CameraUpdateFactory.zoomTo( level ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加marker
|
||||
*
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
public Marker addMarker( MarkerOptions options ) {
|
||||
return mAMap.addMarker( options );
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存上次地图缩放级别
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean storeMapZoomLevel() {
|
||||
if ( checkAMapView() ) {
|
||||
final AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
mLastZoomLevel = options.getZoom();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原上次的缩放级别
|
||||
*/
|
||||
public void restoreMapZoomLevel() {
|
||||
if ( checkAMapView() ) {
|
||||
final AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
options.setZoom( mLastZoomLevel );
|
||||
mMapView.setViewOptions( options );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 交通态势开关
|
||||
*
|
||||
* @param enable
|
||||
*/
|
||||
public void setTrafficEnabled( boolean enable ) {
|
||||
if ( checkAMap() ) {
|
||||
mAMap.setTrafficEnabled( enable );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缩放地图
|
||||
*
|
||||
* @param zoomIn 放大
|
||||
*/
|
||||
public void changeZoom( boolean zoomIn ) {
|
||||
if ( checkAMapView() ) {
|
||||
if ( zoomIn ) {
|
||||
mMapView.zoomIn();
|
||||
} else {
|
||||
mMapView.zoomOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图类型
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void setMapType( int type ) {
|
||||
if ( checkAMap() ) {
|
||||
mAMap.setMapType( type );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航样式:
|
||||
*
|
||||
* @param naviMode
|
||||
*/
|
||||
public void setNaviMode( int naviMode ) {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.setNaviMode( naviMode );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图倾斜度
|
||||
*
|
||||
* @param tile
|
||||
*/
|
||||
public void setTilt( int tile ) {
|
||||
if ( checkAMapView() ) {
|
||||
final AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
options.setTilt( tile );
|
||||
mMapView.setViewOptions( options );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览全程
|
||||
*/
|
||||
public void displayOverview() {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.displayOverview();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭全程预览
|
||||
*/
|
||||
public void recoverLockMode() {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.recoverLockMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,6 @@ public interface UiController {
|
||||
|
||||
FragmentManager _getSupportFragmentManager();
|
||||
|
||||
AMapServiceVisitor getAMapServiceVisitor();
|
||||
|
||||
//CommonAddressModel getCommonAddressModel();
|
||||
|
||||
void popBackStackImmediate();
|
||||
|
||||
@@ -3,12 +3,10 @@ package com.mogo.module.navi.ui.search;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -17,26 +15,12 @@ import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.location.AMapLocationListener;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.AMapUtils;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.animation.Animation;
|
||||
import com.amap.api.maps.model.animation.TranslateAnimation;
|
||||
import com.amap.api.services.geocoder.RegeocodeAddress;
|
||||
import com.amap.api.services.help.Tip;
|
||||
|
||||
import com.mogo.module.map.location.AMapLocationManager;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
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.SearchPoiAdapter;
|
||||
import com.mogo.module.navi.ui.base.BaseFragment;
|
||||
import com.mogo.module.navi.ui.base.MapUIController;
|
||||
import com.mogo.module.navi.ui.base.UiController;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
@@ -53,8 +37,8 @@ import java.util.List;
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
|
||||
*/
|
||||
@Route( path = "/amap/search" )
|
||||
public class SearchFragment extends BaseFragment implements SearchView,
|
||||
AMapLocationListener {
|
||||
public class SearchFragment extends BaseFragment implements SearchView
|
||||
{
|
||||
|
||||
public static final String TAG = "search";
|
||||
|
||||
@@ -91,12 +75,6 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
*/
|
||||
private int mUiMode = SearchConstants.UI_MODE_COMMON;
|
||||
|
||||
/**
|
||||
* 地图选点的marker
|
||||
*/
|
||||
private Marker mChoicePointMaker = null;
|
||||
private AMapLocation mLastAMapLocation;
|
||||
|
||||
@Override
|
||||
public void onAttach( Context context ) {
|
||||
super.onAttach( context );
|
||||
@@ -134,8 +112,6 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
return;
|
||||
}
|
||||
multiSearchMyLocationUI();
|
||||
AMapLocationManager.getInstance( mContext ).addLocationListener( this );
|
||||
AMapLocationManager.getInstance( mContext ).start();
|
||||
} );
|
||||
mChoicePoint = findViewById( R.id.amap_search_poi_choice_point );
|
||||
mChoicePoint.setOnClickListener( view -> {
|
||||
@@ -147,8 +123,6 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
shortToast( "网络未连接,请检查网络" );
|
||||
return;
|
||||
}
|
||||
AMapLocationManager.getInstance( mContext ).addLocationListener( this );
|
||||
AMapLocationManager.getInstance( mContext ).start();
|
||||
} );
|
||||
|
||||
mActionButton = findViewById( R.id.amap_search_action_setting );
|
||||
@@ -191,7 +165,7 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mSearchBox.setCompoundDrawables( null, null, rightDrawable, null );
|
||||
rightDrawable.setBounds( 0, 0, rightDrawable.getIntrinsicWidth(), rightDrawable.getIntrinsicHeight() );
|
||||
}
|
||||
removeChoicePointMarker();
|
||||
//removeChoicePointMarker();
|
||||
mSearchBox.setTag( null );
|
||||
if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
@@ -199,7 +173,6 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 0 ), 0 );
|
||||
mSearchBox.setLayoutParams( params );
|
||||
}
|
||||
mLastAMapLocation = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +196,7 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mSearchBox.setCompoundDrawables( null, null, rightDrawable, null );
|
||||
}
|
||||
mActionButton.setVisibility( View.INVISIBLE );
|
||||
removeChoicePointMarker();
|
||||
//removeChoicePointMarker();
|
||||
mSearchBox.setTag( null );
|
||||
if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
@@ -231,7 +204,6 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 0 ), 0 );
|
||||
mSearchBox.setLayoutParams( params );
|
||||
}
|
||||
mLastAMapLocation = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +219,7 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mActionButton.setVisibility( View.VISIBLE );
|
||||
mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
|
||||
mSearchBox.setCompoundDrawables( null, null, null, null );
|
||||
removeChoicePointMarker();
|
||||
//removeChoicePointMarker();
|
||||
mSearchBox.setTag( null );
|
||||
if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
@@ -270,7 +242,6 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mActionButton.setVisibility( View.VISIBLE );
|
||||
mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
|
||||
mSearchBox.setCompoundDrawables( null, null, null, null );
|
||||
showChoicePointMarker();
|
||||
mSearchBox.setTag( null );
|
||||
if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
@@ -278,104 +249,42 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 15 ), 0 );
|
||||
mSearchBox.setLayoutParams( params );
|
||||
}
|
||||
mLastAMapLocation = null;
|
||||
}
|
||||
|
||||
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 );
|
||||
//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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged( AMapLocation aMapLocation ) {
|
||||
//final String checkMsg = AMapUtils.getAMapLocationErrorMsg( aMapLocation );
|
||||
//if ( AMapUtils.LOC_SUCCESS.equals( checkMsg ) ) {
|
||||
// mLastAMapLocation = aMapLocation;
|
||||
// MapUIController.getInstance().moveCurrentPositionToCenter( new LatLng( aMapLocation.getLatitude(), aMapLocation.getLongitude() ) );
|
||||
// if ( mUiMode == SearchConstants.UI_MODE_MULTI_MY_LOCATION ) {
|
||||
// showMyLocationAddress( aMapLocation );
|
||||
// } else if ( mUiMode == SearchConstants.UI_MODE_MULTI_CHOICE_POINT ) {
|
||||
// showChoicePointAddress( aMapLocation );// 显示当前中心点地址
|
||||
// }
|
||||
//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, checkMsg, Toast.LENGTH_SHORT ).show();
|
||||
// Toast.makeText( mContext, "请选择位置", Toast.LENGTH_SHORT ).show();
|
||||
//}
|
||||
AMapLocationManager.getInstance( mContext ).removeLocationListener( this );
|
||||
AMapLocationManager.getInstance( mContext ).stop();
|
||||
}
|
||||
|
||||
private void showMyLocationAddress( AMapLocation location ) {
|
||||
if ( location == null ) {
|
||||
return;
|
||||
}
|
||||
mSearchBox.setEnabled( false );
|
||||
mSearchBox.setText( location.getPoiName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示点选marker,隐藏自车marker
|
||||
*/
|
||||
private void showChoicePointMarker() {
|
||||
|
||||
final AMap aMap = mUiController.getAMapServiceVisitor().getMap();
|
||||
if ( aMap == null ) {
|
||||
return;
|
||||
}
|
||||
// AMapService 里设置了监听,此处会覆盖
|
||||
LatLng latLng = aMap.getCameraPosition().target;
|
||||
Point screenPosition = aMap.getProjection().toScreenLocation( latLng );
|
||||
mChoicePointMaker = aMap.addMarker( new MarkerOptions().zIndex( 1 ).anchor( 0.5f, 0.5f ).position( latLng ).icon( BitmapDescriptorFactory.fromResource( R.drawable.ic_search_choice_point ) ) );
|
||||
mChoicePointMaker.setPositionByPixels( screenPosition.x, screenPosition.y );
|
||||
MapUIController.getInstance().changeMyLocationVisibility( false );
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏点选marker,显示自车marker
|
||||
*/
|
||||
private void removeChoicePointMarker() {
|
||||
if ( mChoicePointMaker != null ) {
|
||||
mChoicePointMaker.remove();
|
||||
}
|
||||
mChoicePointMaker = null;
|
||||
MapUIController.getInstance().changeMyLocationVisibility( true );
|
||||
}
|
||||
|
||||
private void showChoicePointAddress( AMapLocation location ) {
|
||||
if ( location == null ) {
|
||||
return;
|
||||
}
|
||||
mSearchBox.setEnabled( false );
|
||||
mSearchBox.setText( location.getPoiName() );
|
||||
}
|
||||
|
||||
// view interface
|
||||
|
||||
@@ -385,7 +294,7 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSearchPoiResult( List< Tip > datums, boolean showDelete ) {
|
||||
public void renderSearchPoiResult( List<MogoTip> datums, boolean showDelete ) {
|
||||
|
||||
if ( datums == null || datums.isEmpty() ) {
|
||||
mSearchResult.setVisibility( View.GONE );
|
||||
@@ -408,13 +317,7 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
mPoiAdapter.setOnDeleteAllClickedListener( NULL -> {
|
||||
mSearchPresenter.deleteAllCachedPoi();
|
||||
} );
|
||||
mPoiAdapter.setOnActionButtonClickedListener( poi -> {
|
||||
final Disposable disposable = mSearchPresenter.cacheCommonAddressPoi( poi ).subscribe( output -> {
|
||||
Toast.makeText( mContext, "设置成功!", Toast.LENGTH_SHORT ).show();
|
||||
mActionSuccess = true;
|
||||
} );
|
||||
mSearchPresenter.addDisposable( disposable );
|
||||
} );
|
||||
|
||||
mPoiAdapter.setShowDelete( showDelete );
|
||||
mSearchResult.setAdapter( mPoiAdapter );
|
||||
} else {
|
||||
@@ -435,17 +338,21 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
return mUiMode;
|
||||
}
|
||||
|
||||
@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 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() {
|
||||
//
|
||||
@@ -458,43 +365,43 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
|
||||
// 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();
|
||||
|
||||
}
|
||||
}
|
||||
///**
|
||||
// * 屏幕中心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();
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* @param searchPoi 导航目的地
|
||||
@@ -562,8 +469,7 @@ public class SearchFragment extends BaseFragment implements SearchView,
|
||||
}
|
||||
mPoiAdapter = null;
|
||||
mSearchBoxRightDrawableBitmap = null;
|
||||
removeChoicePointMarker();
|
||||
AMapLocationManager.getInstance( mContext ).release();
|
||||
//removeChoicePointMarker();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
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.navi.IMogoNaviListener;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
|
||||
@Route( path = MogoModulePaths.PATH_MODULE_SEARCH )
|
||||
public class SearchFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
private SearchFragment mAppsFragment;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
mAppsFragment = new SearchFragment();
|
||||
mAppsFragment.setArguments( data );
|
||||
return mAppsFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return MogoModulePaths.PATH_MODULE_SEARCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return IMogoModuleProvider.TYPE_FRAGMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,18 +7,8 @@ import android.text.TextUtils;
|
||||
import android.widget.EditText;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.services.core.LatLonPoint;
|
||||
import com.amap.api.services.geocoder.GeocodeResult;
|
||||
import com.amap.api.services.geocoder.GeocodeSearch;
|
||||
import com.amap.api.services.geocoder.RegeocodeAddress;
|
||||
import com.amap.api.services.geocoder.RegeocodeQuery;
|
||||
import com.amap.api.services.geocoder.RegeocodeResult;
|
||||
import com.amap.api.services.help.Inputtips;
|
||||
import com.amap.api.services.help.InputtipsQuery;
|
||||
import com.amap.api.services.help.Tip;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.module.common.TextWatcherAdapter;
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
@@ -39,13 +29,10 @@ import java.util.List;
|
||||
* 搜搜页逻辑处理
|
||||
*/
|
||||
public class SearchPresenter extends Presenter< SearchView >
|
||||
implements Inputtips.InputtipsListener, GeocodeSearch.OnGeocodeSearchListener {
|
||||
{
|
||||
|
||||
private Inputtips mSearchEngine;
|
||||
private GeocodeSearch mGeocodeSearch;
|
||||
|
||||
private CompositeDisposable mCompositeDisposable;
|
||||
private CameraPosition mLastCameraPosition;
|
||||
|
||||
public SearchPresenter( SearchView view ) {
|
||||
super( view );
|
||||
@@ -102,22 +89,10 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
}
|
||||
break;
|
||||
}
|
||||
final InputtipsQuery searchQuery = new InputtipsQuery( keyword, "" );
|
||||
if ( mSearchEngine == null ) {
|
||||
mSearchEngine = new Inputtips( getContext(), searchQuery );
|
||||
mSearchEngine.setInputtipsListener( this );
|
||||
} else {
|
||||
mSearchEngine.setQuery( searchQuery );
|
||||
}
|
||||
mSearchEngine.requestInputtipsAsyn();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetInputtips( List<Tip> list, int i ) {
|
||||
if ( mView != null ) {
|
||||
mView.renderSearchPoiResult( list, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缓存搜索到的导航地址
|
||||
@@ -125,7 +100,7 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
* @param tip
|
||||
* @return
|
||||
*/
|
||||
public Single cacheSelectPoiItem( Tip tip ) {
|
||||
public Single cacheSelectPoiItem( MogoTip tip ) {
|
||||
return Single.create( emitter -> {
|
||||
SearchPoi poi = EntityConvertUtils.tipToPoi( tip );
|
||||
//ignore insert result
|
||||
@@ -167,52 +142,37 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
} );
|
||||
mCompositeDisposable.add( disposable );
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存搜索位置为常用地址设置
|
||||
*
|
||||
* @param tip
|
||||
* @return
|
||||
*/
|
||||
public Single cacheCommonAddressPoi( Tip tip ) {
|
||||
return Single.<List<Long>>create( emitter -> {
|
||||
SearchPoi poi = EntityConvertUtils.tipToPoi( tip );
|
||||
emitterCommonAddress( emitter, poi );
|
||||
} ).subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() );
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存地理位置常用地址设置
|
||||
*
|
||||
* @param location
|
||||
* @return
|
||||
*/
|
||||
public Single cacheCommonAddressPoi( AMapLocation location ) {
|
||||
return Single.
|
||||
<List<Long>>create( emitter -> {
|
||||
SearchPoi poi = EntityConvertUtils.aMapLocation2Poi( location );
|
||||
emitterCommonAddress( emitter, poi );
|
||||
} )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() );
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存反地理位置编码常用地址设置
|
||||
*
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
public Single cacheCommonAddressPoi( RegeocodeAddress address ) {
|
||||
|
||||
return Single.
|
||||
<List<Long>>create( emitter -> {
|
||||
SearchPoi poi = EntityConvertUtils.geocodeAddress2Poi( address, mLastCameraPosition );
|
||||
emitterCommonAddress( emitter, poi );
|
||||
} )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() );
|
||||
}
|
||||
//
|
||||
///**
|
||||
// * 缓存搜索位置为常用地址设置
|
||||
// *
|
||||
// * @param tip
|
||||
// * @return
|
||||
// */
|
||||
//public Single cacheCommonAddressPoi( MogoTip tip ) {
|
||||
// return Single.<List<Long>>create( emitter -> {
|
||||
// SearchPoi poi = EntityConvertUtils.tipToPoi( tip );
|
||||
// emitterCommonAddress( emitter, poi );
|
||||
// } ).subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() );
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * 缓存地理位置常用地址设置
|
||||
// *
|
||||
// * @param location
|
||||
// * @return
|
||||
// */
|
||||
//public Single cacheCommonAddressPoi( AMapLocation location ) {
|
||||
// return Single.
|
||||
// <List<Long>>create( emitter -> {
|
||||
// SearchPoi poi = EntityConvertUtils.aMapLocation2Poi( location );
|
||||
// emitterCommonAddress( emitter, poi );
|
||||
// } )
|
||||
// .subscribeOn( Schedulers.io() )
|
||||
// .observeOn( AndroidSchedulers.mainThread() );
|
||||
//}
|
||||
//
|
||||
//
|
||||
|
||||
private void emitterCommonAddress( SingleEmitter<List<Long>> emitter, SearchPoi poi ) {
|
||||
String poiId = null;
|
||||
@@ -249,32 +209,7 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
//}
|
||||
}
|
||||
|
||||
private void startSearchPoiByPoint( CameraPosition position ) {
|
||||
if ( position == null ) {
|
||||
return;
|
||||
}
|
||||
RegeocodeQuery
|
||||
query = new RegeocodeQuery( new LatLonPoint( position.target.latitude, position.target.longitude ), 200, GeocodeSearch.AMAP );
|
||||
if ( mGeocodeSearch == null ) {
|
||||
mGeocodeSearch = new GeocodeSearch( getContext() );
|
||||
mGeocodeSearch.setOnGeocodeSearchListener( this );
|
||||
}
|
||||
mGeocodeSearch.getFromLocationAsyn( query );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegeocodeSearched( RegeocodeResult regeocodeResult, int resultID ) {
|
||||
if ( resultID == 1000 ) { // success
|
||||
mView.renderChoicePointResult( regeocodeResult.getRegeocodeAddress() );
|
||||
} else {
|
||||
mView.renderChoicePointResult( null );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeocodeSearched( GeocodeResult geocodeResult, int resultID ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
@@ -287,8 +222,5 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
mCompositeDisposable = null;
|
||||
}
|
||||
//CameraChangedLiveData.getInstance().removeAllObserver();
|
||||
mSearchEngine = null;
|
||||
mGeocodeSearch = null;
|
||||
mLastCameraPosition = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
import android.widget.EditText;
|
||||
import com.amap.api.services.geocoder.RegeocodeAddress;
|
||||
import com.amap.api.services.help.Tip;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -20,7 +19,7 @@ public interface SearchView extends IView {
|
||||
* @param datums
|
||||
* @param showDelete 是否显示清空历史记录项
|
||||
*/
|
||||
void renderSearchPoiResult(List<Tip> datums, boolean showDelete);
|
||||
void renderSearchPoiResult(List<MogoTip> datums, boolean showDelete);
|
||||
|
||||
int getSearchType();
|
||||
|
||||
@@ -31,12 +30,12 @@ public interface SearchView extends IView {
|
||||
*/
|
||||
int getUiMode();
|
||||
|
||||
/**
|
||||
* 显示逆地理位置编码结果
|
||||
*
|
||||
* @param address
|
||||
*/
|
||||
void renderChoicePointResult(RegeocodeAddress address);
|
||||
///**
|
||||
// * 显示逆地理位置编码结果
|
||||
// *
|
||||
// * @param address
|
||||
// */
|
||||
//void renderChoicePointResult(RegeocodeAddress address);
|
||||
|
||||
/**
|
||||
* 选点完毕后marker动画
|
||||
|
||||
Reference in New Issue
Block a user