Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
* Ask permission when entering the general preferences.
* fix #230: page not loading because of '$' signs.
* fix #232: user profiles in private messages.
* fix #233: on the topic list, keep the filter (Favorites, Read...) when rotating the screen

## v1.0.1

### Fixed

* #2 : reply window opened multiple times
* #8 : event received too late in activity lifecycle
* #9 : nullpointer exception in user manager
* #2: reply window opened multiple times
* #8: event received too late in activity lifecycle
* #9: nullpointer exception in user manager

## v1.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import android.content.Context;

import androidx.annotation.NonNull;

import com.ayuget.redface.R;

public enum TopicFilter {
Expand All @@ -26,6 +28,7 @@ public enum TopicFilter {
PARTICIPATED,
READ;

@NonNull
public String resolve(Context context) {
if (this == NONE) {
return context.getResources().getString(R.string.action_topics_filter_all);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
@FragmentWithArgs
public class TopicListFragment extends ToggleToolbarFragment implements TopicsAdapter.OnTopicClickedListener {
private static final String ARG_LAST_LOADED_PAGE = "last_loaded_page";
private static final String ARG_TOPIC_FILTER = "topic_filter";

/**
* Interface definition for a callback to be invoked when a topic in this fragment has
Expand Down Expand Up @@ -133,6 +134,13 @@ public TopicListFragment() {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Restore the list of topics when the fragment is recreated by the framework
if (savedInstanceState != null) {
lastLoadedPage = savedInstanceState.getInt(ARG_LAST_LOADED_PAGE, 0);
topicFilter = (TopicFilter) savedInstanceState.get(ARG_TOPIC_FILTER);
savedInstanceState.clear();
}

if (topicFilter == null) {
topicFilter = TopicFilter.NONE;
}
Expand Down Expand Up @@ -188,17 +196,6 @@ private void refreshTopicList() {
loadTopics();
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

// Restore the list of topics when the fragment is recreated by the framework
if (savedInstanceState != null) {
lastLoadedPage = savedInstanceState.getInt(ARG_LAST_LOADED_PAGE, 0);
savedInstanceState.clear();
}
}

@Override
public void onResume() {
super.onResume();
Expand All @@ -209,7 +206,7 @@ public void onResume() {
refreshTopicList();
});

if (displayedTopics == null || displayedTopics.size() == 0 || settings.refreshTopicList()) {
if (displayedTopics == null || displayedTopics.isEmpty() || settings.refreshTopicList()) {
displayedTopics = new ArrayList<>();
loadTopics();
} else {
Expand Down Expand Up @@ -299,6 +296,7 @@ public void onCreateOptionsMenu(Toolbar toolbar) {
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(ARG_LAST_LOADED_PAGE, lastLoadedPage);
outState.putSerializable(ARG_TOPIC_FILTER, topicFilter);
}

@Override
Expand Down Expand Up @@ -379,7 +377,7 @@ public void onNext(List<Topic> loadedTopics) {
public void onError(Throwable throwable) {
Timber.e(throwable, "Error loading first page for category '%s', subcategory '%s'", category.name(), subcategory);

if (displayedTopics.size() == 0) {
if (displayedTopics.isEmpty()) {
dataPresenter.showErrorView();
} else {
SnackbarHelper.make(TopicListFragment.this, R.string.error_loading_topics).show();
Expand Down