opt
This commit is contained in:
@@ -14,6 +14,17 @@ public class AMapConstants {
|
||||
*/
|
||||
public static final float AMAP_ZOOM_COMMON_LEVEL = 15.0f;
|
||||
|
||||
|
||||
/**
|
||||
* 设置家和公司的Key
|
||||
*/
|
||||
public static final String KEY_SET_HOME_COMPONY = "key_home";
|
||||
|
||||
/**
|
||||
* 序列号实体的Key
|
||||
*/
|
||||
public static final String KEY_PARCELABLE = "key_Parcelable";
|
||||
|
||||
/**
|
||||
* 点击当前位置按钮的地图缩放级别
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.module.navi.constants
|
||||
|
||||
import android.content.Context
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.map.navi.IMogoNavi
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager
|
||||
import com.mogo.service.map.IMogoMapService
|
||||
import com.mogo.service.module.IMogoRegisterCenter
|
||||
|
||||
/**
|
||||
*@author zyz
|
||||
* 2020-01-08.
|
||||
*/
|
||||
object SearchServiceHolder {
|
||||
|
||||
val fragmentManager:IMogoFragmentManager = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_FRAGMENT_MANAGER
|
||||
).navigation() as IMogoFragmentManager
|
||||
val mapService:IMogoMapService = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_SERVICES_MAP
|
||||
).navigation() as IMogoMapService
|
||||
val listenerCenter:IMogoRegisterCenter = ARouter.getInstance().build(
|
||||
MogoServicePaths.PATH_REGISTER_CENTER
|
||||
).navigation() as IMogoRegisterCenter
|
||||
|
||||
|
||||
fun push(
|
||||
fragment: Fragment,
|
||||
tag: String
|
||||
) {
|
||||
val builder = FragmentDescriptor.Builder()
|
||||
builder.fragment(fragment)
|
||||
val build = builder.tag(tag)
|
||||
.build()
|
||||
fragmentManager.push(build)
|
||||
}
|
||||
|
||||
|
||||
fun getNavi(context: Context):IMogoNavi{
|
||||
return mapService.getNavi(context)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.mogo.module.navi.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import com.mogo.map.navi.MogoCalculatePath;
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2019-08-13.
|
||||
*/
|
||||
public class CalculatePathAdapter extends RecycleBaseAdapter<MogoCalculatePath> {
|
||||
|
||||
private int current = 0;
|
||||
private int lastPosition = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CalculatePathAdapter(Context context, List<MogoCalculatePath> list) {
|
||||
super(context, list, R.layout.item_calculate_path_map);
|
||||
}
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecycleViewHolder holder, MogoCalculatePath item) {
|
||||
|
||||
//holder.setText(R.id.tv_position, tip.getName());
|
||||
//holder.setText(R.id.tv_position_des, tip.getAddress());
|
||||
|
||||
holder.itemView.setTag(R.id.tag_position, holder.getLayoutPosition());
|
||||
holder.itemView.setOnClickListener(onClickListener);
|
||||
holder.itemView.setSelected(current == holder.getLayoutPosition());
|
||||
|
||||
View mName = holder.getView(R.id.amap_calculate_item_strategy_name);
|
||||
holder.setText(R.id.amap_calculate_item_strategy_name, item.getStrategyName());
|
||||
mName.setBackgroundResource(getStrategyNameBkgResId(holder.getLayoutPosition()));
|
||||
holder.setText(R.id.amap_calculate_item_strategy_time, item.getTime());
|
||||
holder.setText(R.id.amap_calculate_item_strategy_distance, item.getDistance());
|
||||
holder.setText(R.id.amap_calculate_item_strategy_desc, item.getDesc());
|
||||
}
|
||||
|
||||
public void setOnClickListener(View.OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
public void setCurrent(int current) {
|
||||
this.current = current;
|
||||
notifyItemChanged(lastPosition);
|
||||
notifyItemChanged(current);
|
||||
lastPosition = current;
|
||||
}
|
||||
|
||||
public MogoCalculatePath getCurrentItem() {
|
||||
return list.get(current);
|
||||
}
|
||||
|
||||
private int getStrategyNameBkgResId(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return R.drawable.amap_calculate_navi_strategy1_bkg;
|
||||
case 1:
|
||||
return R.drawable.amap_calculate_navi_strategy2_bkg;
|
||||
default:
|
||||
return R.drawable.amap_calculate_navi_strategy3_bkg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class HistoryPoiAdapter extends RecycleBaseAdapter<SearchPoi> {
|
||||
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.setTag(R.id.tag_item, tip);
|
||||
holder.itemView.setOnClickListener(onClickListener);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2019-08-13.
|
||||
*/
|
||||
public class SearchCategoryAdapter extends RecycleBaseAdapter<MogoTip> {
|
||||
|
||||
private int current = 0;
|
||||
private int lastPosition = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public SearchCategoryAdapter(Context context, List<MogoTip> list) {
|
||||
super(context, list, R.layout.item_search_category);
|
||||
}
|
||||
|
||||
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.setText(R.id.iv_position,String.valueOf(holder.getLayoutPosition()+1));
|
||||
holder.itemView.setTag(R.id.tag_position, holder.getLayoutPosition());
|
||||
holder.itemView.setOnClickListener(onClickListener);
|
||||
holder.itemView.setSelected(current == holder.getLayoutPosition());
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public void setCurrent(int current) {
|
||||
this.current = current;
|
||||
notifyItemChanged(lastPosition);
|
||||
notifyItemChanged(current);
|
||||
lastPosition = current;
|
||||
}
|
||||
|
||||
|
||||
public MogoTip getCurrentItem(){
|
||||
return list.get(current);
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,12 @@ public abstract class RecycleBaseAdapter<T> extends
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void clear(){
|
||||
if (list != null) {
|
||||
list.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
public void messageShow(String mes)
|
||||
{
|
||||
if (toast==null){
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.ui.adapter.HistoryPoiAdapter;
|
||||
import com.mogo.module.navi.ui.adapter.SearchPoiAdapter;
|
||||
import com.mogo.module.navi.ui.base.BaseFragment;
|
||||
import com.mogo.module.navi.ui.base.UiController;
|
||||
import com.mogo.module.navi.ui.setting.NaviSettingFragment;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 搜索页面
|
||||
* <p>
|
||||
* 普通搜索:从首页点击搜索按钮进入:包含:仅输入搜索(列表不包含设置按钮)
|
||||
* {@link SearchConstants#SEARCH_TYPE_COMMON}
|
||||
* <p>
|
||||
* 地址设置搜索:设置家、公司、其他的地址:包含当前位置、选点、搜索列表(列表包含设置按钮)、普通页面
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_COMPANY}
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
|
||||
*/
|
||||
public abstract class BaseSearchFragment extends BaseFragment implements SearchView {
|
||||
|
||||
|
||||
public int mSearchType;
|
||||
|
||||
protected SearchPresenter mSearchPresenter;
|
||||
|
||||
private View mClose;
|
||||
private EditText mSearchBox;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置常用地址(我的位置、选点)时的设置按钮
|
||||
*/
|
||||
private TextView mActionButton;
|
||||
|
||||
/**
|
||||
* 地址设置是否完成
|
||||
*/
|
||||
private boolean mActionSuccess = false;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof UiController) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_search;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getLifecycle().addObserver(mSearchPresenter = new SearchPresenter(this));
|
||||
}
|
||||
|
||||
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mSearchBox = view.findViewById(R.id.et_navi_search);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示我的位置,并且可设置为家
|
||||
*/
|
||||
//private void multiSearchMyLocationUI() {
|
||||
// mUiMode = SearchConstants.UI_MODE_MULTI_MY_LOCATION;
|
||||
// mSearchBox.setEnabled( false );
|
||||
// mMyLocation.setVisibility( View.GONE );
|
||||
// mChoicePoint.setVisibility( View.GONE );
|
||||
// mCurrentLocation.setVisibility( View.GONE );
|
||||
// mSearchResult.setVisibility( View.GONE );
|
||||
// mActionButton.setVisibility( View.VISIBLE );
|
||||
// mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
|
||||
// mSearchBox.setCompoundDrawables( null, null, null, null );
|
||||
// //removeChoicePointMarker();
|
||||
// mSearchBox.setTag( null );
|
||||
// if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
// final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
// params.addRule( RelativeLayout.LEFT_OF, R.id.amap_search_action_setting );
|
||||
// mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 15 ), 0 );
|
||||
// mSearchBox.setLayoutParams( params );
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* 显示我的位置,并且可设置为家
|
||||
*/
|
||||
//private void multiSearchChoicePointUI() {
|
||||
// mUiMode = SearchConstants.UI_MODE_MULTI_CHOICE_POINT;
|
||||
// mSearchBox.setEnabled( false );
|
||||
// mMyLocation.setVisibility( View.GONE );
|
||||
// mChoicePoint.setVisibility( View.GONE );
|
||||
// mCurrentLocation.setVisibility( View.GONE );
|
||||
// mSearchResult.setVisibility( View.GONE );
|
||||
// mActionButton.setVisibility( View.VISIBLE );
|
||||
// mActionButton.setText( SearchUtils.getSearchTypeActionName( mSearchType ) );
|
||||
// mSearchBox.setCompoundDrawables( null, null, null, null );
|
||||
// mSearchBox.setTag( null );
|
||||
// if ( mSearchBox.getLayoutParams() instanceof RelativeLayout.LayoutParams ) {
|
||||
// final RelativeLayout.LayoutParams params = ( ( RelativeLayout.LayoutParams ) mSearchBox.getLayoutParams() );
|
||||
// params.addRule( RelativeLayout.LEFT_OF, R.id.amap_search_action_setting );
|
||||
// mSearchBox.setPadding( 0, 0, WindowUtils.dip2px( mContext, 15 ), 0 );
|
||||
// mSearchBox.setLayoutParams( params );
|
||||
// }
|
||||
//}
|
||||
private void saveCurrentLocationAsCommonAddress() {
|
||||
//if ( mLastAMapLocation == null ) {
|
||||
// shortToast( "定位失败,请重试" );
|
||||
// return;
|
||||
//}
|
||||
//final Disposable disposable = mSearchPresenter.cacheCommonAddressPoi( mLastAMapLocation ).subscribe( output -> {
|
||||
// Toast.makeText( mContext, "设置成功!", Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = true;
|
||||
//}, error -> {
|
||||
// if ( error instanceof Exception) {
|
||||
// Toast.makeText( mContext, ( (Exception) error ).getMessage(), Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = false;
|
||||
// }
|
||||
//} );
|
||||
//mSearchPresenter.addDisposable( disposable );
|
||||
}
|
||||
|
||||
private void saveRegeoAddressAsCommonAddress() {
|
||||
//if ( mSearchBox.getTag() instanceof RegeocodeAddress ) {
|
||||
// final Disposable disposable = mSearchPresenter.cacheCommonAddressPoi( ( ( RegeocodeAddress ) mSearchBox.getTag() ) ).subscribe( output -> {
|
||||
// Toast.makeText( mContext, "设置成功!", Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = true;
|
||||
// }, error -> {
|
||||
// if ( error instanceof Exception) {
|
||||
// Toast.makeText( mContext, ( (Exception) error ).getMessage(), Toast.LENGTH_SHORT ).show();
|
||||
// mActionSuccess = false;
|
||||
// }
|
||||
// } );
|
||||
// mSearchPresenter.addDisposable( disposable );
|
||||
//} else {
|
||||
// Toast.makeText( mContext, "请选择位置", Toast.LENGTH_SHORT ).show();
|
||||
//}
|
||||
}
|
||||
|
||||
// view interface
|
||||
|
||||
@Override
|
||||
public EditText getSearchBox() {
|
||||
return mSearchBox;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSearchType() {
|
||||
return mSearchType;
|
||||
}
|
||||
|
||||
@Override public void startJumpAnimation() {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
//public void renderChoicePointResult( RegeocodeAddress address ) {
|
||||
// if ( address == null ) {
|
||||
// mSearchBox.setTag( null );
|
||||
// mSearchBox.setText( "" );
|
||||
// return;
|
||||
// }
|
||||
// mSearchBox.setTag( address );
|
||||
// mSearchBox.setText( address.getFormatAddress() );
|
||||
//}
|
||||
//
|
||||
//@Override
|
||||
//public void renderErrorView() {
|
||||
//
|
||||
//}
|
||||
//
|
||||
//@Override
|
||||
//public void renderContentView() {
|
||||
//
|
||||
//}
|
||||
|
||||
// view interface end
|
||||
|
||||
///**
|
||||
// * 屏幕中心marker 跳动
|
||||
// */
|
||||
//@Override
|
||||
//public void startJumpAnimation() {
|
||||
//
|
||||
// final AMap aMap = mUiController.getAMapServiceVisitor().getMap();
|
||||
//
|
||||
// if ( mChoicePointMaker != null ) {
|
||||
// //根据屏幕距离计算需要移动的目标点
|
||||
// final LatLng latLng = mChoicePointMaker.getPosition();
|
||||
// Point point = aMap.getProjection().toScreenLocation( latLng );
|
||||
// point.y -= WindowUtils.dip2px( mContext, 125 );
|
||||
// LatLng target = aMap.getProjection()
|
||||
// .fromScreenLocation( point );
|
||||
// //使用TranslateAnimation,填写一个需要移动的目标点
|
||||
// Animation animation = new TranslateAnimation( target );
|
||||
// animation.setInterpolator( new Interpolator() {
|
||||
// @Override
|
||||
// public float getInterpolation( float input ) {
|
||||
// // 模拟重加速度的interpolator
|
||||
// if ( input <= 0.5 ) {
|
||||
// return ( float ) ( 0.5f - 2 * ( 0.5 - input ) * ( 0.5 - input ) );
|
||||
// } else {
|
||||
// return ( float ) ( 0.5f - Math.sqrt( ( input - 0.5f ) * ( 1.5f - input ) ) );
|
||||
// }
|
||||
// }
|
||||
// } );
|
||||
// //整个移动所需要的时间
|
||||
// animation.setDuration( 600 );
|
||||
// //设置动画
|
||||
// mChoicePointMaker.setAnimation( animation );
|
||||
// //开始动画
|
||||
// mChoicePointMaker.startAnimation();
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
private void navi2Location(SearchPoi searchPoi) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出搜索,进行清理
|
||||
*/
|
||||
private void exitSearch() {
|
||||
|
||||
switch (mSearchType) {
|
||||
case SearchConstants.SEARCH_TYPE_COMMON:
|
||||
try {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_HOME:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (mSearchPresenter != null) {
|
||||
mSearchPresenter.onDestroy(getViewLifecycleOwner());
|
||||
getLifecycle().removeObserver(mSearchPresenter);
|
||||
mSearchPresenter = null;
|
||||
}
|
||||
mSearchBox.setTag(null);
|
||||
//removeChoicePointMarker();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.mogo.module.navi.ui.search
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mogo.map.search.inputtips.MogoTip
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.bean.SearchPoi
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.ui.adapter.SearchCategoryAdapter
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.cv_search_result
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.tv_navi_navi
|
||||
import kotlinx.android.synthetic.main.fragment_setting_address.rv_search_result
|
||||
import kotlinx.android.synthetic.main.include_search_bar.et_navi_search
|
||||
import kotlinx.android.synthetic.main.include_search_bar.iv_navi_back
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-09.
|
||||
*/
|
||||
class CategorySearchFragment : BaseSearchFragment() {
|
||||
|
||||
private lateinit var mAdapter: SearchCategoryAdapter
|
||||
|
||||
private var category:String?=null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
category=arguments?.getString("category")
|
||||
}
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_search_category
|
||||
}
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mAdapter = SearchCategoryAdapter(activity, ArrayList())
|
||||
|
||||
rv_search_result.layoutManager =
|
||||
LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
rv_search_result.adapter = mAdapter
|
||||
|
||||
et_navi_search.setText(category)
|
||||
|
||||
|
||||
iv_navi_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
|
||||
tv_navi_navi.setOnClickListener {
|
||||
|
||||
var newInstance = ChoosePathFragment.newInstance(mAdapter.currentItem)
|
||||
|
||||
SearchServiceHolder.push(newInstance, MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT)
|
||||
}
|
||||
mAdapter.setOnClickListener {
|
||||
var position = it.getTag(R.id.tag_position) as Int
|
||||
mAdapter.setCurrent(position)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
mSearchPresenter.startSearchPoiByInput(category)
|
||||
|
||||
}
|
||||
override fun renderSearchPoiResult(
|
||||
datums: List<MogoTip>,
|
||||
showDelete: Boolean
|
||||
) {
|
||||
|
||||
mAdapter.setDatas(datums)
|
||||
cv_search_result.visibility=View.VISIBLE
|
||||
|
||||
}
|
||||
|
||||
override fun showHistory(datums: List<SearchPoi>) {
|
||||
|
||||
}
|
||||
|
||||
companion object{
|
||||
fun newInstance( category:String):Fragment{
|
||||
var bundle = Bundle()
|
||||
bundle.putString("category",category)
|
||||
var categorySerachFragment = CategorySearchFragment()
|
||||
categorySerachFragment.arguments=bundle
|
||||
return categorySerachFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.mogo.module.navi.ui.search
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mogo.map.navi.IMogoNaviListener
|
||||
import com.mogo.map.navi.MogoCalculatePath
|
||||
import com.mogo.map.navi.MogoNaviInfo
|
||||
import com.mogo.map.search.inputtips.MogoTip
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils
|
||||
import com.mogo.module.navi.bean.SearchPoi
|
||||
import com.mogo.module.navi.constants.AMapConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.ui.adapter.CalculatePathAdapter
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.rv_search_result
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.tv_navi_navi
|
||||
import kotlinx.android.synthetic.main.include_search_bar.et_navi_search
|
||||
import kotlinx.android.synthetic.main.include_search_bar.iv_navi_back
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-09.
|
||||
*/
|
||||
class ChoosePathFragment : BaseFragment(), IMogoNaviListener {
|
||||
override fun onInitNaviFailure() {
|
||||
}
|
||||
|
||||
override fun onInitNaviSuccess() {
|
||||
}
|
||||
|
||||
override fun onNaviInfoUpdate(naviinfo: MogoNaviInfo?) {
|
||||
}
|
||||
|
||||
override fun onStartNavi() {
|
||||
}
|
||||
|
||||
override fun onStopNavi() {
|
||||
}
|
||||
|
||||
override fun onCalculateSuccess() {
|
||||
mAdapter.setDatas(SearchServiceHolder.getNavi(activity!!).calculatedStrategies)
|
||||
}
|
||||
|
||||
override fun onoCalculateFailed() {
|
||||
}
|
||||
|
||||
private lateinit var mAdapter:CalculatePathAdapter
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_search_category
|
||||
}
|
||||
var mogoTip: MogoTip?=null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mogoTip = arguments?.getParcelable<MogoTip>(AMapConstants.KEY_PARCELABLE)
|
||||
}
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
iv_navi_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
|
||||
tv_navi_navi.text=getString(R.string.start_navi)
|
||||
|
||||
et_navi_search.setText(getString(R.string.choose_path))
|
||||
et_navi_search.isEnabled=false
|
||||
SearchServiceHolder.getNavi(context!!).naviTo(mogoTip?.point)
|
||||
|
||||
SearchServiceHolder.listenerCenter.registerMogoNaviListener(MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT,this)
|
||||
|
||||
var arrayList = ArrayList<MogoCalculatePath>()
|
||||
mAdapter= CalculatePathAdapter(activity,arrayList)
|
||||
rv_search_result.layoutManager=LinearLayoutManager(activity,LinearLayoutManager.VERTICAL,false)
|
||||
|
||||
rv_search_result.adapter=mAdapter
|
||||
tv_navi_navi.setOnClickListener {
|
||||
SearchServiceHolder.getNavi(activity!!).startNavi(false)
|
||||
}
|
||||
|
||||
mAdapter.setOnClickListener {
|
||||
var position = it.getTag(R.id.tag_position) as Int
|
||||
mAdapter.setCurrent(position)
|
||||
mAdapter.currentItem.onItemClickInteraction.onItemClicked(mAdapter.currentItem.mTagId)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object{
|
||||
fun newInstance(searchPoi: MogoTip):Fragment{
|
||||
var bundle = Bundle()
|
||||
bundle.putParcelable(AMapConstants.KEY_PARCELABLE, searchPoi)
|
||||
var choosePathFragment = ChoosePathFragment()
|
||||
choosePathFragment.arguments=bundle
|
||||
return choosePathFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,28 @@
|
||||
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.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.database.AppDataBase;
|
||||
import com.mogo.module.navi.constants.AMapConstants;
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder;
|
||||
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.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import com.mogo.module.navi.ui.setting.NaviSettingFragment;
|
||||
import com.mogo.module.navi.ui.setting.SettingAddressFragment;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -45,23 +37,19 @@ import java.util.List;
|
||||
* {@link SearchConstants#SEARCH_TYPE_MULTI_HOME}
|
||||
*/
|
||||
@Route(path = MogoModulePaths.PATH_FRAGMENT_SEARCH)
|
||||
public class SearchFragment extends BaseFragment implements SearchView {
|
||||
public class SearchFragment extends BaseSearchFragment implements SearchView, View.OnClickListener {
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 设置常用地址(我的位置、选点)时的设置按钮
|
||||
*/
|
||||
@@ -73,7 +61,6 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
private boolean mActionSuccess = false;
|
||||
private View rlHistory;
|
||||
private TextView tvEmpty;
|
||||
IMogoFragmentManager fragmentManager;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -84,8 +71,6 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
|
||||
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentManager = (IMogoFragmentManager) ARouter.getInstance().build(MogoServicePaths.PATH_FRAGMENT_MANAGER).navigation();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,12 +81,10 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getLifecycle().addObserver(mSearchPresenter = new SearchPresenter(this));
|
||||
}
|
||||
|
||||
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mSearchBox = view.findViewById(R.id.et_navi_search);
|
||||
mSearchResult = view.findViewById(R.id.rv_navi_search);
|
||||
rvHistory = view.findViewById(R.id.rv_navi_history);
|
||||
rlHistory = view.findViewById(R.id.rl_navi_history);
|
||||
@@ -113,23 +96,26 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
mSearchResult.setLayoutManager(linearLayoutManager);
|
||||
|
||||
mPoiAdapter= new SearchPoiAdapter(getActivity(),new ArrayList<>());
|
||||
mPoiAdapter = new SearchPoiAdapter(getActivity(), new ArrayList<>());
|
||||
mSearchResult.setAdapter(mPoiAdapter);
|
||||
|
||||
mHistoryAdapter= new HistoryPoiAdapter(getActivity(),new ArrayList<>());
|
||||
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) {
|
||||
fragmentManager.pop();
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager().pop();
|
||||
}
|
||||
});
|
||||
|
||||
mHistoryAdapter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
|
||||
SearchPoi item = (SearchPoi) v.getTag(R.id.tag_item);
|
||||
MogoTip mogoTip = EntityConvertUtils.poi2MogoTip(item);
|
||||
SearchServiceHolder.INSTANCE.push(ChoosePathFragment.Companion.newInstance(mogoTip),
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -138,16 +124,57 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
MogoTip tag = (MogoTip) v.getTag(R.id.tag_position);
|
||||
SearchPoi searchPoi = EntityConvertUtils.tipToPoi(tag);
|
||||
mSearchPresenter.insert(searchPoi);
|
||||
SearchServiceHolder.INSTANCE.push(ChoosePathFragment.Companion.newInstance(tag),
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
findViewById(R.id.tv_navi_history_clear).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
mSearchPresenter.deleteAllCachedPoi();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.tv_navi_setting).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
push(new NaviSettingFragment(), MogoModulePaths.PATH_FRAGMENT_SETTING);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.tv_navi_company).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
pupSettingAddress(1);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.tv_navi_home).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
pupSettingAddress(0);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.tv_navi_wash).setOnClickListener(this);
|
||||
findViewById(R.id.tv_navi_toilet).setOnClickListener(this);
|
||||
findViewById(R.id.tv_navi_gas).setOnClickListener(this);
|
||||
findViewById(R.id.tv_navi_restaurant).setOnClickListener(this);
|
||||
findViewById(R.id.tv_navi_park).setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void push(Fragment fragment, String tag) {
|
||||
FragmentDescriptor.Builder builder = new FragmentDescriptor.Builder();
|
||||
builder.fragment(fragment);
|
||||
FragmentDescriptor build =
|
||||
builder.tag(tag).build();
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager().push(build);
|
||||
}
|
||||
|
||||
private void pupSettingAddress(int type) {
|
||||
|
||||
FragmentDescriptor.Builder builder = new FragmentDescriptor.Builder();
|
||||
builder.fragment(SettingAddressFragment.Companion.newInstance(type));
|
||||
FragmentDescriptor build =
|
||||
builder.tag(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME).build();
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager().push(build);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,16 +255,9 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
//}
|
||||
}
|
||||
|
||||
// view interface
|
||||
|
||||
@Override
|
||||
public EditText getSearchBox() {
|
||||
return mSearchBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSearchPoiResult(List<MogoTip> datums, boolean showDelete) {
|
||||
if (datums==null||datums.isEmpty()) {
|
||||
if (datums == null || datums.isEmpty()) {
|
||||
showEmpty(getString(R.string.search_empty));
|
||||
return;
|
||||
}
|
||||
@@ -247,7 +267,7 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
|
||||
@Override public void showHistory(List<SearchPoi> datums) {
|
||||
|
||||
if (datums==null||datums.isEmpty()) {
|
||||
if (datums == null || datums.isEmpty()) {
|
||||
showEmpty(getString(R.string.history_empty));
|
||||
return;
|
||||
}
|
||||
@@ -325,10 +345,8 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
private void navi2Location(SearchPoi searchPoi) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,20 +366,6 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
@@ -374,10 +378,20 @@ public class SearchFragment extends BaseFragment implements SearchView {
|
||||
tvEmpty.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showEmpty(String str){
|
||||
private void showEmpty(String str) {
|
||||
rlHistory.setVisibility(View.GONE);
|
||||
tvEmpty.setText(str);
|
||||
mSearchResult.setVisibility(View.GONE);
|
||||
tvEmpty.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 类别
|
||||
*/
|
||||
@Override public void onClick(View v) {
|
||||
TextView category = (TextView) v;
|
||||
String text = category.getText().toString();
|
||||
push(CategorySearchFragment.Companion.newInstance(text),
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
}
|
||||
};
|
||||
|
||||
private void startSearchPoiByInput( String keyword ) {
|
||||
public void startSearchPoiByInput( String keyword ) {
|
||||
MogoInputtipsQuery mogoInputtipsQuery = new MogoInputtipsQuery();
|
||||
mogoInputtipsQuery.setKeyword(keyword);
|
||||
IMogoInputtipsSearch inputtipsSearch =
|
||||
|
||||
@@ -1,14 +1,33 @@
|
||||
package com.mogo.module.navi.ui.setting
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.iv_back
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.tv_navi_sound_type
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-07.
|
||||
*/
|
||||
@Route(path= MogoModulePaths.PATH_FRAGMENT_SETTING)
|
||||
class NaviSettingFragment : BaseFragment() {
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_navi_setting
|
||||
}
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
iv_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.mogo.module.navi.ui.setting
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.map.search.inputtips.MogoTip
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.bean.SearchPoi
|
||||
import com.mogo.module.navi.constants.AMapConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.ui.adapter.SearchPoiAdapter
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import com.mogo.module.navi.ui.search.BaseSearchFragment
|
||||
import kotlinx.android.synthetic.main.fragment_navi_setting.iv_back
|
||||
import kotlinx.android.synthetic.main.include_search_bar.iv_navi_back
|
||||
import kotlinx.android.synthetic.main.fragment_setting_address.group_set_address
|
||||
import kotlinx.android.synthetic.main.fragment_setting_address.rv_search_result
|
||||
import kotlinx.android.synthetic.main.fragment_setting_address.tv_navi_choose_point
|
||||
import kotlinx.android.synthetic.main.fragment_setting_address.tv_navi_my_location
|
||||
import kotlinx.android.synthetic.main.fragment_setting_address.tv_set_as_home
|
||||
import kotlinx.android.synthetic.main.include_search_bar.et_navi_search
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-07.
|
||||
*/
|
||||
@Route(path = MogoModulePaths.PATH_FRAGMENT_SETTING_HOME)
|
||||
class SettingAddressFragment : BaseSearchFragment() {
|
||||
override fun renderSearchPoiResult(
|
||||
datums: MutableList<MogoTip>?,
|
||||
showDelete: Boolean
|
||||
) {
|
||||
mAdapter.setDatas(datums)
|
||||
group_set_address.visibility = View.GONE
|
||||
rv_search_result.visibility = View.VISIBLE
|
||||
|
||||
}
|
||||
|
||||
override fun showHistory(datums: MutableList<SearchPoi>?) {
|
||||
}
|
||||
|
||||
private var style: Int = 0
|
||||
private lateinit var mAdapter: SearchPoiAdapter
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
style = arguments?.getInt(AMapConstants.KEY_SET_HOME_COMPONY) ?: 0
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_setting_address
|
||||
}
|
||||
|
||||
fun isHome(): Boolean {
|
||||
return style == 0
|
||||
}
|
||||
|
||||
fun isCompony(): Boolean {
|
||||
return style == 1
|
||||
}
|
||||
|
||||
fun isSearch(): Boolean {
|
||||
return group_set_address.visibility == View.GONE
|
||||
}
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
||||
if (isHome()) {
|
||||
tv_set_as_home.text = resources.getString(R.string.set_as_home_navi)
|
||||
} else {
|
||||
tv_set_as_home.text = resources.getString(R.string.set_as_compony_navi)
|
||||
}
|
||||
|
||||
mAdapter = SearchPoiAdapter(activity, ArrayList())
|
||||
|
||||
rv_search_result.layoutManager =
|
||||
LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
rv_search_result.adapter = mAdapter
|
||||
|
||||
|
||||
iv_navi_back.setOnClickListener {
|
||||
if (group_set_address.visibility == View.VISIBLE) {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
} else {
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tv_navi_choose_point.setOnClickListener {
|
||||
group_set_address.visibility = View.GONE
|
||||
tv_set_as_home.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
tv_navi_my_location.setOnClickListener {
|
||||
group_set_address.visibility = View.GONE
|
||||
tv_set_as_home.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun reset() {
|
||||
group_set_address.visibility = View.VISIBLE
|
||||
rv_search_result.visibility = View.GONE
|
||||
mAdapter.clear()
|
||||
et_navi_search.setText("")
|
||||
tv_set_as_home.visibility = View.GONE
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(type: Int = 0): Fragment {
|
||||
|
||||
var settingAddressFragment = SettingAddressFragment()
|
||||
val bundle = Bundle()
|
||||
bundle.putInt(AMapConstants.KEY_SET_HOME_COMPONY, type)
|
||||
settingAddressFragment.setArguments(bundle)
|
||||
return settingAddressFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user