@Test public void testMakeItemTag() { final FragmentManager mockFragmentManager = mock(FragmentManager.class); final FragmentPagerAdapter adapter = new Adapter(mockFragmentManager); for (int i = 0; i < 10; i++) { assertThat(adapter.makeItemTag(android.R.id.list, i), is("android:pager:" + CONTAINER_ID + ":" + i)); } adapter.setMakeItemTags(false); assertThat(adapter.makeItemTag(android.R.id.list, 10), is(nullValue())); }
@Nullable protected String makeItemTag(@IdRes final int containerId, final long itemId) { return makeItemTags ? "android:pager:" + containerId + ":" + itemId : null; }
FragmentPagerAdapter extends PagerAdapter { @Nullable protected String makeItemTag(@IdRes final int containerId, final long itemId) { return makeItemTags ? "android:pager:" + containerId + ":" + itemId : null; } }
FragmentPagerAdapter extends PagerAdapter { @Nullable protected String makeItemTag(@IdRes final int containerId, final long itemId) { return makeItemTags ? "android:pager:" + containerId + ":" + itemId : null; } FragmentPagerAdapter(@NonNull final FragmentManager fragmentManager); }
FragmentPagerAdapter extends PagerAdapter { @Nullable protected String makeItemTag(@IdRes final int containerId, final long itemId) { return makeItemTags ? "android:pager:" + containerId + ":" + itemId : null; } 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 { @Nullable protected String makeItemTag(@IdRes final int containerId, final long itemId) { return makeItemTags ? "android:pager:" + containerId + ":" + itemId : null; } 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; }