opt
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
package com.mogo.module.navi.ui.search;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearch;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
||||
@@ -37,7 +42,7 @@ public class CategoryPresenter extends Presenter< CategoryView > {
|
||||
|
||||
MogoPoiSearchQuery poiSearchQuery = new MogoPoiSearchQuery( keyword, keyword );
|
||||
poiSearchQuery.setPageSize( 10 );
|
||||
poiSearchQuery.setLocation( SearchApisHolder.getUiControllerApis().getWindowCenterLocation() );
|
||||
poiSearchQuery.setLocation( getCurrentLatLon() );
|
||||
IMogoPoiSearch poiSearch = SearchApisHolder.getMapServiceApis().getPoiSearch( getContext(), poiSearchQuery );
|
||||
|
||||
poiSearch.setPoiSearchListener( new IMogoPoiSearchListener() {
|
||||
@@ -56,6 +61,26 @@ public class CategoryPresenter extends Presenter< CategoryView > {
|
||||
poiSearch.searchPOIAsyn();
|
||||
}
|
||||
|
||||
private MogoLatLng getCurrentLatLon() {
|
||||
MogoLatLng latLon = SearchApisHolder.getNaviApis().getCarLocation();
|
||||
if ( latLon == null ) {
|
||||
Location location = SearchApisHolder.getNaviApis().getCarLocation2();
|
||||
if ( location != null ) {
|
||||
latLon = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
}
|
||||
}
|
||||
if ( latLon == null ) {
|
||||
MogoLocation location = SearchApisHolder.getLocationClientApis().getLastKnowLocation();
|
||||
if ( location != null ) {
|
||||
latLon = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
}
|
||||
}
|
||||
if ( latLon == null ) {
|
||||
latLon = SearchApisHolder.getUiControllerApis().getWindowCenterLocation();
|
||||
}
|
||||
return latLon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.mogo.map.marker.MogoMarkerOptions
|
||||
import com.mogo.map.search.geo.MogoPoiItem
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy
|
||||
import com.mogo.module.common.map.Scene
|
||||
import com.mogo.module.common.utils.CarSeries
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.constants.SearchApisHolder
|
||||
import com.mogo.module.navi.manager.AddressManager
|
||||
@@ -30,10 +31,6 @@ import kotlinx.android.synthetic.main.fragment_search_category.*
|
||||
* 2020-01-09.
|
||||
*/
|
||||
class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBack, IMogoMarkerClickListener {
|
||||
// override fun onMarkerClicked(marker: IMogoMarker?): Boolean {
|
||||
//
|
||||
// return true
|
||||
// }
|
||||
|
||||
override fun onCmdSelected(cmd: String?) {
|
||||
if (cmd?.startsWith("position") == true) {
|
||||
@@ -44,24 +41,13 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCmdAction(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onCmdCancel(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakSelectTimeOut(speakText: String?) {
|
||||
}
|
||||
|
||||
private val TAG: String = "CategorySearchFragment"
|
||||
private var addMarkers: ArrayList<IMogoMarker> = ArrayList()
|
||||
var arrayList = ArrayList<MogoMarkerOptions>()
|
||||
var locationList = ArrayList<MogoLatLng>()
|
||||
|
||||
private lateinit var cmds: ArrayList<String>
|
||||
|
||||
override fun renderSearchPoiResult(datums: List<MogoPoiItem>?) {
|
||||
mAdapter.setDatas(datums)
|
||||
cv_search_result.visibility = View.VISIBLE
|
||||
@@ -88,7 +74,9 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
// .anchor(0.5f, 1f)
|
||||
.longitude(datums[index].point?.lng ?: 0.0)
|
||||
arrayList.add(options)
|
||||
locationList.add(datums[index].point)
|
||||
if( locationList.size < 3 ){
|
||||
locationList.add(datums[index].point)
|
||||
}
|
||||
|
||||
var int2String = StringUtils.int2String(index + 1)
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("position${index}", arrayOf("第${int2String}个", "第${int2String}条"), this)
|
||||
@@ -102,10 +90,10 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
addMarkers.clear()
|
||||
var marginBounder = resources.getDimensionPixelSize(R.dimen.dp_60) * 2
|
||||
SearchApisHolder.getUiControllerApis().showBounds(TAG,
|
||||
null,
|
||||
locationList[0],
|
||||
locationList,
|
||||
Rect(cv_search_result.width + marginBounder, marginBounder, marginBounder, marginBounder),
|
||||
false
|
||||
true
|
||||
)
|
||||
|
||||
for (options in arrayList) {
|
||||
@@ -200,7 +188,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
arrayList.get(mAdapter.current).icon(getMarkerIcon(mAdapter.current))
|
||||
if (moveToCenter) {
|
||||
SearchApisHolder.getStatusManager().setUserInteractionStatus(TAG, true, false)
|
||||
SearchApisHolder.getUiControllerApis().moveToCenter(current.position, true)
|
||||
SearchApisHolder.getUiControllerApis().moveToCenter(current.position, CarSeries.CAR_SERIES_F80X == CarSeries.getSeries())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,10 +224,6 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(category: String): Fragment {
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(SearchApisHolder.getUiControllerApis(), Scene.CATEGORY_SEARCH)
|
||||
|
||||
@@ -19,6 +19,4 @@ public interface CategoryView extends IView {
|
||||
* @param datums
|
||||
*/
|
||||
void renderSearchPoiResult(List<MogoPoiItem> datums);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user