List of usage examples for twitter4j Twitter destroySavedSearch
SavedSearch destroySavedSearch(long id) throws TwitterException;
From source file:com.daiv.android.twitter.adapters.SavedSearchArrayAdapter.java
License:Apache License
@Override public void bindView(final View view, Context mContext, final String trend) { final ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(trend);/*from w w w. j a va 2 s . co m*/ holder.text.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { final String search = trend; new AlertDialog.Builder(context) .setTitle(context.getResources().getString(R.string.delete_saved_search)) .setMessage(context.getResources().getString(R.string.cache_dialog_summary)) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Toast.makeText(context, context.getString(R.string.deleting_search), Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { long id = -1; Twitter twitter = Utils.getTwitter(context, AppSettings.getInstance(context)); try { ResponseList<SavedSearch> searches = twitter.savedSearches() .getSavedSearches(); for (int i = 0; i < searches.size(); i++) { String name = searches.get(i).getName(); Log.v("Test_saved_searches", name); if (name.equals(search)) { id = searches.get(i).getId(); Log.v("Test_saved_searches", "id to delete: " + id); } } if (id != -1) { twitter.destroySavedSearch(id); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, context.getString(R.string.success), Toast.LENGTH_SHORT).show(); } }); } else { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show(); } }); } } catch (Exception e) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show(); } }); } } }).start(); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }).create().show(); return false; } }); }
From source file:com.klinker.android.twitter.adapters.SavedSearchArrayAdapter.java
License:Apache License
@Override public void bindView(final View view, Context mContext, final String trend) { final ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(trend);/*from w w w . java 2s . c o m*/ holder.text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent search = new Intent(context, SearchedTrendsActivity.class); search.setAction(Intent.ACTION_SEARCH); search.putExtra(SearchManager.QUERY, trend); context.startActivity(search); } }); holder.text.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { final String search = trend; new AlertDialog.Builder(context) .setTitle(context.getResources().getString(R.string.delete_saved_search)) .setMessage(context.getResources().getString(R.string.cache_dialog_summary)) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Toast.makeText(context, context.getString(R.string.deleting_search), Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { int id = -1; Twitter twitter = Utils.getTwitter(context, AppSettings.getInstance(context)); try { ResponseList<SavedSearch> searches = twitter.savedSearches() .getSavedSearches(); for (int i = 0; i < searches.size(); i++) { String name = searches.get(i).getName(); Log.v("talon_saved_searches", name); if (name.equals(search)) { id = searches.get(i).getId(); Log.v("talon_saved_searches", "id to delete: " + id); } } if (id != -1) { twitter.destroySavedSearch(id); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, context.getString(R.string.success), Toast.LENGTH_SHORT).show(); SavedSearchesActivity.getSearches(); } }); } else { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show(); } }); } } catch (Exception e) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show(); } }); } } }).start(); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }).create().show(); return false; } }); }
From source file:twitter4j.examples.savedsearches.DestroySavedSearch.java
License:Apache License
/** * Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id] * * @param args message/*from w ww .j a v a 2 s . c o m*/ */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); SavedSearch savedSearch = twitter.destroySavedSearch(Integer.parseInt(args[0])); System.out.println("Successfully deleted saved search [name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]"); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to delete the saved search: " + te.getMessage()); System.exit(-1); } }