Initialize variable directly before using

This commit is contained in:
ByteHamster 2020-01-01 14:34:04 +01:00
parent 5fc6877a87
commit c409d1c0a6
1 changed files with 3 additions and 7 deletions

View File

@ -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.