From 8c3f25d8be35a51e3edb98e150409b4bdfa3aa5b Mon Sep 17 00:00:00 2001 From: zhangyuanzhen Date: Mon, 10 Feb 2020 13:59:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMGOS-366?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../navi/constants/SearchServiceHolder.kt | 5 ++++ .../navi/ui/search/CategoryPresenter.java | 1 - .../module/navi/ui/search/SearchFragment.java | 28 +++++++++++++------ .../navi/ui/search/SearchPresenter.java | 6 ++++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/constants/SearchServiceHolder.kt b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/constants/SearchServiceHolder.kt index 6b125b6951..d1a89d9c3f 100644 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/constants/SearchServiceHolder.kt +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/constants/SearchServiceHolder.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import androidx.fragment.app.Fragment import com.alibaba.android.arouter.launcher.ARouter +import com.mogo.map.location.IMogoLocationClient import com.mogo.map.marker.IMogoMarkerManager import com.mogo.map.navi.IMogoNavi import com.mogo.map.search.geo.IMogoGeoSearch @@ -59,6 +60,10 @@ object SearchServiceHolder{ return mapService.getNavi(context) } + fun getLocationClient(): IMogoLocationClient { + return mapService.getLocationClient(context) + } + fun getMapUIController(): IMogoMapUIController { return mapService.mapUIController } diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategoryPresenter.java b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategoryPresenter.java index 89cb757852..0e85d32520 100644 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategoryPresenter.java +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategoryPresenter.java @@ -64,7 +64,6 @@ public class CategoryPresenter extends Presenter { public void startSearchLocalPoiByInput(String keyword) { MogoPoiSearchQuery mogoInputtipsQuery = new MogoPoiSearchQuery(keyword, keyword); mogoInputtipsQuery.setPageSize(10); - mogoInputtipsQuery.getCity(); mogoInputtipsQuery.setLocation( SearchServiceHolder.INSTANCE.getMapUIController().getWindowCenterLocation()); IMogoPoiSearch inputtipsSearch = diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java index 62c0ea2e45..1255bb8b01 100644 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchFragment.java @@ -83,7 +83,7 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); SearchServiceHolder.INSTANCE.getMarkerManger().removeMarkers(); - SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation( false ); + SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation(false); moveMapToCenter(); } @@ -116,10 +116,12 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi mHistoryAdapter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - SearchServiceHolder.INSTANCE.getAnalyticsManager().track("Navigation_History_destination", new HashMap()); + SearchServiceHolder.INSTANCE.getAnalyticsManager() + .track("Navigation_History_destination", new HashMap()); SearchPoi item = (SearchPoi) v.getTag(R.id.tag_item); MogoTip mogoTip = EntityConvertUtils.poi2MogoTip(item); - SearchServiceHolder.INSTANCE.push(ChoosePathFragment.Companion.newInstance(mogoTip.getPoint()), + SearchServiceHolder.INSTANCE.push( + ChoosePathFragment.Companion.newInstance(mogoTip.getPoint()), MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT); } }); @@ -128,9 +130,15 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi @Override public void onClick(View v) { MogoTip tag = (MogoTip) v.getTag(R.id.tag_position); SearchPoi searchPoi = EntityConvertUtils.tipToPoi(tag); - mSearchPresenter.insert(searchPoi); - SearchServiceHolder.INSTANCE.push(ChoosePathFragment.Companion.newInstance(tag.getPoint()), - MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT); + if (tag.getPoint() == null) { + push(CategorySearchFragment.Companion.newInstance(tag.getName()), + MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY); + } else { + mSearchPresenter.insert(searchPoi); + SearchServiceHolder.INSTANCE.push( + ChoosePathFragment.Companion.newInstance(tag.getPoint()), + MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT); + } } }); @@ -142,7 +150,8 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi findViewById(R.id.tv_navi_setting).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - SearchServiceHolder.INSTANCE.getAnalyticsManager().track("Navigation_button_setting", new HashMap()); + SearchServiceHolder.INSTANCE.getAnalyticsManager() + .track("Navigation_button_setting", new HashMap()); push(new NaviSettingFragment(), MogoModulePaths.PATH_FRAGMENT_SETTING); } @@ -168,7 +177,8 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi findViewById(R.id.tv_navi_search).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - SearchServiceHolder.INSTANCE.getAnalyticsManager().track("Navigation_button_search", new HashMap()); + SearchServiceHolder.INSTANCE.getAnalyticsManager() + .track("Navigation_button_search", new HashMap()); mSearchPresenter.startSearchPoiByInput(mSearchBox.getText().toString()); } @@ -404,7 +414,7 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi @Override public void onDestroyView() { super.onDestroyView(); - SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation( true ); + SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation(true); moveMapToRight(); } } diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchPresenter.java b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchPresenter.java index 74cbbe8708..bf0a049789 100644 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchPresenter.java +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/SearchPresenter.java @@ -8,6 +8,7 @@ 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.location.MogoLocation; import com.mogo.map.search.geo.MogoPoiItem; import com.mogo.map.search.inputtips.IMogoInputtipsListener; import com.mogo.map.search.inputtips.IMogoInputtipsSearch; @@ -100,6 +101,11 @@ public class SearchPresenter extends Presenter< SearchView > public void startSearchPoiByInput( String keyword ) { MogoInputtipsQuery mogoInputtipsQuery = new MogoInputtipsQuery(); mogoInputtipsQuery.setKeyword(keyword); + + MogoLocation lastKnowLocation = + SearchServiceHolder.INSTANCE.getLocationClient().getLastKnowLocation(); + mogoInputtipsQuery.setCity(lastKnowLocation.getCityName()); + mogoInputtipsQuery.setCityLimit(true); IMogoInputtipsSearch inputtipsSearch = mMapService.getInputtipsSearch(getContext(), mogoInputtipsQuery);