Example usage for android.view MenuItem isChecked

List of usage examples for android.view MenuItem isChecked

Introduction

In this page you can find the example usage for android.view MenuItem isChecked.

Prototype

public boolean isChecked();

Source Link

Document

Return whether the item is currently displaying a check mark.

Usage

From source file:org.voidsink.anewjkuapp.fragment.LvaDetailFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_refresh_lvas:
        Intent mUpdateService = new Intent(getActivity(), UpdateService.class);
        mUpdateService.putExtra(Consts.ARG_UPDATE_KUSSS_COURSES, true);
        mUpdateService.putExtra(Consts.ARG_UPDATE_KUSSS_ASSESSMENTS, true);
        getActivity().startService(mUpdateService);

        return true;
    case R.id.action_toggle_visible_lvas:
        item.setChecked(item.isCheckable() && !item.isChecked());
        PreferenceWrapper.setShowCoursesWithAssessmentOnly(getContext(), item.isChecked());
        return true;
    default://  w w w .ja va  2 s  .co  m
        return super.onOptionsItemSelected(item);
    }
}

From source file:info.papdt.blacklight.ui.statuses.NewPostActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.isCheckable() && item.isEnabled()) {
        item.setChecked(!item.isChecked());
    }/*from  ww w . j a  v a2s  .c  o m*/

    int id = item.getItemId();
    if (id == android.R.id.home) {
        finish();
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:io.jawg.osmcontributor.ui.activities.MapActivity.java

private void onFilterItemClick(MenuItem item) {
    long id = item.getItemId();
    if (item.isChecked()) {
        poiTypesHidden.remove(id);// w  w  w.  j  a va  2  s.  c  om
    } else {
        poiTypesHidden.add(id);
    }
    selectAllMenuItem.setChecked(poiTypesHidden.isEmpty());
    eventBus.post(new PleaseApplyPoiFilter(poiTypesHidden));
}

From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java

@SuppressLint("SetTextI18n")
@Override/*from w  w w. j a v  a 2s  .co m*/
public boolean onOptionsItemSelected(MenuItem item) {
    if (Constants.DEBUG && item.getItemId() == R.id.debug_accept_any_log) {
        boolean newCheckedState = !item.isChecked();
        item.setChecked(newCheckedState);
        mDebugModeAcceptAnyCode = newCheckedState;
        if (newCheckedState && TextUtils.isEmpty(mCodeEditText[0].getText())) {
            mCodeEditText[0].setText("ABCD");
            mCodeEditText[1].setText("EFGH");
            mCodeEditText[2].setText("IJKL");
            mCodeEditText[3].setText("MNOP");
            mCodeEditText[4].setText("QRST");
            mCodeEditText[5].setText("UVWX");
            Notify.create(getActivity(), "Actual backup code is all 'A's", Style.WARN).show();
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:fiser.Activities.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.crear:
        Intent detailIntent = new Intent(this, SitioDetailActivity.class);
        Sitio sitio = new Sitio();
        sitio.id = new Random().nextInt(Integer.MAX_VALUE);
        detailIntent.putExtra("sitio", sitio);
        startActivityForResult(detailIntent, PICK_CONTACT_REQUEST);
        return true;
    case R.id.settings:
        detailIntent = new Intent(this, SitioSettingsActivity.class);
        startActivity(detailIntent);//  w w  w .j  a v a  2 s .c om
        return true;
    case R.id.cerca:
        item.setChecked(!item.isChecked());
        listaRecargar(item.isChecked());
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:io.jawg.osmcontributor.ui.activities.MapActivity.java

private void onOtherItemClick(MenuItem menuItem) {
    boolean checked = menuItem.isChecked();
    Poi.AccessibilityType accessibilityType = null;
    switch (menuItem.getItemId()) {
    case R.id.display_open_notes_item:
        displayOpenNotes = checked;//from   w w  w.  j  av  a  2s  .  c  o  m
        break;
    case R.id.display_closed_notes_item:
        displayClosedNotes = checked;
        break;
    case R.id.display_yes_accessibility:
        accessibilityType = Poi.AccessibilityType.YES;
        break;
    case R.id.display_limited_accessibility:
        accessibilityType = Poi.AccessibilityType.LIMITED;
        break;
    case R.id.display_no_accessibility:
        accessibilityType = Poi.AccessibilityType.NO;
        break;
    case R.id.display_unknown_accessibility:
        accessibilityType = Poi.AccessibilityType.UNKNOWN;
        break;
    }
    if (accessibilityType != null) {
        if (checked) {
            poiAccessibilityTypesHidden.remove(accessibilityType);
        } else {
            poiAccessibilityTypesHidden.add(accessibilityType);
        }
        eventBus.post(new PleaseApplyAccessibilityFilter(poiAccessibilityTypesHidden));
    } else {
        eventBus.post(new PleaseApplyNoteFilterEvent(displayOpenNotes, displayClosedNotes));
    }
}

From source file:org.jamienicol.episodes.ShowsListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_refresh_all_shows:
        refreshAllShows();/*from  www.j av a 2 s  .  c  o  m*/
        return true;

    case R.id.menu_filter_all:
    case R.id.menu_filter_starred:
    case R.id.menu_filter_uncompleted:
    case R.id.menu_filter_archived:
        if (!item.isChecked()) {
            item.setChecked(true);
        }

        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
        final SharedPreferences.Editor editor = prefs.edit();
        if (item.getItemId() == R.id.menu_filter_all) {
            editor.putInt(KEY_PREF_SHOWS_FILTER, SHOWS_FILTER_ALL);
        } else if (item.getItemId() == R.id.menu_filter_starred) {
            editor.putInt(KEY_PREF_SHOWS_FILTER, SHOWS_FILTER_STARRED);
        } else if (item.getItemId() == R.id.menu_filter_uncompleted) {
            editor.putInt(KEY_PREF_SHOWS_FILTER, SHOWS_FILTER_UNCOMPLETED);
        } else if (item.getItemId() == R.id.menu_filter_archived) {
            editor.putInt(KEY_PREF_SHOWS_FILTER, SHOWS_FILTER_ARCHIVED);
        }
        editor.apply();

        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.inovex.zabbixmobile.activities.BaseActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
    Intent intent;/* w w  w  . j  a v a  2 s  .c  om*/
    if (menuItem.isChecked())
        menuItem.setChecked(false);
    else
        menuItem.setChecked(true);

    if (mServerSelectMode) {
        selectServerItem(menuItem.getItemId());
        toggleServerSelectionMode();
        return true;
    }

    //Closing drawer on item click
    switch (menuItem.getItemId()) {
    case R.id.navigation_item_problems:
        intent = new Intent(this, ProblemsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        mDrawerLayout.closeDrawers();
        break;
    case R.id.navigation_item_events:
        intent = new Intent(this, EventsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        mDrawerLayout.closeDrawers();
        break;
    case R.id.navigation_item_checks:
        intent = new Intent(this, ChecksActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        mDrawerLayout.closeDrawers();
        break;
    case R.id.navigation_item_screens:
        intent = new Intent(this, ScreensActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        mDrawerLayout.closeDrawers();
        break;
    case R.id.navigation_settings:
        intent = new Intent(this, ZaxPreferenceActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivityForResult(intent, REQUEST_CODE_PREFERENCES);
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        return true;
    case R.id.navigation_manage_servers:
        intent = new Intent(this, ServersActivity.class);
        break;
    case R.id.navigation_info:
        intent = new Intent(this, InfoActivity.class);
        break;
    default:
        return true;
    }
    startActivity(intent);
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

    // update selected item and title, then close the drawer
    //mDrawerFragment.selectMenuItem(position);
    return true;
}

From source file:de.grobox.transportr.trips.search.DirectionsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_swap_locations:
        swapLocations();/*from w w  w .j  a v  a 2  s  .  c o m*/
        return true;
    case R.id.action_departure:
        viewModel.setIsDeparture(true);
        return true;
    case R.id.action_arrival:
        viewModel.setIsDeparture(false);
        return true;
    case R.id.action_navigation_expand:
        viewModel.setIsExpanded(!item.isChecked());
        return true;
    case R.id.action_choose_products:
        new ProductDialogFragment().show(getActivity().getSupportFragmentManager(), ProductDialogFragment.TAG);
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.emman.tame.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.

    int id = item.getItemId();
    if (id == R.id.settings) {
        startActivity(new Intent(this, Settings.class));
        return true;
    } else if (id == R.id.debug) {
        item.setChecked(!item.isChecked());
        if (item.isChecked())
            Utils.burntToast(this, getString(R.string.item_msg_tamelog, FILE_TAME_LOG));
        updateSharedPrefs(mPreferences, TAME_DEBUG, Utils.boolToString(item.isChecked()));
        return true;
    } else if (id == R.id.sob) {
        item.setChecked(!item.isChecked());
        TextView mSOBNote = (TextView) findViewById(R.id.sobnote);
        if (mSOBNote != null)
            mSOBNote.setEnabled(item.isChecked());
        updateSharedPrefs(mPreferences, SET_ON_BOOT, Utils.boolToString(item.isChecked()));
        return true;
    }/*from  w  w w  .ja  va2 s . c  o m*/
    return super.onOptionsItemSelected(item);
}