Skip to content

Commit

Permalink
Merge pull request #120 from RamolaWeb/master
Browse files Browse the repository at this point in the history
fix bug in news feed activity
  • Loading branch information
RamolaWeb authored Oct 23, 2016
2 parents 2165f6e + 9b8ac69 commit 4e8e28a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
40 changes: 19 additions & 21 deletions app/src/main/java/appteam/nith/hillffair/adapters/CardAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
import android.widget.TextView;
import android.widget.Toast;

import appteam.nith.hillffair.R;
import appteam.nith.hillffair.application.MyApplication;
import appteam.nith.hillffair.application.SharedPref;
import appteam.nith.hillffair.models.Dislike;
import appteam.nith.hillffair.models.Likecount;
import appteam.nith.hillffair.models.NewsfeedModel2;
import appteam.nith.hillffair.utilities.APIINTERFACE;
import appteam.nith.hillffair.utilities.Utils;
import com.bumptech.glide.Glide;
import com.like.LikeButton;
import com.like.OnLikeListener;
Expand All @@ -29,13 +21,17 @@
import java.util.Date;
import java.util.Locale;

import appteam.nith.hillffair.R;
import appteam.nith.hillffair.application.MyApplication;
import appteam.nith.hillffair.application.SharedPref;
import appteam.nith.hillffair.models.Likecount;
import appteam.nith.hillffair.models.NewsfeedModel2;
import appteam.nith.hillffair.utilities.APIINTERFACE;
import appteam.nith.hillffair.utilities.Utils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import static appteam.nith.hillffair.R.id.lyk_status;
import static appteam.nith.hillffair.R.id.no_of_likes;


/**
* Created by parvesh_dhull on 28/9/16.
Expand Down Expand Up @@ -136,8 +132,10 @@ public void onResponse(Call<Likecount> call, Response<Likecount> response) {
Likecount likes = response.body();
if (likes != null && response.isSuccess()) {
if (likes.isSuccess()) {
card.setStatus(true);
Log.d("id",card.get_id());
Toast.makeText(mContext, "Post Liked", Toast.LENGTH_SHORT).show();
card.setLikes(likes.getLikes());
h.no_of_likes.setText("" + likes.getLikes());
} else {
Toast.makeText(mContext, "Internal Error", Toast.LENGTH_SHORT).show();
Expand All @@ -156,20 +154,20 @@ public void onFailure(Call<Likecount> call, Throwable t) {

@Override
public void unLiked(LikeButton likeButton) {

APIINTERFACE mApiService = Utils.getRetrofitService();
Call<Dislike> mservice = mApiService.dislike(card.get_id(),new SharedPref(MyApplication.getAppContext()).getUserId());
Call<Likecount> mservice = mApiService.likecount(card.get_id(),new SharedPref(MyApplication.getAppContext()).getUserId());

mservice.enqueue(new Callback<Dislike>() {
mservice.enqueue(new Callback<Likecount>() {
@Override
public void onResponse(Call<Dislike> call, Response<Dislike> response) {
Dislike likes1 = response.body();
if (likes1 != null && response.isSuccess()) {
if (likes1.isSuccess()) {

public void onResponse(Call<Likecount> call, Response<Likecount> response) {
Likecount likes = response.body();
if (likes != null && response.isSuccess()) {
if (likes.isSuccess()) {
card.setStatus(false);
Log.d("id",card.get_id());
Toast.makeText(mContext, "Post Disliked", Toast.LENGTH_SHORT).show();
h.no_of_likes.setText("" + likes1.getDisLikes());
card.setLikes(likes.getLikes());
h.no_of_likes.setText("" + likes.getLikes());
} else {
Toast.makeText(mContext, "Internal Error", Toast.LENGTH_SHORT).show();

Expand All @@ -178,7 +176,7 @@ public void onResponse(Call<Dislike> call, Response<Dislike> response) {
}

@Override
public void onFailure(Call<Dislike> call, Throwable t) {
public void onFailure(Call<Likecount> call, Throwable t) {

Toast.makeText(mContext, "Check Your Internet Connectivity and Permissions", Toast.LENGTH_SHORT).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.google.gson.annotations.SerializedName;

import appteam.nith.hillffair.R;
import appteam.nith.hillffair.application.SharedPref;
import appteam.nith.hillffair.models.ProfileDataModel;
import appteam.nith.hillffair.utilities.APIINTERFACE;
import appteam.nith.hillffair.utilities.Utils;
import com.google.gson.annotations.SerializedName;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
Expand Down Expand Up @@ -270,6 +269,7 @@ public void onResponse(Call<ProfileDataModel> call, Response<ProfileDataModel> r
else {
progress.setVisibility(View.GONE);
Toast.makeText(getActivity(), "Please check your network connection and internet permission", Toast.LENGTH_LONG).show();

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,8 @@ public boolean isStatus() {
public void setStatus(boolean status) {
this.status = status;
}

public void setLikes(int likes) {
this.likes = likes;
}
}

0 comments on commit 4e8e28a

Please sign in to comment.