Skip to content

Commit

Permalink
Fix reblog animation executed
Browse files Browse the repository at this point in the history
This commit fix the reblog button animation executed while viewing a
thread and executing other action than reblog.
  • Loading branch information
captainepoch committed Jul 10, 2024
1 parent cd5d1c8 commit c610904
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private void callReblogService(final Status status, final boolean reblog, final
.observeOn(AndroidSchedulers.mainThread())
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY)))
.subscribe(
(newStatus) -> updateStatus(position, status),
(newStatus) -> updateStatus(position, status, reblog),
(err) -> Timber.e(
err,
"Failed to reblog status %s, Error[%s]",
Expand All @@ -333,7 +333,7 @@ public void onFavourite(final boolean favourite, final int position) {

timelineCases.getValue().favourite(statuses.get(position), favourite)
.observeOn(AndroidSchedulers.mainThread()).as(autoDisposable(from(this)))
.subscribe((newStatus) -> updateStatus(position, newStatus),
.subscribe((newStatus) -> updateStatus(position, newStatus, false),
(t) -> Log.d(TAG, "Failed to favourite status: " + status.getId(), t));
}

Expand All @@ -343,18 +343,21 @@ public void onBookmark(final boolean bookmark, final int position) {

timelineCases.getValue().bookmark(statuses.get(position), bookmark)
.observeOn(AndroidSchedulers.mainThread()).as(autoDisposable(from(this)))
.subscribe((newStatus) -> updateStatus(position, newStatus),
.subscribe((newStatus) -> updateStatus(position, newStatus, false),
(t) -> Log.d(TAG, "Failed to bookmark status: " + status.getId(), t));
}

private void updateStatus(int position, Status status) {
// TODO: remove boolean reblog because it's a nasty hack
private void updateStatus(int position, Status status, boolean reblog) {
if(position >= 0 && position < statuses.size()) {
Status actionableStatus = status.getActionableStatus();

if (!actionableStatus.getReblogged() && recyclerView != null) {
ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
if (holder instanceof StatusViewHolder || holder instanceof StatusDetailedViewHolder) {
((StatusBaseViewHolder) holder).reblogButtonAnimate();
if (reblog) {
if (!actionableStatus.getReblogged() && recyclerView != null) {
ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
if (holder instanceof StatusViewHolder || holder instanceof StatusDetailedViewHolder) {
((StatusBaseViewHolder) holder).reblogButtonAnimate();
}
}
}

Expand Down

0 comments on commit c610904

Please sign in to comment.