Skip to content

Commit

Permalink
Move the code that checks if the Fragment is still attached closer to…
Browse files Browse the repository at this point in the history
… the code that actually use the activity
  • Loading branch information
daniloercoli committed Mar 21, 2024
1 parent ae0e624 commit 88e9cab
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2321,14 +2321,19 @@ private void updateCurrentTagIfTime() {
new Thread() {
@Override
public void run() {
// Check the fragment is attached to the activity when this Thread starts.
FragmentActivity activity = getActivity();
if (activity == null) {
return;
}
if (ReaderTagTable.shouldAutoUpdateTag(getCurrentTag()) && isAdded()) {
// Check the fragment is attached right after `shouldAutoUpdateTag`
FragmentActivity activity = getActivity();
if (activity == null) {
return;
}
activity.runOnUiThread(() -> updateCurrentTag());
} else {
// Check the fragment is attached to the activity when this Thread starts.
FragmentActivity activity = getActivity();
if (activity == null) {
return;
}
activity.runOnUiThread(() -> {
if (isBookmarksList() && isPostAdapterEmpty() && isAdded()) {
setEmptyTitleAndDescriptionForBookmarksList();
Expand Down

0 comments on commit 88e9cab

Please sign in to comment.