From b2c0ed69f6da6751bdc30fecbefc31bb983a5024 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sat, 7 Jul 2018 12:09:15 +0200 Subject: [PATCH] fix crash in ViewThreadFragment --- .../keylesspalace/tusky/ViewThreadActivity.java | 15 ++++++++------- .../tusky/fragment/ViewThreadFragment.java | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java index 1518e6cf2..2033134e4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java @@ -26,7 +26,6 @@ import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; -import com.keylesspalace.tusky.entity.Status; import com.keylesspalace.tusky.fragment.ViewThreadFragment; import com.keylesspalace.tusky.util.LinkHelper; @@ -49,12 +48,9 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor return intent; } - public static Intent startIntentFromStatus(Context context, Status status) { - return startIntent(context, status.getActionableId(), status.getActionableStatus().getUrl()); - } - private static final String ID_EXTRA = "id"; private static final String URL_EXTRA = "url"; + private static final String FRAGMENT_TAG = "ViewThreadFragment_"; private int revealButtonState = REVEAL_BUTTON_HIDDEN; @@ -78,9 +74,14 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor } String id = getIntent().getStringExtra(ID_EXTRA); + + fragment = (ViewThreadFragment)getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG + id); + if(fragment == null) { + fragment = ViewThreadFragment.newInstance(id); + } + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); - fragment = ViewThreadFragment.newInstance(id); - fragmentTransaction.replace(R.id.fragment_container, fragment); + fragmentTransaction.replace(R.id.fragment_container, fragment, FRAGMENT_TAG + id); fragmentTransaction.commit(); } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java index 7beb62785..8cc4e7f60 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java @@ -144,7 +144,6 @@ public final class ViewThreadFragment extends SFragment implements }); } - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {