forked from organicmaps/organicmaps
[android] Changed search POI behaviour.
This commit is contained in:
parent
dee0e3e7d7
commit
a1f2adc6e6
5 changed files with 26 additions and 53 deletions
|
@ -1611,7 +1611,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (controller.isPlanning() || controller.isBuilding() || controller.isErrorEncountered())
|
||||
{
|
||||
if (showAddStartOrFinishFrame(controller, true))
|
||||
{
|
||||
if (completion != null)
|
||||
completion.run();
|
||||
return;
|
||||
}
|
||||
|
||||
showLineFrame(false, new Runnable()
|
||||
{
|
||||
|
|
|
@ -18,7 +18,6 @@ import android.widget.TextView;
|
|||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.api.RoutePoint;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
|
@ -43,7 +42,6 @@ import java.util.concurrent.TimeUnit;
|
|||
public class RoutingController
|
||||
{
|
||||
private static final String TAG = RoutingController.class.getSimpleName();
|
||||
private static final int NO_SLOT = 0;
|
||||
|
||||
private enum State
|
||||
{
|
||||
|
@ -89,7 +87,7 @@ public class RoutingController
|
|||
|
||||
private BuildState mBuildState = BuildState.NONE;
|
||||
private State mState = State.NONE;
|
||||
private int mWaitingPoiPickSlot = NO_SLOT;
|
||||
private boolean mWaitingPoiPick;
|
||||
|
||||
@Nullable
|
||||
private MapObject mStartPoint;
|
||||
|
@ -523,7 +521,7 @@ public class RoutingController
|
|||
mStartPoint = null;
|
||||
mEndPoint = null;
|
||||
setPointsInternal();
|
||||
mWaitingPoiPickSlot = NO_SLOT;
|
||||
mWaitingPoiPick = false;
|
||||
mUberRequestHandled = false;
|
||||
|
||||
setBuildState(BuildState.NONE);
|
||||
|
@ -611,7 +609,7 @@ public class RoutingController
|
|||
|
||||
public boolean isWaitingPoiPick()
|
||||
{
|
||||
return (mWaitingPoiPickSlot != NO_SLOT);
|
||||
return mWaitingPoiPick;
|
||||
}
|
||||
|
||||
public boolean isUberRequestHandled()
|
||||
|
@ -835,22 +833,9 @@ public class RoutingController
|
|||
|
||||
void searchPoi()
|
||||
{
|
||||
if (mStartPoint == null)
|
||||
{
|
||||
searchPoi(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEndPoint == null)
|
||||
searchPoi(2);
|
||||
}
|
||||
|
||||
void searchPoi(int slotId)
|
||||
{
|
||||
mLogger.d(TAG, "searchPoi: " + slotId);
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_SEARCH_POINT);
|
||||
AlohaHelper.logClick(AlohaHelper.ROUTING_SEARCH_POINT);
|
||||
mWaitingPoiPickSlot = slotId;
|
||||
mWaitingPoiPick = true;
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.showSearch();
|
||||
|
@ -858,31 +843,24 @@ public class RoutingController
|
|||
}
|
||||
}
|
||||
|
||||
private void onPoiSelectedInternal(@Nullable MapObject point, int slot)
|
||||
public void onPoiSelected(@Nullable MapObject point)
|
||||
{
|
||||
if (point != null)
|
||||
mWaitingPoiPick = false;
|
||||
|
||||
if (point != null && point.getMapObjectType() == MapObject.MY_POSITION)
|
||||
{
|
||||
if (slot == 1)
|
||||
if (mStartPoint == null)
|
||||
setStartPoint(point);
|
||||
else
|
||||
else if (mEndPoint == null)
|
||||
setEndPoint(point);
|
||||
}
|
||||
|
||||
if (mContainer == null)
|
||||
return;
|
||||
|
||||
mContainer.updateMenu();
|
||||
showRoutePlan();
|
||||
}
|
||||
|
||||
public void onPoiSelected(@Nullable MapObject point)
|
||||
{
|
||||
int slot = mWaitingPoiPickSlot;
|
||||
mWaitingPoiPickSlot = NO_SLOT;
|
||||
|
||||
onPoiSelectedInternal(point, slot);
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.updatePoints();
|
||||
mContainer.updateMenu();
|
||||
showRoutePlan();
|
||||
}
|
||||
}
|
||||
|
||||
public static CharSequence formatRoutingTime(Context context, int seconds, @DimenRes int unitsSize)
|
||||
|
|
|
@ -182,13 +182,13 @@ public class RoutingPlanController extends ToolbarController implements SlotFram
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
RoutingController.get().searchPoi(order);
|
||||
RoutingController.get().searchPoi();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
RoutingController.get().searchPoi(order);
|
||||
RoutingController.get().searchPoi();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder>
|
|||
@Override
|
||||
void processClick(SearchResult result, int order)
|
||||
{
|
||||
mSearchFragment.showSingleResultOnMap(result, order);
|
||||
mSearchFragment.showSingleResultOnMap(order);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ import com.mapswithme.maps.MwmApplication;
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
import com.mapswithme.maps.ads.Banner;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.downloader.CountrySuggestFragment;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
|
@ -462,15 +460,10 @@ public class SearchFragment extends BaseMwmFragment
|
|||
return false;
|
||||
}
|
||||
|
||||
private void processSelected(SearchResult result)
|
||||
private void processSelected()
|
||||
{
|
||||
if (mFromRoutePlan)
|
||||
{
|
||||
//noinspection ConstantConditions
|
||||
final MapObject point = new MapObject("", 0L, 0, MapObject.SEARCH, result.name, "",
|
||||
result.description.featureType, "", result.lat, result.lon, "", null, false, "", null, null);
|
||||
RoutingController.get().onPoiSelected(point);
|
||||
}
|
||||
RoutingController.get().onPoiSelected(null);
|
||||
|
||||
mToolbarController.deactivate();
|
||||
|
||||
|
@ -478,16 +471,14 @@ public class SearchFragment extends BaseMwmFragment
|
|||
Utils.navigateToParent(getActivity());
|
||||
}
|
||||
|
||||
void showSingleResultOnMap(SearchResult result, int resultIndex)
|
||||
void showSingleResultOnMap(int resultIndex)
|
||||
{
|
||||
final String query = getQuery();
|
||||
SearchRecents.add(query);
|
||||
SearchEngine.cancelApiCall();
|
||||
|
||||
if (!mFromRoutePlan)
|
||||
SearchEngine.showResult(resultIndex);
|
||||
|
||||
processSelected(result);
|
||||
SearchEngine.showResult(resultIndex);
|
||||
processSelected();
|
||||
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.SEARCH_ITEM_CLICKED);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue