@Test(expected = IllegalStateException.class) public void testStartUpdateWithViewWithoutId() { final FragmentManager mockFragmentManager = mock(FragmentManager.class); final FragmentPagerAdapter adapter = new Adapter(mockFragmentManager); adapter.startUpdate(new FrameLayout(context)); }
@Override public void startUpdate(@NonNull final ViewGroup container) { if (container.getId() == View.NO_ID) throw new IllegalStateException( "ViewPager with adapter " + this + " requires a view id!" ); }
FragmentPagerAdapter extends PagerAdapter { @Override public void startUpdate(@NonNull final ViewGroup container) { if (container.getId() == View.NO_ID) throw new IllegalStateException( "ViewPager with adapter " + this + " requires a view id!" ); } }
FragmentPagerAdapter extends PagerAdapter { @Override public void startUpdate(@NonNull final ViewGroup container) { if (container.getId() == View.NO_ID) throw new IllegalStateException( "ViewPager with adapter " + this + " requires a view id!" ); } FragmentPagerAdapter(@NonNull final FragmentManager fragmentManager); }
FragmentPagerAdapter extends PagerAdapter { @Override public void startUpdate(@NonNull final ViewGroup container) { if (container.getId() == View.NO_ID) throw new IllegalStateException( "ViewPager with adapter " + this + " requires a view id!" ); } FragmentPagerAdapter(@NonNull final FragmentManager fragmentManager); @Override void startUpdate(@NonNull final ViewGroup container); @SuppressLint("CommitTransaction") @Override @NonNull Object instantiateItem(@NonNull final ViewGroup container, final int position); long getItemId(final int position); @NonNull abstract Fragment getItem(int position); @Override void setPrimaryItem(@NonNull final ViewGroup container, final int position, @Nullable final Object object); @Nullable Fragment getPrimaryFragment(); @IntRange(from = NO_POSITION) int getPrimaryPosition(); @Override boolean isViewFromObject(@NonNull final View view, @NonNull final Object object); @SuppressLint("CommitTransaction") @Override void destroyItem(@NonNull final ViewGroup container, final int position, @NonNull final Object object); @Override void finishUpdate(@NonNull final ViewGroup container); }
FragmentPagerAdapter extends PagerAdapter { @Override public void startUpdate(@NonNull final ViewGroup container) { if (container.getId() == View.NO_ID) throw new IllegalStateException( "ViewPager with adapter " + this + " requires a view id!" ); } FragmentPagerAdapter(@NonNull final FragmentManager fragmentManager); @Override void startUpdate(@NonNull final ViewGroup container); @SuppressLint("CommitTransaction") @Override @NonNull Object instantiateItem(@NonNull final ViewGroup container, final int position); long getItemId(final int position); @NonNull abstract Fragment getItem(int position); @Override void setPrimaryItem(@NonNull final ViewGroup container, final int position, @Nullable final Object object); @Nullable Fragment getPrimaryFragment(); @IntRange(from = NO_POSITION) int getPrimaryPosition(); @Override boolean isViewFromObject(@NonNull final View view, @NonNull final Object object); @SuppressLint("CommitTransaction") @Override void destroyItem(@NonNull final ViewGroup container, final int position, @NonNull final Object object); @Override void finishUpdate(@NonNull final ViewGroup container); static final int NO_POSITION; static final long NO_ID; }