Fix timeline breaking due to newly introduced variables in utils classes

This commit is contained in:
HellPie 2018-08-31 02:17:56 +02:00 committed by HellPie
parent 73dc85a115
commit 95976d6869
2 changed files with 20 additions and 2 deletions

View File

@ -146,6 +146,7 @@ public class TimelineFragment extends SFragment implements
private boolean didLoadEverythingBottom;
private boolean alwaysShowSensitiveMedia;
private boolean collapseLongStatusContent;
@Override
protected TimelineCases timelineCases() {
@ -158,7 +159,11 @@ public class TimelineFragment extends SFragment implements
public StatusViewData apply(Either<Placeholder, Status> input) {
Status status = input.getAsRightOrNull();
if (status != null) {
return ViewDataUtils.statusToViewData(status, alwaysShowSensitiveMedia);
return ViewDataUtils.statusToViewData(
status,
alwaysShowSensitiveMedia,
collapseLongStatusContent
);
} else {
Placeholder placeholder = input.getAsLeft();
return new StatusViewData.Placeholder(placeholder.id, false);
@ -262,6 +267,8 @@ public class TimelineFragment extends SFragment implements
filterRemoveRegexMatcher = Pattern.compile(regexFilter, Pattern.CASE_INSENSITIVE)
.matcher("");
}
collapseLongStatusContent = preferences.getBoolean("collapseLongStatuses", true);
}
private void setupSwipeRefreshLayout() {
@ -687,7 +694,12 @@ public class TimelineFragment extends SFragment implements
case "alwaysShowSensitiveMedia": {
//it is ok if only newly loaded statuses are affected, no need to fully refresh
alwaysShowSensitiveMedia = sharedPreferences.getBoolean("alwaysShowSensitiveMedia", false);
break;
}
case "collapseLongStatuses":
// As for "always show sensitive media" settings, only apply this to newer posts
collapseLongStatusContent = sharedPreferences.getBoolean("collapseLongStatuses", true);
break;
}
}

View File

@ -91,6 +91,7 @@ public final class ViewThreadFragment extends SFragment implements
private String thisThreadsStatusId;
private Card card;
private boolean alwaysShowSensitiveMedia;
private boolean collapseLongStatusContent;
private int statusIndex = 0;
@ -98,7 +99,11 @@ public final class ViewThreadFragment extends SFragment implements
new PairedList<>(new Function<Status, StatusViewData.Concrete>() {
@Override
public StatusViewData.Concrete apply(Status input) {
return ViewDataUtils.statusToViewData(input, alwaysShowSensitiveMedia);
return ViewDataUtils.statusToViewData(
input,
alwaysShowSensitiveMedia,
collapseLongStatusContent
);
}
});
@ -154,6 +159,7 @@ public final class ViewThreadFragment extends SFragment implements
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(
getActivity());
alwaysShowSensitiveMedia = preferences.getBoolean("alwaysShowSensitiveMedia", false);
collapseLongStatusContent = preferences.getBoolean("collapseLongStatuses", true);
boolean mediaPreviewEnabled = preferences.getBoolean("mediaPreviewEnabled", true);
adapter.setMediaPreviewEnabled(mediaPreviewEnabled);
recyclerView.setAdapter(adapter);