Search in sources :

Example 11 with ActionBarDrawerToggle

use of androidx.appcompat.app.ActionBarDrawerToggle in project SwipeRecyclerView by yanzhenjie.

the class DrawerActivity method onCreate.

@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);
}
Also used : ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout)

Example 12 with ActionBarDrawerToggle

use of androidx.appcompat.app.ActionBarDrawerToggle in project AntennaPod by AntennaPod.

the class MainActivity method setupToolbarToggle.

public void setupToolbarToggle(@NonNull Toolbar toolbar, boolean displayUpArrow) {
    if (drawerLayout != null) {
        // Tablet layout does not have a drawer
        if (drawerToggle != null) {
            drawerLayout.removeDrawerListener(drawerToggle);
        }
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
        drawerLayout.addDrawerListener(drawerToggle);
        drawerToggle.syncState();
        drawerToggle.setDrawerIndicatorEnabled(!displayUpArrow);
        drawerToggle.setToolbarNavigationClickListener(v -> getSupportFragmentManager().popBackStack());
    } else if (!displayUpArrow) {
        toolbar.setNavigationIcon(null);
    } else {
        toolbar.setNavigationIcon(ThemeUtils.getDrawableFromAttr(this, R.attr.homeAsUpIndicator));
        toolbar.setNavigationOnClickListener(v -> getSupportFragmentManager().popBackStack());
    }
}
Also used : Bundle(android.os.Bundle) SearchFragment(de.danoeh.antennapod.fragment.SearchFragment) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) Handler(android.os.Handler) Looper(android.os.Looper) Fragment(androidx.fragment.app.Fragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContextCompat(androidx.core.content.ContextCompat) TargetApi(android.annotation.TargetApi) Log(android.util.Log) QueueFragment(de.danoeh.antennapod.fragment.QueueFragment) PlaybackService(de.danoeh.antennapod.core.service.playback.PlaybackService) ThemeUtils(de.danoeh.antennapod.ui.common.ThemeUtils) MediaButtonReceiver(de.danoeh.antennapod.core.receiver.MediaButtonReceiver) TransitionEffect(de.danoeh.antennapod.fragment.TransitionEffect) FragmentTransaction(androidx.fragment.app.FragmentTransaction) ThreadMode(org.greenrobot.eventbus.ThreadMode) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) Nullable(androidx.annotation.Nullable) DownloadsFragment(de.danoeh.antennapod.fragment.DownloadsFragment) MessageEvent(de.danoeh.antennapod.event.MessageEvent) Toolbar(androidx.appcompat.widget.Toolbar) Snackbar(com.google.android.material.snackbar.Snackbar) MainActivityStarter(de.danoeh.antennapod.ui.appstartintent.MainActivityStarter) NavDrawerFragment(de.danoeh.antennapod.fragment.NavDrawerFragment) Context(android.content.Context) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) AutoUpdateManager(de.danoeh.antennapod.core.util.download.AutoUpdateManager) FeedItemlistFragment(de.danoeh.antennapod.fragment.FeedItemlistFragment) Intent(android.content.Intent) ArrayUtils(org.apache.commons.lang3.ArrayUtils) AudioManager(android.media.AudioManager) MenuItem(android.view.MenuItem) Toast(android.widget.Toast) EventBus(org.greenrobot.eventbus.EventBus) StorageUtils(de.danoeh.antennapod.core.util.StorageUtils) Build(android.os.Build) FragmentManager(androidx.fragment.app.FragmentManager) SubscriptionFragment(de.danoeh.antennapod.fragment.SubscriptionFragment) R(de.danoeh.antennapod.R) LockableBottomSheetBehavior(de.danoeh.antennapod.view.LockableBottomSheetBehavior) CastEnabledActivity(de.danoeh.antennapod.playback.cast.CastEnabledActivity) AudioPlayerFragment(de.danoeh.antennapod.fragment.AudioPlayerFragment) RatingDialog(de.danoeh.antennapod.dialog.RatingDialog) PreferenceUpgrader(de.danoeh.antennapod.preferences.PreferenceUpgrader) Glide(com.bumptech.glide.Glide) Validate(org.apache.commons.lang3.Validate) Subscribe(org.greenrobot.eventbus.Subscribe) SharedPreferences(android.content.SharedPreferences) PlaybackHistoryFragment(de.danoeh.antennapod.fragment.PlaybackHistoryFragment) Configuration(android.content.res.Configuration) EpisodesFragment(de.danoeh.antennapod.fragment.EpisodesFragment) EditText(android.widget.EditText) AddFeedFragment(de.danoeh.antennapod.fragment.AddFeedFragment) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle)

Example 13 with ActionBarDrawerToggle

use of androidx.appcompat.app.ActionBarDrawerToggle 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 14 with ActionBarDrawerToggle

use of androidx.appcompat.app.ActionBarDrawerToggle in project twicalico by moko256.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.MainActivityTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    disposable = new CompositeDisposable();
    client = GlobalApplicationKt.getClient(this);
    accountsModel = GlobalApplicationKt.getAccountsModel(this);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.getChildAt(0).setOnClickListener(v -> {
        Fragment fragment = getMainFragment();
        if (fragment instanceof MovableTopInterface) {
            ((MovableTopInterface) fragment).moveToTop();
        }
    });
    drawer = findViewById(R.id.drawer_layout);
    if (drawer != null) {
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        toggle.setDrawerSlideAnimationEnabled(false);
        toggle.syncState();
        drawer.addDrawerListener(this);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.color_primary_dark));
    }
    navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(item -> {
        int id = item.getItemId();
        if (!item.isChecked()) {
            switch(id) {
                case R.id.nav_timeline:
                    replaceFragment(new HomeTimeLineFragment());
                    break;
                case R.id.nav_mentions:
                    replaceFragment(new MentionsFragment());
                    break;
                case R.id.nav_account:
                    startMyUserActivity();
                    break;
                case R.id.nav_follow_and_follower:
                    replaceFragment(new MyFollowFollowerFragment());
                    break;
                case R.id.nav_like:
                    replaceFragment(UserLikeFragment.Companion.newInstance(client.getAccessToken().getUserId()));
                    break;
                case R.id.nav_lists:
                    replaceFragment(SelectListsEntriesFragment.Companion.newInstance(client.getAccessToken().getUserId()));
                    break;
                case R.id.nav_settings:
                    startActivity(new Intent(this, SettingsActivity.class));
                    break;
            }
        }
        if (drawer != null) {
            drawer.closeDrawer(GravityCompat.START);
        }
        return (id != R.id.nav_settings) && (id != R.id.nav_account);
    });
    View headerView = navigationView.inflateHeaderView(R.layout.nav_header_main);
    userNameText = headerView.findViewById(R.id.user_name);
    userIdText = headerView.findViewById(R.id.user_id);
    userImage = headerView.findViewById(R.id.user_image);
    userToggleImage = headerView.findViewById(R.id.toggle_account);
    userBackgroundImage = headerView.findViewById(R.id.user_bg_image);
    userBackgroundImage.setOnClickListener(v -> changeIsDrawerAccountsSelection());
    accountListView = new RecyclerView(this);
    accountListView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    accountListView.setLayoutManager(new LinearLayoutManager(this));
    accountListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    accountListView.setVisibility(View.GONE);
    navigationView.addHeaderView(accountListView);
    adapter = new SelectAccountsAdapter(this);
    adapter.onImageButtonClickListener = accessToken -> {
        if (accessToken.getUserId() != client.getAccessToken().getUserId()) {
            changeIsDrawerAccountsSelection();
            if (drawer != null) {
                drawer.closeDrawer(GravityCompat.START);
            }
            GlobalApplicationKt.preferenceRepository.putString(KEY_ACCOUNT_KEY, accessToken.getKeyString());
            ((GlobalApplication) getApplication()).initCurrentClient(accessToken);
            client = GlobalApplicationKt.getClient(this);
            adapter.updateSelectedPosition(accessToken);
            updateDrawerImage();
            clearAndPrepareFragment();
        }
    };
    adapter.onAddButtonClickListener = v -> startActivityForResult(new Intent(this, OAuthActivity.class), REQUEST_OAUTH);
    adapter.onRemoveButtonClickListener = v -> new AlertDialog.Builder(this).setMessage(R.string.confirm_logout).setCancelable(true).setPositiveButton(R.string.do_logout, (dialog, i) -> {
        AccessToken token = accountsModel.get(GlobalApplicationKt.preferenceRepository.getString(KEY_ACCOUNT_KEY, "-1"));
        accountsModel.delete(token);
        adapter.removeAccessTokensAndUpdate(token);
        int point = accountsModel.size() - 1;
        if (point != -1) {
            AccessToken accessToken = accountsModel.getAccessTokens().get(point);
            GlobalApplicationKt.preferenceRepository.putString(KEY_ACCOUNT_KEY, accessToken.getKeyString());
            ((GlobalApplication) getApplication()).initCurrentClient(accessToken);
            client = GlobalApplicationKt.getClient(this);
            adapter.updateSelectedPosition(accessToken);
            updateDrawerImage();
            updateAccountsList();
            clearAndPrepareFragment();
        } else {
            GlobalApplicationKt.preferenceRepository.putString(KEY_ACCOUNT_KEY, "-1");
            ((GlobalApplication) getApplication()).clearCurrentClient();
            startActivityForResult(new Intent(this, OAuthActivity.class), REQUEST_OAUTH);
        }
    }).setNegativeButton(android.R.string.cancel, null).show();
    accountListView.setAdapter(adapter);
    findViewById(R.id.fab).setOnClickListener(v -> startActivity(new Intent(this, PostActivity.class)));
    tabLayout = findViewById(R.id.toolbar_tab);
    tabLayout.addOnTabSelectedListener(this);
    alwaysCloseApp = GlobalApplicationKt.preferenceRepository.getBoolean(KEY_ALWAYS_CLOSE_APP, true);
    recycledViewPool = new RecyclerView.RecycledViewPool();
    recycledViewPool.setMaxRecycledViews(R.layout.layout_post_card, 16);
    getSupportFragmentManager().addOnBackStackChangedListener(() -> attachFragment(getMainFragment()));
    if (client == null) {
        startActivityForResult(new Intent(this, OAuthActivity.class), REQUEST_OAUTH);
    } else {
        updateDrawerImage();
        updateAccountsList();
        if (savedInstanceState == null) {
            prepareFragment();
        }
        if (client.getAccessToken().getToken().isEmpty()) {
            Toast.makeText(this, R.string.please_re_login, Toast.LENGTH_LONG).show();
        }
    }
}
Also used : LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) ImageView(android.widget.ImageView) AccountsModel(com.github.moko256.twitlatte.model.AccountsModel) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) DrawableTransitionOptions(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat) RequestManager(com.bumptech.glide.RequestManager) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) Fragment(androidx.fragment.app.Fragment) View(android.view.View) ListEntry(com.github.moko256.latte.client.base.entity.ListEntry) EmojiToTextViewSetter(com.github.moko256.twitlatte.view.EmojiToTextViewSetter) Schedulers(io.reactivex.schedulers.Schedulers) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContextCompat(androidx.core.content.ContextCompat) MediaUrlConverter(com.github.moko256.latte.client.base.MediaUrlConverter) TabLayout(com.google.android.material.tabs.TabLayout) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) DpToPxKt(com.github.moko256.twitlatte.view.DpToPxKt) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) KEY_ALWAYS_CLOSE_APP(com.github.moko256.twitlatte.repository.PreferenceRepositoryKt.KEY_ALWAYS_CLOSE_APP) Toolbar(androidx.appcompat.widget.Toolbar) Emoji(com.github.moko256.latte.client.base.entity.Emoji) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) NavigationView(com.google.android.material.navigation.NavigationView) User(com.github.moko256.latte.client.base.entity.User) Pair(android.util.Pair) Intent(android.content.Intent) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) TwitterStringUtils(com.github.moko256.twitlatte.text.TwitterStringUtils) Toast(android.widget.Toast) Menu(android.view.Menu) Build(android.os.Build) FragmentManager(androidx.fragment.app.FragmentManager) GravityCompat(androidx.core.view.GravityCompat) Client(com.github.moko256.twitlatte.entity.Client) VerifyCredentialOnSubscribe(com.github.moko256.twitlatte.rx.VerifyCredentialOnSubscribe) KEY_ACCOUNT_KEY(com.github.moko256.twitlatte.repository.PreferenceRepositoryKt.KEY_ACCOUNT_KEY) CachedUsersSQLiteOpenHelper(com.github.moko256.twitlatte.database.CachedUsersSQLiteOpenHelper) AccessToken(com.github.moko256.latte.client.base.entity.AccessToken) Glide(com.bumptech.glide.Glide) FragmentPagerAdapter(com.github.moko256.twitlatte.widget.FragmentPagerAdapter) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Fragment(androidx.fragment.app.Fragment) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) NavigationView(com.google.android.material.navigation.NavigationView) AccessToken(com.github.moko256.latte.client.base.entity.AccessToken) RecyclerView(androidx.recyclerview.widget.RecyclerView) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) LinearLayout(android.widget.LinearLayout) Toolbar(androidx.appcompat.widget.Toolbar)

Example 15 with ActionBarDrawerToggle

use of androidx.appcompat.app.ActionBarDrawerToggle in project MyJapanese by 54wall.

the class MainActivity method initDrawerLayout.

private void initDrawerLayout() {
    mDrawerLayout = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    Log.i(TAG, "initDrawerLayout: OK");
}
Also used : ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle)

Aggregations

ActionBarDrawerToggle (androidx.appcompat.app.ActionBarDrawerToggle)18 View (android.view.View)10 Intent (android.content.Intent)8 TextView (android.widget.TextView)7 NavigationView (com.google.android.material.navigation.NavigationView)7 DrawerLayout (androidx.drawerlayout.widget.DrawerLayout)6 Toolbar (androidx.appcompat.widget.Toolbar)5 Handler (android.os.Handler)4 ImageView (android.widget.ImageView)4 Fragment (androidx.fragment.app.Fragment)4 SharedPreferences (android.content.SharedPreferences)3 Build (android.os.Build)3 Bundle (android.os.Bundle)3 ArgbEvaluator (android.animation.ArgbEvaluator)2 Context (android.content.Context)2 IntentFilter (android.content.IntentFilter)2 Configuration (android.content.res.Configuration)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Uri (android.net.Uri)2 KeyEvent (android.view.KeyEvent)2