From c409d1c0a63ec95851fc8f9a74c2e0e3de744286 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 1 Jan 2020 14:34:04 +0100 Subject: [PATCH] Initialize variable directly before using --- .../danoeh/antennapod/fragment/ItemPagerFragment.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java index fdac649d1..20188a8a6 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemPagerFragment.java @@ -50,9 +50,6 @@ public class ItemPagerFragment extends Fragment { * @return The ItemFragment instance */ public static ItemPagerFragment newInstance(long[] feeditems, int feedItemPos) { - if (feeditems.length <= feedItemPos) { - throw new IllegalArgumentException("Trying to show a feed item that is out of the list"); - } ItemPagerFragment fragment = new ItemPagerFragment(); Bundle args = new Bundle(); args.putLongArray(ARG_FEEDITEMS, feeditems); @@ -62,7 +59,6 @@ public class ItemPagerFragment extends Fragment { } private long[] feedItems; - private int feedItemPos; private FeedItem item; private Disposable disposable; @@ -70,9 +66,6 @@ public class ItemPagerFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); - - feedItems = getArguments().getLongArray(ARG_FEEDITEMS); - feedItemPos = getArguments().getInt(ARG_FEEDITEM_POS); } @Override @@ -81,6 +74,9 @@ public class ItemPagerFragment extends Fragment { super.onCreateView(inflater, container, savedInstanceState); View layout = inflater.inflate(R.layout.feeditem_pager_fragment, container, false); + feedItems = getArguments().getLongArray(ARG_FEEDITEMS); + int feedItemPos = getArguments().getInt(ARG_FEEDITEM_POS); + ViewPager pager = layout.findViewById(R.id.pager); // FragmentStatePagerAdapter documentation: // > When using FragmentStatePagerAdapter the host ViewPager must have a valid ID set.