1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Fixed crash in Subscriptions section

This commit is contained in:
Somethingweirdhere 2018-06-08 21:27:50 +02:00 committed by Christian Schabesberger
parent 54b21c716a
commit edb75c4bab

View File

@ -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.app.AppCompatActivity;
@ -241,8 +242,15 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
}
private void onImportFromServiceSelected(int serviceId) {
if (getParentFragment() == null) return;
NavigationHelper.openSubscriptionsImportFragment(getParentFragment().getFragmentManager(), serviceId);
FragmentManager fragmentManager;
if (getParentFragment() == null)
{
fragmentManager = getFragmentManager();
} else {
fragmentManager = getParentFragment().getFragmentManager();
}
NavigationHelper.openSubscriptionsImportFragment(fragmentManager, serviceId);
}
private void onImportPreviousSelected() {
@ -321,20 +329,35 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
@Override
public void selected(ChannelInfoItem selectedItem) {
try {
final FragmentManager fragmentManager = getParentFragment() == null
? getFragmentManager()
: getParentFragment().getFragmentManager();
// Requires the parent fragment to find holder for fragment replacement
NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(),
NavigationHelper.openChannelFragment(fragmentManager,
selectedItem.getServiceId(),
selectedItem.getUrl(),
selectedItem.getName());
} catch (Exception e) {
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
}
}
});
//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());
}