mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
fix nullpointer, cleanup
This commit is contained in:
parent
94a58f3aa8
commit
13a13829a8
@ -73,7 +73,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
private View mAddKey;
|
private View mAddKey;
|
||||||
|
|
||||||
private static final int LOADER_ID_USER_IDS = 0;
|
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 UserIdsAdapter mUserIdsAdapter;
|
||||||
private SubkeysAdapter mSubkeysAdapter;
|
private SubkeysAdapter mSubkeysAdapter;
|
||||||
@ -202,7 +202,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
// Prepare the loaders. Either re-connect with an existing ones,
|
// Prepare the loaders. Either re-connect with an existing ones,
|
||||||
// or start new ones.
|
// or start new ones.
|
||||||
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this);
|
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) {
|
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);
|
UserIdsAdapter.USER_IDS_PROJECTION, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
case LOADER_ID_KEYS: {
|
case LOADER_ID_SUBKEYS: {
|
||||||
Uri baseUri = KeychainContract.Keys.buildKeysUri(mDataUri);
|
Uri baseUri = KeychainContract.Keys.buildKeysUri(mDataUri);
|
||||||
return new CursorLoader(getActivity(), baseUri,
|
return new CursorLoader(getActivity(), baseUri,
|
||||||
SubkeysAdapter.KEYS_PROJECTION, null, null, null);
|
SubkeysAdapter.SUBKEYS_PROJECTION, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -234,7 +234,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
mUserIdsAdapter.swapCursor(data);
|
mUserIdsAdapter.swapCursor(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOADER_ID_KEYS:
|
case LOADER_ID_SUBKEYS:
|
||||||
mSubkeysAdapter.swapCursor(data);
|
mSubkeysAdapter.swapCursor(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
case LOADER_ID_USER_IDS:
|
case LOADER_ID_USER_IDS:
|
||||||
mUserIdsAdapter.swapCursor(null);
|
mUserIdsAdapter.swapCursor(null);
|
||||||
break;
|
break;
|
||||||
case LOADER_ID_KEYS:
|
case LOADER_ID_SUBKEYS:
|
||||||
mSubkeysAdapter.swapCursor(null);
|
mSubkeysAdapter.swapCursor(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class ViewKeyKeysFragment extends LoaderFragment implements
|
|||||||
setContentShown(false);
|
setContentShown(false);
|
||||||
Uri baseUri = Keys.buildKeysUri(mDataUri);
|
Uri baseUri = Keys.buildKeysUri(mDataUri);
|
||||||
return new CursorLoader(getActivity(), baseUri,
|
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) {
|
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||||
|
@ -42,7 +42,7 @@ public class SubkeysAdapter extends CursorAdapter {
|
|||||||
|
|
||||||
private ColorStateList mDefaultTextColor;
|
private ColorStateList mDefaultTextColor;
|
||||||
|
|
||||||
public static final String[] KEYS_PROJECTION = new String[]{
|
public static final String[] SUBKEYS_PROJECTION = new String[]{
|
||||||
Keys._ID,
|
Keys._ID,
|
||||||
Keys.KEY_ID,
|
Keys.KEY_ID,
|
||||||
Keys.RANK,
|
Keys.RANK,
|
||||||
@ -80,8 +80,7 @@ public class SubkeysAdapter extends CursorAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public Cursor swapCursor(Cursor newCursor) {
|
public Cursor swapCursor(Cursor newCursor) {
|
||||||
hasAnySecret = false;
|
hasAnySecret = false;
|
||||||
if (newCursor != null) {
|
if (newCursor != null && newCursor.moveToFirst()) {
|
||||||
newCursor.moveToFirst();
|
|
||||||
do {
|
do {
|
||||||
if (newCursor.getInt(INDEX_HAS_SECRET) != 0) {
|
if (newCursor.getInt(INDEX_HAS_SECRET) != 0) {
|
||||||
hasAnySecret = true;
|
hasAnySecret = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user