Example usage for android.view MenuItem getTitle

List of usage examples for android.view MenuItem getTitle

Introduction

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

Prototype

public CharSequence getTitle();

Source Link

Document

Retrieve the current title of the item.

Usage

From source file:com.github.kanata3249.ffxieq.android.EquipmentSelectorActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    EquipmentListView elv = (EquipmentListView) findViewById(R.id.ListView);

    if (item.getGroupId() == R.id.FilterByType) {
        if (item.getItemId() < 0) {
            mFilterByType = "";
        } else {/*from w w  w .j a  va2  s . c  o  m*/
            mFilterByType = (String) item.getTitle();
        }
        elv.setFilterByType(mFilterByType);
        return true;
    }

    switch (item.getItemId()) {
    case R.id.OrderByName:
        mOrderByName = !mOrderByName;
        if (elv != null) {
            elv.setOrderByName(mOrderByName);
        }
        return true;
    case R.id.Remove: {
        Intent result = new Intent();

        result.putExtra("From", "EquipmentSelector");
        result.putExtra("Part", mPart);
        result.putExtra("Id", -1);
        result.putExtra("AugId", -1);
        setResult(RESULT_OK, result);
        finish();
        return true;
    }
    case R.id.Filter:
        showDialog(0);
        return true;
    case R.id.ResetFilter:
        if (elv != null) {
            elv.setFilter("");
        }
        mFilterID = -1;
        return true;
    case R.id.AugmentList: {
        Intent result = new Intent();

        result.putExtra("From", "EquipmentSelector");
        result.putExtra("Part", mPart);
        setResult(RESULT_FIRST_USER, result);
        finish();
        return true;
    }

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

From source file:pw.dedominic.airc.App.java

/**
 * handles nav items/*from w w w.j  a  v  a  2 s  .c  o  m*/
 *
 * @param item the selected item
 * @return true if handled
 */
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
        onBackPressed();
    }
    Server selected = dao.queryForId(item.getTitle().toString());
    if (selected != null && editSelect) {
        createOrEditServer(selected.getTitle());
        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        drawer.closeDrawer(Gravity.LEFT);
        editSelect = false;
        deleteSelect = false;
        return true;
    } else if (selected != null && deleteSelect) {
        removeServer(selected.getTitle());
        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        drawer.closeDrawer(Gravity.LEFT);
        deleteSelect = false;
        editSelect = false;
        return true;
    } else if (selected != null) {
        changeServer(selected);
        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        drawer.closeDrawer(Gravity.LEFT);
    }

    if (item.getTitle().toString().equals("Add Server")) {
        if (editSelect || deleteSelect) {
            editSelect = false;
            deleteSelect = false;
        }
        createOrEditServer("");
        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        drawer.closeDrawer(Gravity.LEFT);
    } else if (item.getTitle().toString().equals("Edit Server")) {
        if (!editSelect) {
            Toast.makeText(this, "Tap Server to Edit or retap to cancel", Toast.LENGTH_SHORT).show();
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
        } else {
            Toast.makeText(this, "Canceled", Toast.LENGTH_SHORT).show();
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        }
        if (deleteSelect)
            deleteSelect = false;
        editSelect = !editSelect;
    } else if (item.getTitle().toString().equals("Delete Server")) {
        if (!deleteSelect) {
            Toast.makeText(this, "Tap Server to delete or retap to cancel", Toast.LENGTH_SHORT).show();
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
        } else {
            Toast.makeText(this, "Canceled", Toast.LENGTH_SHORT).show();
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        }
        if (editSelect)
            editSelect = false;
        deleteSelect = !deleteSelect;
    } else if (item.getTitle().toString().equals("Settings")) {
        editSelect = false;
        deleteSelect = false;
        showSettings();
        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        drawer.closeDrawer(Gravity.LEFT);
    } else if (item.getTitle().toString().equals("Exit")) {
        finishAffinity();
        System.exit(0);
    }
    return true;
}

From source file:org.lathanh.android.mvp.demo.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    FragmentManager fragmentManager = getSupportFragmentManager();

    if (id == R.id.clear) {
        Fragment activeFragment = fragmentManager.findFragmentById(R.id.container);
        if (activeFragment != null) {
            fragmentManager.beginTransaction().remove(activeFragment).setBreadCrumbTitle(R.string.clear)
                    .commit();/* w  ww  . j av a2s .  c  om*/
        }
        return true;
    } else {
        for (MenuOption menuOption : MenuOption.values()) {
            if (id == menuOption.menuId) {
                fragmentManager.beginTransaction().replace(R.id.container, menuOption.newInstance())
                        .setBreadCrumbTitle(item.getTitle()).commit();
                return true;
            }
        }
    }

    return super.onOptionsItemSelected(item);
}

From source file:fr.poucedor.poucedor.MapActivity.java

private void setupDrawerLayout() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    navigationView = (NavigationView) findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override// w  w w .j  a va 2s .com
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            Intent intent;
            switch (menuItem.getItemId()) {
            case R.id.navdrawer_item_ranking:
                intent = new Intent(MapActivity.this, RankingActivity.class);
                startActivity(intent);
                return true;
            case R.id.navdrawer_item_settings:
                intent = new Intent(MapActivity.this, SettingsActivity.class);
                startActivity(intent);
                return true;
            default:
                Snackbar.make(content, menuItem.getTitle() + " pressed", Snackbar.LENGTH_LONG).show();
                menuItem.setChecked(true);
                drawerLayout.closeDrawers();
                return true;
            }
        }
    });
}

From source file:cz.yetanotherview.webcamviewer.app.MainActivity.java

private void setupNavDrawer() {

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
    mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override// w  ww  . ja va  2 s. com
        public boolean onNavigationItemSelected(MenuItem menuItem) {

            menuItem.setChecked(true);
            mDrawerLayout.closeDrawer(GravityCompat.START);
            String title = menuItem.getTitle().toString();
            switch (menuItem.getItemId()) {
            case R.id.latest_webcams:
                setNewRootFragment(StandardAppBarFragment.newInstance(), R.id.latest_webcams, title);
                return true;
            case R.id.popular_webcams:
                setNewRootFragment(StandardAppBarFragment.newInstance(), R.id.popular_webcams, title);
                return true;
            case R.id.nearby_webcams:
                setNewRootFragment(StandardAppBarFragment.newInstance(), R.id.nearby_webcams, title);
                return true;
            case R.id.selecting_by_name:
                setNewRootFragment(SearchAppBarFragment.newInstance(), R.id.selecting_by_name, title);
                return true;
            case R.id.selecting_by_country:
                //setNewRootFragment(StandardAppBarFragment.newInstance(), R.id.selecting_by_country, title);
                return true;
            case R.id.selecting_by_type:
                setNewRootFragment(TabHolderFragment.newInstance(), R.id.selecting_by_type, title);
                return true;
            case R.id.live_streams:
                setNewRootFragment(StandardAppBarFragment.newInstance(), R.id.live_streams, title);
                return true;
            case R.id.selecting_from_map:
                setNewRootFragment(MapAppBarFragment.newInstance(), R.id.selecting_from_map, title);
                return true;
            case R.id.favorites_webcams:
                //setNewRootFragment(StandardAppBarFragment.newInstance(), R.id.favorites_webcams, title);
                return true;
            case R.id.all_local_webcams:
                setNewRootFragment(StandardLocalAppBarFragment.newInstance(), R.id.all_local_webcams, title);
                return true;
            case R.id.action_settings:
                openSettings();
                return true;
            case R.id.action_menu_help:
                openHelp();
                return true;
            default:
                return true;
            }
        }
    });
}

From source file:br.liveo.ndrawer.ui.fragment.FragmentNotificationsfacebook.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getTitle() == "Yes") {

        Log.i("yes", "reached yes");

        if (pos != null) {
            Log.i("yes2", "reached yes");

        }//  ww w . ja  v a2  s  .  co  m

    }
    //        else if(item.getTitle()=="Action 2"){
    //
    //        }
    else {
        return false;
    }
    return true;
}

From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    AugmentListView lv = (AugmentListView) findViewById(R.id.ListView);

    if (item.getGroupId() == R.id.FilterByType) {
        if (item.getItemId() < 0) {
            mFilterByType = "";
        } else {//w ww  .j a  v  a 2s  .c om
            mFilterByType = (String) item.getTitle();
        }
        lv.setFilterByType(mFilterByType);
        return true;
    }

    switch (item.getItemId()) {
    case R.id.OrderByName:
        mOrderByName = !mOrderByName;
        if (lv != null) {
            lv.setOrderByName(mOrderByName);
        }
        return true;
    case R.id.Remove: {
        Intent result = new Intent();

        result.putExtra("From", "AugmentSelector");
        result.putExtra("Part", mPart);
        result.putExtra("Id", -1);
        result.putExtra("AugId", -1);
        setResult(RESULT_OK, result);
        finish();
        return true;
    }
    case R.id.Filter:
        showDialog(0);
        return true;
    case R.id.ResetFilter:
        if (lv != null) {
            lv.setFilter("");
        }
        mFilterID = -1;
        return true;
    case R.id.EquipmentList: {
        Intent result = new Intent();

        result.putExtra("From", "AugmentSelector");
        result.putExtra("Part", mPart);
        setResult(RESULT_FIRST_USER, result);
        finish();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.techno.jay.codingcontests.Home.java

private void applyFontToMenuItem(MenuItem mi) {
    Typeface font = Typeface.createFromAsset(getAssets(), "ProductSans-Regular.ttf");
    SpannableString mNewTitle = new SpannableString(mi.getTitle());
    mNewTitle.setSpan(new CustomTypefaceSpan("", font), 0, mNewTitle.length(),
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    mi.setTitle(mNewTitle);//w ww.j a v  a 2s .c  o m
}

From source file:com.github.rubensousa.floatingtoolbar.FloatingToolbar.java

@Override
public boolean onLongClick(View v) {
    if (!mMorphed || mMorphing) {
        return false;
    }/*from   ww  w .  j  a  v a 2 s.c o  m*/

    if (mClickListener != null) {
        MenuItem item = (MenuItem) v.getTag();
        if (mShowToast) {
            if (mToast != null) {
                mToast.cancel();
            }
            mToast = Toast.makeText(getContext(), item.getTitle(), Toast.LENGTH_SHORT);
            mToast.setGravity(Gravity.BOTTOM, 0, (int) (getHeight() * 1.25f));
            mToast.show();
        }
        mClickListener.onItemLongClick(item);
        return true;
    } else {
        return false;
    }
}

From source file:tm.alashow.datmusic.ui.activity.MainActivity.java

/**
 * Set file size and audio bitrate to download menu
 *
 * @param bottomSheet menu where located download button
 * @param audio       file for get info//from   ww  w. j av a2s.co m
 */
private void setSizeAndBitrate(BottomSheet bottomSheet, Audio audio) {
    MenuItem menuItem = bottomSheet.getMenu().findItem(R.id.download);
    long bitrate = audio.getBytes() / audio.getDuration() / 120;
    menuItem.setTitle(String.format(Locale.US, "%s (%s ~ %d kbps)", menuItem.getTitle(),
            U.humanReadableByteCount(audio.getBytes(), false), bitrate));
    bottomSheet.invalidate();
}