diff options
author | ByteHamster <info@bytehamster.com> | 2020-01-07 12:28:12 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-01-07 12:28:12 +0100 |
commit | fcfcb9223a1ef5724cbbf6050b87e5c5c1dd8ba3 (patch) | |
tree | b95021f027758b9079833171a4244aedb2d0e2b1 /app/src | |
parent | a8b126221c3ae4a4e449cd090963e2403e2c3dd3 (diff) | |
download | AntennaPod-fcfcb9223a1ef5724cbbf6050b87e5c5c1dd8ba3.zip |
Make episode filter persistent
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index 3949a03a9..fdb74fa64 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -1,5 +1,7 @@ package de.danoeh.antennapod.fragment; +import android.content.Context; +import android.content.SharedPreferences; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.recyclerview.widget.LinearLayoutManager; @@ -20,6 +22,8 @@ import de.danoeh.antennapod.dialog.FilterDialog; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Set; @@ -32,12 +36,13 @@ public class AllEpisodesFragment extends EpisodesListFragment { public static final String TAG = "AllEpisodesFragment"; private static final String PREF_NAME = "PrefAllEpisodesFragment"; + private static final String PREF_FILTER = "filter"; private static final int EPISODES_PER_PAGE = 150; private static final int VISIBLE_EPISODES_SCROLL_THRESHOLD = 5; private static int page = 1; - private static FeedItemFilter feedItemFilter = new FeedItemFilter(""); + private FeedItemFilter feedItemFilter = new FeedItemFilter(""); @Override protected boolean showOnlyNewEpisodes() { @@ -69,6 +74,9 @@ public class AllEpisodesFragment extends EpisodesListFragment { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = super.onCreateView(inflater, container, savedInstanceState); + SharedPreferences prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + feedItemFilter = new FeedItemFilter(prefs.getString(PREF_FILTER, "")); + recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { /* Total number of episodes after last load */ @@ -146,7 +154,9 @@ public class AllEpisodesFragment extends EpisodesListFragment { FilterDialog filterDialog = new FilterDialog(getContext(), feedItemFilter) { @Override protected void updateFilter(Set<String> filterValues) { - feedItemFilter = new FeedItemFilter(filterValues.toArray(new String[filterValues.size()])); + feedItemFilter = new FeedItemFilter(filterValues.toArray(new String[0])); + SharedPreferences prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + prefs.edit().putString(PREF_FILTER, StringUtils.join(filterValues, ",")).apply(); loadItems(); } }; |