Search in sources :

Example 11 with StreamingService

use of org.schabi.newpipe.extractor.StreamingService in project NewPipe by TeamNewPipe.

the class MainActivity method setupDrawer.

private void setupDrawer() {
    final Toolbar toolbar = findViewById(R.id.toolbar);
    drawer = findViewById(R.id.drawer_layout);
    drawerItems = findViewById(R.id.navigation);
    for (StreamingService s : NewPipe.getServices()) {
        String title = s.getServiceInfo().getName() + (ServiceHelper.isBeta(s) ? " (beta)" : "");
        MenuItem item = drawerItems.getMenu().add(R.id.menu_services_group, s.getServiceId(), 0, title);
        item.setIcon(ServiceHelper.getIcon(s.getServiceId()));
    }
    drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
    toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.drawer_open, R.string.drawer_close);
    toggle.syncState();
    drawer.addDrawerListener(toggle);
    drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {

        private int lastService;

        @Override
        public void onDrawerOpened(View drawerView) {
            lastService = ServiceHelper.getSelectedServiceId(MainActivity.this);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            if (lastService != ServiceHelper.getSelectedServiceId(MainActivity.this)) {
                new Handler(Looper.getMainLooper()).post(MainActivity.this::recreate);
            }
        }
    });
    drawerItems.setNavigationItemSelectedListener(this::changeService);
    setupDrawerFooter();
    setupDrawerHeader();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Handler(android.os.Handler) MenuItem(android.view.MenuItem) StreamingService(org.schabi.newpipe.extractor.StreamingService) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 12 with StreamingService

use of org.schabi.newpipe.extractor.StreamingService in project NewPipe by TeamNewPipe.

the class MainFragment method createKioskMenu.

/*//////////////////////////////////////////////////////////////////////////
    // Select Kiosk
    //////////////////////////////////////////////////////////////////////////*/
private void createKioskMenu(Menu menu, MenuInflater menuInflater) throws Exception {
    StreamingService service = NewPipe.getService(currentServiceId);
    KioskList kl = service.getKioskList();
    int i = 0;
    for (final String ks : kl.getAvailableKiosks()) {
        menu.add(0, KIOSK_MENU_OFFSET + i, Menu.NONE, KioskTranslator.getTranslatedKioskName(ks, getContext())).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                try {
                    NavigationHelper.openKioskFragment(getFragmentManager(), currentServiceId, ks);
                } catch (Exception e) {
                    ErrorActivity.reportError(activity, e, activity.getClass(), null, ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR, "none", "", R.string.app_ui_crash));
                }
                return true;
            }
        });
        i++;
    }
}
Also used : KioskList(org.schabi.newpipe.extractor.kiosk.KioskList) MenuItem(android.view.MenuItem) StreamingService(org.schabi.newpipe.extractor.StreamingService)

Aggregations

StreamingService (org.schabi.newpipe.extractor.StreamingService)12 ExtractionException (org.schabi.newpipe.extractor.exceptions.ExtractionException)5 Intent (android.content.Intent)4 View (android.view.View)3 TextView (android.widget.TextView)3 IOException (java.io.IOException)3 Handler (android.os.Handler)2 RecyclerView (android.support.v7.widget.RecyclerView)2 MenuItem (android.view.MenuItem)2 ImageView (android.widget.ImageView)2 ParsingException (org.schabi.newpipe.extractor.exceptions.ParsingException)2 StyleRes (android.support.annotation.StyleRes)1 NavigationView (android.support.design.widget.NavigationView)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 ListPreference (android.support.v7.preference.ListPreference)1 Preference (android.support.v7.preference.Preference)1 Toolbar (android.support.v7.widget.Toolbar)1 Consumer (io.reactivex.functions.Consumer)1 InterruptedIOException (java.io.InterruptedIOException)1