Search in sources :

Example 1 with ExternalPlayerFragment

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

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(UserPreferences.getNoTitleTheme());
    super.onCreate(savedInstanceState);
    StorageUtils.checkStorageAvailability(this);
    setContentView(R.layout.main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        findViewById(R.id.shadow).setVisibility(View.GONE);
        int elevation = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        getSupportActionBar().setElevation(elevation);
    }
    currentTitle = getTitle();
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navList = (ListView) findViewById(R.id.nav_list);
    navDrawer = findViewById(R.id.nav_layout);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close);
    if (savedInstanceState != null) {
        int backstackCount = savedInstanceState.getInt(SAVE_BACKSTACK_COUNT, 0);
        drawerToggle.setDrawerIndicatorEnabled(backstackCount == 0);
    }
    drawerLayout.setDrawerListener(drawerToggle);
    final FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(() -> drawerToggle.setDrawerIndicatorEnabled(fm.getBackStackEntryCount() == 0));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    navAdapter = new NavListAdapter(itemAccess, this);
    navList.setAdapter(navAdapter);
    navList.setOnItemClickListener(navListClickListener);
    navList.setOnItemLongClickListener(newListLongClickListener);
    registerForContextMenu(navList);
    navAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            selectedNavListIndex = getSelectedNavListIndex();
        }
    });
    findViewById(R.id.nav_settings).setOnClickListener(v -> {
        drawerLayout.closeDrawer(navDrawer);
        startActivity(new Intent(MainActivity.this, PreferenceController.getPreferenceActivity()));
    });
    FragmentTransaction transaction = fm.beginTransaction();
    Fragment mainFragment = fm.findFragmentByTag("main");
    if (mainFragment != null) {
        transaction.replace(R.id.main_view, mainFragment);
    } else {
        String lastFragment = getLastNavFragment();
        if (ArrayUtils.contains(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);
            }
        }
    }
    externalPlayerFragment = new ExternalPlayerFragment();
    transaction.replace(R.id.playerFragment, externalPlayerFragment, ExternalPlayerFragment.TAG);
    transaction.commit();
    checkFirstLaunch();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) NavListAdapter(de.danoeh.antennapod.adapter.NavListAdapter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ExternalPlayerFragment(de.danoeh.antennapod.fragment.ExternalPlayerFragment) Intent(android.content.Intent) DataSetObserver(android.database.DataSetObserver) QueueFragment(de.danoeh.antennapod.fragment.QueueFragment) Fragment(android.support.v4.app.Fragment) DownloadsFragment(de.danoeh.antennapod.fragment.DownloadsFragment) ItemlistFragment(de.danoeh.antennapod.fragment.ItemlistFragment) ExternalPlayerFragment(de.danoeh.antennapod.fragment.ExternalPlayerFragment) SubscriptionFragment(de.danoeh.antennapod.fragment.SubscriptionFragment) PlaybackHistoryFragment(de.danoeh.antennapod.fragment.PlaybackHistoryFragment) EpisodesFragment(de.danoeh.antennapod.fragment.EpisodesFragment) AddFeedFragment(de.danoeh.antennapod.fragment.AddFeedFragment)

Aggregations

Intent (android.content.Intent)1 DataSetObserver (android.database.DataSetObserver)1 Fragment (android.support.v4.app.Fragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 NavListAdapter (de.danoeh.antennapod.adapter.NavListAdapter)1 AddFeedFragment (de.danoeh.antennapod.fragment.AddFeedFragment)1 DownloadsFragment (de.danoeh.antennapod.fragment.DownloadsFragment)1 EpisodesFragment (de.danoeh.antennapod.fragment.EpisodesFragment)1 ExternalPlayerFragment (de.danoeh.antennapod.fragment.ExternalPlayerFragment)1 ItemlistFragment (de.danoeh.antennapod.fragment.ItemlistFragment)1 PlaybackHistoryFragment (de.danoeh.antennapod.fragment.PlaybackHistoryFragment)1 QueueFragment (de.danoeh.antennapod.fragment.QueueFragment)1 SubscriptionFragment (de.danoeh.antennapod.fragment.SubscriptionFragment)1