Example usage for android.view Menu clear

List of usage examples for android.view Menu clear

Introduction

In this page you can find the example usage for android.view Menu clear.

Prototype

public void clear();

Source Link

Document

Remove all existing items from the menu, leaving it empty as if it had just been created.

Usage

From source file:org.saydroid.tether.usb.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Log.d(TAG, "sayCV - onPrepareOptionsMenu");
    if (mScreenService.getCurrentScreen().hasMenu()) {
        menu.clear();
        return mScreenService.getCurrentScreen().createOptionsMenu(menu);
    }/*  w  w  w . j  a v  a 2 s.com*/
    return false;
}

From source file:com.sagar.sunshine.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        ViewParent vp = getView().getParent();
        if (vp instanceof CardView) {
            ((View) vp).setVisibility(View.VISIBLE);
        }/*from   w  ww  .j  av  a2s .c  o m*/

        int weatherId = data.getInt(COL_WEATHER_CONDITION_ID);

        if (Utility.usingLocalGraphics(getActivity())) {
            mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));
        } else {
            Glide.with(this).load(Utility.getArtUrlForWeatherCondition(getActivity(), weatherId))
                    .error(Utility.getArtResourceForWeatherCondition(weatherId)).crossFade().into(mIconView);
        }

        long date = data.getLong(COL_WEATHER_DATE);
        String dateText = Utility.getFullFriendlyDayString(getActivity(), date);
        mDateView.setText(dateText);

        String description = Utility.getStringForWeatherCondition(getActivity(), weatherId);
        mDescriptionView.setText(description);
        mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description));

        mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description));

        boolean isMetric = Utility.isMetric(getActivity());

        double high = data.getDouble(COL_WEATHER_MAX_TEMP);
        String highString = Utility.formatTemperature(getActivity(), high);
        mHighTempView.setText(highString);
        mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString));

        double low = data.getDouble(COL_WEATHER_MIN_TEMP);
        String lowString = Utility.formatTemperature(getActivity(), low);
        mLowTempView.setText(lowString);
        mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString));

        float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
        mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));
        mHumidityView.setContentDescription(getString(R.string.a11y_humidity, mHumidityView.getText()));
        mHumidityLabelView.setContentDescription(mHumidityView.getContentDescription());

        float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
        float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
        mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));
        mWindView.setContentDescription(getString(R.string.a11y_wind, mWindView.getText()));
        mWindLabelView.setContentDescription(mWindView.getContentDescription());

        float pressure = data.getFloat(COL_WEATHER_PRESSURE);
        mPressureView.setText(getString(R.string.format_pressure, pressure));
        mPressureView.setContentDescription(getString(R.string.a11y_pressure, mPressureView.getText()));
        mPressureLabelView.setContentDescription(mPressureView.getContentDescription());

        mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

    }
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar);

    if (mTransitionAnimation) {
        activity.supportStartPostponedEnterTransition();

        if (null != toolbarView) {
            activity.setSupportActionBar(toolbarView);

            activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
            activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    } else {
        if (null != toolbarView) {
            Menu menu = toolbarView.getMenu();
            if (null != menu)
                menu.clear();
            toolbarView.inflateMenu(R.menu.detailfragment);
            finishCreatingMenu(toolbarView.getMenu());
        }
    }
}

From source file:com.tingtingapps.securesms.ConversationListActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuInflater inflater = this.getMenuInflater();
    menu.clear();

    inflater.inflate(R.menu.text_secure_normal, menu);
    inflater.inflate(R.menu.lock, menu);
    menu.findItem(R.id.menu_clear_passphrase).setVisible(true); //!TextSecurePreferences.isPasswordDisabled(this)

    inflater.inflate(R.menu.conversation_list, menu);
    MenuItem menuItem = menu.findItem(R.id.menu_search);
    initializeSearch(menuItem);//from  ww  w  .  j a va2 s .  c om

    super.onPrepareOptionsMenu(menu);
    return true;
}

From source file:com.gmail.at.faint545.fragments.QueueFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    /* Only show these options if there are jobs to delete */
    if (mSelectedPositions.size() > 0 && mJobs.size() > 0) {
        menu.add(Menu.NONE, DELETE, Menu.NONE, "Delete selected");
        menu.add(Menu.NONE, PAUSE, Menu.NONE, "Pause selected");
        menu.add(Menu.NONE, RESUME, Menu.NONE, "Resume selected");
    } else if (mJobs.size() > 0) {
        menu.add(Menu.NONE, DELETE, Menu.NONE, "Delete all");
        menu.add(Menu.NONE, PAUSE, Menu.NONE, "Pause all");
        menu.add(Menu.NONE, RESUME, Menu.NONE, "Resume all");
    }//w  ww. ja v a  2s  .co m
    super.onPrepareOptionsMenu(menu);
}

From source file:com.activiti.android.app.fragments.task.TasksFragment.java

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

From source file:com.synchophy.ui.CoverFlowActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    menu.add(0, BrowseActivity.MAIN, 0, R.string.mainMenu).setIcon(android.R.drawable.ic_menu_revert);
    menu.add(0, BrowseActivity.PLAYLIST, 1, R.string.playlist).setIcon(R.drawable.ic_menu_pmix_playlist);
    menu.add(0, BrowseActivity.FILTER, 1,
            PlayerManager.isFiltering() ? R.string.stopFiltering : R.string.startFiltering)
            .setIcon(PlayerManager.isFiltering() ? R.drawable.ic_menu_stop : R.drawable.ic_menu_filter);

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileActions.java

private void getMenu(Menu menu) {
    menu.clear();

    MenuItem mi;//from   w  ww.j a v  a2s  .c om

    if (getFragment() instanceof ListingModeFragment) {
        switch (((ListingModeFragment) getFragment()).getMode()) {
        case FileExplorerFragment.MODE_LISTING:
            if (selectedFolder.isEmpty()) {
                mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload);
                mi.setIcon(R.drawable.ic_upload);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

                mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST + 100, R.string.share);
                mi.setIcon(R.drawable.ic_share);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            }

            mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete);
            mi.setIcon(R.drawable.ic_delete);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            break;

        case FileExplorerFragment.MODE_PICK:

            if (selectedFolder.isEmpty()) {
                mi = menu.add(Menu.NONE, R.id.menu_file_send, Menu.FIRST, R.string.action_upload);
                mi.setIcon(R.drawable.ic_upload);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS);
            }

            break;

        default:
            break;
        }
        mi = menu.add(Menu.NONE, R.id.menu_select_all, Menu.FIRST + 200, R.string.select_all);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }
}

From source file:net.idlesoft.android.apps.github.activities.SingleActivityItem.java

public boolean onPrepareOptionsMenu(final Menu menu) {
    if (menu.hasVisibleItems()) {
        menu.clear();
    }//from   ww  w.  ja  va  2 s . c om
    menu.add(0, 0, 0, "Back to Main").setIcon(android.R.drawable.ic_menu_revert);
    menu.add(0, 1, 0, "Clear Preferences");
    menu.add(0, 2, 0, "Clear Cache");
    return true;
}

From source file:cn.wjh1119.bestnews.ui.fragment.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {

        //?????view
        FetchDetailDataFromSqlTask fetchDetailDataFromSqlTask = new FetchDetailDataFromSqlTask();
        fetchDetailDataFromSqlTask// w  w  w  . j  ava2 s . c  o  m
                .setOnDataFinishedListener(new FetchDetailDataFromSqlTask.OnDataFinishedListener() {
                    @Override
                    public void onDataSuccessfully(HashMap data) {

                        String title = data.get("title").toString();
                        String source = data.get("source").toString();
                        String pubDate = data.get("pubDate").toString();
                        String content = data.get("content").toString();
                        String link = data.get("link").toString();
                        //                    BitmapDrawable drawable = (BitmapDrawable) data.get("drawable");
                        Object imageTextFromSql = data.get("imageUrl");
                        String imageUrl = null;
                        if (imageTextFromSql != null) {
                            imageUrl = data.get("imageUrl").toString();
                        }

                        mTitleView.setText(title);
                        mTitleView.setFocusable(true);
                        mTitleView.setFocusableInTouchMode(true);
                        mTitleView.requestFocus();
                        TextPaint paint = mTitleView.getPaint();
                        paint.setFakeBoldText(true);
                        mSourceView.setText(source);
                        mPubDateView.setText(pubDate);
                        mContentView.setText(content);

                        if (imageUrl != null) {
                            Bitmap bitmap = imageManager.showCacheBitmap(imageUrl);
                            if (bitmap != null) {
                                mImageView.setImageBitmap(bitmap);

                            } else {
                                imageManager.downloadImage(imageUrl, new ImageManager.onImageLoaderListener() {

                                    @Override
                                    public void onImageLoader(Bitmap bitmap, String url) {
                                        if (bitmap != null) {
                                            mImageView.setImageBitmap(bitmap);
                                        } else {
                                            mImageView.setImageResource(R.mipmap.picture_fail_loading);
                                        }
                                    }
                                });
                            }
                        }

                        SpannableStringBuilder ssb = new SpannableStringBuilder("??");
                        ssb.setSpan(new URLSpan(link), 0, ssb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

                        ForegroundColorSpan span = new ForegroundColorSpan(Color.BLUE);
                        ssb.setSpan(span, 0, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

                        mLinkView.setText(ssb);
                        // ??MovementMethod
                        mLinkView.setMovementMethod(LinkMovementMethod.getInstance());
                        // ??ClickableSpan
                        mLinkView.setHighlightColor(0xff8FABCC);
                    }

                    @Override
                    public void onDataFailed() {

                    }
                });
        fetchDetailDataFromSqlTask.execute(data);
    }
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar_detail);

    // We need to start the enter transition after the data has loaded
    if (mTransitionAnimation) {
        activity.supportStartPostponedEnterTransition();

        if (null != toolbarView) {
            activity.setSupportActionBar(toolbarView);
            activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
            activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    } else {
        if (null != toolbarView) {
            Menu menu = toolbarView.getMenu();
            if (null != menu)
                menu.clear();
        }
    }
}

From source file:com.flowzr.activity.BudgetListFragment.java

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