public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
          final InstagramImage instagramImage = (InstagramImage) adapter.getItem(i);

          // build dialog
          List<String> dialogItems = new ArrayList<String>();

          // 0: like/unlike
          if (instagramImage.user_has_liked == true) {
            dialogItems.add("Unlike");
          } else {
            dialogItems.add("Like");
          }

          // 1: comment
          dialogItems.add("Comment");

          // 2: share
          dialogItems.add("Share");

          final CharSequence[] items = dialogItems.toArray(new String[dialogItems.size()]);

          AlertDialog.Builder builder = new AlertDialog.Builder(FeedActivity.this);
          builder.setTitle("Choose your action");
          builder.setItems(
              items,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                  switch (item) {
                    case 0:
                      if (instagramImage.user_has_liked == true) {
                        unlike(instagramImage);
                      } else {
                        like(instagramImage);
                      }
                      break;
                    case 1:
                      showCommentDialog(instagramImage);
                      break;
                    case 2:
                      showShareDialog(instagramImage);
                      break;
                    default:
                      break;
                  }
                }
              });
          AlertDialog alert = builder.create();
          alert.show();
        }
  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();
 }