Search in sources :

Example 11 with DrawerLayout

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();
}
Also used : SharedPreferences(android.content.SharedPreferences) ServiceGenerator(app.insti.api.ServiceGenerator) SessionManager(app.insti.SessionManager) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) Intent(android.content.Intent) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) FeedFragment(app.insti.fragment.FeedFragment) Toolbar(androidx.appcompat.widget.Toolbar) SuppressLint(android.annotation.SuppressLint)

Example 12 with DrawerLayout

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);
}
Also used : NavigationView(com.google.android.material.navigation.NavigationView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) NavigationView(com.google.android.material.navigation.NavigationView)

Example 13 with DrawerLayout

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;
}
Also used : Intent(android.content.Intent) ChangeLog(de.cketti.library.changelog.ChangeLog) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout)

Example 14 with DrawerLayout

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);
        }
    });
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) LinearInterpolator(android.view.animation.LinearInterpolator) TabLayout(com.google.android.material.tabs.TabLayout) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) ViewPager(androidx.viewpager.widget.ViewPager)

Aggregations

DrawerLayout (androidx.drawerlayout.widget.DrawerLayout)14 Intent (android.content.Intent)7 View (android.view.View)7 ActionBarDrawerToggle (androidx.appcompat.app.ActionBarDrawerToggle)6 Toolbar (androidx.appcompat.widget.Toolbar)5 Bundle (android.os.Bundle)4 ViewGroup (android.view.ViewGroup)4 NonNull (androidx.annotation.NonNull)4 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 Configuration (android.content.res.Configuration)3 Uri (android.net.Uri)3 Handler (android.os.Handler)3 MenuItem (android.view.MenuItem)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 Fragment (androidx.fragment.app.Fragment)3 NavigationView (com.google.android.material.navigation.NavigationView)3 SuppressLint (android.annotation.SuppressLint)2 SharedPreferences (android.content.SharedPreferences)2 Menu (android.view.Menu)2