forked from organicmaps/organicmaps
[android] Added search cancel before another search start
This commit is contained in:
parent
ab684a5dfd
commit
a01a6f9c48
5 changed files with 28 additions and 26 deletions
|
@ -598,28 +598,19 @@ extern "C"
|
|||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_search_SearchEngine_nativeCancelInteractiveSearch(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, []()
|
||||
{
|
||||
g_framework->NativeFramework()->CancelSearch(search::Mode::Viewport);
|
||||
});
|
||||
g_framework->NativeFramework()->CancelSearch(search::Mode::Viewport);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_search_SearchEngine_nativeCancelEverywhereSearch(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, []()
|
||||
{
|
||||
g_framework->NativeFramework()->CancelSearch(search::Mode::Everywhere);
|
||||
});
|
||||
g_framework->NativeFramework()->CancelSearch(search::Mode::Everywhere);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_search_SearchEngine_nativeCancelAllSearches(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, []()
|
||||
{
|
||||
g_framework->NativeFramework()->CancelAllSearches();
|
||||
});
|
||||
g_framework->NativeFramework()->CancelAllSearches();
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
|
|
|
@ -480,7 +480,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
args.putBoolean(DownloaderActivity.EXTRA_OPEN_DOWNLOADED, openDownloaded);
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
SearchEngine.cancelAllSearches();
|
||||
SearchEngine.cancel();
|
||||
mSearchController.refreshToolbar();
|
||||
replaceFragment(MapManager.nativeIsLegacyMode() ? MigrationFragment.class : DownloaderFragment.class, args, null);
|
||||
}
|
||||
|
@ -609,6 +609,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void runSearch()
|
||||
{
|
||||
SearchEngine.cancel();
|
||||
SearchEngine.searchInteractive(mSearchController.getQuery(), System.nanoTime(),
|
||||
false /* isMapAndTable */,
|
||||
mFilterController != null ? mFilterController.getFilter() : null,
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.mapswithme.maps.search;
|
|||
import android.app.Activity;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.widget.SearchToolbarController;
|
||||
|
@ -85,8 +86,7 @@ public class FloatingSearchToolbarController extends SearchToolbarController
|
|||
|
||||
private void cancelSearchApiAndHide(boolean clearText)
|
||||
{
|
||||
SearchEngine.cancelApiCall();
|
||||
SearchEngine.cancelInteractiveSearch();
|
||||
SearchEngine.cancel();
|
||||
|
||||
if (clearText)
|
||||
clear();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mapswithme.maps.search;
|
||||
|
||||
import android.support.annotation.MainThread;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
|
@ -117,6 +118,7 @@ public enum SearchEngine implements NativeSearchListener,
|
|||
* @param timestamp Search results are filtered according to it after multiple requests.
|
||||
* @return whether search was actually started.
|
||||
*/
|
||||
@MainThread
|
||||
public static boolean search(String query, long timestamp, boolean hasLocation,
|
||||
double lat, double lon, @Nullable HotelsFilter hotelsFilter,
|
||||
@Nullable BookingFilterParams bookingParams)
|
||||
|
@ -130,6 +132,7 @@ public enum SearchEngine implements NativeSearchListener,
|
|||
return false;
|
||||
}
|
||||
|
||||
@MainThread
|
||||
public static void searchInteractive(@NonNull String query, @NonNull String locale, long timestamp,
|
||||
boolean isMapAndTable, @Nullable HotelsFilter hotelsFilter,
|
||||
@Nullable BookingFilterParams bookingParams)
|
||||
|
@ -141,12 +144,14 @@ public enum SearchEngine implements NativeSearchListener,
|
|||
} catch (UnsupportedEncodingException ignored) { }
|
||||
}
|
||||
|
||||
@MainThread
|
||||
public static void searchInteractive(@NonNull String query, long timestamp, boolean isMapAndTable,
|
||||
@Nullable HotelsFilter hotelsFilter, @Nullable BookingFilterParams bookingParams)
|
||||
{
|
||||
searchInteractive(query, Language.getKeyboardLocale(), timestamp, isMapAndTable, hotelsFilter, bookingParams);
|
||||
}
|
||||
|
||||
@MainThread
|
||||
public static void searchMaps(String query, long timestamp)
|
||||
{
|
||||
try
|
||||
|
@ -166,31 +171,35 @@ public enum SearchEngine implements NativeSearchListener,
|
|||
return sSavedQuery;
|
||||
}
|
||||
|
||||
public static void cancelApiCall()
|
||||
@MainThread
|
||||
public static void cancel()
|
||||
{
|
||||
cancelApiCall();
|
||||
cancelAllSearches();
|
||||
}
|
||||
@MainThread
|
||||
private static void cancelApiCall()
|
||||
{
|
||||
if (ParsedMwmRequest.hasRequest())
|
||||
ParsedMwmRequest.setCurrentRequest(null);
|
||||
Framework.nativeClearApiPoints();
|
||||
}
|
||||
|
||||
@MainThread
|
||||
public static void cancelInteractiveSearch()
|
||||
{
|
||||
sSavedQuery = "";
|
||||
nativeCancelInteractiveSearch();
|
||||
}
|
||||
|
||||
public static void cancelEverywhereSearch()
|
||||
{
|
||||
sSavedQuery = "";
|
||||
nativeCancelEverywhereSearch();
|
||||
}
|
||||
|
||||
public static void cancelAllSearches()
|
||||
@MainThread
|
||||
private static void cancelAllSearches()
|
||||
{
|
||||
sSavedQuery = "";
|
||||
nativeCancelAllSearches();
|
||||
}
|
||||
|
||||
@MainThread
|
||||
public static void showResult(int index)
|
||||
{
|
||||
sSavedQuery = "";
|
||||
|
|
|
@ -547,7 +547,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
{
|
||||
final String query = getQuery();
|
||||
SearchRecents.add(query);
|
||||
SearchEngine.cancelApiCall();
|
||||
SearchEngine.cancel();
|
||||
|
||||
if (!RoutingController.get().isWaitingPoiPick())
|
||||
SearchEngine.showResult(resultIndex);
|
||||
|
@ -598,8 +598,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
|
||||
private void stopSearch()
|
||||
{
|
||||
SearchEngine.cancelApiCall();
|
||||
SearchEngine.cancelAllSearches();
|
||||
SearchEngine.cancel();
|
||||
updateSearchView();
|
||||
}
|
||||
|
||||
|
@ -611,6 +610,8 @@ public class SearchFragment extends BaseMwmFragment
|
|||
|
||||
private void runSearch()
|
||||
{
|
||||
SearchEngine.cancel();
|
||||
|
||||
HotelsFilter hotelsFilter = null;
|
||||
BookingFilterParams bookingFilterParams = null;
|
||||
if (mFilterController != null)
|
||||
|
|
Loading…
Add table
Reference in a new issue