Merge pull request #3713 from ByteHamster/initialize-variable-before-use

Initialize variable directly before using
This commit is contained in:
H. Lehmann 2020-01-01 21:32:41 +01:00 committed by GitHub
commit c668464968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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.