Search in sources :

Example 1 with NavDrawerFragment

use of de.danoeh.antennapod.fragment.NavDrawerFragment in project AntennaPod by AntennaPod.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    lastTheme = UserPreferences.getNoTitleTheme();
    setTheme(lastTheme);
    if (savedInstanceState != null) {
        ensureGeneratedViewIdGreaterThan(savedInstanceState.getInt(KEY_GENERATED_VIEW_ID, 0));
    }
    super.onCreate(savedInstanceState);
    StorageUtils.checkStorageAvailability(this);
    setContentView(R.layout.main);
    recycledViewPool.setMaxRecycledViews(R.id.view_type_episode_item, 25);
    drawerLayout = findViewById(R.id.drawer_layout);
    navDrawer = findViewById(R.id.navDrawerFragment);
    setNavDrawerSize();
    final FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentByTag(MAIN_FRAGMENT_TAG) == null) {
        String lastFragment = NavDrawerFragment.getLastNavFragment(this);
        if (ArrayUtils.contains(NavDrawerFragment.NAV_DRAWER_TAGS, lastFragment)) {
            loadFragment(lastFragment, null);
        } else {
            try {
                loadFeedFragmentById(Integer.parseInt(lastFragment), null);
            } catch (NumberFormatException e) {
                // it's not a number, this happens if we removed
                // a label from the NAV_DRAWER_TAGS
                // give them a nice default...
                loadFragment(QueueFragment.TAG, null);
            }
        }
    }
    FragmentTransaction transaction = fm.beginTransaction();
    NavDrawerFragment navDrawerFragment = new NavDrawerFragment();
    transaction.replace(R.id.navDrawerFragment, navDrawerFragment, NavDrawerFragment.TAG);
    AudioPlayerFragment audioPlayerFragment = new AudioPlayerFragment();
    transaction.replace(R.id.audioplayerFragment, audioPlayerFragment, AudioPlayerFragment.TAG);
    transaction.commit();
    checkFirstLaunch();
    PreferenceUpgrader.checkUpgrades(this);
    View bottomSheet = findViewById(R.id.audioplayerFragment);
    sheetBehavior = (LockableBottomSheetBehavior) BottomSheetBehavior.from(bottomSheet);
    sheetBehavior.setPeekHeight((int) getResources().getDimension(R.dimen.external_player_height));
    sheetBehavior.setHideable(false);
    sheetBehavior.setBottomSheetCallback(bottomSheetCallback);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) AudioPlayerFragment(de.danoeh.antennapod.fragment.AudioPlayerFragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NavDrawerFragment(de.danoeh.antennapod.fragment.NavDrawerFragment)

Aggregations

View (android.view.View)1 FragmentManager (androidx.fragment.app.FragmentManager)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 AudioPlayerFragment (de.danoeh.antennapod.fragment.AudioPlayerFragment)1 NavDrawerFragment (de.danoeh.antennapod.fragment.NavDrawerFragment)1