use of androidx.drawerlayout.widget.DrawerLayout in project IITB-App by wncc.
the class MainActivity method onCreate.
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Check for dark theme */
SharedPreferences sharedPref = getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
Utils.isDarkTheme = sharedPref.getBoolean(Constants.DARK_THEME, false);
if (Utils.isDarkTheme)
this.setTheme(R.style.AppThemeDark);
ServiceGenerator serviceGenerator = new ServiceGenerator(getApplicationContext());
Utils.setRetrofitInterface(serviceGenerator.getRetrofitInterface());
Utils.makeGson();
Utils.makeMarkwon(getApplicationContext());
/* Make notification channel on oreo */
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
createNotificationChannel();
}
setContentView(R.layout.activity_main);
session = new SessionManager(getApplicationContext());
if (session.isLoggedIn()) {
Utils.setSessionId(session.getSessionID());
}
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();
feedFragment = new FeedFragment();
updateFragment(feedFragment);
Intent intent = getIntent();
if (intent != null) {
// Check for data passed by FCM
if (intent.getExtras() != null && intent.getBundleExtra(Constants.MAIN_INTENT_EXTRAS) != null) {
handleFCMIntent(intent.getBundleExtra(Constants.MAIN_INTENT_EXTRAS));
} else {
handleIntent(intent);
}
}
checkLatestVersion();
}
use of androidx.drawerlayout.widget.DrawerLayout in project IITB-App by wncc.
the class MainActivity method updateNavigationView.
private void updateNavigationView() {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View header = navigationView.getHeaderView(0);
header.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Utils.openUserFragment(currentUser.getUserID(), MainActivity.this);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
});
TextView nameTextView = header.findViewById(R.id.user_name_nav_header);
TextView rollNoTextView = header.findViewById(R.id.user_rollno_nav_header);
ImageView profilePictureImageView = header.findViewById(R.id.user_profile_picture_nav_header);
nameTextView.setText(currentUser.getUserName());
rollNoTextView.setText(currentUser.getUserRollNumber());
Picasso.get().load(currentUser.getUserProfilePictureUrl()).resize(200, 0).placeholder(R.drawable.user_placeholder).into(profilePictureImageView);
}
use of androidx.drawerlayout.widget.DrawerLayout in project Gadgetbridge by Freeyourgadget.
the class ControlCenterv2 method onNavigationItemSelected.
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
switch(item.getItemId()) {
case R.id.action_settings:
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(settingsIntent, MENU_REFRESH_CODE);
return true;
case R.id.action_debug:
Intent debugIntent = new Intent(this, DebugActivity.class);
startActivity(debugIntent);
return true;
case R.id.action_data_management:
Intent dbIntent = new Intent(this, DataManagementActivity.class);
startActivity(dbIntent);
return true;
case R.id.action_notification_management:
Intent blIntent = new Intent(this, NotificationManagementActivity.class);
startActivity(blIntent);
return true;
case R.id.device_action_discover:
launchDiscoveryActivity();
return true;
case R.id.action_quit:
GBApplication.quit();
return true;
case R.id.donation_link:
// TODO: centralize if ever used somewhere else
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://liberapay.com/Gadgetbridge"));
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
return true;
case R.id.external_changelog:
ChangeLog cl = createChangeLog();
try {
cl.getLogDialog().show();
} catch (Exception ignored) {
GB.toast(getBaseContext(), "Error showing Changelog", Toast.LENGTH_LONG, GB.ERROR);
}
return true;
case R.id.about:
Intent aboutIntent = new Intent(this, AboutActivity.class);
startActivity(aboutIntent);
return true;
}
return true;
}
use of androidx.drawerlayout.widget.DrawerLayout in project Slide by ccrama.
the class Discover method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstance);
applyColorTheme("");
setContentView(R.layout.activity_multireddits);
((DrawerLayout) findViewById(R.id.drawer_layout)).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
setupAppBar(R.id.toolbar, R.string.discover_title, true, false);
mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
TabLayout tabs = (TabLayout) findViewById(R.id.sliding_tabs);
tabs.setTabMode(TabLayout.MODE_FIXED);
tabs.setSelectedTabIndicatorColor(new ColorPreferences(Discover.this).getColor("no sub"));
ViewPager pager = (ViewPager) findViewById(R.id.content_view);
pager.setAdapter(new DiscoverPagerAdapter(getSupportFragmentManager()));
tabs.setupWithViewPager(pager);
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
findViewById(R.id.header).animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
}
});
}
Aggregations