aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/rssin/android/FilterActivity.java10
-rwxr-xr-xapp/src/main/java/org/rssin/rssin/Filter.java28
-rw-r--r--app/src/main/res/values/strings.xml2
3 files changed, 37 insertions, 3 deletions
diff --git a/app/src/main/java/org/rssin/android/FilterActivity.java b/app/src/main/java/org/rssin/android/FilterActivity.java
index b8631db..5d57977 100644
--- a/app/src/main/java/org/rssin/android/FilterActivity.java
+++ b/app/src/main/java/org/rssin/android/FilterActivity.java
@@ -91,6 +91,16 @@ public class FilterActivity extends ActionBarActivity {
return super.onOptionsItemSelected(item);
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ try {
+ filter.storeFeedSorter(DefaultStorageProvider.getInstance(this));
+ } catch (Exception e) {
+ Toast.makeText(this, getResources().getString(R.string.error_save_feedsorter), Toast.LENGTH_SHORT).show();
+ }
+ }
+
/**
* Custom ArrayAdapter to display Keywords
*/
diff --git a/app/src/main/java/org/rssin/rssin/Filter.java b/app/src/main/java/org/rssin/rssin/Filter.java
index 2e1188e..a66f955 100755
--- a/app/src/main/java/org/rssin/rssin/Filter.java
+++ b/app/src/main/java/org/rssin/rssin/Filter.java
@@ -133,8 +133,30 @@ public class Filter implements Storable {
* @param storageProvider
* @throws Exception
*/
- public synchronized void storeFeedSorter(StorageProvider storageProvider) throws Exception {
- ensureFeedSorter(storageProvider);
- storageProvider.store(storageKey, feedSorter);
+ public synchronized void storeFeedSorter(StorageProvider storageProvider) {
+ Thread thread = new Thread(new FeedSorterStorer(storageKey, storageProvider, feedSorter));
+ thread.start();
+ }
+
+ private class FeedSorterStorer implements Runnable {
+ private final Object storageKey;
+ private final StorageProvider storageProvider;
+ private final FeedSorter feedSorter;
+
+ public FeedSorterStorer(Object storageKey, StorageProvider storageProvider, FeedSorter feedSorter) {
+ this.storageKey = storageKey;
+ this.storageProvider = storageProvider;
+ this.feedSorter = feedSorter;
+ }
+
+ @Override
+ public void run() {
+ ensureFeedSorter(storageProvider);
+ try {
+ storageProvider.store(storageKey, feedSorter);
+ } catch (Exception e) {
+ Log.e("Filter", "Failed to store FeedSorter", e);
+ }
+ }
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index da60e14..09d325e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -29,4 +29,6 @@
<string name="error_invalid_url">Invalid URL</string>
<string name="error_net_load">Internet problem</string>
+
+ <string name="error_save_feedsorter">Couldn\'t store personal preferences</string>
</resources>