fix nullpointer, cleanup

This commit is contained in:
Dominik Schürmann 2014-07-02 16:47:12 +02:00
parent 94a58f3aa8
commit 13a13829a8
3 changed files with 9 additions and 10 deletions

View File

@ -73,7 +73,7 @@ public class EditKeyFragment extends LoaderFragment implements
private View mAddKey;
private static final int LOADER_ID_USER_IDS = 0;
private static final int LOADER_ID_KEYS = 1;
private static final int LOADER_ID_SUBKEYS = 1;
private UserIdsAdapter mUserIdsAdapter;
private SubkeysAdapter mSubkeysAdapter;
@ -202,7 +202,7 @@ public class EditKeyFragment extends LoaderFragment implements
// Prepare the loaders. Either re-connect with an existing ones,
// or start new ones.
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this);
getLoaderManager().initLoader(LOADER_ID_KEYS, null, this);
getLoaderManager().initLoader(LOADER_ID_SUBKEYS, null, this);
}
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
@ -215,10 +215,10 @@ public class EditKeyFragment extends LoaderFragment implements
UserIdsAdapter.USER_IDS_PROJECTION, null, null, null);
}
case LOADER_ID_KEYS: {
case LOADER_ID_SUBKEYS: {
Uri baseUri = KeychainContract.Keys.buildKeysUri(mDataUri);
return new CursorLoader(getActivity(), baseUri,
SubkeysAdapter.KEYS_PROJECTION, null, null, null);
SubkeysAdapter.SUBKEYS_PROJECTION, null, null, null);
}
default:
@ -234,7 +234,7 @@ public class EditKeyFragment extends LoaderFragment implements
mUserIdsAdapter.swapCursor(data);
break;
case LOADER_ID_KEYS:
case LOADER_ID_SUBKEYS:
mSubkeysAdapter.swapCursor(data);
break;
@ -251,7 +251,7 @@ public class EditKeyFragment extends LoaderFragment implements
case LOADER_ID_USER_IDS:
mUserIdsAdapter.swapCursor(null);
break;
case LOADER_ID_KEYS:
case LOADER_ID_SUBKEYS:
mSubkeysAdapter.swapCursor(null);
break;
}

View File

@ -87,7 +87,7 @@ public class ViewKeyKeysFragment extends LoaderFragment implements
setContentShown(false);
Uri baseUri = Keys.buildKeysUri(mDataUri);
return new CursorLoader(getActivity(), baseUri,
SubkeysAdapter.KEYS_PROJECTION, null, null, null);
SubkeysAdapter.SUBKEYS_PROJECTION, null, null, null);
}
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

View File

@ -42,7 +42,7 @@ public class SubkeysAdapter extends CursorAdapter {
private ColorStateList mDefaultTextColor;
public static final String[] KEYS_PROJECTION = new String[]{
public static final String[] SUBKEYS_PROJECTION = new String[]{
Keys._ID,
Keys.KEY_ID,
Keys.RANK,
@ -80,8 +80,7 @@ public class SubkeysAdapter extends CursorAdapter {
@Override
public Cursor swapCursor(Cursor newCursor) {
hasAnySecret = false;
if (newCursor != null) {
newCursor.moveToFirst();
if (newCursor != null && newCursor.moveToFirst()) {
do {
if (newCursor.getInt(INDEX_HAS_SECRET) != 0) {
hasAnySecret = true;