Skip to content

Commit

Permalink
Fix sort order of articles on app restart
Browse files Browse the repository at this point in the history
When restarting the app, now the articles get sorted in the way they
were ordered before. This is done by not only checking the
savedInstanceState for sorting order but also the settings.

Close wallabag#797
Close wallabag#781
Close wallabag#713
  • Loading branch information
NWuensche committed Aug 17, 2019
1 parent 261e83b commit 321abd5
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.List;

import fr.gaulupeau.apps.InThePoche.R;
import fr.gaulupeau.apps.Poche.data.Settings;

public abstract class RecyclerViewListFragment<T> extends Fragment
implements Sortable, Searchable {
Expand Down Expand Up @@ -59,7 +60,16 @@ public void onCreate(Bundle savedInstanceState) {
searchQuery = savedInstanceState.getString(STATE_SEARCH_QUERY);
}
}
if(sortOrder == null) sortOrder = Sortable.SortOrder.DESC;

if(sortOrder == null) {
// Try getting sortOrder from settings
if(this.getContext() != null) {
Settings settings = new Settings(this.getContext());
sortOrder = settings.getListSortOrder();
} else {
sortOrder = Sortable.SortOrder.DESC;
}
}

itemList = new ArrayList<>();

Expand Down

0 comments on commit 321abd5

Please sign in to comment.