use of retrofit.Response in project nmid-headline by miao1007.
the class ImagesFeedAdapter method disPatchOnClick.
private void disPatchOnClick(final StreamViewHolder viewHolder, final int position, final ImageInfo imageInfo) {
viewHolder.mBtn_like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
RetrofitUtils.getCachedAdapter(HeadlineService.END_POINT).create(ImageService.class).likeImage(knoImageList.get(position).getIdmember(), imageInfo.isHaveClickLike() ? 0 : 1).enqueue(new Callback<ImageLikeResult>() {
@Override
public void onResponse(Response<ImageLikeResult> response) {
if (response.body().status == 1) {
RetrofitUtils.disMsg(v.getContext(), !imageInfo.isHaveClickLike() ? "Success!" : "取消成功");
int currentLike = imageInfo.getCount_like() + (imageInfo.isHaveClickLike() ? (0) : (1));
viewHolder.likesCount.setText(currentLike + "人 觉得赞");
updateHeartButton(viewHolder, true, !imageInfo.isHaveClickLike());
imageInfo.setIsLike(!imageInfo.isHaveClickLike());
}
}
@Override
public void onFailure(Throwable t) {
}
});
}
});
viewHolder.mIv_stream_previous.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), PhotoViewActivity.class);
intent.putExtra(PhotoViewActivity.IMAGE_SIEZ_FULL, imageInfo.getImageurl());
intent.putExtra(PhotoViewActivity.IMAGE_SIEZ_PREVIOUS, imageInfo.getPrevirousurl());
v.getContext().startActivity(intent);
}
});
}
Aggregations