mirror of
https://github.com/tuskyapp/Tusky
synced 2025-02-09 13:08:47 +01:00
Fix thread view showing button but not collapsing by implementing the feature
This commit is contained in:
parent
b2dbd16678
commit
ba7ccf97de
@ -503,6 +503,8 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||
setSpoilerText(status.getSpoilerText(), status.getStatusEmojis(), status.isExpanded(), listener);
|
||||
}
|
||||
|
||||
// When viewing threads this ViewHolder is used and the main post does not have a collapse
|
||||
// button by design so avoid crashing the app when that happens
|
||||
if(contentCollapseButton != null) {
|
||||
if(status.isCollapsible() && (status.isExpanded() || status.getSpoilerText() == null || status.getSpoilerText().isEmpty())) {
|
||||
contentCollapseButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
@ -55,6 +55,7 @@ import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
||||
import com.keylesspalace.tusky.network.MastodonApi;
|
||||
import com.keylesspalace.tusky.network.TimelineCases;
|
||||
import com.keylesspalace.tusky.util.PairedList;
|
||||
import com.keylesspalace.tusky.util.SmartLengthInputFilter;
|
||||
import com.keylesspalace.tusky.util.ThemeUtils;
|
||||
import com.keylesspalace.tusky.util.ViewDataUtils;
|
||||
import com.keylesspalace.tusky.view.ConversationLineItemDecoration;
|
||||
@ -361,7 +362,32 @@ public final class ViewThreadFragment extends SFragment implements
|
||||
|
||||
@Override
|
||||
public void onContentCollapsedChange(boolean isCollapsed, int position) {
|
||||
// No need to implement this method as status threads always show all content in a status.
|
||||
if(position < 0 || position >= statuses.size()) {
|
||||
Log.e(TAG, String.format("Tried to access out of bounds status position: %d of %d", position, statuses.size() - 1));
|
||||
return;
|
||||
}
|
||||
|
||||
StatusViewData.Concrete status = statuses.getPairedItem(position);
|
||||
if(status == null) {
|
||||
// Statuses PairedList contains a base type of StatusViewData.Concrete and also doesn't
|
||||
// check for null values when adding values to it although this doesn't seem to be an issue.
|
||||
Log.e(TAG, String.format(
|
||||
"Expected StatusViewData.Concrete, got null instead at position: %d of %d",
|
||||
position,
|
||||
statuses.size() - 1
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
StatusViewData.Concrete updatedStatus = new StatusViewData.Builder(status)
|
||||
.setCollapsible(collapseLongStatusContent && !SmartLengthInputFilter.hasBadRatio(
|
||||
status.getContent(),
|
||||
SmartLengthInputFilter.LENGTH_DEFAULT
|
||||
))
|
||||
.setCollapsed(isCollapsed)
|
||||
.createStatusViewData();
|
||||
statuses.setPairedItem(position, updatedStatus);
|
||||
recyclerView.post(() -> adapter.setItem(position, updatedStatus, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user