Rename the WikivoyageSearchCore to a WikivoyageSearchHelper
This commit is contained in:
parent
8dbc2df22a
commit
927ed3c58f
2 changed files with 13 additions and 12 deletions
|
@ -21,14 +21,15 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||
import net.osmand.plus.wikivoyage.WikivoyageArticleDialogFragment;
|
||||
import net.osmand.plus.wikivoyage.data.SearchResult;
|
||||
import net.osmand.plus.wikivoyage.search.WikivoyageSearchHelper.SearchListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment implements WikivoyageSearchCore.SearchListener {
|
||||
public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment implements SearchListener {
|
||||
|
||||
public static final String TAG = "WikivoyageSearchDialogFragment";
|
||||
|
||||
private WikivoyageSearchCore searchCore;
|
||||
private WikivoyageSearchHelper searchHelper;
|
||||
private String searchQuery = "";
|
||||
|
||||
private SearchRecyclerViewAdapter adapter;
|
||||
|
@ -41,7 +42,7 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment imp
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
searchCore = new WikivoyageSearchCore(app);
|
||||
searchHelper = new WikivoyageSearchHelper(app);
|
||||
final boolean nightMode = !app.getSettings().isLightContent();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
|
@ -75,12 +76,12 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment imp
|
|||
public void afterTextChanged(Editable s) {
|
||||
String newQuery = s.toString();
|
||||
if (newQuery.isEmpty()) {
|
||||
searchCore.cancelSearch();
|
||||
searchHelper.cancelSearch();
|
||||
switchProgressBarVisibility(false);
|
||||
adapter.setItems(null);
|
||||
} else if (!searchQuery.equalsIgnoreCase(newQuery)) {
|
||||
searchQuery = newQuery;
|
||||
searchCore.search(searchQuery);
|
||||
searchHelper.search(searchQuery);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -116,8 +117,8 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment imp
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (searchCore != null) {
|
||||
searchCore.registerListener(this);
|
||||
if (searchHelper != null) {
|
||||
searchHelper.registerListener(this);
|
||||
}
|
||||
searchEt.requestFocus();
|
||||
}
|
||||
|
@ -125,9 +126,9 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment imp
|
|||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (searchCore != null) {
|
||||
searchCore.unregisterListener(this);
|
||||
searchCore.cancelSearch();
|
||||
if (searchHelper != null) {
|
||||
searchHelper.unregisterListener(this);
|
||||
searchHelper.cancelSearch();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class WikivoyageSearchCore {
|
||||
public class WikivoyageSearchHelper {
|
||||
|
||||
private static final int TIMEOUT_BETWEEN_CHARS = 700;
|
||||
private static final int SLEEP_TIME = 50;
|
||||
|
@ -26,7 +26,7 @@ public class WikivoyageSearchCore {
|
|||
private OsmandApplication application;
|
||||
private Set<SearchListener> listeners = new HashSet<>();
|
||||
|
||||
WikivoyageSearchCore(OsmandApplication application) {
|
||||
WikivoyageSearchHelper(OsmandApplication application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
Loading…
Reference in a new issue