mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Bug 1018240 - Part 2: invalidate BrowserSearch engine list when locale has changed. r=bnicholson
This commit is contained in:
parent
f704f37465
commit
e782441df2
@ -56,7 +56,10 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Fragment that displays frecency search results in a ListView.
|
||||
@ -104,8 +107,14 @@ public class BrowserSearch extends HomeFragment
|
||||
// Client that performs search suggestion queries
|
||||
private volatile SuggestClient mSuggestClient;
|
||||
|
||||
// List of search engines from gecko
|
||||
private ArrayList<SearchEngine> mSearchEngines;
|
||||
// List of search engines from Gecko.
|
||||
// Do not mutate this list.
|
||||
// Access to this member must only occur from the UI thread.
|
||||
private List<SearchEngine> mSearchEngines;
|
||||
|
||||
// Track the locale that was last in use when we filled mSearchEngines.
|
||||
// Access to this member must only occur from the UI thread.
|
||||
private Locale mLastLocale;
|
||||
|
||||
// Whether search suggestions are enabled or not
|
||||
private boolean mSuggestionsEnabled;
|
||||
@ -227,6 +236,11 @@ public class BrowserSearch extends HomeFragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// Fetch engines if we need to.
|
||||
if (mSearchEngines.isEmpty() || !Locale.getDefault().equals(mLastLocale)) {
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
|
||||
}
|
||||
|
||||
Telemetry.startUISession(TelemetryContract.Session.FRECENCY);
|
||||
}
|
||||
|
||||
@ -325,8 +339,6 @@ public class BrowserSearch extends HomeFragment
|
||||
registerForContextMenu(mList);
|
||||
EventDispatcher.getInstance().registerGeckoThreadListener(this,
|
||||
"SearchEngines:Data");
|
||||
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -506,11 +518,15 @@ public class BrowserSearch extends HomeFragment
|
||||
}
|
||||
|
||||
private void setSuggestions(ArrayList<String> suggestions) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
mSearchEngines.get(0).setSuggestions(suggestions);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void setSearchEngines(JSONObject data) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
// This method is called via a Runnable posted from the Gecko thread, so
|
||||
// it's possible the fragment and/or its view has been destroyed by the
|
||||
// time we get here. If so, just abort.
|
||||
@ -555,7 +571,8 @@ public class BrowserSearch extends HomeFragment
|
||||
}
|
||||
}
|
||||
|
||||
mSearchEngines = searchEngines;
|
||||
mSearchEngines = Collections.unmodifiableList(searchEngines);
|
||||
mLastLocale = Locale.getDefault();
|
||||
|
||||
if (mAdapter != null) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
Loading…
Reference in New Issue
Block a user