Search in sources :

Example 1 with AnalyticsManager

use of com.simplecity.amp_library.utils.AnalyticsManager in project Shuttle by timusus.

the class LibraryController method setupViewPager.

private void setupViewPager() {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    CategoryItem.getCategoryItems(sharedPreferences);
    if (pagerAdapter != null && refreshPagerAdapter) {
        pagerAdapter.removeAllChildFragments();
        refreshPagerAdapter = false;
        pager.setAdapter(null);
    }
    int defaultPage = 1;
    pagerAdapter = new PagerAdapter(getChildFragmentManager());
    List<CategoryItem> categoryItems = Stream.of(CategoryItem.getCategoryItems(sharedPreferences)).filter(categoryItem -> categoryItem.isChecked).toList();
    int defaultPageType = settingsManager.getDefaultPageType();
    for (int i = 0; i < categoryItems.size(); i++) {
        CategoryItem categoryItem = categoryItems.get(i);
        pagerAdapter.addFragment(categoryItem.getFragment(getContext()));
        if (categoryItem.type == defaultPageType) {
            defaultPage = i;
        }
    }
    int currentPage = Math.min(defaultPage, pagerAdapter.getCount());
    pager.setAdapter(pagerAdapter);
    pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
    pager.setCurrentItem(currentPage);
    slidingTabLayout.setupWithViewPager(pager);
    pager.postDelayed(() -> {
        if (pager != null) {
            new RatingSnackbar(settingsManager, analyticsManager).show(pager, () -> {
                ShuttleUtils.openShuttleLink(getActivity(), getActivity().getPackageName(), getActivity().getPackageManager());
                return Unit.INSTANCE;
            });
        }
    }, 1000);
}
Also used : R(com.simplecity.amp_library.R) Genre(com.simplecity.amp_library.model.Genre) NavigationEventRelay(com.simplecity.amp_library.ui.screens.drawer.NavigationEventRelay) Bundle(android.os.Bundle) PlaylistDetailFragment(com.simplecity.amp_library.ui.screens.playlist.detail.PlaylistDetailFragment) AlbumDetailFragment(com.simplecity.amp_library.ui.screens.album.detail.AlbumDetailFragment) Rx.onErrorLogAndRethrow(com.afollestad.aesthetic.Rx.onErrorLogAndRethrow) CategoryItem(com.simplecity.amp_library.model.CategoryItem) AnalyticsManager(com.simplecity.amp_library.utils.AnalyticsManager) PagerAdapter(com.simplecity.amp_library.ui.adapters.PagerAdapter) BindView(butterknife.BindView) Aesthetic(com.afollestad.aesthetic.Aesthetic) View(android.view.View) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) PreferenceManager(android.preference.PreferenceManager) Unbinder(butterknife.Unbinder) Playlist(com.simplecity.amp_library.model.Playlist) IntentFilter(android.content.IntentFilter) Fragment(android.support.v4.app.Fragment) FragmentInfo(test.com.androidnavigation.fragment.FragmentInfo) CastManager(com.simplecity.amp_library.cast.CastManager) AlbumListFragment(com.simplecity.amp_library.ui.screens.album.list.AlbumListFragment) RxBroadcast(com.cantrowitz.rxbroadcast.RxBroadcast) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) BaseFragment(com.simplecity.amp_library.ui.common.BaseFragment) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) Unit(kotlin.Unit) SearchFragment(com.simplecity.amp_library.ui.screens.search.SearchFragment) ContextualToolbarHost(com.simplecity.amp_library.ui.views.ContextualToolbarHost) Nullable(android.support.annotation.Nullable) AppBarLayout(android.support.design.widget.AppBarLayout) Album(com.simplecity.amp_library.model.Album) Stream(com.annimon.stream.Stream) ButterKnife(butterknife.ButterKnife) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) ViewPager(android.support.v4.view.ViewPager) NonNull(android.support.annotation.NonNull) ArtistDetailFragment(com.simplecity.amp_library.ui.screens.artist.detail.ArtistDetailFragment) RatingSnackbar(com.simplecity.amp_library.ui.views.RatingSnackbar) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) TabLayout(android.support.design.widget.TabLayout) Inject(javax.inject.Inject) MultiSheetEventRelay(com.simplecity.amp_library.ui.views.multisheet.MultiSheetEventRelay) GenreDetailFragment(com.simplecity.amp_library.ui.screens.genre.detail.GenreDetailFragment) GenreListFragment(com.simplecity.amp_library.ui.screens.genre.list.GenreListFragment) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) ViewBackgroundAction(com.afollestad.aesthetic.ViewBackgroundAction) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) Rx.distinctToMainThread(com.afollestad.aesthetic.Rx.distinctToMainThread) CastButtonFactory(com.google.android.gms.cast.framework.CastButtonFactory) PlaylistListFragment(com.simplecity.amp_library.ui.screens.playlist.list.PlaylistListFragment) MultiSheetView(com.simplecity.multisheetview.ui.view.MultiSheetView) LayoutInflater(android.view.LayoutInflater) AndroidSupportInjection(dagger.android.support.AndroidSupportInjection) ToolbarListener(com.simplecity.amp_library.ui.common.ToolbarListener) SuggestedFragment(com.simplecity.amp_library.ui.screens.suggested.SuggestedFragment) SharedPreferences(android.content.SharedPreferences) Toolbar(android.support.v7.widget.Toolbar) Pair(android.support.v4.util.Pair) TransitionInflater(android.transition.TransitionInflater) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) AlbumArtistListFragment(com.simplecity.amp_library.ui.screens.artist.list.AlbumArtistListFragment) SharedPreferences(android.content.SharedPreferences) PagerAdapter(com.simplecity.amp_library.ui.adapters.PagerAdapter) CategoryItem(com.simplecity.amp_library.model.CategoryItem) RatingSnackbar(com.simplecity.amp_library.ui.views.RatingSnackbar)

Aggregations

IntentFilter (android.content.IntentFilter)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 PreferenceManager (android.preference.PreferenceManager)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 AppBarLayout (android.support.design.widget.AppBarLayout)1 TabLayout (android.support.design.widget.TabLayout)1 Fragment (android.support.v4.app.Fragment)1 Pair (android.support.v4.util.Pair)1 ViewCompat (android.support.v4.view.ViewCompat)1 ViewPager (android.support.v4.view.ViewPager)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 Toolbar (android.support.v7.widget.Toolbar)1 Transition (android.transition.Transition)1 TransitionInflater (android.transition.TransitionInflater)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1