Example usage for android.app Activity invalidateOptionsMenu

List of usage examples for android.app Activity invalidateOptionsMenu

Introduction

In this page you can find the example usage for android.app Activity invalidateOptionsMenu.

Prototype

public void invalidateOptionsMenu() 

Source Link

Document

Declare that the options menu has changed, so should be recreated.

Usage

From source file:Main.java

public static void invalidateOptionsMenu(Activity activity) {
    activity.invalidateOptionsMenu();
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void invalidateOptionsMenu(Activity activity) {
    activity.invalidateOptionsMenu();
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void invalidateOptionsMenu(Activity activity) {
    // Not necessary in pre-Honeycomb, because menu is drawn on tap.
    if (isHoneycomb())
        activity.invalidateOptionsMenu();
}

From source file:Main.java

public static void invalidateOptionsMenu(final Activity a) {
    if (Build.VERSION.SDK_INT >= 11) {
        a.runOnUiThread(new Runnable() {

            @Override/*from w  w w .  jav a 2 s.com*/
            public void run() {
                a.invalidateOptionsMenu();
            }
        });

    }
}

From source file:de.vanita5.twittnuker.fragment.support.BaseSupportFragment.java

public void invalidateOptionsMenu() {
    final Activity activity = getActivity();
    if (activity == null)
        return;/*from w  ww .j  a  va  2s .c  om*/
    activity.invalidateOptionsMenu();
}

From source file:com.tapchatapp.android.app.fragment.MainFragment.java

@Subscribe
public void onServiceStateChanged(ServiceStateChangedEvent event) {
    mTabsAdapter.notifyDataSetChanged();

    final TitlePageIndicator tabs = (TitlePageIndicator) getView().findViewById(R.id.pager_tabs);
    tabs.notifyDataSetChanged();/*from   w w w  .j  a  v a 2  s  . co m*/

    final ViewPager viewPager = (ViewPager) getView().findViewById(R.id.pager);

    View view = getView();
    if (view != null) {
        boolean showNoConnections = (mTabsAdapter.isLoaded() && mTabsAdapter.getCount() == 0);
        boolean showPager = mTabsAdapter.getCount() > 0;
        view.findViewById(R.id.no_connections).setVisibility(showNoConnections ? View.VISIBLE : View.GONE);
        view.findViewById(R.id.pager).setVisibility(showPager ? View.VISIBLE : View.GONE);
        view.findViewById(R.id.pager_tabs).setVisibility(showPager ? View.VISIBLE : View.GONE);
    }

    Activity activity = getActivity();
    if (activity != null) {
        activity.invalidateOptionsMenu();
    }

    // FIXME: Fix ViewPager to do this properly above.
    if (mPendingSelectItem >= 0 && mTabsAdapter.getCount() > mPendingSelectItem) {
        viewPager.setCurrentItem(mPendingSelectItem);
        mPendingSelectItem = -1;
    }
}

From source file:com.google.android.apps.mytracks.util.Api11Adapter.java

@Override
public void invalidMenu(Activity activity) {
    activity.invalidateOptionsMenu();
}

From source file:com.github.pockethub.android.ui.comment.RawCommentFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    commentText = (EditText) view.findViewById(R.id.et_comment);
    addImageFab = (FloatingActionButton) view.findViewById(R.id.fab_add_image);

    // @TargetApi() required to ensure build passes
    // noinspection Convert2Lambda
    addImageFab.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
        @Override//w ww.j a va2  s.c  o m
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                Fragment fragment = RawCommentFragment.this;
                String permission = Manifest.permission.READ_EXTERNAL_STORAGE;

                if (ContextCompat.checkSelfPermission(getActivity(),
                        permission) != PackageManager.PERMISSION_GRANTED) {
                    PermissionsUtils.askForPermission(fragment, READ_PERMISSION_REQUEST, permission,
                            R.string.read_permission_title, R.string.read_permission_content);
                } else {
                    startImagePicker();
                }
            } else {
                startImagePicker();
            }
        }
    });

    commentText.addTextChangedListener(new TextWatcherAdapter() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            Activity activity = getActivity();
            if (activity != null) {
                activity.invalidateOptionsMenu();
            }
        }
    });
    commentText.setOnTouchListener((v, event) -> {
        commentText.requestFocusFromTouch();
        return false;
    });

    setText(initComment);
}

From source file:com.esri.android.rt.map.PopupFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    PopupContainerView view = null;/*from w  w w  .  ja  v  a 2  s  .  c  o m*/

    if (mPopupContainer != null) {
        view = mPopupContainer.getPopupContainerView();
        view.setOnPageChangelistener(new OnPageChangeListener() {

            @Override
            public void onPageSelected(int arg0) {

            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
                // Refresh menu item while swipping popups
                Activity activity = (Activity) mMapView.getContext();
                activity.invalidateOptionsMenu();
            }

            @Override
            public void onPageScrollStateChanged(int arg0) {

            }
        });
    }
    return view;
}

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/*  w w w .  j a  va2 s.c om*/
        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();
}