Skip to content

Instantly share code, notes, and snippets.

@heartofrevel
Created August 19, 2014 08:51
Show Gist options
  • Save heartofrevel/fc391f3c9e46252aa472 to your computer and use it in GitHub Desktop.
Save heartofrevel/fc391f3c9e46252aa472 to your computer and use it in GitHub Desktop.
Remove Support
JsonObjectRequest req = new JsonObjectRequest(Request.Method.DELETE, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject arg0) {
// TODO Auto-generated method stub
Toast.makeText(mContext, "Support Removed", Toast.LENGTH_SHORT).show();
tvLike.setVisibility(View.INVISIBLE);
tvDislike.setVisibility(View.INVISIBLE);
layoutUserDetails.setVisibility(View.INVISIBLE);
tvLike.setText(String.valueOf(Integer
.parseInt((String) tvLike
.getText()) - 1));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError arg0) {
// TODO Auto-generated method stub
Toast.makeText(mContext, "Support Error Removed", Toast.LENGTH_SHORT).show();
tvLike.setVisibility(View.INVISIBLE);
tvDislike.setVisibility(View.INVISIBLE);
layoutUserDetails.setVisibility(View.INVISIBLE);
tvLike.setText(String.valueOf(Integer
.parseInt((String) tvLike
.getText()) - 1));
}
}){
@Override
public Map<String, String> getHeaders()
throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
if (Check.isTokenPresent(mContext)) {
headers.put(
"Authorization",
"Token "
+ pref.getString("thotr_token",
"123"));
} else {
FlurryAgent.onError("tokenNotAvailable",
"tokenNotAvailable", "HomeFroagment");
Log.d("error header ",
"token not available error");
Toast.makeText(mContext,
R.string.authorizationproblem,
Toast.LENGTH_SHORT).show();
}
return headers;
}
};
supported.remove(postID);
AppController.getInstance().addToRequestQueue(req, "Remove Support Request");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment