Search in sources :

Example 1 with NavListAdapter

use of de.danoeh.antennapod.adapter.NavListAdapter in project AntennaPod by AntennaPod.

the class MediaplayerInfoActivity method setupGUI.

@Override
protected void setupGUI() {
    super.setupGUI();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        findViewById(R.id.shadow).setVisibility(View.GONE);
        AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBar);
        float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        appBarLayout.setElevation(px);
    }
    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);
    drawerToggle.setDrawerIndicatorEnabled(false);
    drawerLayout.setDrawerListener(drawerToggle);
    navAdapter = new NavListAdapter(itemAccess, this);
    navList.setAdapter(navAdapter);
    navList.setOnItemClickListener((parent, view, position, id) -> {
        int viewType = parent.getAdapter().getItemViewType(position);
        if (viewType != NavListAdapter.VIEW_TYPE_SECTION_DIVIDER) {
            Intent intent = new Intent(MediaplayerInfoActivity.this, MainActivity.class);
            intent.putExtra(MainActivity.EXTRA_NAV_TYPE, viewType);
            intent.putExtra(MainActivity.EXTRA_NAV_INDEX, position);
            startActivity(intent);
        }
        drawerLayout.closeDrawer(navDrawer);
    });
    navList.setOnItemLongClickListener((parent, view, position, id) -> {
        if (position < navAdapter.getTags().size()) {
            showDrawerPreferencesDialog();
            return true;
        } else {
            mPosition = position;
            return false;
        }
    });
    registerForContextMenu(navList);
    drawerToggle.syncState();
    findViewById(R.id.nav_settings).setOnClickListener(v -> {
        drawerLayout.closeDrawer(navDrawer);
        startActivity(new Intent(MediaplayerInfoActivity.this, PreferenceController.getPreferenceActivity()));
    });
    butPlaybackSpeed = (Button) findViewById(R.id.butPlaybackSpeed);
    butCastDisconnect = (ImageButton) findViewById(R.id.butCastDisconnect);
    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter = new MediaplayerInfoPagerAdapter(getSupportFragmentManager(), media);
    pagerAdapter.setController(controller);
    pager.setAdapter(pagerAdapter);
    CirclePageIndicator pageIndicator = (CirclePageIndicator) findViewById(R.id.page_indicator);
    pageIndicator.setViewPager(pager);
    loadLastFragment();
    pager.onSaveInstanceState();
}
Also used : NavListAdapter(de.danoeh.antennapod.adapter.NavListAdapter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) AppBarLayout(android.support.design.widget.AppBarLayout) CirclePageIndicator(com.viewpagerindicator.CirclePageIndicator) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with NavListAdapter

use of de.danoeh.antennapod.adapter.NavListAdapter 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)2 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)2 NavListAdapter (de.danoeh.antennapod.adapter.NavListAdapter)2 DataSetObserver (android.database.DataSetObserver)1 AppBarLayout (android.support.design.widget.AppBarLayout)1 Fragment (android.support.v4.app.Fragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 Toolbar (android.support.v7.widget.Toolbar)1 CirclePageIndicator (com.viewpagerindicator.CirclePageIndicator)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