Example usage for android.provider SearchRecentSuggestions clearHistory

List of usage examples for android.provider SearchRecentSuggestions clearHistory

Introduction

In this page you can find the example usage for android.provider SearchRecentSuggestions clearHistory.

Prototype

public void clearHistory() 

Source Link

Document

Completely delete the history.

Usage

From source file:ru.lizaalert.common.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
    switch (menuItem.getItemId()) {
    case R.id.action_clear_history:
        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionProvider.AUTHORITY,
                MySuggestionProvider.MODE);
        suggestions.clearHistory();
        return true;
    case R.id.action_search:
        onSearchRequested();/*w  w w  .  j av a 2  s  .co m*/
        return true;
    case R.id.action_about:
        startActivity(new Intent(this, About.class));
        return true;
    case R.id.action_update_yp:
        YellowPagesLoader.getInstance(this).fetchDataAsync();
        return true;
    }
    return (super.onOptionsItemSelected(menuItem));
}

From source file:com.zzolta.android.gfrecipes.fragments.RecipeDetailFragment.java

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

    final MenuItem share = menu.findItem(R.id.action_share);
    RecipeDetailShareActionProvider.getInstance()
            .setShareActionProvider((ShareActionProvider) MenuItemCompat.getActionProvider(share));

    final MenuItem clearSearchHistory = menu.findItem(R.id.action_clear_search_history);
    clearSearchHistory.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override// w w  w.j  a  v  a2  s.c o  m
        public boolean onMenuItemClick(MenuItem item) {
            new Builder(getActivity()).setTitle(getString(R.string.action_clear_search_history))
                    .setMessage(getString(R.string.confirmation_clear_search_history))
                    .setIcon(drawable.ic_dialog_alert).setPositiveButton(string.yes, new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
                                    getActivity(), RecipeSearchRecentSuggestionsProvider.AUTHORITY,
                                    RecipeSearchRecentSuggestionsProvider.MODE);
                            suggestions.clearHistory();
                        }
                    }).setNegativeButton(string.no, null).show();
            return true;
        }
    });

    final MenuItem addToMyRecipes = menu.findItem(R.id.action_add_to_my_recipes);
    addToMyRecipes.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            myRecipeHandler(true);
            return true;
        }
    });

    final MenuItem removeFromMyRecipes = menu.findItem(R.id.action_remove_from_my_recipes);
    removeFromMyRecipes.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            myRecipeHandler(false);
            return true;
        }
    });
}

From source file:com.ratebeer.android.gui.fragments.SearchFragment.java

@OptionsItem(R.id.menu_clearhistory)
protected void onClearHistory() {
    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
            SearchHistoryProvider.AUTHORITY, SearchHistoryProvider.MODE);
    suggestions.clearHistory();
}

From source file:net.vivekiyer.GAL.CorporateAddressBook.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.menu_search:
        return this.onSearchRequested();
    case R.id.settings:
        CorporateAddressBook.showConfiguration(this);
        return true;
    case R.id.clearSearchHistory:
        final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                RecentGALSearchTermsProvider.AUTHORITY, RecentGALSearchTermsProvider.MODE);
        suggestions.clearHistory();
        return true;
    default://from www  . j  av  a 2s. c o m
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java

private void logoutFromTwitter() {

    context.sendBroadcast(new Intent("com.daiv.android.STOP_PUSH_SERVICE"));

    int currentAccount = sharedPrefs.getInt("current_account", 1);
    boolean login1 = sharedPrefs.getBoolean("is_logged_in_1", false);
    boolean login2 = sharedPrefs.getBoolean("is_logged_in_2", false);

    // Delete the data for the logged out account
    SharedPreferences.Editor e = sharedPrefs.edit();
    e.remove("authentication_token_" + currentAccount);
    e.remove("authentication_token_secret_" + currentAccount);
    e.remove("is_logged_in_" + currentAccount);
    e.remove("new_notification");
    e.remove("new_retweets");
    e.remove("new_favorites");
    e.remove("new_follows");
    e.remove("current_position_" + currentAccount);
    e.remove("last_activity_refresh_" + currentAccount);
    e.remove("original_activity_refresh_" + currentAccount);
    e.remove("activity_follower_count_" + currentAccount);
    e.remove("activity_latest_followers_" + currentAccount);
    e.commit();/*from   ww  w. ja  v  a2s  .  c  o m*/

    HomeDataSource homeSources = HomeDataSource.getInstance(context);
    homeSources.deleteAllTweets(currentAccount);

    MentionsDataSource mentionsSources = MentionsDataSource.getInstance(context);
    mentionsSources.deleteAllTweets(currentAccount);

    DMDataSource dmSource = DMDataSource.getInstance(context);
    dmSource.deleteAllTweets(currentAccount);

    FavoriteUsersDataSource favs = FavoriteUsersDataSource.getInstance(context);
    favs.deleteAllUsers(currentAccount);

    InteractionsDataSource inters = InteractionsDataSource.getInstance(context);
    inters.deleteAllInteractions(currentAccount);

    ActivityDataSource activity = ActivityDataSource.getInstance(context);
    activity.deleteAll(currentAccount);

    FavoriteTweetsDataSource favTweets = FavoriteTweetsDataSource.getInstance(context);
    favTweets.deleteAllTweets(currentAccount);

    try {
        long account1List1 = sharedPrefs.getLong("account_" + currentAccount + "_list_1", 0l);
        long account1List2 = sharedPrefs.getLong("account_" + currentAccount + "_list_2", 0l);

        ListDataSource list = ListDataSource.getInstance(context);
        list.deleteAllTweets(account1List1);
        list.deleteAllTweets(account1List2);
    } catch (Exception x) {

    }

    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY,
            MySuggestionsProvider.MODE);
    suggestions.clearHistory();

    AppSettings.invalidate();

    if (currentAccount == 1 && login2) {
        e.putInt("current_account", 2).commit();
        finish();
        Intent next = new Intent(context, MainActivity.class);
        startActivity(next);
    } else if (currentAccount == 2 && login1) {
        e.putInt("current_account", 1).commit();
        finish();
        Intent next = new Intent(context, MainActivity.class);
        startActivity(next);
    } else { // only the one account
        e.putInt("current_account", 1).commit();
        finish();
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
    }

}

From source file:com.klinker.android.twitter.ui.drawer_activities.DrawerActivity.java

private void logoutFromTwitter() {

    context.sendBroadcast(new Intent("com.klinker.android.STOP_PUSH_SERVICE"));

    int currentAccount = sharedPrefs.getInt("current_account", 1);
    boolean login1 = sharedPrefs.getBoolean("is_logged_in_1", false);
    boolean login2 = sharedPrefs.getBoolean("is_logged_in_2", false);

    // Delete the data for the logged out account
    SharedPreferences.Editor e = sharedPrefs.edit();
    e.remove("authentication_token_" + currentAccount);
    e.remove("authentication_token_secret_" + currentAccount);
    e.remove("is_logged_in_" + currentAccount);
    e.remove("new_notification");
    e.remove("new_retweets");
    e.remove("new_favorites");
    e.remove("new_follows");
    e.remove("current_position_" + currentAccount);
    e.commit();/* ww  w  . j a v a 2 s .co m*/

    HomeDataSource homeSources = HomeDataSource.getInstance(context);
    homeSources.deleteAllTweets(currentAccount);

    MentionsDataSource mentionsSources = MentionsDataSource.getInstance(context);
    mentionsSources.deleteAllTweets(currentAccount);

    DMDataSource dmSource = DMDataSource.getInstance(context);
    dmSource.deleteAllTweets(currentAccount);

    FavoriteUsersDataSource favs = FavoriteUsersDataSource.getInstance(context);
    favs.deleteAllUsers(currentAccount);

    InteractionsDataSource inters = InteractionsDataSource.getInstance(context);
    inters.deleteAllInteractions(currentAccount);

    try {
        long account1List1 = sharedPrefs.getLong("account_" + currentAccount + "_list_1", 0l);
        long account1List2 = sharedPrefs.getLong("account_" + currentAccount + "_list_2", 0l);

        ListDataSource list = ListDataSource.getInstance(context);
        list.deleteAllTweets(account1List1);
        list.deleteAllTweets(account1List2);
    } catch (Exception x) {

    }

    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY,
            MySuggestionsProvider.MODE);
    suggestions.clearHistory();

    AppSettings.invalidate();

    if (currentAccount == 1 && login2) {
        e.putInt("current_account", 2).commit();
        finish();
        Intent next = new Intent(context, MainActivity.class);
        startActivity(next);
    } else if (currentAccount == 2 && login1) {
        e.putInt("current_account", 1).commit();
        finish();
        Intent next = new Intent(context, MainActivity.class);
        startActivity(next);
    } else { // only the one account
        e.putInt("current_account", 1).commit();
        finish();
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
    }

}

From source file:com.klinker.android.twitter.activities.drawer_activities.DrawerActivity.java

private void logoutFromTwitter() {

    context.sendBroadcast(new Intent("com.klinker.android.STOP_PUSH_SERVICE"));

    int currentAccount = sharedPrefs.getInt("current_account", 1);
    boolean login1 = sharedPrefs.getBoolean("is_logged_in_1", false);
    boolean login2 = sharedPrefs.getBoolean("is_logged_in_2", false);

    // Delete the data for the logged out account
    SharedPreferences.Editor e = sharedPrefs.edit();
    e.remove("authentication_token_" + currentAccount);
    e.remove("authentication_token_secret_" + currentAccount);
    e.remove("is_logged_in_" + currentAccount);
    e.remove("new_notification");
    e.remove("new_retweets");
    e.remove("new_favorites");
    e.remove("new_follows");
    e.remove("current_position_" + currentAccount);
    e.remove("last_activity_refresh_" + currentAccount);
    e.remove("original_activity_refresh_" + currentAccount);
    e.remove("activity_follower_count_" + currentAccount);
    e.remove("activity_latest_followers_" + currentAccount);
    e.commit();/*from  w  ww .  j  a  va2s  .  com*/

    HomeDataSource homeSources = HomeDataSource.getInstance(context);
    homeSources.deleteAllTweets(currentAccount);

    MentionsDataSource mentionsSources = MentionsDataSource.getInstance(context);
    mentionsSources.deleteAllTweets(currentAccount);

    DMDataSource dmSource = DMDataSource.getInstance(context);
    dmSource.deleteAllTweets(currentAccount);

    FavoriteUsersDataSource favs = FavoriteUsersDataSource.getInstance(context);
    favs.deleteAllUsers(currentAccount);

    InteractionsDataSource inters = InteractionsDataSource.getInstance(context);
    inters.deleteAllInteractions(currentAccount);

    ActivityDataSource activity = ActivityDataSource.getInstance(context);
    activity.deleteAll(currentAccount);

    FavoriteTweetsDataSource favTweets = FavoriteTweetsDataSource.getInstance(context);
    favTweets.deleteAllTweets(currentAccount);

    try {
        long account1List1 = sharedPrefs.getLong("account_" + currentAccount + "_list_1", 0l);
        long account1List2 = sharedPrefs.getLong("account_" + currentAccount + "_list_2", 0l);

        ListDataSource list = ListDataSource.getInstance(context);
        list.deleteAllTweets(account1List1);
        list.deleteAllTweets(account1List2);
    } catch (Exception x) {

    }

    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY,
            MySuggestionsProvider.MODE);
    suggestions.clearHistory();

    AppSettings.invalidate();

    if (currentAccount == 1 && login2) {
        e.putInt("current_account", 2).commit();
        finish();
        Intent next = new Intent(context, MainActivity.class);
        startActivity(next);
    } else if (currentAccount == 2 && login1) {
        e.putInt("current_account", 1).commit();
        finish();
        Intent next = new Intent(context, MainActivity.class);
        startActivity(next);
    } else { // only the one account
        e.putInt("current_account", 1).commit();
        finish();
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
    }

}