Java Code Examples for android.support.v4.app.FragmentActivity#supportInvalidateOptionsMenu()

The following examples show how to use android.support.v4.app.FragmentActivity#supportInvalidateOptionsMenu() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageListFragment.java    From SteamGifts with MIT License 6 votes vote down vote up
@Override
public void addItems(List<? extends IEndlessAdaptable> items, boolean clearExistingItems, String foundXsrfToken) {
    super.addItems(items, clearExistingItems, foundXsrfToken);

    if (items != null && clearExistingItems) {
        // The top message for the first page (clearExistingItems == true) will be marked as the last we've actually looked at/dismissed and will not be shown in a notification again.
        for (IEndlessAdaptable item : items)
            if (item instanceof Comment) {
                CheckForNewMessages.setLastDismissedCommentId(getContext(), ((Comment) item).getPermalinkId());
                break;
            }
    }

    FragmentActivity activity = getActivity();
    if (activity != null)
        activity.supportInvalidateOptionsMenu();
}
 
Example 2
Source File: MessageListFragment.java    From SteamGifts with MIT License 6 votes vote down vote up
public void onMarkedMessagesRead() {
    for (int i = 0, size = adapter.getItemCount(); i < size; ++i) {
        IEndlessAdaptable element = adapter.getItem(i);
        if (!(element instanceof Comment))
            continue;

        Comment comment = (Comment) element;

        if (comment.isHighlighted()) {
            comment.setHighlighted(false);
            adapter.notifyItemChanged(i);
        }
    }

    adapter.setXsrfToken(null);

    FragmentActivity activity = getActivity();
    if (activity != null)
        activity.supportInvalidateOptionsMenu();

    // We no longer have any notifications
    SteamGiftsUserData.getCurrent(getContext()).setMessageNotification(0);
}
 
Example 3
Source File: LoginUtils.java    From android-galaxyzoo with GNU General Public License v3.0 6 votes vote down vote up
public static void logOut(final ZooFragment fragment) {
    final Activity activity = fragment.getActivity();
    final AccountRemoveTask task = new AccountRemoveTask(activity) {
        @Override
        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();
}
 
Example 4
Source File: GiveawayListFragment.java    From SteamGifts with MIT License 5 votes vote down vote up
@Override
public void onFilterUpdated() {
    refresh();

    FragmentActivity activity = getActivity();
    if (activity != null)
        activity.supportInvalidateOptionsMenu();
}
 
Example 5
Source File: SavedGiveawaysFragment.java    From SteamGifts with MIT License 5 votes vote down vote up
/**
 * Callback for {@link #enteredGameListTask}
 * <p>Note: do NOT call this from within this class.</p>
 */
@Override
public void addItems(List<? extends IEndlessAdaptable> items, boolean clearExistingItems) {
    if (items != null) {
        // closed or not deleted
        boolean foundAnyClosedGiveaways = false;

        // do nothing much except update the status of existing giveaways.
        for (IEndlessAdaptable endlessAdaptable : items) {
            ProfileGiveaway giveaway = (ProfileGiveaway) endlessAdaptable;
            if (!giveaway.isOpen() && !giveaway.isDeleted()) {
                foundAnyClosedGiveaways = true;
                break;
            }

            Giveaway existingGiveaway = adapter.findItem(giveaway.getGiveawayId());
            if (existingGiveaway != null) {
                existingGiveaway.setEntries(giveaway.getEntries());
                existingGiveaway.setEntered(true);
                adapter.notifyItemChanged(existingGiveaway);
            }
        }

        FragmentActivity activity = getActivity();
        if (activity != null)
            activity.supportInvalidateOptionsMenu();

        // have we found any non-closed giveaways?
        if (foundAnyClosedGiveaways) {
            enteredGameListTask = null;
        } else {
            enteredGameListTask = new LoadEnteredGameListTask(this, enteredGameListTask.getPage() + 1);
            enteredGameListTask.execute();
        }
    } else {
        showSnack("Failed to update entered giveaways", Snackbar.LENGTH_LONG);
    }
}