Integrating youtube like button and comment in my app - android

In my android app there is a portion which shows list of pictures. Each picture is associated with a video id.On Clicking that picture corresponding video id will be passed to youtube player and that video will be played in youtube player. Below each picture there is a like button and a comment button. I want to integrate them with youtube like and comment.So that on clicking like or commenting a video in my app is same as clicking like or commenting on youtube. How can I impliment that?

Used this code for like youtube Videos....
//getPostLikeBtn (Create this Method.)
private void getPostLikeBtn(final String rating) {
String tag_json_obj = "recipeLike";
final SpotsDialog spotsDialog = new SpotsDialog(context);
spotsDialog.show();
spotsDialog.setMessage("Loading...");
StringRequest jsonObjectRequest = new StringRequest(Request.Method.POST,
"https://www.googleapis.com/youtube/v3/videos/rate",
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
spotsDialog.dismiss();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
try {
spotsDialog.dismiss();
try {
if (error.networkResponse.data != null) {
try {
String body = new String(error.networkResponse.data, "UTF-8");
Log.e("errorLike", body);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
spotsDialog.dismiss();
Toast.makeText(context, getResources().getString(R.string.try_again), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(context, getResources().getString(R.string.try_again), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
// hide the progress dialog
}
}) {
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
int mStatusCode = response.statusCode;
Log.e("mStatusCode", "" + mStatusCode);
if (mStatusCode == 204) {
Toast.makeText(context, "Successfully updated", Toast.LENGTH_SHORT).show();
getLikeShare();
} else {
Toast.makeText(context, getResources().getString(R.string.try_again), Toast.LENGTH_SHORT).show();
}
return super.parseNetworkResponse(response);
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
SharedPreferences prefs = getSharedPreferences("GOOGLE_TOKEN", MODE_PRIVATE);
String token = prefs.getString("token", null);
params.put("Authorization", "Bearer " + token);
return params;
}
#Override
protected Map<String, String> getParams() {
Map<String, String> jsonObject = new HashMap<>();
try {
jsonObject.put("id", "Video id");
jsonObject.put("rating", rating);
} catch (Exception e) {
e.printStackTrace();
}
Log.e("jsonObject", "" + jsonObject);
return jsonObject;
}
};
AppController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_obj);
}
I hope this is usefull for you..

Related

How to pass multiple information array and a image array to server?

I have an array which is contain image quantity for image and another is image size array which is contain image size, also an image array. I'm trying to send them to server but i failed every time. I'm trying many example but nothing was worked for me. Is there any other way to do this ? Please give me some hints or link.
how to send array of params using volley in android
public void uploadMultipleImage(String url, final List<SelectedImageModel> selectedImageModels)
{
VolleyMultipartRequest multipartRequest = new VolleyMultipartRequest(Request.Method.POST, url, new Response.Listener<NetworkResponse>() {
#Override
public void onResponse(NetworkResponse response) {
String resultResponse = new String(response.data);
responseListener.onResultSuccess(resultResponse);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
NetworkResponse networkResponse = error.networkResponse;
String result = new String(networkResponse.data);
responseListener.onResultSuccess(result);
}
}) {
#Override
protected Map<String, String> getParams() {
HashMap<String, String> params = new HashMap<>(selectedImageModels.size());
for(int i=0; i<selectedImageModels.size(); i++)
params.put("size["+i+"]",selectedImageModels.get(i).getPhotoSize());
for(int i=0; i<selectedImageModels.size(); i++)
params.put("quantity["+i+"]",selectedImageModels.get(i).getPhotoQuantity());
return params;
}
#Override
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer "+requiredInfo.getAccessToken());
headers.put("Accept", "application/json");
headers.put("Content-Type", "x-www-form-urlencoded");
return headers;
}
#Override
protected Map<String, DataPart> getByteData() {
Map<String, DataPart> params = new HashMap<>(selectedImageModels.size());
for(int i=0; i<selectedImageModels.size(); i++)
params.put("image["+i+"]",new DataPart("imageName",UserProfile.getFileDataFromDrawable(selectedImageModels.get(i).getPhoto())));
return params;
}
};
requestQueue.add(multipartRequest);
}
Every time i'm getting com.android.volley.server error 500 this error
Make a method for send array of params.
private String makeJsonObjectParams() {
//In mediaData,I am sending image to AWS and I will get the download link and I
// am storing the downloadurl in downloadurl arrayslist.
JSONArray mediaData = new JSONArray();
try {
if(img1 != 1) {
JSONObject temp = new JSONObject();
temp.put("file", download_url.get(0));
temp.put("type", "signature");
mediaData.put(temp);
}
if(img2 != 1){
JSONObject temp1 = new JSONObject();
temp1.put("file", download_url.get(1));
temp1.put("type", "id proof");
mediaData.put(temp1);
}
} catch (JSONException e) {
e.printStackTrace();
}
//for sending normal details like text
JSONObject updateDetails = new JSONObject();
try {
updateDetails.put("status", 2);
updateDetails.put("userId", sharedPreferences.getString("user_ID",""));
updateDetails.put("deviceToken", splash_screen.android_id);
} catch (JSONException e) {
e.printStackTrace();
}
JSONObject jsonVerificationDetails = new JSONObject();
try {
jsonVerificationDetails.put("type", verificatin_type);
jsonVerificationDetails.put("durationOfStay", durationOfStay.getText().toString());
jsonVerificationDetails.put("media", mediaData);
} catch (JSONException e) {
e.printStackTrace();
}
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put("verificationDetails", jsonVerificationDetails);
jsonBody.put("updateDetails", updateDetails);
} catch (JSONException e) {
e.printStackTrace();
}
final String mRequestBody = jsonBody.toString();
return mRequestBody;
}
}
Through the below code send the code to server.
void submitData(){
try {
RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this);
final String mRequestBody = makeJsonObjectParams();
StringRequest stringRequest = new StringRequest(Request.Method.POST, completedTaskUrl, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
//do whatever you want
}
} catch (JSONException e) {
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}) {
#Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
#Override
public byte[] getBody() throws AuthFailureError {
try {
return mRequestBody == null ? null : mRequestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException uee) {
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", mRequestBody, "utf-8");
return null;
}
}
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String responseString = "";
if (response != null) {
responseString = String.valueOf(response.statusCode);
}
// return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
return super.parseNetworkResponse(response);
}
};
requestQueue=Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
} catch (Exception e) {//JSONException e
e.printStackTrace();
}
}

How to solve the problem in login json parsing using volley?

public void userLogin() {
try {
String URL = "http://influence360.in/orezmiapp/index.php/mobile/login";
System.out.println("Arun URL :- " + URL);
final JSONObject jsonBody = new JSONObject();
jsonBody.put("type", "2");
jsonBody.put("email", email);
jsonBody.put("password", password);
final String mRequestBody = jsonBody.toString();
Log.e("JSON String is :- ", " " + mRequestBody);
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.e("LOG_VOLLEY", response);
try {
Toast.makeText(activity, "loginactivity entered", Toast.LENGTH_LONG).show();
JSONObject jsonObject = new JSONObject(response);
int status = jsonObject.getInt("status");
Toast.makeText(activity, status, Toast.LENGTH_LONG).show();
if (status == 1000) {
JSONObject data = jsonBody.getJSONObject("data");
//sessionManager.setUserid(data.getString("Cust_id"));
// sessionManager.setBirthday(data.getString("Dob"));
sessionManager.setUserfirstname(data.getString("Cust_Name"));
startActivity(new Intent(LoginScreen.this, Profile.class));
finish();
} else {
Toast.makeText(activity, "Hello", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(activity, e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}, new Response.ErrorListener()
{
#Override
public void onErrorResponse(VolleyError error) {
Log.e("LOG_VOLLEY", error.toString());
}
})
{
#Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
return headers;
}
#Override
public byte[] getBody() throws AuthFailureError {
try {
return mRequestBody == null ? null : mRequestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException uee) {
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", mRequestBody, "utf-8");
return null;
}
}
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String responseString = "";
if (response != null) {
responseString = String.valueOf(response.statusCode);
Log.e("Response String : -", " " + responseString);
}
return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
}
};
RequestQueue requestQueue = Volley.newRequestQueue(activity);
requestQueue.add(stringRequest);
stringRequest.setRetryPolicy(new
DefaultRetryPolicy(60000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}
I got the error
value of type 200 org.json.Integer cant be converted into JSONObject. Please help me to solve this. I didnt get any solution regarding this. Thankyou in advance.Please help me out.I will be highly obliged if anybody give the solution.Thank you in advance. If anybody has the solution please give me that.

Volley send parameters and JSON body

I want to send some data to the server and the data has some parameters and it has a large body of JSON. I am trying to use aVolley to send this data.
The getParams() function is never called for some reason.
Here is my code:
final StringRequest stringReq = new StringRequest(Request.Method.POST, API_URL, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
if (Util.IS_DEBUG_LOGGABLE) {
Log.d(TAG, "onResponse: Sent Data");
}
Toast.makeText(getContext(), R.string.config_changed, Toast.LENGTH_SHORT).show();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
if (Util.IS_DEBUG_LOGGABLE) {
Log.d(TAG, "onErrorResponse: Data Not Sent Because server could not verify");
}
Toast.makeText(getContext(), getString(R.string.msg_data_not_sent, error), Toast.LENGTH_SHORT).show();
}
}) {
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> pars = new HashMap<>();
if (Util.IS_DEBUG_LOGGABLE) {
Log.d(TAG, "getParams: Called");
}
pars.put(PARAM1, "testf18");
pars.put(PARAM2, "Save");
return pars;
}
#Override
public byte[] getBody() throws AuthFailureError {
try {
if (Util.IS_DEBUG_LOGGABLE) {
Log.d(TAG, "getBody: Called");
}
return response.toString().getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", response.toString(), "utf-8");
return null;
}
}
};
RequestHelperClass.addToRequestQueue(stringReq, getContext());
Please help.

Integrating youtube like button in android app

I want to integrate youtube like button in my android app. By refering through this tutorial Videos: rate
I found this api link https://www.googleapis.com/youtube/v3/videos/rate can be used to do that. Can anybody tell me how can I pass a particular video Id along with this api link
Used this code for like youtube Videos....
//getPostLikeBtn (Create this Method.)
private void getPostLikeBtn(final String rating) {
String tag_json_obj = "recipeLike";
final SpotsDialog spotsDialog = new SpotsDialog(context);
spotsDialog.show();
spotsDialog.setMessage("Loading...");
StringRequest jsonObjectRequest = new StringRequest(Request.Method.POST,
"https://www.googleapis.com/youtube/v3/videos/rate",
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
spotsDialog.dismiss();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
try {
spotsDialog.dismiss();
try {
if (error.networkResponse.data != null) {
try {
String body = new String(error.networkResponse.data, "UTF-8");
Log.e("errorLike", body);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
spotsDialog.dismiss();
Toast.makeText(context, getResources().getString(R.string.try_again), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(context, getResources().getString(R.string.try_again), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
// hide the progress dialog
}
}) {
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
int mStatusCode = response.statusCode;
Log.e("mStatusCode", "" + mStatusCode);
if (mStatusCode == 204) {
Toast.makeText(context, "Successfully updated", Toast.LENGTH_SHORT).show();
getLikeShare();
} else {
Toast.makeText(context, getResources().getString(R.string.try_again), Toast.LENGTH_SHORT).show();
}
return super.parseNetworkResponse(response);
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
SharedPreferences prefs = getSharedPreferences("GOOGLE_TOKEN", MODE_PRIVATE);
String token = prefs.getString("token", null);
params.put("Authorization", "Bearer " + token);
return params;
}
#Override
protected Map<String, String> getParams() {
Map<String, String> jsonObject = new HashMap<>();
try {
jsonObject.put("id", "Video id");
jsonObject.put("rating", rating);
} catch (Exception e) {
e.printStackTrace();
}
Log.e("jsonObject", "" + jsonObject);
return jsonObject;
}
};
AppController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_obj);
}
I hope this is usefull for you..

Activity leak while using volley listeners

I'm using volley library for sending requests and I have a memory leak. I traced it with leak canary and it seems to be from my requests mListeners. after some searching I cancel all my requests in my current activity but still I have a leak I could use some help thanks here is my download code:
(note: I use singleton pattern for getting volley request queue)
private void startImageDownloadService(final NEWS selectedNews) {
if (selectedNews.getIMG_URL() != null && !selectedNews.getIMG_URL().equals("null")) {
ImageRequest imageRequest = new ImageRequest(selectedNews.getIMG_URL(),
new Response.Listener<Bitmap>() {
#Override
public void onResponse(Bitmap bitmap) {
newsImage_imageView.setVisibility(View.VISIBLE);
newsImage_imageView.setImageBitmap(bitmap);
saveImageToFileStarter(bitmap, selectedNews);
}
}, 200, 200, null, null, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(getApplicationContext(), "Failed to download image", Toast.LENGTH_SHORT).show();
}
});
imageRequest.setShouldCache(false);
MyVolleySingleton.getInstance(getApplicationContext()).addToRequestQueue(imageRequest, "newsActivityImage");
//
}
}
private void requestLike(final ImageButton likeButton, final long id) {
try {
StringRequest jsonRequest = new StringRequest(Request.Method.POST, G.likeURL + id + "/like",
new Response.Listener<String>() {
#Override
public void onResponse(String s) {
try {
Log.e("requestLikeJson", s);
JSONObject likeObject = new JSONObject(s);
int likeNumbers = likeObject.getInt("likes");
// Toast.makeText(NewsActivity.this, likeNumbers + "", Toast.LENGTH_LONG)
// .show();
if (likeButton.getTag().equals("notliked")) {
setLikeChangeInDatabase(false, id, likeNumbers);
}
else{
setLikeChangeInDatabase(true, id, likeNumbers);
}
// viewsCount_textView.setText("" + likeNumbers);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(NewsActivity.this, "No Internet connection", Toast.LENGTH_LONG).show();
try {
volleyError.printStackTrace();
Log.e("network error", new String(volleyError.networkResponse.data));
} catch (Exception e) {
e.printStackTrace();
}
if (likeButton.getTag().equals("notliked")) {
likeButton.setTag("liked");
likeButtonImageSetter();
} else {
likeButton.setTag("notliked");
likeButtonImageSetter();
}
Animation shake = AnimationUtils.loadAnimation(NewsActivity.this, R.anim.actionfeedback);
likeButton.startAnimation(shake);
}
}) {
#Override
public Priority getPriority() {
return Priority.HIGH;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
Log.e("sent token", "Token " + G.token);
params.put("Authorization", "Token " + G.token);
params.put("Accept-Language", "en-US,en;q=0.8,fa;q=0.6,pt;q=0.4,ar;q=0.2,gl;q=0.2");
return params;
}
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String utf8String = null;
try {
utf8String = new String(response.data, "UTF-8");
return Response.success(utf8String, HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
}
}
};
jsonRequest.setRetryPolicy(new DefaultRetryPolicy(
G.socketTimeout,
0,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
MyVolleySingleton.getInstance(getApplicationContext()).addToRequestQueue(jsonRequest, "like");
} catch (Exception e) {
}
}
private void requestView(long id) {
try {
StringRequest jsonRequest = new StringRequest(Request.Method.GET, G.viewURL + id + "/view", new Response.Listener<String>() {
#Override
public void onResponse(String s) {
try {
JSONObject viewObject = new JSONObject(s);
Log.e("requestViewJson", s);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError volleyError) {
try {
volleyError.printStackTrace();
Log.e("network error", new String(volleyError.networkResponse.data));
} catch (Exception e) {
e.printStackTrace();
}
}
}) {
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
Log.e("sent token", "Token " + G.token);
params.put("Authorization", "Token " + G.token);
params.put("Accept-Language", "en-US,en;q=0.8,fa;q=0.6,pt;q=0.4,ar;q=0.2,gl;q=0.2");
return params;
}
#Override
public Priority getPriority() {
return Priority.HIGH;
}
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String utf8String = null;
try {
utf8String = new String(response.data, "UTF-8");
return Response.success(utf8String, HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
}
}
};
jsonRequest.setRetryPolicy(new DefaultRetryPolicy(
G.socketTimeout,
0,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
MyVolleySingleton.getInstance(getApplicationContext()).addToRequestQueue(jsonRequest,"view");
} catch (Exception e) {
}
}
and in my onStop() I have :
#Override
protected void onStop() {
try {//new change
MyVolleySingleton.getInstance(getApplicationContext()).cancelPendingRequests("newsActivityImage");
MyVolleySingleton.getInstance(getApplicationContext()).cancelPendingRequests("view");
MyVolleySingleton.getInstance(getApplicationContext()).cancelPendingRequests("like");
loadImageFromFile.cancel(true);
loadImageFromFile=null;
}catch (Exception e){}
super.onStop();
}
After some researching I found that the volley listeners cause the activity leak because they are instantiated as anonymous classes and therefore hold an implicit reference to their outer class (in this example news activity) so I made a separate class for VolleyRequest (just to make them customizable not really related to the leak) and made a listener interface which I implement as an innerclass and use a weak reference to have access to the activity
request code :
public class MyVolleyStringRequest extends com.android.volley.toolbox.StringRequest {
StringResponseListener mListener;
public MyVolleyStringRequest(int method, String url, final StringResponseListener mListener) {
super(method, url, new Response.Listener<String>() {
#Override
public void onResponse(String s) {
mListener.onSuccess(s);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError volleyError) {
mListener.onFailure(volleyError);
}
});
this.mListener = mListener;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
Log.e("sent token", "Token " + G.token);
params.put("Authorization", "Token " + G.token);
params.put("Accept-Language", "en-US,en;q=0.8,fa;q=0.6,pt;q=0.4,ar;q=0.2,gl;q=0.2");
return params;
}
#Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
try {
String utf8String = new String(response.data, "UTF-8");
return Response.success(utf8String, HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
}
}
}
requestLike and requestView Code:
private void requestLike(final ImageButton likeButton, final long id) {
MyVolleyStringRequest likeRequest = new MyVolleyStringRequest(Request.Method.POST, G.likeURL + id + "/like",
new RequestLikeStringListener(this));
MyVolleySingleton.getInstance(getApplicationContext()).addToRequestQueue(likeRequest, "like");
}
private void requestView(long id) {
MyVolleyStringRequest viewRequest = new MyVolleyStringRequest(Request.Method.GET, G.viewURL + id + "/view",
new RequestViewStringListener());
MyVolleySingleton.getInstance(getApplicationContext()).addToRequestQueue(viewRequest, "view");
}
listener interface code :
public interface StringResponseListener {
void onSuccess(String response);
void onFailure(VolleyError error);
}
innerclasses code:
public static class RequestLikeStringListener implements StringResponseListener{
WeakReference<NewsActivity> contextWeakReference;
RequestLikeStringListener(NewsActivity context){
contextWeakReference = new WeakReference<>(context);
}
public void onSuccess(String response) {
try {
NewsActivity context = contextWeakReference.get();
if(context != null) {
ImageButton likeButton = (ImageButton) context.findViewById(R.id.likeButton);
Log.e("requestLikeJson", response);
JSONObject likeObject = new JSONObject(response);
int likeNumbers = likeObject.getInt("likes");
if (likeButton.getTag().equals("notliked")) {
context.setLikeChangeInDatabase(false, contextWeakReference.get().id, likeNumbers);
} else {
context.setLikeChangeInDatabase(true, contextWeakReference.get().id, likeNumbers);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
public void onFailure(VolleyError error) {
NewsActivity context = contextWeakReference.get();
if(context != null) {
ImageButton likeButton = (ImageButton) context.findViewById(R.id.likeButton);
Toast.makeText(context, "No Internet connection", Toast.LENGTH_LONG).show();
try {
error.printStackTrace();
Log.e("network error", new String(error.networkResponse.data));
} catch (Exception e) {
e.printStackTrace();
}
if (likeButton.getTag().equals("notliked")) {
likeButton.setTag("liked");
context.likeButtonImageSetter();
} else {
likeButton.setTag("notliked");
context.likeButtonImageSetter();
}
Animation shake = AnimationUtils.loadAnimation(context, R.anim.actionfeedback);
likeButton.startAnimation(shake);
}
}
hope it helps someone!

Categories

Resources