mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
parametrize FileImportCache for filename
This commit is contained in:
parent
c00343d516
commit
aa625d4fbf
@ -25,7 +25,7 @@ public class FileImportCacheTest {
|
||||
@Test
|
||||
public void testInputOutput() throws Exception {
|
||||
|
||||
FileImportCache<Bundle> cache = new FileImportCache<Bundle>(Robolectric.application);
|
||||
FileImportCache<Bundle> cache = new FileImportCache<Bundle>(Robolectric.application, "test.pcl");
|
||||
|
||||
ArrayList<Bundle> list = new ArrayList<Bundle>();
|
||||
|
||||
|
@ -477,7 +477,7 @@ public class KeychainIntentService extends IntentService
|
||||
} else {
|
||||
// get entries from cached file
|
||||
FileImportCache<ParcelableKeyRing> cache =
|
||||
new FileImportCache<ParcelableKeyRing>(this);
|
||||
new FileImportCache<ParcelableKeyRing>(this, "key_import.pcl");
|
||||
entries = cache.readCacheIntoList();
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,8 @@ public class ImportKeysActivity extends ActionBarActivity {
|
||||
// to prevent Java Binder problems on heavy imports
|
||||
// read FileImportCache for more info.
|
||||
try {
|
||||
FileImportCache<ParcelableKeyRing> cache = new FileImportCache<ParcelableKeyRing>(this);
|
||||
FileImportCache<ParcelableKeyRing> cache =
|
||||
new FileImportCache<ParcelableKeyRing>(this, "key_import.pcl");
|
||||
cache.writeCache(selectedEntries);
|
||||
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
@ -46,10 +46,11 @@ public class FileImportCache<E extends Parcelable> {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private static final String FILENAME = "key_import.pcl";
|
||||
private final String mFilename;
|
||||
|
||||
public FileImportCache(Context context) {
|
||||
this.mContext = context;
|
||||
public FileImportCache(Context context, String filename) {
|
||||
mContext = context;
|
||||
mFilename = filename;
|
||||
}
|
||||
|
||||
public void writeCache(ArrayList<E> selectedEntries) throws IOException {
|
||||
@ -64,7 +65,7 @@ public class FileImportCache<E extends Parcelable> {
|
||||
throw new IOException("cache dir is null!");
|
||||
}
|
||||
|
||||
File tempFile = new File(mContext.getCacheDir(), FILENAME);
|
||||
File tempFile = new File(mContext.getCacheDir(), mFilename);
|
||||
|
||||
DataOutputStream oos = new DataOutputStream(new FileOutputStream(tempFile));
|
||||
|
||||
@ -98,7 +99,7 @@ public class FileImportCache<E extends Parcelable> {
|
||||
throw new IOException("cache dir is null!");
|
||||
}
|
||||
|
||||
final File tempFile = new File(cacheDir, FILENAME);
|
||||
final File tempFile = new File(cacheDir, mFilename);
|
||||
final DataInputStream ois = new DataInputStream(new FileInputStream(tempFile));
|
||||
|
||||
return new Iterator<E>() {
|
||||
|
Loading…
Reference in New Issue
Block a user