Fixes #1930069. Prevents NPE in GesturesActivity. Ensures the store is always != null.

This commit is contained in:
Romain Guy 2009-07-17 16:17:40 -07:00
parent 27f98955ad
commit 6c8bbcb5a2
2 changed files with 7 additions and 7 deletions

View File

@ -81,7 +81,7 @@ public class GesturesActivity extends ListActivity implements AdapterView.OnItem
setListAdapter(new GesturesSettingsAdapter(mAdapter)); setListAdapter(new GesturesSettingsAdapter(mAdapter));
getListView().setOnItemClickListener(this); getListView().setOnItemClickListener(this);
mStore = Launcher.getGestureLibrary(); mStore = Launcher.getGestureLibrary(this);
mTask = (GesturesLoadTask) new GesturesLoadTask().execute(); mTask = (GesturesLoadTask) new GesturesLoadTask().execute();
registerForContextMenu(getListView()); registerForContextMenu(getListView());

View File

@ -246,11 +246,7 @@ public final class Launcher extends Activity implements View.OnClickListener, On
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mInflater = getLayoutInflater(); mInflater = getLayoutInflater();
if (sLibrary == null) { getGestureLibrary(this);
// The context is not kept by the library so it's safe to do this
sLibrary = GestureLibraries.fromPrivateFile(Launcher.this,
GesturesConstants.STORE_NAME);
}
mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetManager = AppWidgetManager.getInstance(this);
@ -1983,7 +1979,11 @@ public final class Launcher extends Activity implements View.OnClickListener, On
return sModel; return sModel;
} }
static GestureLibrary getGestureLibrary() { static GestureLibrary getGestureLibrary(Context context) {
if (sLibrary == null) {
// The context is not kept by the library so it's safe to do this
sLibrary = GestureLibraries.fromPrivateFile(context, GesturesConstants.STORE_NAME);
}
return sLibrary; return sLibrary;
} }