Search in sources :

Example 1 with FragmentStatePagerAdapter

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);
}
Also used : FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) Fragment(androidx.fragment.app.Fragment) PlaylistPagerFragment(com.naman14.timber.subfragments.PlaylistPagerFragment)

Example 2 with FragmentStatePagerAdapter

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;
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) MultiViewPager(com.naman14.timber.widgets.MultiViewPager) View(android.view.View) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist)

Example 3 with FragmentStatePagerAdapter

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;
}
Also used : FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) View(android.view.View) Fragment(androidx.fragment.app.Fragment)

Example 4 with FragmentStatePagerAdapter

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");
    }
}
Also used : FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) ScrollView(android.widget.ScrollView) FragmentPagerAdapter(androidx.fragment.app.FragmentPagerAdapter) AbsListView(android.widget.AbsListView) RecyclerView(androidx.recyclerview.widget.RecyclerView) WebView(android.webkit.WebView) Fragment(androidx.fragment.app.Fragment) PagerAdapter(androidx.viewpager.widget.PagerAdapter) FragmentPagerAdapter(androidx.fragment.app.FragmentPagerAdapter) FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter)

Aggregations

FragmentStatePagerAdapter (androidx.fragment.app.FragmentStatePagerAdapter)4 Fragment (androidx.fragment.app.Fragment)3 View (android.view.View)2 WebView (android.webkit.WebView)1 AbsListView (android.widget.AbsListView)1 ScrollView (android.widget.ScrollView)1 FragmentPagerAdapter (androidx.fragment.app.FragmentPagerAdapter)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 PagerAdapter (androidx.viewpager.widget.PagerAdapter)1 ArtistInfoListener (com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener)1 ArtistQuery (com.naman14.timber.lastfmapi.models.ArtistQuery)1 LastfmArtist (com.naman14.timber.lastfmapi.models.LastfmArtist)1 Artist (com.naman14.timber.models.Artist)1 PlaylistPagerFragment (com.naman14.timber.subfragments.PlaylistPagerFragment)1 MultiViewPager (com.naman14.timber.widgets.MultiViewPager)1