Example usage for android.support.v4.app FragmentActivity supportInvalidateOptionsMenu

List of usage examples for android.support.v4.app FragmentActivity supportInvalidateOptionsMenu

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity supportInvalidateOptionsMenu.

Prototype

public void supportInvalidateOptionsMenu() 

Source Link

Document

Invalidate the activity's options menu.

Usage

From source file:Main.java

public static void activity_invalidateOptionsMenu(FragmentActivity act) {
    act.supportInvalidateOptionsMenu();
}

From source file:com.murrayc.galaxyzoo.app.LoginUtils.java

public static void logOut(final ZooFragment fragment) {
    final Activity activity = fragment.getActivity();
    final AccountRemoveTask task = new AccountRemoveTask(activity) {
        @Override//from   w w  w.  j  a  v  a  2  s . co m
        protected void onPostExecute(final Void result) {
            super.onPostExecute(result);

            //Make sure that the currently-shown menu will update:
            ZooFragment.setCachedLoggedIn(false);

            //TODO: This doesn't actually seem to cause the (various) child fragments'
            //onPrepareOptionsMenu() methods to be called. Maybe it doesn't work with
            //nested child fragments.
            if (activity instanceof FragmentActivity) {
                final FragmentActivity fragmentActivity = (FragmentActivity) activity;
                fragmentActivity.supportInvalidateOptionsMenu();
            } else {
                activity.invalidateOptionsMenu();
            }
        }
    };
    task.execute();
}

From source file:org.getlantern.firetweet.fragment.support.BaseSupportFragment.java

public void invalidateOptionsMenu() {
    final FragmentActivity activity = getActivity();
    if (activity == null)
        return;// ww w. j  a  v  a  2  s.com
    activity.supportInvalidateOptionsMenu();
}

From source file:ru.yandex.subtitles.ui.fragment.AbstractFragment.java

public void invalidateOptionsMenu() {
    if (mToolbar != null) {
        createToolbarOptionsMenu(mToolbar);
    } else {/*from  w ww. ja  v a2 s.  c  o  m*/
        final FragmentActivity activity = getActivity();
        if (activity != null) {
            activity.supportInvalidateOptionsMenu();
        }
    }
}

From source file:com.dwdesign.tweetings.fragment.BaseFragment.java

public void invalidateOptionsMenu() {
    final FragmentActivity activity = getActivity();
    if (activity == null)
        return;/*from   w  w w  .j  av  a 2  s. c o m*/
    if (activity instanceof BaseActivity) {
        ((BaseActivity) activity).invalidateSupportOptionsMenu();
    } else {
        activity.supportInvalidateOptionsMenu();
    }
}

From source file:com.vuze.android.remote.AndroidUtils.java

public static void invalidateOptionsMenuHC(final Activity activity, final ActionMode mActionMode) {
    if (activity == null) {
        return;//from  w w w .  j a  va2  s .  co  m
    }
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (activity instanceof FragmentActivity) {
                FragmentActivity aba = (FragmentActivity) activity;
                aba.supportInvalidateOptionsMenu();
            } else {
                ActivityCompat.invalidateOptionsMenu(activity);
            }
            invalidateActionMode();
        }

        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        private void invalidateActionMode() {
            if (mActionMode != null) {
                mActionMode.invalidate();
            }
        }
    });
}

From source file:com.vuze.android.remote.AndroidUtils.java

public static void invalidateOptionsMenuHC(final Activity activity,
        final android.support.v7.view.ActionMode mActionMode) {
    if (activity == null) {
        return;//from ww w . j  a  v  a  2 s .  c  o m
    }
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (activity.isFinishing()) {
                return;
            }
            if (mActionMode != null) {
                mActionMode.invalidate();
                return;
            }
            if (activity instanceof FragmentActivity) {
                FragmentActivity aba = (FragmentActivity) activity;
                aba.supportInvalidateOptionsMenu();
            } else {
                ActivityCompat.invalidateOptionsMenu(activity);
            }
        }
    });
}

From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingFragment.java

@MainThread
private void displayMeeting(Meeting meeting) {
    FragmentActivity activity = getActivity();
    if (activity == null)
        return;//from  www  .  j a v a 2s. c o m
    setHasOptionsMenu(true);
    activity.supportInvalidateOptionsMenu();
    // Update the UI views
    Log.v(TAG, "meetingState = " + meeting.getState());
    // Show the "stop meeting" button if the meeting is not finished.
    mBinding.btnStopMeeting.setVisibility(
            meeting.getState() == State.NOT_STARTED || meeting.getState() == State.IN_PROGRESS ? View.VISIBLE
                    : View.INVISIBLE);
    // Only enable the "stop meeting" button if the meeting is in progress.
    mBinding.btnStopMeeting.setEnabled(meeting.getState() == State.IN_PROGRESS);

    // Show the horizontal progress bar for in progress meetings
    mBinding.headerProgressBar
            .setVisibility(meeting.getState() == State.IN_PROGRESS ? View.VISIBLE : View.INVISIBLE);

    // Update the chronometer
    if (meeting.getState() == State.IN_PROGRESS) {
        // If the meeting is in progress, show the Chronometer.
        long timeSinceMeetingStartedMillis = System.currentTimeMillis() - meeting.getStartDate();
        mBinding.tvMeetingDuration.setBase(SystemClock.elapsedRealtime() - timeSinceMeetingStartedMillis);
        mBinding.tvMeetingDuration.start();
    } else if (meeting.getState() == State.FINISHED) {
        // For finished meetings, show the duration we retrieved from the db.
        mBinding.tvMeetingDuration.stop();
        mBinding.tvMeetingDuration.setText(DateUtils.formatElapsedTime(meeting.getDuration()));
    }
}

From source file:com.androzic.waypoint.WaypointList.java

@SuppressLint("InflateParams")
@Override//from w w w  . j  a va 2  s . co  m
public boolean onOptionsItemSelected(MenuItem item) {
    final FragmentActivity activity = getActivity();
    switch (item.getItemId()) {
    case R.id.action_sort_alpha:
        adapter.sort(0);
        mSortMode = 0;
        activity.supportInvalidateOptionsMenu();
        return true;
    case R.id.action_sort_size:
        adapter.sort(1);
        mSortMode = 1;
        activity.supportInvalidateOptionsMenu();
        return true;
    case R.id.action_load_waypoints:
        WaypointFileList fileListDialog = new WaypointFileList(this);
        fileListDialog.show(getFragmentManager(), "dialog");
        return true;
    case R.id.action_new_waypoint_set:
        View view = getActivity().getLayoutInflater().inflate(R.layout.dlg_filename, null);
        final EditText textEntryView = (EditText) view.findViewById(R.id.name_text);
        new AlertDialog.Builder(activity).setTitle(R.string.waypointset).setView(view)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String name = textEntryView.getText().toString();
                        if (!"".equals(name)) {
                            WaypointSet set = new WaypointSet(name);
                            Androzic application = Androzic.getApplication();
                            application.addWaypointSet(set);
                            activity.supportInvalidateOptionsMenu();
                            adapter.notifyDataSetChanged();
                        }
                    }
                }).setNegativeButton(R.string.cancel, null).create().show();
        return true;
    case R.id.action_project_waypoint:
        WaypointProject waypointProjectDialog = new WaypointProject();
        waypointProjectDialog.setTargetFragment(this, DIALOG_WAYPOINT_PROJECT);
        waypointProjectDialog.show(getFragmentManager(), "dialog");
        return true;
    default:
        Androzic application = Androzic.getApplication();
        try {
            application.getWaypointSets().get(item.getItemId());
            application.removeWaypointSet(item.getItemId());
            activity.supportInvalidateOptionsMenu();
            adapter.notifyDataSetChanged();
        } catch (IndexOutOfBoundsException e) {
            return super.onOptionsItemSelected(item);
        }
        return true;
    }
}

From source file:it.imwatch.nfclottery.DropboxOptionsFragment.java

/** Ask the user to link/unlink his Dropbox account */
private void toggleDropboxLink() {
    final FragmentActivity activity = getActivity();
    if (activity != null) {
        DbxAccountManager dbxAcctMgr = DropboxHelper.getAccountManager(activity);
        if (dbxAcctMgr == null) {
            showFeedback(activity, getString(R.string.dropbox_unavailable), Style.ALERT);
            return;
        }/*w  w w  .j a  va2 s . c om*/

        if (!dbxAcctMgr.hasLinkedAccount()) {
            dbxAcctMgr.startLink(activity, REQUEST_LINK_TO_DBX);
        } else {
            dbxAcctMgr.unlink();
            // The options menu has changed after unlinking from Dropbox
            activity.supportInvalidateOptionsMenu();
        }
    } else {
        Log.e(TAG, "Not attached to an Activity; cannot toggle Dropbox link");
    }
}