1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-01-12 18:30:32 +00:00

Fixed crash in Subscriptions section

This commit is contained in:
Somethingweirdhere 2018-06-08 21:27:50 +02:00
parent c9b267b072
commit 97b26596d2

View File

@ -13,6 +13,7 @@ import android.os.Parcelable;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
@ -239,8 +240,15 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
} }
private void onImportFromServiceSelected(int serviceId) { private void onImportFromServiceSelected(int serviceId) {
if (getParentFragment() == null) return; FragmentManager fragmentManager;
NavigationHelper.openSubscriptionsImportFragment(getParentFragment().getFragmentManager(), serviceId);
if (getParentFragment() == null)
{
fragmentManager = getFragmentManager();
} else {
fragmentManager = getParentFragment().getFragmentManager();
}
NavigationHelper.openSubscriptionsImportFragment(fragmentManager, serviceId);
} }
private void onImportPreviousSelected() { private void onImportPreviousSelected() {
@ -318,15 +326,32 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
infoListAdapter.setOnChannelSelectedListener(new OnClickGesture<ChannelInfoItem>() { infoListAdapter.setOnChannelSelectedListener(new OnClickGesture<ChannelInfoItem>() {
@Override @Override
public void selected(ChannelInfoItem selectedItem) { public void selected(ChannelInfoItem selectedItem) {
// Requires the parent fragment to find holder for fragment replacement FragmentManager fragmentManager;
NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(),
if (getParentFragment() == null)
{
fragmentManager = getFragmentManager();
} else {
fragmentManager = getParentFragment().getFragmentManager();
}
NavigationHelper.openChannelFragment(fragmentManager,
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName()); selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
} }
}); });
//noinspection ConstantConditions //noinspection ConstantConditions
whatsNewItemListHeader.setOnClickListener(v -> 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()); importExportListHeader.setOnClickListener(v -> importExportOptions.switchState());
} }