androidx.appcompat.app.ActionBarDrawerToggle Java Examples

The following examples show how to use androidx.appcompat.app.ActionBarDrawerToggle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrawerLayoutEx.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
void setup(Configuration config, View drawerContainer, ActionBarDrawerToggle drawerToggle) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
    boolean landscape = prefs.getBoolean("landscape", true);
    boolean landscape3 = prefs.getBoolean("landscape3", false);

    if (normal && landscape && landscape3 &&
            config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setScrimColor(Color.TRANSPARENT);
        openDrawer(drawerContainer, false);
        drawerToggle.onDrawerOpened(drawerContainer);
    } else {
        setScrimColor(Helper.resolveColor(getContext(), R.attr.colorDrawerScrim));
        closeDrawer(drawerContainer, false);
        drawerToggle.onDrawerClosed(drawerContainer);
    }
}
 
Example #2
Source File: NavigationDrawer.java    From Open-Source-Android-Weather-App with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Suspect 2
        setContentView(R.layout.activity_main);
        //Toolbar toolbar = findViewById(R.id.drawer_layout);
        //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);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        //NavigationView navigationView = findViewById(R.id.nav_view);
        NavigationView navigationView = findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
    }
 
Example #3
Source File: MainActivity.java    From QuickDevFramework with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mFragmentManager = getSupportFragmentManager();
    if (savedInstanceState != null) {
        restoreFragments(savedInstanceState);
    }
    else {
        initFragments();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_main);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.app_name, R.string.app_name);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    initApiSampleList();
}
 
Example #4
Source File: PhotoActivity.java    From CrazyDaily with Apache License 2.0 6 votes vote down vote up
@Override
protected void initView() {
    setSupportActionBar(mToolbar);
    handleStatusbarTransparent();
    mPhotoDrawer.setScrimColor(Color.TRANSPARENT);
    mDrawerToggle = new ActionBarDrawerToggle(this, mPhotoDrawer, mToolbar, R.string.open, R.string.close);

    mCropRadioRadioGroup.check(R.id.photo_crop_ratio_origin);
    mCropRatioX.addTextChangedListener(mCropRatioTextWatcher);
    mCropRatioY.addTextChangedListener(mCropRatioTextWatcher);
    mCropCompressRadioGroup.check(R.id.photo_crop_compress_jpg);
    mCropQuality.setText(DEFAULT_COMPRESS_QUALITY);
    mCropQuality.addTextChangedListener(mCropQualityTextWatcher);
    mCropResolutionWidth.addTextChangedListener(mCropResolutionTextWatcher);
    mCropResolutionHeight.addTextChangedListener(mCropResolutionTextWatcher);
}
 
Example #5
Source File: DrawerActivity.java    From SwipeRecyclerView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mRecyclerView.setSwipeMenuCreator(mSwipeMenuCreator);
    mRecyclerView.setOnItemMenuClickListener(mItemMenuClickListener);

    DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, mToolbar, R.string.app_name,
        R.string.app_name);
    drawerLayout.addDrawerListener(drawerToggle);
    drawerToggle.syncState();

    mRecyclerView.setAdapter(mAdapter);
    mAdapter.notifyDataSetChanged(mDataList);
}
 
Example #6
Source File: BaseActivity.java    From privacy-friendly-interval-timer with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if(getSupportActionBar() == null) {
        setSupportActionBar(toolbar);
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();

    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);

    selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}
 
Example #7
Source File: OverScrollDemoActivity.java    From overscroll-decor with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_overscroll_demo);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.recycler_view_demo_title);
    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.drawer_nav);
    navigationView.setNavigationItemSelectedListener(this);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fragment_placeholder, new RecyclerViewDemoFragment())
                .commit();
    }
}
 
Example #8
Source File: MainActivity.java    From busybox with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrefStore.setLocale(this);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    output = findViewById(R.id.outputView);
    scroll = findViewById(R.id.scrollView);

    // enable context clickable
    output.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example #9
Source File: MainActivity.java    From Android-Image-Cropper with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setHomeButtonEnabled(true);

  mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

  mDrawerToggle =
      new ActionBarDrawerToggle(
          this, mDrawerLayout, R.string.main_drawer_open, R.string.main_drawer_close);
  mDrawerToggle.setDrawerIndicatorEnabled(true);
  mDrawerLayout.setDrawerListener(mDrawerToggle);

  if (savedInstanceState == null) {
    setMainFragmentByPreset(CropDemoPreset.RECT);
  }
}
 
Example #10
Source File: MainActivity.java    From ArcNavigationView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = 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();
        }
    });

    drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    NavigationView navigationViewRight = findViewById(R.id.nav_view_right);
    navigationViewRight.setNavigationItemSelectedListener(this);
    navigationView.setNavigationItemSelectedListener(this);
}
 
Example #11
Source File: MainActivity.java    From android-biometricprompt with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @SuppressLint("WrongConstant")
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    DrawerLayout drawer = 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 = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
 
Example #12
Source File: MainActivity.java    From iBeacon-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    Log.i("TimeAttendantFast", "Main Activity Create");
    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);

    TimeAttendantFastFragment fragment = TimeAttendantFastFragment.newInstance();
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.contentFrame, fragment, null).disallowAddToBackStack().commit();
}
 
Example #13
Source File: MainActivity.java    From android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ButterKnife.bind(this);

    DrawerLayout drawer = 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 = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
 
Example #14
Source File: DrawerNavigationTest.java    From WiFiAnalyzer with GNU General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    when(mainActivity.findViewById(R.id.drawer_layout)).thenReturn(drawerLayout);

    fixture = new DrawerNavigation(mainActivity, toolbar) {
        @Override
        ActionBarDrawerToggle create(
            @NonNull MainActivity mainActivityInput,
            @NonNull Toolbar toolbarInput,
            @NonNull DrawerLayout drawerLayoutInput,
            int openDrawerContentDescRes,
            int closeDrawerContentDescRes) {

            Assert.assertEquals(mainActivity, mainActivityInput);
            Assert.assertEquals(toolbar, toolbarInput);
            Assert.assertEquals(drawerLayout, drawerLayoutInput);
            Assert.assertEquals(R.string.navigation_drawer_open, openDrawerContentDescRes);
            Assert.assertEquals(R.string.navigation_drawer_close, closeDrawerContentDescRes);

            return actionBarDrawerToggle;
        }
    };
}
 
Example #15
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
private void setupDrawer() {
  mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

    /** Called when a drawer has settled in a completely open state. */
    public void onDrawerOpened(View drawerView) {
      super.onDrawerOpened(drawerView);
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }

    /** Called when a drawer has settled in a completely closed state. */
    public void onDrawerClosed(View view) {
      super.onDrawerClosed(view);
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }
  };

  mDrawerToggle.setDrawerIndicatorEnabled(true);
  mDrawerLayout.addDrawerListener(mDrawerToggle);
}
 
Example #16
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
/**
 * Set up the navigation drawer
 */
private void setupDrawer() {

  mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

    /** Called when a drawer has settled in a completely open state. */
    public void onDrawerOpened(View drawerView) {
      super.onDrawerOpened(drawerView);
      getSupportActionBar().setTitle(mActivityTitle);
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }

    /** Called when a drawer has settled in a completely closed state. */
    public void onDrawerClosed(View view) {
      super.onDrawerClosed(view);
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }
  };

  mDrawerToggle.setDrawerIndicatorEnabled(true);
  mDrawerLayout.addDrawerListener(mDrawerToggle);
}
 
Example #17
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
private void setupDrawer() {
  mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

    // called when drawer has settled in an open state
    public void onDrawerOpened(View drawerView) {
      super.onDrawerOpened(drawerView);
      // change the title to the nav bar
      getSupportActionBar().setTitle(getResources().getString(R.string.navbar_title));
      // invalidate options menu
      invalidateOptionsMenu();
    }

    // called when drawer has settled in a closed state
    public void onDrawerClosed(View view) {
      super.onDrawerClosed(view);
      // set title to the app
      getSupportActionBar().setTitle(mActivityTitle);
      // invalidate options menu
      invalidateOptionsMenu();
    }
  };
  // enable draw indicator
  mDrawerToggle.setDrawerIndicatorEnabled(true);
  // attach toggle to drawer layout
  mDrawerLayout.setDrawerListener(mDrawerToggle);
}
 
Example #18
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
/**
 * set up the drawer
 */
private void setupDrawer() {
  mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

    /** Called when a drawer has settled in a completely open state. */
    public void onDrawerOpened(View drawerView) {
      super.onDrawerOpened(drawerView);
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }

    /** Called when a drawer has settled in a completely closed state. */
    public void onDrawerClosed(View view) {
      super.onDrawerClosed(view);
      invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }
  };

  mDrawerToggle.setDrawerIndicatorEnabled(true);
  mDrawerLayout.addDrawerListener(mDrawerToggle);

  mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
 
Example #19
Source File: MainActivity.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    fragmentManager = getSupportFragmentManager();

    DrawerLayout drawer = 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);

    //add the first one as the default fragment.
    fragmentManager.beginTransaction().replace(R.id.container, new SupportDialogFragment()).commit();
}
 
Example #20
Source File: MainChatActivity.java    From twiliochat-android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main_chat);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  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();

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refreshLayout);

  FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();

  chatFragment = new MainChatFragment();
  fragmentTransaction.add(R.id.fragment_container, chatFragment);
  fragmentTransaction.commit();

  context = this;
  mainActivity = this;
  logoutButton = (Button) findViewById(R.id.buttonLogout);
  addChannelButton = (Button) findViewById(R.id.buttonAddChannel);
  usernameTextView = (TextView) findViewById(R.id.textViewUsername);
  channelsListView = (ListView) findViewById(R.id.listViewChannels);

  channelManager = ChannelManager.getInstance();
  setUsernameTextView();

  setUpListeners();
  checkTwilioClient();
}
 
Example #21
Source File: DrawerNavigation.java    From WiFiAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
ActionBarDrawerToggle create(
    @NonNull MainActivity mainActivity,
    @NonNull Toolbar toolbar,
    @NonNull DrawerLayout drawer,
    @StringRes int openDrawerContentDescRes,
    @StringRes int closeDrawerContentDescRes) {
    return new ActionBarDrawerToggle(
        mainActivity,
        drawer,
        toolbar,
        openDrawerContentDescRes,
        closeDrawerContentDescRes);
}
 
Example #22
Source File: MainUI.java    From Busybox-Installer-No-Root with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_ui);

    context = getApplicationContext();

    MobileAds.initialize(this);

    mAdView = findViewById(R.id.adView);
    mAdView.loadAd(new AdRequest.Builder().build());

    Toolbar toolbar = findViewById(R.id.toolbar);

    setSupportActionBar(toolbar);

    DrawerLayout drawer = 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 = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            mAdView.loadAd(new AdRequest.Builder().build());
        }
    });

    if(savedInstanceState == null){
        MenuItem selected = navigationView.getMenu().findItem(R.id.method1);
        selected.setCheckable(true);
        selected.setChecked(true);
        newFragment(0);
    }
}
 
Example #23
Source File: AdvanceDrawer4Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance4);
    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();
        }
    });

    drawer = (AdvanceDrawerLayout) 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);

    drawer.setViewScale(Gravity.END, 0.9f);
    drawer.setViewElevation(Gravity.END, 20);


}
 
Example #24
Source File: MainActivity.java    From Daedalus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    if (Daedalus.isDarkTheme()) {
        setTheme(R.style.AppTheme_Dark_NoActionBar_TransparentStatusBar);
    }
    super.onCreate(savedInstanceState);

    instance = this;

    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    //setSupportActionBar(toolbar); //causes toolbar issues

    DrawerLayout drawer = findViewById(R.id.main_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 = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    ((TextView) navigationView.getHeaderView(0).findViewById(R.id.textView_nav_version)).setText(getString(R.string.nav_version) + " " + BuildConfig.VERSION_NAME);
    ((TextView) navigationView.getHeaderView(0).findViewById(R.id.textView_nav_git_commit)).setText(getString(R.string.nav_git_commit) + " " + BuildConfig.GIT_COMMIT);

    updateUserInterface(getIntent());
}
 
Example #25
Source File: AdvanceDrawer2Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance2);
    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();
        }
    });

    drawer = (AdvanceDrawerLayout) 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);

    drawer.setViewScale(Gravity.START, 0.9f);
    drawer.setViewElevation(Gravity.START, 20);


}
 
Example #26
Source File: AdvanceDrawer5Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance5);
    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();
        }
    });

    drawer = (AdvanceDrawerLayout) 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);

    drawer.setViewScale(Gravity.START, 0.9f);
    drawer.setRadius(Gravity.START, 35);
    drawer.setViewElevation(Gravity.START, 20);


}
 
Example #27
Source File: AdvanceDrawer1Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance1);
    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();
        }
    });

    drawer = (AdvanceDrawerLayout) 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);

    drawer.useCustomBehavior(Gravity.START);
    drawer.useCustomBehavior(Gravity.END);

}
 
Example #28
Source File: AdvanceDrawer3Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance3);
    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();
        }
    });

    drawer = (AdvanceDrawerLayout) 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);

    drawer.setViewScale(Gravity.START, 0.9f);
    drawer.setViewElevation(Gravity.START, 20);

    drawer.useCustomBehavior(Gravity.END);

}
 
Example #29
Source File: MainActivity.java    From scratchCardLayout with Apache License 2.0 5 votes vote down vote up
private void setupActionbarWithToggle() {
    setSupportActionBar(binding.toolbar);
    binding.toolbar.setTitle(getString(R.string.app_name));
    if (getSupportActionBar() != null) {
        ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(
                this, binding.drawerLayout, binding.toolbar,
                R.string.navigation_drawer_open, R.string.navigation_drawer_close
        );
        binding.drawerLayout.setDrawerListener(mDrawerToggle);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        mDrawerToggle.syncState();
    }
}
 
Example #30
Source File: Advance3DDrawer1Activity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advance_3d_1);
    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();
        }
    });

    drawer = (Advance3DDrawerLayout) 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);

    drawer.setViewScale(GravityCompat.START, 0.96f);
    drawer.setRadius(GravityCompat.START, 20);
    drawer.setViewElevation(GravityCompat.START, 8);
    drawer.setViewRotation(GravityCompat.START, 15);



}