public void postComment(String comment, InstagramImage image) { List<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add(new BasicNameValuePair("text", comment)); postParams.add( new BasicNameValuePair("access_token", Utils.getAccessToken(getApplicationContext()))); String url = Constants.MEDIA_ENDPOINT + image.id + Constants.COMMENT_MEDIA_ENDPOINT; JSONObject jsonResponse = Utils.doRestfulPut(httpClient, url, postParams, this); if (jsonResponse != null) { image.comment_list.add(new Comment(Utils.getUsername(getApplicationContext()), comment)); adapter.notifyDataSetChanged(); } else { Toast.makeText(this, "Comment failed", Toast.LENGTH_SHORT).show(); } }
public void unlike(InstagramImage image) { List<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add( new BasicNameValuePair("access_token", Utils.getAccessToken(getApplicationContext()))); String url = Constants.MEDIA_ENDPOINT + image.id + Constants.LIKE_MEDIA_ENDPOINT; String access_url = Utils.decorateEndpoint(url, Utils.getAccessToken(getApplicationContext())); JSONObject jsonResponse = Utils.doRestfulDelete(httpClient, access_url, this); if (jsonResponse != null) { image.liker_list.remove(Utils.getUsername(getApplicationContext())); image.liker_count--; image.user_has_liked = false; adapter.notifyDataSetChanged(); } }
public void like(InstagramImage image) { List<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add( new BasicNameValuePair("access_token", Utils.getAccessToken(getApplicationContext()))); String url = Constants.MEDIA_ENDPOINT + image.id + Constants.LIKE_MEDIA_ENDPOINT; JSONObject jsonResponse = Utils.doRestfulPut(httpClient, url, postParams, this); if (jsonResponse != null) { if (image.liker_list == null) image.liker_list = new ArrayList<String>(); image.liker_list.add(Utils.getUsername(getApplicationContext())); image.liker_count++; image.user_has_liked = true; adapter.notifyDataSetChanged(); } }
public void clearCache(View view) { adapter.imageLoader.clearCache(); adapter.notifyDataSetChanged(); }
private void refresh() { instagramImageList.clear(); adapter.notifyDataSetChanged(); new FetchActivity().execute(); }