use of androidx.fragment.app.FragmentStatePagerAdapter in project Timber by naman14.
the class PlaylistFragment method initPager.
private void initPager() {
pager.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
recyclerView.setAdapter(null);
adapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {
@Override
public int getCount() {
return playlistcount;
}
@Override
public Fragment getItem(int position) {
return PlaylistPagerFragment.newInstance(position);
}
};
pager.setAdapter(adapter);
pager.setOffscreenPageLimit(3);
}
use of androidx.fragment.app.FragmentStatePagerAdapter in project Timber by naman14.
the class ArtistBioFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_artist_bio, container, false);
Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
}
@Override
public void artistInfoFailed() {
}
});
final MultiViewPager pager = (MultiViewPager) rootView.findViewById(R.id.tagspager);
final FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getActivity().getSupportFragmentManager()) {
@Override
public int getCount() {
return 20;
}
@Override
public Fragment getItem(int position) {
return ArtistTagFragment.newInstance(position);
}
};
pager.setAdapter(adapter);
return rootView;
}
use of androidx.fragment.app.FragmentStatePagerAdapter in project Timber by naman14.
the class StyleSelectorFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_style_selector, container, false);
if (ACTION.equals(Constants.SETTINGS_STYLE_SELECTOR_NOWPLAYING)) {
}
pager = (MultiViewPager) rootView.findViewById(R.id.pager);
adapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {
@Override
public int getCount() {
return 6;
}
@Override
public Fragment getItem(int position) {
selectorFragment = SubStyleSelectorFragment.newInstance(position, ACTION);
return selectorFragment;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
};
pager.setAdapter(adapter);
scrollToCurrentStyle();
return rootView;
}
use of androidx.fragment.app.FragmentStatePagerAdapter in project BGARefreshLayout-Android by bingoogolapple.
the class BGAStickyNavLayout method regetNestedContentView.
/**
* 重新获取嵌套的内容视图
*/
private void regetNestedContentView() {
int currentItem = mDirectViewPager.getCurrentItem();
PagerAdapter adapter = mDirectViewPager.getAdapter();
if (adapter instanceof FragmentPagerAdapter || adapter instanceof FragmentStatePagerAdapter) {
Fragment item = (Fragment) adapter.instantiateItem(mDirectViewPager, currentItem);
mNestedContentView = item.getView();
// 清空之前的
mNestedNormalView = null;
mNestedAbsListView = null;
mNestedRecyclerView = null;
mNestedScrollView = null;
mNestedWebView = null;
if (mNestedContentView instanceof AbsListView) {
mNestedAbsListView = (AbsListView) mNestedContentView;
mNestedAbsListView.setOnScrollListener(mLvOnScrollListener);
if (!isHeaderViewCompleteInvisible()) {
mNestedAbsListView.setSelection(0);
}
} else if (mNestedContentView instanceof RecyclerView) {
mNestedRecyclerView = (RecyclerView) mNestedContentView;
mNestedRecyclerView.removeOnScrollListener(mRvOnScrollListener);
mNestedRecyclerView.addOnScrollListener(mRvOnScrollListener);
if (!isHeaderViewCompleteInvisible()) {
mNestedRecyclerView.scrollToPosition(0);
}
} else if (mNestedContentView instanceof ScrollView) {
mNestedScrollView = (ScrollView) mNestedContentView;
if (!isHeaderViewCompleteInvisible()) {
mNestedScrollView.scrollTo(mNestedScrollView.getScrollX(), 0);
}
} else if (mNestedContentView instanceof WebView) {
mNestedWebView = (WebView) mNestedContentView;
if (!isHeaderViewCompleteInvisible()) {
mNestedWebView.scrollTo(mNestedWebView.getScrollX(), 0);
}
} else {
mNestedNormalView = mNestedContentView;
}
} else {
throw new IllegalStateException(BGAStickyNavLayout.class.getSimpleName() + "的第三个子控件为ViewPager时,其adapter必须是FragmentPagerAdapter或者FragmentStatePagerAdapter");
}
}
Aggregations