Search in sources :

Example 76 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project crypto-android by lizitca.

the class MenuActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_menu);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    new MenuPresenter(this).start();
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 77 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project ForPDA by RadiationX.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (EmptyActivity.empty(App.get().getPreferences().getString("auth.user.nick", ""))) {
        startActivity(new Intent(this, EmptyActivity.class));
        finish();
        return;
    }
    Intent intent = getIntent();
    if (intent != null) {
        checkWebView = intent.getBooleanExtra(CHECK_WEBVIEW, checkWebView);
    }
    if (checkWebView) {
        Observable.fromCallable(() -> App.get().isWebViewFound(this)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(aBoolean -> {
            if (!aBoolean) {
                startActivity(new Intent(App.getContext(), WebVewNotFoundActivity.class));
                finish();
            }
        });
    }
    currentThemeIsDark = App.get().isDarkTheme();
    setTheme(currentThemeIsDark ? R.style.DarkAppTheme_NoActionBar : R.style.LightAppTheme_NoActionBar);
    setContentView(R.layout.activity_main);
    DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    /*
        * Т.к. 2 вьюхи, делаю цвет в 2 раза прозрачнее, чтобы компенсировать это.
        * P.S. Чем больше вьюх в DrawerLayout находятся до NavigationView, тем сильнее будет затенение
        * P.S.S. Первая вьюха - контейнер фрагментов, вторая - view_for_measure
        * */
    drawerLayout.setScrimColor(0x4C000000);
    drawers = new Drawers(this, drawerLayout);
    drawers.init(savedInstanceState);
    drawerHeader = new DrawerHeader(this, drawerLayout);
    drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            if (drawerView.getId() == R.id.menu_drawer) {
                if (App.get().getPreferences().getBoolean("drawers.tooltip.link_open", true)) {
                    SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawerView.findViewById(R.id.drawer_header_open_link)).text(R.string.tooltip_link).gravity(Gravity.BOTTOM).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
                    tooltip.show();
                    tooltips.add(tooltip);
                    App.get().getPreferences().edit().putBoolean("drawers.tooltip.link_open", false).apply();
                }
            }
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            if (drawerView.getId() == R.id.menu_drawer) {
                if (App.get().getPreferences().getBoolean("drawers.tooltip.tabs_drawer", true)) {
                    SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawers.getTabDrawer()).text(R.string.tooltip_tabs).gravity(Gravity.START).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
                    tooltip.show();
                    tooltips.add(tooltip);
                    App.get().getPreferences().edit().putBoolean("drawers.tooltip.tabs_drawer", false).apply();
                }
            }
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            if (newState == DrawerLayout.STATE_DRAGGING) {
                TabFragment fragment = TabManager.get().getActive();
                if (fragment != null) {
                    fragment.hidePopupWindows();
                }
            }
        }
    });
    receiver = new NetworkStateReceiver();
    receiver.registerReceiver();
    KeyboardUtil keyboardUtil = new KeyboardUtil(this, findViewById(R.id.fragments_container));
    keyboardUtil.enable();
    final View viewDiff = findViewById(R.id.view_for_measure);
    viewDiff.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> measureView(v));
    if (Preferences.Notifications.Update.isEnabled(getApplicationContext())) {
        new SimpleUpdateChecker().checkFromGitHub(this);
    }
    checkIntent(getIntent());
}
Also used : SimpleTooltip(io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip) SimpleUpdateChecker(forpdateam.ru.forpda.ui.activities.updatechecker.SimpleUpdateChecker) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment) View(android.view.View) KeyboardUtil(forpdateam.ru.forpda.ui.views.KeyboardUtil) DrawerLayout(android.support.v4.widget.DrawerLayout) Drawers(forpdateam.ru.forpda.ui.views.drawers.Drawers) NetworkStateReceiver(forpdateam.ru.forpda.common.receivers.NetworkStateReceiver) DrawerHeader(forpdateam.ru.forpda.ui.views.drawers.DrawerHeader)

Example 78 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Androidified by D3v3sh5ingh.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) FloatingActionButton(android.support.design.widget.FloatingActionButton) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) Toolbar(android.support.v7.widget.Toolbar)

Example 79 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Riksdagskollen by OAndell.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setItemIconTintList(null);
    initPartyFragments();
    initMenuOptions();
    // Mark News-fragment as selected at startup
    navigationView.getMenu().getItem(0).getSubMenu().getItem(0).setChecked(true);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 80 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project underlx by underlx.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Object conn = getLastCustomNonConfigurationInstance();
    if (conn != null && ((LocServiceConnection) conn).getBinder() != null) {
        // have the service connection survive through activity configuration changes
        // (e.g. screen orientation changes)
        mConnection = (LocServiceConnection) conn;
        locService = mConnection.getBinder().getService();
        locBound = true;
    } else if (!locBound) {
        startService(new Intent(this, MainService.class));
        getApplicationContext().bindService(new Intent(getApplicationContext(), MainService.class), mConnection, Context.BIND_AUTO_CREATE);
    }
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    if (savedInstanceState == null) {
        // show initial fragment
        Fragment newFragment = null;
        if (getIntent() != null) {
            String id = getIntent().getStringExtra(EXTRA_INITIAL_FRAGMENT);
            if (id != null) {
                newFragment = getNewFragment(pageStringToResourceId(id));
                planRouteTo = getIntent().getStringExtra(EXTRA_PLAN_ROUTE_TO_STATION);
            }
            if (getIntent().getBooleanExtra(EXTRA_FROM_INTRO, false)) {
                showTargetPrompt();
            }
        }
        if (newFragment == null) {
            newFragment = new HomeFragment();
        }
        replaceFragment(newFragment, false);
    }
    IntentFilter filter = new IntentFilter();
    filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_PROGRESS);
    filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_FINISHED);
    filter.addAction(MainService.ACTION_TOPOLOGY_UPDATE_AVAILABLE);
    filter.addAction(MainService.ACTION_CACHE_EXTRAS_PROGRESS);
    filter.addAction(MainService.ACTION_CACHE_EXTRAS_FINISHED);
    filter.addAction(FeedbackUtil.ACTION_FEEDBACK_PROVIDED);
    bm = LocalBroadcastManager.getInstance(this);
    bm.registerReceiver(mBroadcastReceiver, filter);
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            SharedPreferences sharedPref = getSharedPreferences("settings", MODE_PRIVATE);
            boolean isFirstStart = sharedPref.getBoolean("fuse_first_run", true);
            if (isFirstStart) {
                // intro will request permission for us
                final Intent i = new Intent(MainActivity.this, IntroActivity.class);
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        startActivity(i);
                        finish();
                    }
                });
            } else {
                boolean locationEnabled = sharedPref.getBoolean(PreferenceNames.LocationEnable, true);
                if (locationEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
                            }
                        }
                    });
                }
            }
        }
    });
    // Start the thread
    t.start();
}
Also used : IntentFilter(android.content.IntentFilter) IntroActivity(im.tny.segvault.disturbances.ui.intro.IntroActivity) SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) DisturbanceFragment(im.tny.segvault.disturbances.ui.fragment.top.DisturbanceFragment) DialogFragment(android.support.v4.app.DialogFragment) HelpFragment(im.tny.segvault.disturbances.ui.fragment.top.HelpFragment) TopFragment(im.tny.segvault.disturbances.ui.fragment.TopFragment) Fragment(android.support.v4.app.Fragment) UnconfirmedTripsFragment(im.tny.segvault.disturbances.ui.fragment.UnconfirmedTripsFragment) RouteFragment(im.tny.segvault.disturbances.ui.fragment.top.RouteFragment) AnnouncementFragment(im.tny.segvault.disturbances.ui.fragment.top.AnnouncementFragment) AboutFragment(im.tny.segvault.disturbances.ui.fragment.top.AboutFragment) MapFragment(im.tny.segvault.disturbances.ui.fragment.top.MapFragment) HomeStatsFragment(im.tny.segvault.disturbances.ui.fragment.HomeStatsFragment) HomeLinesFragment(im.tny.segvault.disturbances.ui.fragment.HomeLinesFragment) GeneralPreferenceFragment(im.tny.segvault.disturbances.ui.fragment.top.GeneralPreferenceFragment) HtmlDialogFragment(im.tny.segvault.disturbances.ui.fragment.HtmlDialogFragment) HomeFragment(im.tny.segvault.disturbances.ui.fragment.top.HomeFragment) TripFragment(im.tny.segvault.disturbances.ui.fragment.TripFragment) TripHistoryFragment(im.tny.segvault.disturbances.ui.fragment.top.TripHistoryFragment) NotifPreferenceFragment(im.tny.segvault.disturbances.ui.fragment.top.NotifPreferenceFragment) HomeFragment(im.tny.segvault.disturbances.ui.fragment.top.HomeFragment) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)218 View (android.view.View)153 NavigationView (android.support.design.widget.NavigationView)118 Toolbar (android.support.v7.widget.Toolbar)98 DrawerLayout (android.support.v4.widget.DrawerLayout)96 TextView (android.widget.TextView)85 AdapterView (android.widget.AdapterView)51 ImageView (android.widget.ImageView)48 ListView (android.widget.ListView)48 Intent (android.content.Intent)45 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)35 ActionBar (android.support.v7.app.ActionBar)31 SharedPreferences (android.content.SharedPreferences)30 RecyclerView (android.support.v7.widget.RecyclerView)23 Bundle (android.os.Bundle)20 FloatingActionButton (android.support.design.widget.FloatingActionButton)20 LinearLayout (android.widget.LinearLayout)19 MenuItem (android.view.MenuItem)17 BindView (butterknife.BindView)15 ArrayList (java.util.ArrayList)15