Bug 962047 - Default search engines are not displayed after turning on search suggestions. r=margaret

This commit is contained in:
Chenxia Liu 2014-01-23 15:35:28 -08:00
Родитель 9fe218dee9
Коммит 2b3a75ff8e
2 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -80,8 +80,12 @@ public abstract class CustomListPreference extends Preference implements View.On
protected abstract int getPreferenceLayoutResource();
/**
* Set whether this object's UI should display this as the default item. To ensure proper ordering,
* this method should only be called after this Preference is added to the PreferenceCategory.
* Set whether this object's UI should display this as the default item.
* Note: This must be called from the UI thread because it touches the view hierarchy.
*
* To ensure proper ordering, this method should only be called after this Preference
* is added to the PreferenceCategory.
*
* @param isDefault Flag indicating if this represents the default list item.
*/
public void setIsDefault(boolean isDefault) {

Просмотреть файл

@ -16,6 +16,7 @@ import org.json.JSONObject;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.ThreadUtils;
public class SearchPreferenceCategory extends CustomListCategory implements GeckoEventListener {
public static final String LOGTAG = "SearchPrefCategory";
@ -81,7 +82,7 @@ public class SearchPreferenceCategory extends CustomListCategory implements Geck
JSONObject engineJSON = engines.getJSONObject(i);
final String engineName = engineJSON.getString("name");
SearchEnginePreference enginePreference = new SearchEnginePreference(getContext(), this);
final SearchEnginePreference enginePreference = new SearchEnginePreference(getContext(), this);
enginePreference.setSearchEngineFromJSON(engineJSON);
enginePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
@ -100,7 +101,12 @@ public class SearchPreferenceCategory extends CustomListCategory implements Geck
// We set this here, not in setSearchEngineFromJSON, because it allows us to
// keep a reference to the default engine to use when the AlertDialog
// callbacks are used.
enginePreference.setIsDefault(true);
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
enginePreference.setIsDefault(true);
}
});
mDefaultReference = enginePreference;
}
} catch (JSONException e) {