Example usage for android.view MenuInflater inflate

List of usage examples for android.view MenuInflater inflate

Introduction

In this page you can find the example usage for android.view MenuInflater inflate.

Prototype

public void inflate(@MenuRes int menuRes, Menu menu) 

Source Link

Document

Inflate a menu hierarchy from the specified XML resource.

Usage

From source file:com.androguide.honamicontrol.soundcontrol.SoundFragment.java

private static void createCards() {
    String sectionColor = fa.getString(R.string.sound_control_color);
    mCardUI.addStack(new CardStack(""));

    if (!Helpers.doesFileExist(FAUX_SC_VERSION)) {
        mCardUI.addCard(new CardTextStripe(fa.getString(R.string.unsupported),
                fa.getString(R.string.sound_control_unsupported), "#C74B46", "#C74B46", false));

    } else {/*w  w w.j av  a 2  s . com*/

        String[] headphoneGains = CPUHelper.readOneLineNotRoot(FAUX_SC_HEADPHONE).split(" ");
        int headphoneGainLeft = Integer.valueOf(headphoneGains[0]);
        if (headphoneGainLeft > 100)
            headphoneGainLeft -= 256;

        int headphoneGainRight = Integer.valueOf(headphoneGains[1]);
        if (headphoneGainRight > 100)
            headphoneGainRight -= 256;

        final CardDoubleSeekBar headphoneCard = new CardDoubleSeekBar(
                fa.getString(R.string.sc_headphone_digital_gain),
                fa.getString(R.string.sc_headphone_digital_gain_desc), sectionColor, "", FAUX_SC_HEADPHONE, 40,
                headphoneGainLeft + 30, headphoneGainRight + 30, fa, null);
        mCards.add(headphoneCard);
        mCardUI.addCard(headphoneCard);

        String[] headphonePAGains = CPUHelper.readOneLineNotRoot(FAUX_SC_HEADPHONE_POWERAMP).split(" ");
        int headphonePAGainLeft = Integer.valueOf(headphonePAGains[0]);
        int headphonePAGainRight = Integer.valueOf(headphonePAGains[1]);
        CardDoubleSeekBarPA headphonePaCard = new CardDoubleSeekBarPA(
                fa.getString(R.string.sc_headphone_analog_gain),
                fa.getString(R.string.sc_headphone_analog_gain_desc), sectionColor, "",
                FAUX_SC_HEADPHONE_POWERAMP, 12, headphonePAGainLeft, headphonePAGainRight, fa, null);
        mCards.add(headphonePaCard);
        mCardUI.addCard(headphonePaCard);

        String[] speakerGains = CPUHelper.readOneLineNotRoot(FAUX_SC_SPEAKER).split(" ");
        int speakerGainLeft = Integer.valueOf(speakerGains[0]);
        if (speakerGainLeft > 100)
            speakerGainLeft -= 256;

        int speakerGainRight = Integer.valueOf(speakerGains[1]);
        if (speakerGainRight > 100)
            speakerGainRight -= 256;

        CardDoubleSeekBar speakerCard = new CardDoubleSeekBar(fa.getString(R.string.sc_speaker_gain),
                fa.getString(R.string.sc_speaker_gain_desc), fa.getString(R.string.sound_control_color), "",
                FAUX_SC_SPEAKER, 40, speakerGainLeft + 30, speakerGainRight + 30, fa, null);

        mCards.add(speakerCard);
        mCardUI.addCard(speakerCard);

        int micGain = Integer.valueOf(CPUHelper.readOneLine(FAUX_SC_MIC));
        if (micGain > 100)
            micGain -= 256;

        CardSeekBarSC micCard = new CardSeekBarSC(fa.getString(R.string.sc_mic_gain),
                fa.getString(R.string.sc_mic_gain_desc), fa.getString(R.string.sound_control_color), "",
                FAUX_SC_MIC, 40, micGain + 30, fa, new ActionMode.Callback() {
                    private Boolean isApplied = false;

                    @Override
                    public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                        MenuInflater inflater = actionMode.getMenuInflater();
                        inflater.inflate(R.menu.contextual_menu, menu);
                        return true;
                    }

                    @Override
                    public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                        return false;
                    }

                    @Override
                    public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                        switch (menuItem.getItemId()) {
                        case R.id.cancel:
                            actionMode.finish();
                            break;
                        case R.id.apply:
                            isApplied = true;
                            SharedPreferences prefs = fa
                                    .getSharedPreferences("syskernelsound_control_3gpl_mic_gain", 0);
                            int toApply = prefs.getInt("VALUE", 0);
                            Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                                    + "busybox echo " + toApply + " "
                                    + Helpers.getSoundCountrolBitRepresentation(toApply, 0) + " > "
                                    + FAUX_SC_MIC + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                            bootPrefs.edit()
                                    .putString("SC_MIC",
                                            toApply + " "
                                                    + Helpers.getSoundCountrolBitRepresentation(toApply, 0))
                                    .commit();
                            actionMode.finish();
                        }
                        return false;
                    }

                    @Override
                    public void onDestroyActionMode(ActionMode actionMode) {
                        if (!isApplied) {
                            mCardUI.clearCards();
                            createCards();
                        }
                    }
                });
        mCards.add(micCard);
        mCardUI.addCard(micCard);

        int camMicGain = Integer.valueOf(CPUHelper.readOneLine(FAUX_SC_CAM_MIC));
        if (camMicGain > 100)
            camMicGain -= 256;

        CardSeekBarSC camCard = new CardSeekBarSC(fa.getString(R.string.sc_cam_mic_gain),
                fa.getString(R.string.sc_cam_mic_gain_desc), fa.getString(R.string.sound_control_color), "",
                FAUX_SC_CAM_MIC, 40, camMicGain + 30, fa, new ActionMode.Callback() {
                    private Boolean isApplied = false;

                    @Override
                    public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                        MenuInflater inflater = actionMode.getMenuInflater();
                        inflater.inflate(R.menu.contextual_menu, menu);
                        return true;
                    }

                    @Override
                    public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                        return false;
                    }

                    @Override
                    public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                        switch (menuItem.getItemId()) {
                        case R.id.cancel:
                            actionMode.finish();
                            break;
                        case R.id.apply:
                            isApplied = true;
                            SharedPreferences prefs = fa
                                    .getSharedPreferences("syskernelsound_control_3gpl_cam_mic_gain", 0);
                            int toApply = prefs.getInt("VALUE", 0);
                            Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                                    + "busybox echo " + toApply + " "
                                    + Helpers.getSoundCountrolBitRepresentation(toApply, 0) + " > "
                                    + FAUX_SC_CAM_MIC + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                            bootPrefs.edit()
                                    .putString("SC_CAM_MIC",
                                            toApply + " "
                                                    + Helpers.getSoundCountrolBitRepresentation(toApply, 0))
                                    .commit();
                            actionMode.finish();
                            break;
                        }
                        return false;
                    }

                    @Override
                    public void onDestroyActionMode(ActionMode actionMode) {
                        if (!isApplied) {
                            mCardUI.clearCards();
                            createCards();
                        }
                    }
                });
        mCards.add(camCard);
        mCardUI.addCard(camCard);
    }
    mCardUI.refresh();
}

From source file:MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_options, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;//from  w  w w  . j a v a2s.c  o m
}

From source file:aws.apps.usbDeviceEnumerator.ui.usbinfo.BaseInfoFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.frag_menu, menu);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:cn.steve.imageloader.fragment.BaseFragment.java

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main_menu, menu);
}

From source file:at.bitfire.davdroid.syncadapter.AddAccountActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.add_account, menu);
    return true;//from w  w w . j  av  a 2  s  . c om
}

From source file:ar.rulosoft.mimanganu.LicenseFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.view_license, menu);
}

From source file:com.android.infosessions.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    return true;// ww  w . jav  a2s.c  o  m
}

From source file:at.wada811.android.library.demos.loader.LoaderListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_search, menu);
    initSearchView(menu.findItem(R.id.search));
    return true;/*from  w ww .  ja  va2  s .  c  om*/
}

From source file:at.bitfire.davdroid.syncadapter.SelectCollectionsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.select_collections, menu);
}

From source file:at.bitfire.davdroid.syncadapter.AccountDetailsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.account_details, menu);
}