From 97b26596d24ae60c7e6f9474dc5659f1092bd6e9 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Fri, 8 Jun 2018 21:27:50 +0200 Subject: [PATCH] Fixed crash in Subscriptions section --- .../subscription/SubscriptionFragment.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java index 5f6ea42ee..83bf849c5 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.java @@ -13,6 +13,7 @@ import android.os.Parcelable; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.app.FragmentManager; import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.ActionBar; import android.support.v7.widget.LinearLayoutManager; @@ -239,8 +240,15 @@ public class SubscriptionFragment extends BaseStateFragment() { @Override public void selected(ChannelInfoItem selectedItem) { - // Requires the parent fragment to find holder for fragment replacement - NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(), + FragmentManager fragmentManager; + + if (getParentFragment() == null) + { + fragmentManager = getFragmentManager(); + } else { + fragmentManager = getParentFragment().getFragmentManager(); + } + NavigationHelper.openChannelFragment(fragmentManager, selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName()); } }); //noinspection ConstantConditions whatsNewItemListHeader.setOnClickListener(v -> - NavigationHelper.openWhatsNewFragment(getParentFragment().getFragmentManager())); + { + FragmentManager fragmentManager; + + if (getParentFragment() == null) + { + fragmentManager = getFragmentManager(); + } else { + fragmentManager = getParentFragment().getFragmentManager(); + } + NavigationHelper.openWhatsNewFragment(fragmentManager); + }); importExportListHeader.setOnClickListener(v -> importExportOptions.switchState()); }