rename nav to search
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package com.mogo.module.navi.bean;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-02
|
||||
* <p>
|
||||
* 实体类操作工具
|
||||
*/
|
||||
public class EntityConvertUtils {
|
||||
|
||||
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 ) {
|
||||
MogoTip MogoTip = poi2MogoTip( poi );
|
||||
if ( MogoTip != null ) {
|
||||
output.add( MogoTip );
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static MogoTip poi2MogoTip( SearchPoi poi ) {
|
||||
if ( poi == null ) {
|
||||
return null;
|
||||
}
|
||||
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( MogoTip MogoTip ) {
|
||||
if ( MogoTip == null ) {
|
||||
return null;
|
||||
}
|
||||
double lat = 0.0;
|
||||
double lng = 0.0;
|
||||
if ( MogoTip.getPoint() != null ) {
|
||||
lat = MogoTip.getPoint().getLat();
|
||||
lng = MogoTip.getPoint().getLng();
|
||||
}
|
||||
return new SearchPoi( MogoTip.getPoiID(),
|
||||
MogoTip.getName(),
|
||||
MogoTip.getAddress(),
|
||||
lat,
|
||||
lng,
|
||||
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(),
|
||||
// "" );
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package com.mogo.module.navi.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
import com.mogo.module.navi.constants.DataConstants;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-02
|
||||
* <p>
|
||||
* 搜索地址表数据结构
|
||||
*/
|
||||
@Entity( tableName = DataConstants.T_SEARCH_POI )
|
||||
public class SearchPoi implements Parcelable {
|
||||
|
||||
public static final SearchPoi NULL = new SearchPoi( null,
|
||||
null,
|
||||
null,
|
||||
0.0,
|
||||
0.0,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
public String pId;
|
||||
private String name;
|
||||
private String address;
|
||||
private double lat;
|
||||
private double lng;
|
||||
private String district;
|
||||
private String adCode;
|
||||
private String typeCode;
|
||||
private String province;
|
||||
private String city;
|
||||
|
||||
|
||||
/**
|
||||
* 插入poi数据类型
|
||||
* <p>
|
||||
* {@link DataConstants#TYPE_COMPANY_ADDRESS}
|
||||
* {@link DataConstants#TYPE_HOME_ADDRESS}
|
||||
* {@link DataConstants#TYPE_POI}
|
||||
*/
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 数据记录时间,自动赋值
|
||||
*/
|
||||
private long time;
|
||||
|
||||
public SearchPoi( String pId,
|
||||
String name,
|
||||
String address,
|
||||
double lat,
|
||||
double lng,
|
||||
String district,
|
||||
String adCode,
|
||||
String typeCode ) {
|
||||
this( pId, name, address, lat, lng, district, adCode, typeCode, "", "", DataConstants.TYPE_POI );
|
||||
}
|
||||
|
||||
private SearchPoi( String pId,
|
||||
String name,
|
||||
String address,
|
||||
double lat,
|
||||
double lng,
|
||||
String district,
|
||||
String adCode,
|
||||
String typeCode,
|
||||
String province,
|
||||
String city,
|
||||
int type ) {
|
||||
this.pId = pId;
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.lat = lat;
|
||||
this.lng = lng;
|
||||
this.district = district;
|
||||
this.adCode = adCode;
|
||||
this.typeCode = typeCode;
|
||||
this.province = province;
|
||||
this.city = city;
|
||||
this.type = type;
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getpId() {
|
||||
return pId;
|
||||
}
|
||||
|
||||
public void setpId( @NonNull String pId ) {
|
||||
this.pId = pId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName( String name ) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress( String address ) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat( double lat ) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng( double lng ) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict( String district ) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
public String getAdCode() {
|
||||
return adCode;
|
||||
}
|
||||
|
||||
public void setAdCode( String adCode ) {
|
||||
this.adCode = adCode;
|
||||
}
|
||||
|
||||
public String getTypeCode() {
|
||||
return typeCode;
|
||||
}
|
||||
|
||||
public void setTypeCode( String typeCode ) {
|
||||
this.typeCode = typeCode;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince( String province ) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity( String city ) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType( int type ) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime( long time ) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeString( this.pId );
|
||||
dest.writeString( this.name );
|
||||
dest.writeString( this.address );
|
||||
dest.writeDouble( this.lat );
|
||||
dest.writeDouble( this.lng );
|
||||
dest.writeString( this.district );
|
||||
dest.writeString( this.adCode );
|
||||
dest.writeString( this.typeCode );
|
||||
dest.writeString( this.province );
|
||||
dest.writeString( this.city );
|
||||
dest.writeInt( this.type );
|
||||
dest.writeLong( this.time );
|
||||
}
|
||||
|
||||
protected SearchPoi( Parcel in ) {
|
||||
this.pId = in.readString();
|
||||
this.name = in.readString();
|
||||
this.address = in.readString();
|
||||
this.lat = in.readDouble();
|
||||
this.lng = in.readDouble();
|
||||
this.district = in.readString();
|
||||
this.adCode = in.readString();
|
||||
this.typeCode = in.readString();
|
||||
this.province = in.readString();
|
||||
this.city = in.readString();
|
||||
this.type = in.readInt();
|
||||
this.time = in.readLong();
|
||||
}
|
||||
|
||||
public static final Creator< SearchPoi > CREATOR = new Creator< SearchPoi >() {
|
||||
@Override
|
||||
public SearchPoi createFromParcel( Parcel source ) {
|
||||
return new SearchPoi( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchPoi[] newArray( int size ) {
|
||||
return new SearchPoi[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.module.navi.constants;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-04
|
||||
* <p>
|
||||
* 地图基本参数配置
|
||||
*/
|
||||
public class AMapConstants {
|
||||
|
||||
/**
|
||||
* 初始化地图缩放级别
|
||||
*/
|
||||
public static final float AMAP_ZOOM_COMMON_LEVEL = 15.0f;
|
||||
|
||||
/**
|
||||
* 点击当前位置按钮的地图缩放级别
|
||||
*/
|
||||
public static final float AMAP_ZOOM_CURRENT_LOCATION_LEVEL = AMAP_ZOOM_COMMON_LEVEL;
|
||||
|
||||
public static final float AMPA_BEARING = 0.0f;
|
||||
|
||||
public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED = 1f;
|
||||
public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED = 0.3f;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.module.navi.constants;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-12
|
||||
* <p>
|
||||
* 自定义地图样式
|
||||
*/
|
||||
public class CustomMapStyle {
|
||||
|
||||
public static final String STYLE_ID = "e3e33a3423230b219494b40c4d71d93a";
|
||||
|
||||
public static final String ASSET_STYLE_DATA = "style.data";
|
||||
|
||||
public static final String ASSET_STYLE_EXTRA_DATA = "style_extra.data";
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mogo.module.navi.constants;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* @since 2019-10-02
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class DataConstants {
|
||||
|
||||
public static final int DB_VERSION = 1;
|
||||
public static final String DB_NAME = "zhidao.amap.db";
|
||||
|
||||
public static final String T_SEARCH_POI = "t_search_poi";
|
||||
|
||||
public static final int TYPE_POI = 0; // 普通搜索的类型
|
||||
public static final int TYPE_HOME_ADDRESS = 1; // 家地址
|
||||
public static final int TYPE_COMPANY_ADDRESS = 2; // 公司地址
|
||||
|
||||
public static final String POI_ID_HOME = "common_address_home";
|
||||
public static final String POI_ID_COMPANY = "common_address_company";
|
||||
|
||||
public static final String CP_AUTHORITY = "com.zhidao.amap";
|
||||
|
||||
// 家的地址
|
||||
public static final Uri CONTENT_HOME_ADDRESS_URI = Uri.parse( "content://com.zhidao.amap/homeAddress" );
|
||||
public static final int HOME_ADDRESS_CODE = TYPE_HOME_ADDRESS;
|
||||
public static final String HOME_ADDRESS_PATH = "homeAddress";
|
||||
public static final String HOME_ADDRESS = "homeAddress";
|
||||
public static final String HOME_ADDRESS_NAME = "homeAddressName";
|
||||
public static final String HOME_ADDRESS_LATITUDE = "homeAddressLatitude";
|
||||
public static final String HOME_ADDRESS_LONGITUDE = "homeAddressLongitude";
|
||||
|
||||
// 公司地址
|
||||
public static final Uri CONTENT_COMPANY_ADDRESS_URI = Uri.parse( "content://com.zhidao.amap/companyAddress" );
|
||||
public static final int COMPANY_ADDRESS_CODE = TYPE_COMPANY_ADDRESS;
|
||||
public static final String COMPANY_ADDRESS_PATH = "companyAddress";
|
||||
public static final String COMPANY_ADDRESS = "companyAddress";
|
||||
public static final String COMPANY_ADDRESS_NAME = "companyAddressName";
|
||||
public static final String COMPANY_ADDRESS_LATITUDE = "companyAddressLatitude";
|
||||
public static final String COMPANY_ADDRESS_LONGITUDE = "companyAddressLongitude";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mogo.module.navi.dao;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.constants.DataConstants;
|
||||
import io.reactivex.Single;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-02
|
||||
* <p>
|
||||
* 搜索页面数据操作
|
||||
*/
|
||||
@Dao
|
||||
public interface SearchPoiDao {
|
||||
|
||||
@Insert( onConflict = OnConflictStrategy.REPLACE )
|
||||
List<Long> insert(SearchPoi... datums);
|
||||
|
||||
@Query( "SELECT * FROM " + DataConstants.T_SEARCH_POI + " WHERE type=" + DataConstants.TYPE_POI + " ORDER BY time DESC LIMIT :limit" )
|
||||
Single<List< SearchPoi >> getLastN(int limit);
|
||||
|
||||
@Query( "SELECT * FROM " + DataConstants.T_SEARCH_POI + " WHERE type=" + DataConstants.TYPE_POI )
|
||||
Single<List< SearchPoi >> getAll();
|
||||
|
||||
@Query( "SELECT * FROM " + DataConstants.T_SEARCH_POI + " WHERE type=" + DataConstants.TYPE_HOME_ADDRESS )
|
||||
Single<List< SearchPoi >> getHomeAddress();
|
||||
|
||||
@Query( "SELECT * FROM " + DataConstants.T_SEARCH_POI + " WHERE type=" + DataConstants.TYPE_COMPANY_ADDRESS )
|
||||
Single<List< SearchPoi >> getCompanyAddress();
|
||||
|
||||
@Delete
|
||||
int delete(SearchPoi poi);
|
||||
|
||||
@Delete
|
||||
int deleteAll(List<SearchPoi> list);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.mogo.module.navi.database;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.dao.SearchPoiDao;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2019-08-15.
|
||||
*/
|
||||
|
||||
@Database(entities = { SearchPoi.class}, version = 1, exportSchema = false)
|
||||
public abstract class AppDataBase extends RoomDatabase {
|
||||
public abstract SearchPoiDao poiDao();
|
||||
|
||||
private static volatile AppDataBase INSTANCE;
|
||||
|
||||
public static AppDataBase getDatabase(Context context){
|
||||
if (INSTANCE == null) {
|
||||
synchronized (AppDataBase.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
|
||||
AppDataBase.class, "android_room_dev.db").build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mogo.module.navi.ui
|
||||
|
||||
import android.app.Activity
|
||||
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
|
||||
import com.mogo.module.navi.ui.base.BaseActivity
|
||||
|
||||
@Route(path = MogoModulePaths.PATH_MODULE_NAV_ACTIVITY)
|
||||
class NaviActivity : BaseActivity() {
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
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.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 SearchPoiAdapter extends RecycleBaseAdapter<MogoTip> {
|
||||
/**
|
||||
* @param context
|
||||
* @param list
|
||||
*/
|
||||
public SearchPoiAdapter(Context context, List<MogoTip> list) {
|
||||
super(context, list, R.layout.item_search_poi);
|
||||
}
|
||||
private boolean mShowDelete = false;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecycleViewHolder holder, MogoTip 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< MogoTip > datums, boolean showDelete ) {
|
||||
//this.da = datums;
|
||||
setShowDelete( showDelete );
|
||||
setDatas(datums);
|
||||
//notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.mogo.module.navi.ui.adapter.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Title: adapter
|
||||
* </p>
|
||||
* <p>
|
||||
* Description:
|
||||
* </p>
|
||||
* <p>
|
||||
* Copyright: Copyright (c) 2015
|
||||
* </p>
|
||||
* <p>
|
||||
* </p>
|
||||
*/
|
||||
public abstract class RecycleBaseAdapter<T> extends
|
||||
RecyclerView.Adapter<RecycleViewHolder>
|
||||
{
|
||||
|
||||
protected Context context;
|
||||
protected List<T> list;
|
||||
private int resourceID;
|
||||
private Toast toast;
|
||||
|
||||
/**
|
||||
* @param context
|
||||
*/
|
||||
public RecycleBaseAdapter(Context context, List<T> list, int resourceID)
|
||||
{
|
||||
super();
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.resourceID = resourceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecycleViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType)
|
||||
{
|
||||
View v = LayoutInflater.from(context).inflate(resourceID, viewGroup,
|
||||
false);
|
||||
|
||||
RecycleViewHolder holder = RecycleViewHolder
|
||||
.get(v);
|
||||
|
||||
initHolder(holder);
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(
|
||||
RecycleViewHolder viewHolder, int position)
|
||||
{
|
||||
onBindViewHolder(viewHolder, list.get(position % list.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount()
|
||||
{
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
public abstract void onBindViewHolder(
|
||||
RecycleViewHolder holder, T t);
|
||||
|
||||
public void initHolder(RecycleViewHolder holder)
|
||||
{
|
||||
|
||||
}
|
||||
public void setDatas(List<T> list)
|
||||
{
|
||||
setDatas(list, false);
|
||||
}
|
||||
|
||||
public void setDatas(List<T> list, boolean add)
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
this.list.addAll(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.list = list;
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void messageShow(String mes)
|
||||
{
|
||||
if (toast==null){
|
||||
toast= Toast.makeText(context,mes, Toast.LENGTH_LONG);
|
||||
}
|
||||
else{
|
||||
toast.setText(mes);
|
||||
}
|
||||
toast.show();
|
||||
}
|
||||
|
||||
public T getItem(int position){
|
||||
if (list==null||list.size()==0){
|
||||
return null;
|
||||
}
|
||||
return list.get(position);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.mogo.module.navi.ui.adapter.base;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.SpannableString;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class RecycleViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private SparseArray<View> mViews;
|
||||
|
||||
private View mConvertView;
|
||||
|
||||
public RecycleViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
this.mConvertView = itemView;
|
||||
mViews = new SparseArray<View>();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static RecycleViewHolder get(View itemView) {
|
||||
return new RecycleViewHolder(itemView);
|
||||
}
|
||||
|
||||
public View getConvertView() {
|
||||
return mConvertView;
|
||||
}
|
||||
|
||||
public <T extends View> T getView(int viewId) {
|
||||
View view = mViews.get(viewId);
|
||||
if (view == null) {
|
||||
view = mConvertView.findViewById(viewId);
|
||||
mViews.put(viewId, view);
|
||||
}
|
||||
return (T) view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setText(int viewId, String text) {
|
||||
TextView tv = getView(viewId);
|
||||
if (tv==null)return this;
|
||||
tv.setText(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setText(int viewId, SpannableString text) {
|
||||
TextView tv = getView(viewId);
|
||||
tv.setText(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setImageResource(int viewId, int resId) {
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageResource(resId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setImageBitmap(int viewId, Bitmap bitmap) {
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageBitmap(bitmap);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
// public ViewHolder setImageURI(int viewId, String url) {
|
||||
// ImageView view = getView(viewId);
|
||||
// // ImageLoader.getInstance.loadImg(view,url);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setBackgroundImage(int viewId, int resId) {
|
||||
View view = getView(viewId);
|
||||
view.setBackgroundResource(resId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setTextColor(int viewId, int resId) {
|
||||
TextView view = getView(viewId);
|
||||
view.setTextColor(resId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewId
|
||||
* @return
|
||||
*/
|
||||
public RecycleViewHolder setOnClickListener(int viewId,
|
||||
OnClickListener listener) {
|
||||
getView(viewId).setOnClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.module.navi.ui.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-04
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public abstract class AMapBaseFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = "amap.AMapBaseFragment";
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
initViews();
|
||||
}
|
||||
|
||||
protected abstract void initViews();
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState( @NonNull Bundle outState ) {
|
||||
super.onSaveInstanceState( outState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mogo.module.navi.ui.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.mogo.utils.SoftKeyBoardJobber;
|
||||
import com.mogo.utils.statusbar.Eyes;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-02
|
||||
* <p>
|
||||
* 地图 activity 基类
|
||||
*/
|
||||
public class BaseActivity extends AppCompatActivity {
|
||||
|
||||
//@Override
|
||||
//public Context getContext() {
|
||||
// return this;
|
||||
//}
|
||||
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
Eyes.setStatusBarStyle( this, false, Color.parseColor( "#66000000" ), true );
|
||||
getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN );
|
||||
hideSystemUI();
|
||||
}
|
||||
|
||||
protected void hideSystemUI() {
|
||||
//隐藏虚拟按键
|
||||
if ( Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19 ) { // lower api
|
||||
View v = this.getWindow().getDecorView();
|
||||
v.setSystemUiVisibility( View.GONE );
|
||||
} else if ( Build.VERSION.SDK_INT >= 19 ) {
|
||||
//for new api versions.
|
||||
View decorView = getWindow().getDecorView();
|
||||
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
decorView.setSystemUiVisibility( uiOptions );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean enableDispatchTouchEventToDismissSoftKeyBoard() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent( MotionEvent ev ) {
|
||||
if ( ev.getAction() == MotionEvent.ACTION_DOWN && enableDispatchTouchEventToDismissSoftKeyBoard() ) {
|
||||
SoftKeyBoardJobber.hideIfNecessary( this, ev );
|
||||
return super.dispatchTouchEvent( ev );
|
||||
}
|
||||
// 必不可少,否则所有的组件都不会有TouchEvent了
|
||||
if ( getWindow().superDispatchTouchEvent( ev ) ) {
|
||||
return true;
|
||||
}
|
||||
return onTouchEvent( ev );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.mogo.module.navi.ui.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.mogo.utils.NetworkUtils;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-03
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public abstract class BaseFragment extends Fragment {
|
||||
|
||||
protected Context mContext;
|
||||
private View mRootView;
|
||||
|
||||
@Override
|
||||
public void onAttach( Context context ) {
|
||||
super.onAttach( context );
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView( @NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
|
||||
Bundle savedInstanceState ) {
|
||||
mRootView = inflater.inflate( getLayoutId(), container, false );
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
protected < T extends View> T findViewById( @IdRes int id ) {
|
||||
if ( mRootView != null ) {
|
||||
return mRootView.findViewById( id );
|
||||
}
|
||||
if ( getView() != null ) {
|
||||
return getView().findViewById( id );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void overridePendingTransition( int enter, int exit ) {
|
||||
if ( getActivity() != null ) {
|
||||
getActivity().overridePendingTransition( enter, exit );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean checkNetwork() {
|
||||
return NetworkUtils.isConnected( mContext );
|
||||
}
|
||||
|
||||
protected void shortToast( CharSequence msg ) {
|
||||
if ( mContext != null && msg != null ) {
|
||||
Toast.makeText( mContext, msg, Toast.LENGTH_SHORT ).show();
|
||||
}
|
||||
}
|
||||
|
||||
protected void longToast( CharSequence msg ) {
|
||||
if ( mContext != null && msg != null ) {
|
||||
Toast.makeText( mContext, msg, Toast.LENGTH_LONG ).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.mogo.module.navi.ui.base;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-04
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface UiController {
|
||||
|
||||
/**
|
||||
* 显示地图模式
|
||||
*/
|
||||
void onMapMode();
|
||||
|
||||
/**
|
||||
* 显示导航模式
|
||||
*/
|
||||
void onNaviMode();
|
||||
|
||||
/**
|
||||
* 搜索地址
|
||||
*
|
||||
* @param searchType {@link com.zhidao.amap.splitunit.ui.search.SearchConstants}
|
||||
*/
|
||||
void onSearchMode(int searchType);
|
||||
|
||||
/**
|
||||
* 规划路径
|
||||
*/
|
||||
void onCalculateMode();
|
||||
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
void onSettingsMode();
|
||||
|
||||
|
||||
/**
|
||||
* 直接退出应用
|
||||
*/
|
||||
void finishDirectly();
|
||||
|
||||
FragmentManager _getSupportFragmentManager();
|
||||
|
||||
//CommonAddressModel getCommonAddressModel();
|
||||
|
||||
void popBackStackImmediate();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
import com.mogo.module.navi.constants.DataConstants;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-08
|
||||
* <p>
|
||||
* 搜索页面常量字段
|
||||
*/
|
||||
public class SearchConstants {
|
||||
|
||||
/**
|
||||
* 搜索页面类型
|
||||
*/
|
||||
public static final String KEY_SEARCH_TYPE = "type";
|
||||
|
||||
/**
|
||||
* 普通搜索:首页搜索按钮点击
|
||||
*/
|
||||
public static final int SEARCH_TYPE_COMMON = DataConstants.TYPE_POI;
|
||||
|
||||
/**
|
||||
* 设置家:多种搜索方式:普通搜索、我的位置、地图选点
|
||||
*/
|
||||
public static final int SEARCH_TYPE_MULTI_HOME = DataConstants.TYPE_HOME_ADDRESS;
|
||||
|
||||
/**
|
||||
* 设置公司:多种搜索方式:普通搜索、我的位置、地图选点
|
||||
*/
|
||||
public static final int SEARCH_TYPE_MULTI_COMPANY = DataConstants.TYPE_COMPANY_ADDRESS;
|
||||
|
||||
/**
|
||||
* 搜索页面当前状态
|
||||
*/
|
||||
public static final int UI_MODE_COMMON = 1;
|
||||
/**
|
||||
* 搜索页面当前状态:常用地址搜索模式
|
||||
*/
|
||||
public static final int UI_MODE_MULTI = 2;
|
||||
|
||||
/**
|
||||
* 搜索页面当前状态:常用地址搜索模式
|
||||
*/
|
||||
public static final int UI_MODE_MULTI_SEARCH = 5;
|
||||
/**
|
||||
* 搜索页面当前状态:我的位置模式
|
||||
*/
|
||||
public static final int UI_MODE_MULTI_MY_LOCATION = 3;
|
||||
/**
|
||||
* 搜索页面当前状态:选点模式
|
||||
*/
|
||||
public static final int UI_MODE_MULTI_CHOICE_POINT = 4;
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
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;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
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.database.AppDataBase;
|
||||
import com.mogo.module.navi.ui.adapter.HistoryPoiAdapter;
|
||||
import com.mogo.module.navi.ui.adapter.SearchPoiAdapter;
|
||||
import com.mogo.module.navi.ui.base.BaseFragment;
|
||||
import com.mogo.module.navi.ui.base.UiController;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 搜索页面
|
||||
* <p>
|
||||
* 普通搜索:从首页点击搜索按钮进入:包含:仅输入搜索(列表不包含设置按钮)
|
||||
* {@link SearchConstants#SEARCH_TYPE_COMMON}
|
||||
* <p>
|
||||
* 地址设置搜索:设置家、公司、其他的地址:包含当前位置、选点、搜索列表(列表包含设置按钮)、普通页面
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_COMPANY}
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
|
||||
*/
|
||||
@Route(path = "/navi/search")
|
||||
public class SearchFragment extends BaseFragment implements SearchView {
|
||||
|
||||
public static final String TAG = "search";
|
||||
|
||||
public int mSearchType;
|
||||
|
||||
private SearchPresenter mSearchPresenter;
|
||||
|
||||
private View mClose;
|
||||
private EditText mSearchBox;
|
||||
|
||||
private RecyclerView mSearchResult;
|
||||
private RecyclerView rvHistory;
|
||||
private SearchPoiAdapter mPoiAdapter;
|
||||
private HistoryPoiAdapter mHistoryAdapter;
|
||||
|
||||
|
||||
/**
|
||||
* 设置常用地址(我的位置、选点)时的设置按钮
|
||||
*/
|
||||
private TextView mActionButton;
|
||||
|
||||
/**
|
||||
* 地址设置是否完成
|
||||
*/
|
||||
private boolean mActionSuccess = false;
|
||||
private View rlHistory;
|
||||
private TextView tvEmpty;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof UiController) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_search;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getLifecycle().addObserver(mSearchPresenter = new SearchPresenter(this));
|
||||
}
|
||||
|
||||
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mSearchBox = view.findViewById(R.id.et_navi_search);
|
||||
mSearchResult = view.findViewById(R.id.rv_navi_search);
|
||||
rvHistory = view.findViewById(R.id.rv_navi_history);
|
||||
rlHistory = view.findViewById(R.id.rl_navi_history);
|
||||
LinearLayoutManager linearManager =
|
||||
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
|
||||
rvHistory.setLayoutManager(linearManager);
|
||||
LinearLayoutManager linearLayoutManager =
|
||||
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
mSearchResult.setLayoutManager(linearLayoutManager);
|
||||
|
||||
mPoiAdapter= new SearchPoiAdapter(getActivity(),new ArrayList<>());
|
||||
mSearchResult.setAdapter(mPoiAdapter);
|
||||
|
||||
mHistoryAdapter= new HistoryPoiAdapter(getActivity(),new ArrayList<>());
|
||||
rvHistory.setAdapter(mHistoryAdapter);
|
||||
|
||||
tvEmpty = findViewById(R.id.tv_navi_list_empty);
|
||||
|
||||
|
||||
findViewById(R.id.iv_navi_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
|
||||
mHistoryAdapter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mPoiAdapter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
MogoTip tag = (MogoTip) v.getTag(R.id.tag_position);
|
||||
SearchPoi searchPoi = EntityConvertUtils.tipToPoi(tag);
|
||||
mSearchPresenter.insert(searchPoi);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
findViewById(R.id.tv_navi_history_clear).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
mSearchPresenter.deleteAllCachedPoi();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示我的位置,并且可设置为家
|
||||
*/
|
||||
//private void multiSearchMyLocationUI() {
|
||||
// mUiMode = SearchConstants.UI_MODE_MULTI_MY_LOCATION;
|
||||
// mSearchBox.setEnabled( false );
|
||||
// mMyLocation.setVisibility( View.GONE );
|
||||
// mChoicePoint.setVisibility( View.GONE );
|
||||
// mCurrentLocation.setVisibility( View.GONE );
|
||||
// mSearchResult.setVisibility( View.GONE );
|
||||
// mActionButton.setVisibility( View.VISIBLE );
|
||||
// mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
|
||||
// mSearchBox.setCompoundDrawables( null, null, null, null );
|
||||
// //removeChoicePointMarker();
|
||||
// mSearchBox.setTag( null );
|
||||
// if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
// final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
// params.addRule( RelativeLayout.LEFT_OF, R.id.amap_search_action_setting );
|
||||
// mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 15 ), 0 );
|
||||
// mSearchBox.setLayoutParams( params );
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* 显示我的位置,并且可设置为家
|
||||
*/
|
||||
//private void multiSearchChoicePointUI() {
|
||||
// mUiMode = SearchConstants.UI_MODE_MULTI_CHOICE_POINT;
|
||||
// mSearchBox.setEnabled( false );
|
||||
// mMyLocation.setVisibility( View.GONE );
|
||||
// mChoicePoint.setVisibility( View.GONE );
|
||||
// mCurrentLocation.setVisibility( View.GONE );
|
||||
// mSearchResult.setVisibility( View.GONE );
|
||||
// mActionButton.setVisibility( View.VISIBLE );
|
||||
// mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
|
||||
// mSearchBox.setCompoundDrawables( null, null, null, null );
|
||||
// mSearchBox.setTag( null );
|
||||
// if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
// final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
// params.addRule( RelativeLayout.LEFT_OF, R.id.amap_search_action_setting );
|
||||
// mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 15 ), 0 );
|
||||
// mSearchBox.setLayoutParams( params );
|
||||
// }
|
||||
//}
|
||||
private void saveCurrentLocationAsCommonAddress() {
|
||||
//if ( mLastAMapLocation == null ) {
|
||||
// shortToast( "定位失败,请重试" );
|
||||
// return;
|
||||
//}
|
||||
//final Disposable disposable = mSearchPresenter.cacheCommonAddressPoi( mLastAMapLocation ).subscribe( output -> {
|
||||
// Toast.makeText( mContext, "设置成功!", Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = true;
|
||||
//}, error -> {
|
||||
// if ( error instanceof Exception) {
|
||||
// Toast.makeText( mContext, ( (Exception) error ).getMessage(), Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = false;
|
||||
// }
|
||||
//} );
|
||||
//mSearchPresenter.addDisposable( disposable );
|
||||
}
|
||||
|
||||
private void saveRegeoAddressAsCommonAddress() {
|
||||
//if ( mSearchBox.getTag() instanceof RegeocodeAddress ) {
|
||||
// final Disposable disposable = mSearchPresenter.cacheCommonAddressPoi( ( ( RegeocodeAddress ) mSearchBox.getTag() ) ).subscribe( output -> {
|
||||
// Toast.makeText( mContext, "设置成功!", Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = true;
|
||||
// }, error -> {
|
||||
// if ( error instanceof Exception) {
|
||||
// Toast.makeText( mContext, ( (Exception) error ).getMessage(), Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = false;
|
||||
// }
|
||||
// } );
|
||||
// mSearchPresenter.addDisposable( disposable );
|
||||
//} else {
|
||||
// Toast.makeText( mContext, "请选择位置", Toast.LENGTH_SHORT ).show();
|
||||
//}
|
||||
}
|
||||
|
||||
// view interface
|
||||
|
||||
@Override
|
||||
public EditText getSearchBox() {
|
||||
return mSearchBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSearchPoiResult(List<MogoTip> datums, boolean showDelete) {
|
||||
if (datums==null||datums.isEmpty()) {
|
||||
showEmpty(getString(R.string.search_empty));
|
||||
return;
|
||||
}
|
||||
showResult();
|
||||
mPoiAdapter.setDatas(datums);
|
||||
}
|
||||
|
||||
@Override public void showHistory(List<SearchPoi> datums) {
|
||||
|
||||
if (datums==null||datums.isEmpty()) {
|
||||
showEmpty(getString(R.string.history_empty));
|
||||
return;
|
||||
}
|
||||
showHistory();
|
||||
mHistoryAdapter.setDatas(datums);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSearchType() {
|
||||
return mSearchType;
|
||||
}
|
||||
|
||||
@Override public void startJumpAnimation() {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
//public void renderChoicePointResult( RegeocodeAddress address ) {
|
||||
// if ( address == null ) {
|
||||
// mSearchBox.setTag( null );
|
||||
// mSearchBox.setText( "" );
|
||||
// return;
|
||||
// }
|
||||
// mSearchBox.setTag( address );
|
||||
// mSearchBox.setText( address.getFormatAddress() );
|
||||
//}
|
||||
//
|
||||
//@Override
|
||||
//public void renderErrorView() {
|
||||
//
|
||||
//}
|
||||
//
|
||||
//@Override
|
||||
//public void renderContentView() {
|
||||
//
|
||||
//}
|
||||
|
||||
// view interface end
|
||||
|
||||
///**
|
||||
// * 屏幕中心marker 跳动
|
||||
// */
|
||||
//@Override
|
||||
//public void startJumpAnimation() {
|
||||
//
|
||||
// final AMap aMap = mUiController.getAMapServiceVisitor().getMap();
|
||||
//
|
||||
// if ( mChoicePointMaker != null ) {
|
||||
// //根据屏幕距离计算需要移动的目标点
|
||||
// final LatLng latLng = mChoicePointMaker.getPosition();
|
||||
// Point point = aMap.getProjection().toScreenLocation( latLng );
|
||||
// point.y -= WindowUtils.dip2px( mContext, 125 );
|
||||
// LatLng target = aMap.getProjection()
|
||||
// .fromScreenLocation( point );
|
||||
// //使用TranslateAnimation,填写一个需要移动的目标点
|
||||
// Animation animation = new TranslateAnimation( target );
|
||||
// animation.setInterpolator( new Interpolator() {
|
||||
// @Override
|
||||
// public float getInterpolation( float input ) {
|
||||
// // 模拟重加速度的interpolator
|
||||
// if ( input <= 0.5 ) {
|
||||
// return ( float ) ( 0.5f - 2 * ( 0.5 - input ) * ( 0.5 - input ) );
|
||||
// } else {
|
||||
// return ( float ) ( 0.5f - Math.sqrt( ( input - 0.5f ) * ( 1.5f - input ) ) );
|
||||
// }
|
||||
// }
|
||||
// } );
|
||||
// //整个移动所需要的时间
|
||||
// animation.setDuration( 600 );
|
||||
// //设置动画
|
||||
// mChoicePointMaker.setAnimation( animation );
|
||||
// //开始动画
|
||||
// mChoicePointMaker.startAnimation();
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
private void navi2Location(SearchPoi searchPoi) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出搜索,进行清理
|
||||
*/
|
||||
private void exitSearch() {
|
||||
|
||||
switch (mSearchType) {
|
||||
case SearchConstants.SEARCH_TYPE_COMMON:
|
||||
try {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_HOME:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (mSearchPresenter != null) {
|
||||
mSearchPresenter.onDestroy(getViewLifecycleOwner());
|
||||
getLifecycle().removeObserver(mSearchPresenter);
|
||||
mSearchPresenter = null;
|
||||
}
|
||||
mSearchBox.setTag(null);
|
||||
|
||||
mPoiAdapter = null;
|
||||
//removeChoicePointMarker();
|
||||
}
|
||||
|
||||
private void showResult() {
|
||||
rlHistory.setVisibility(View.GONE);
|
||||
mSearchResult.setVisibility(View.VISIBLE);
|
||||
tvEmpty.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showHistory() {
|
||||
rlHistory.setVisibility(View.VISIBLE);
|
||||
mSearchResult.setVisibility(View.GONE);
|
||||
tvEmpty.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showEmpty(String str){
|
||||
rlHistory.setVisibility(View.GONE);
|
||||
tvEmpty.setText(str);
|
||||
mSearchResult.setVisibility(View.GONE);
|
||||
tvEmpty.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
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;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
/**
|
||||
* @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 ModuleType.TYPE_CARD_FRAGMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
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.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.Scheduler;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-02
|
||||
* <p>
|
||||
* 搜搜页逻辑处理
|
||||
*/
|
||||
public class SearchPresenter extends Presenter< SearchView >
|
||||
{
|
||||
|
||||
|
||||
private CompositeDisposable mCompositeDisposable;
|
||||
private IMogoMapService mMapService;
|
||||
|
||||
public SearchPresenter( SearchView view ) {
|
||||
super( view );
|
||||
mCompositeDisposable = new CompositeDisposable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
attachSearchBoxTextWatcher( mView.getSearchBox() );
|
||||
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 ) {
|
||||
return;
|
||||
}
|
||||
editText.addTextChangedListener(watcherAdapter);
|
||||
}
|
||||
|
||||
private final TextWatcherAdapter watcherAdapter = new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void afterTextChanged( Editable s ) {
|
||||
// 避免 disable 设置内容时触发
|
||||
final String input = s.toString();
|
||||
startSearchPoiByInput( input );
|
||||
}
|
||||
};
|
||||
|
||||
private void startSearchPoiByInput( String keyword ) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
inputtipsSearch.requestInputtipsAsyn();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 缓存搜索到的导航地址
|
||||
*
|
||||
* @param tip
|
||||
* @return
|
||||
*/
|
||||
public Single cacheSelectPoiItem( MogoTip tip ) {
|
||||
return Single.create( emitter -> {
|
||||
SearchPoi poi = EntityConvertUtils.tipToPoi( tip );
|
||||
//ignore insert result
|
||||
final List<Long> output = AppDataBase.getDatabase( getContext() ).poiDao().insert( poi );
|
||||
emitter.onSuccess( output );
|
||||
} ).subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() );
|
||||
}
|
||||
|
||||
public void addDisposable( Disposable disposable ) {
|
||||
mCompositeDisposable.add( disposable );
|
||||
}
|
||||
|
||||
public void deleteAllCachedPoi() {
|
||||
|
||||
new AlertDialog.Builder( getContext() )
|
||||
.setMessage( "清空历史记录?" )
|
||||
.setPositiveButton( "立即清空", ( dlg, which ) -> {
|
||||
dlg.dismiss();
|
||||
deleteAllCachedPoiImpl();
|
||||
} )
|
||||
.setNegativeButton( "取消", ( dlg, which ) -> {
|
||||
dlg.dismiss();
|
||||
} )
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void deleteAllCachedPoiImpl() {
|
||||
final Disposable disposable = AppDataBase.getDatabase( getContext() )
|
||||
.poiDao()
|
||||
.getAll()
|
||||
.map( input -> {
|
||||
return AppDataBase.getDatabase( getContext() ).poiDao().deleteAll( input );
|
||||
} )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( count -> {
|
||||
mView.showHistory( null );
|
||||
} );
|
||||
mCompositeDisposable.add( disposable );
|
||||
}
|
||||
//
|
||||
///**
|
||||
// * 缓存搜索位置为常用地址设置
|
||||
// *
|
||||
// * @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;
|
||||
switch ( mView.getSearchType() ) {
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_HOME:
|
||||
poiId = DataConstants.POI_ID_HOME;
|
||||
break;
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_COMPANY:
|
||||
poiId = DataConstants.POI_ID_COMPANY;
|
||||
break;
|
||||
}
|
||||
if ( TextUtils.isEmpty( poiId ) ) {
|
||||
emitter.onError( new IllegalArgumentException( "设置类型错误,请重试" ) );
|
||||
return;
|
||||
}
|
||||
if ( poi == null ) {
|
||||
emitter.onError( new IllegalArgumentException( "位置类型转换错误,请重试" ) );
|
||||
return;
|
||||
}
|
||||
poi.setpId( poiId );
|
||||
poi.setType( mView.getSearchType() );
|
||||
//ignore insert result
|
||||
final List<Long> output = AppDataBase.getDatabase( getContext() ).poiDao().insert( poi );
|
||||
notifyAIAssistCommonAddressChanged();
|
||||
emitter.onSuccess( output );
|
||||
}
|
||||
|
||||
private void notifyAIAssistCommonAddressChanged() {
|
||||
//if ( view.getSearchType() == SearchConstants.SEARCH_TYPE_MULTI_HOME ) {
|
||||
// AddressHelper.notifyHomeAddressChanged( getContext() );
|
||||
//} else if ( view.getSearchType() == SearchConstants.SEARCH_TYPE_MULTI_COMPANY ) {
|
||||
// AddressHelper.notifyCompanyAddressChanged( getContext() );
|
||||
//
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
public void navi2Positon(){
|
||||
//mMapService.getNavi(getContext()).naviTo();
|
||||
}
|
||||
|
||||
public void insert(SearchPoi searchPoi){
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
AppDataBase.getDatabase(getContext()).poiDao().insert(searchPoi);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io()).subscribe();
|
||||
}
|
||||
|
||||
public void clearHistory(List<SearchPoi> list){
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
AppDataBase.getDatabase(getContext()).poiDao().deleteAll(list);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io()).subscribe();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
if ( mView.getSearchBox() != null ) {
|
||||
mView.getSearchBox().removeTextChangedListener( watcherAdapter );
|
||||
}
|
||||
if ( mCompositeDisposable != null && !mCompositeDisposable.isDisposed() ) {
|
||||
mCompositeDisposable.dispose();
|
||||
mCompositeDisposable = null;
|
||||
}
|
||||
//CameraChangedLiveData.getInstance().removeAllObserver();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-08
|
||||
* <p>
|
||||
* 搜索工具类
|
||||
*/
|
||||
public class SearchUtils {
|
||||
|
||||
/**
|
||||
* @param searchType
|
||||
* @return
|
||||
*/
|
||||
public static int checkAndResetSearchType( int searchType ) {
|
||||
switch ( searchType ) {
|
||||
case SearchConstants.SEARCH_TYPE_COMMON:
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_HOME:
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_COMPANY:
|
||||
break;
|
||||
default:
|
||||
searchType = SearchConstants.SEARCH_TYPE_COMMON;
|
||||
break;
|
||||
}
|
||||
return searchType;
|
||||
}
|
||||
|
||||
public static String getSearchTypeActionName( int searchType ) {
|
||||
switch ( searchType ) {
|
||||
case SearchConstants.SEARCH_TYPE_COMMON:
|
||||
return null;
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_HOME:
|
||||
return "设为家";
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_COMPANY:
|
||||
return "设为公司";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-02
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface SearchView extends IView {
|
||||
|
||||
EditText getSearchBox();
|
||||
|
||||
/**
|
||||
* @param datums
|
||||
* @param showDelete 是否显示清空历史记录项
|
||||
*/
|
||||
void renderSearchPoiResult(List<MogoTip> datums, boolean showDelete);
|
||||
|
||||
|
||||
void showHistory(List<SearchPoi> datums);
|
||||
|
||||
int getSearchType();
|
||||
|
||||
|
||||
|
||||
///**
|
||||
// * 显示逆地理位置编码结果
|
||||
// *
|
||||
// * @param address
|
||||
// */
|
||||
//void renderChoicePointResult(RegeocodeAddress address);
|
||||
|
||||
/**
|
||||
* 选点完毕后marker动画
|
||||
*/
|
||||
void startJumpAnimation();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.navi.ui.setting
|
||||
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-07.
|
||||
*/
|
||||
class NaviSettingFragment : BaseFragment() {
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_navi_setting
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user