Search in sources :

Example 1 with Response

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);
        }
    });
}
Also used : Response(retrofit.Response) PhotoViewActivity(cn.edu.cqupt.nmid.headline.ui.activity.PhotoViewActivity) Callback(retrofit.Callback) Intent(android.content.Intent) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ImageService(cn.edu.cqupt.nmid.headline.support.repository.image.ImageService)

Aggregations

Intent (android.content.Intent)1 CardView (android.support.v7.widget.CardView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 InjectView (butterknife.InjectView)1 ImageService (cn.edu.cqupt.nmid.headline.support.repository.image.ImageService)1 PhotoViewActivity (cn.edu.cqupt.nmid.headline.ui.activity.PhotoViewActivity)1 Callback (retrofit.Callback)1 Response (retrofit.Response)1