From c97d74b3706ca2ffdb54725d1c03f47d2bc2aec9 Mon Sep 17 00:00:00 2001 From: Alex Fong Date: Thu, 19 May 2016 16:48:56 +0800 Subject: Changed HashMap to ArrayList --- .../keychain/ui/BackupRestoreFragment.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'OpenKeychain/src/main/java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java index 81198fdb3..e8c4196f2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupRestoreFragment.java @@ -17,9 +17,8 @@ package org.sufficientlysecure.keychain.ui; -import java.util.HashMap; +import java.util.ArrayList; import java.util.Iterator; -import java.util.Map; import android.app.Activity; import android.content.ContentResolver; @@ -31,6 +30,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; +import android.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -47,7 +47,7 @@ import org.sufficientlysecure.keychain.util.FileHelper; public class BackupRestoreFragment extends Fragment { // masterKeyId & subKeyId for multi-key export - private Iterator> mIdsForRepeatAskPassphrase; + private Iterator> mIdsForRepeatAskPassphrase; private static final int REQUEST_REPEAT_PASSPHRASE = 0x00007002; private static final int REQUEST_CODE_INPUT = 0x00007003; @@ -95,10 +95,10 @@ public class BackupRestoreFragment extends Fragment { return; } - new AsyncTask>() { + new AsyncTask>>() { @Override - protected HashMap doInBackground(ContentResolver... resolver) { - HashMap askPassphraseIds = new HashMap<>(); + protected ArrayList> doInBackground(ContentResolver... resolver) { + ArrayList> askPassphraseIds = new ArrayList<>(); Cursor cursor = resolver[0].query( KeyRings.buildUnifiedKeyRingsUri(), new String[]{ KeyRings.MASTER_KEY_ID, @@ -118,13 +118,13 @@ public class BackupRestoreFragment extends Fragment { Long masterKeyId = cursor.getLong(0); Long subKeyId = getFirstSubKeyWithPassphrase(masterKeyId, resolver[0]); if(subKeyId != null) { - askPassphraseIds.put(masterKeyId, subKeyId); + askPassphraseIds.add(new Pair<>(masterKeyId, subKeyId)); } continue; } default: { long masterKeyId = cursor.getLong(0); - askPassphraseIds.put(masterKeyId, masterKeyId); + askPassphraseIds.add(new Pair<>(masterKeyId, masterKeyId)); } } } @@ -169,14 +169,14 @@ public class BackupRestoreFragment extends Fragment { } @Override - protected void onPostExecute(HashMap askPassphraseIds) { + protected void onPostExecute(ArrayList> askPassphraseIds) { super.onPostExecute(askPassphraseIds); FragmentActivity activity = getActivity(); if (activity == null) { return; } - mIdsForRepeatAskPassphrase = askPassphraseIds.entrySet().iterator(); + mIdsForRepeatAskPassphrase = askPassphraseIds.iterator(); if (mIdsForRepeatAskPassphrase.hasNext()) { startPassphraseActivity(); @@ -196,9 +196,9 @@ public class BackupRestoreFragment extends Fragment { } Intent intent = new Intent(activity, PassphraseDialogActivity.class); - Map.Entry keyPair = mIdsForRepeatAskPassphrase.next(); - long masterKeyId = keyPair.getKey(); - long subKeyId = keyPair.getValue(); + Pair keyPair = mIdsForRepeatAskPassphrase.next(); + long masterKeyId = keyPair.first; + long subKeyId = keyPair.second; RequiredInputParcel requiredInput = RequiredInputParcel.createRequiredDecryptPassphrase(masterKeyId, subKeyId); requiredInput.mSkipCaching = true; -- cgit v1.2.3