@Test public void testIsViewFromObject() { final FragmentManager mockFragmentManager = mock(FragmentManager.class); final FragmentStatePagerAdapter adapter = new Adapter(mockFragmentManager); final Fragment mockFragment = mock(Fragment.class); final View view = new View(context); when(mockFragment.getView()).thenReturn(view); assertThat(adapter.isViewFromObject(view, mockFragment), is(true)); when(mockFragment.getView()).thenReturn(new View(context)); assertThat(adapter.isViewFromObject(view, mockFragment), is(false)); }
@Override public boolean isViewFromObject(@NonNull final View view, @NonNull final Object object) { return ((Fragment) object).getView() == view; }
FragmentStatePagerAdapter extends PagerAdapter { @Override public boolean isViewFromObject(@NonNull final View view, @NonNull final Object object) { return ((Fragment) object).getView() == view; } }
FragmentStatePagerAdapter extends PagerAdapter { @Override public boolean isViewFromObject(@NonNull final View view, @NonNull final Object object) { return ((Fragment) object).getView() == view; } FragmentStatePagerAdapter(@NonNull final FragmentManager fragmentManager); }
FragmentStatePagerAdapter extends PagerAdapter { @Override public boolean isViewFromObject(@NonNull final View view, @NonNull final Object object) { return ((Fragment) object).getView() == view; } FragmentStatePagerAdapter(@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); @Override Parcelable saveState(); @Override void restoreState(@Nullable final Parcelable state, @Nullable final ClassLoader loader); }
FragmentStatePagerAdapter extends PagerAdapter { @Override public boolean isViewFromObject(@NonNull final View view, @NonNull final Object object) { return ((Fragment) object).getView() == view; } FragmentStatePagerAdapter(@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); @Override Parcelable saveState(); @Override void restoreState(@Nullable final Parcelable state, @Nullable final ClassLoader loader); static final int NO_POSITION; static final long NO_ID; }