Search in sources :

Example 6 with NavigationView

use of com.google.android.material.navigation.NavigationView in project mopub-android-mediation by mopub.

the class MoPubSampleActivity method syncNavigationMenu.

private void syncNavigationMenu() {
    final NavigationView navigationView = findViewById(R.id.nav_view);
    SampleActivityInternalUtils.updateEndpointMenu(navigationView.getMenu());
    final PersonalInfoManager manager = MoPub.getPersonalInformationManager();
    if (manager != null) {
        final ConsentData consentData = manager.getConsentData();
        navigationView.getMenu().findItem(R.id.nav_force_gdpr).setChecked(consentData.isForceGdprApplies());
        final ConsentStatus consentStatus = manager.getPersonalInfoConsentStatus();
        if (consentStatus.equals(ConsentStatus.POTENTIAL_WHITELIST)) {
            navigationView.getMenu().findItem(R.id.nav_privacy_grant).setChecked(true);
        } else if (consentStatus.equals(ConsentStatus.EXPLICIT_NO)) {
            navigationView.getMenu().findItem(R.id.nav_privacy_revoke).setChecked(true);
        }
    }
}
Also used : PersonalInfoManager(com.mopub.common.privacy.PersonalInfoManager) NavigationView(com.google.android.material.navigation.NavigationView) ConsentStatus(com.mopub.common.privacy.ConsentStatus) ConsentData(com.mopub.common.privacy.ConsentData)

Example 7 with NavigationView

use of com.google.android.material.navigation.NavigationView in project EhViewer by seven332.

the class MainActivity method onCreate2.

@Override
protected void onCreate2(@Nullable Bundle savedInstanceState) {
    setContentView(R.layout.activity_main);
    mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(this, R.id.draw_view);
    mNavView = (NavigationView) ViewUtils.$$(this, R.id.nav_view);
    mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer);
    View headerLayout = mNavView.getHeaderView(0);
    mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar);
    mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name);
    mChangeTheme = (Button) ViewUtils.$$(this, R.id.change_theme);
    mDrawerLayout.setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
    // Pre-L need shadow drawable
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_right, Gravity.RIGHT);
    }
    updateProfile();
    if (mNavView != null) {
        mNavView.setNavigationItemSelectedListener(this);
    }
    mChangeTheme.setText(getThemeText());
    mChangeTheme.setOnClickListener(v -> {
        Settings.putTheme(getNextTheme());
        ((EhApplication) getApplication()).recreate();
    });
    if (savedInstanceState == null) {
        onInit();
        CommonOperations.checkUpdate(this, false);
        checkDownloadLocation();
        if (Settings.getCellularNetworkWarning()) {
            checkCellularNetwork();
        }
    } else {
        onRestore(savedInstanceState);
    }
    EhTagDatabase.update(this);
}
Also used : EhApplication(com.hippo.ehviewer.EhApplication) View(android.view.View) LoadImageView(com.hippo.widget.LoadImageView) TextView(android.widget.TextView) NavigationView(com.google.android.material.navigation.NavigationView)

Example 8 with NavigationView

use of com.google.android.material.navigation.NavigationView in project mopub-android-mediation by mopub.

the class MoPubSampleActivity method setupNavigationDrawer.

private void setupNavigationDrawer(Toolbar toolbar) {
    mDrawerLayout = findViewById(R.id.drawer_layout);
    final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    final NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : NavigationView(com.google.android.material.navigation.NavigationView) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle)

Example 9 with NavigationView

use of com.google.android.material.navigation.NavigationView 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 10 with NavigationView

use of com.google.android.material.navigation.NavigationView 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)

Aggregations

NavigationView (com.google.android.material.navigation.NavigationView)11 View (android.view.View)6 Intent (android.content.Intent)4 TextView (android.widget.TextView)4 ActionBarDrawerToggle (androidx.appcompat.app.ActionBarDrawerToggle)4 ImageView (android.widget.ImageView)3 DrawerLayout (androidx.drawerlayout.widget.DrawerLayout)3 Handler (android.os.Handler)2 Toolbar (androidx.appcompat.widget.Toolbar)2 FragmentManager (androidx.fragment.app.FragmentManager)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 IntentFilter (android.content.IntentFilter)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Pair (android.util.Pair)1 KeyEvent (android.view.KeyEvent)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 ViewGroup (android.view.ViewGroup)1