Search in sources :

Example 1 with FollowUser

use of com.rideread.rideread.data.result.FollowUser in project ride-read-android by Ride-Read.

the class FollowUserAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder tHolder, int position) {
    UserViewHolder holder = (UserViewHolder) tHolder;
    FollowUser user = mUserList.get(position);
    if (isFans) {
        ImgLoader.getInstance().displayImage(user.getFollowerFaceUrl(), holder.mImgAvatar);
        holder.mTvName.setText(user.getFollowerUsername());
        holder.mTvSignature.setText(user.getFollowerSignature());
        holder.mBtnAttention.setVisibility(View.VISIBLE);
        holder.mTvTime.setVisibility(View.GONE);
        //            holder.mTvTime.setText(getFriendlyTimeSpanByNow(((UserInfo) user).getCreatedAt()));
        holder.mBtnAttention.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ApiUtils.follow(user.getTid(), new BaseCallback<BaseModel<DefJsonResult>>() {

                    @Override
                    protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
                        holder.mBtnAttention.setVisibility(View.GONE);
                    }
                });
            }
        });
    } else {
        ImgLoader.getInstance().displayImage(user.getFollowedFaceUrl(), holder.mImgAvatar);
        holder.mTvName.setText(user.getFollowedUsername());
        holder.mTvSignature.setText(user.getFollowedSignature());
        holder.mBtnAttention.setVisibility(View.GONE);
        holder.mTvTime.setVisibility(View.VISIBLE);
    //            holder.mTvTime.setText(getFriendlyTimeSpanByNow(((UserInfo) user).getCreatedAt()));
    }
    holder.mImgAvatar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Bundle bundle = new Bundle();
            bundle.putInt(UserMomentsActivity.SELECTED_UID, isFans ? user.getFid() : user.getTid());
            bundle.putString(UserMomentsActivity.SELECTED_USERNAME, isFans ? user.getFollowerUsername() : user.getFollowedUsername());
            mActivity.gotoActivity(UserMomentsActivity.class, bundle);
        }
    });
//        holder.setIsRecyclable(false);
}
Also used : DefJsonResult(com.rideread.rideread.data.result.DefJsonResult) BaseModel(com.rideread.rideread.function.net.retrofit.BaseModel) Bundle(android.os.Bundle) UserMomentsActivity(com.rideread.rideread.module.profile.view.UserMomentsActivity) FollowUser(com.rideread.rideread.data.result.FollowUser) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) BaseCallback(com.rideread.rideread.function.net.retrofit.BaseCallback)

Example 2 with FollowUser

use of com.rideread.rideread.data.result.FollowUser in project ride-read-android by Ride-Read.

the class SearchUserAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder tHolder, int position) {
    UserViewHolder holder = (UserViewHolder) tHolder;
    FollowUser user = mUserList.get(position);
    if (0 == user.getTid()) {
        //粉丝
        ImgLoader.getInstance().displayImage(user.getFollowerFaceUrl(), holder.mImgAvatar);
        holder.mTvName.setText(user.getFollowerUsername());
        holder.mTvSignature.setText(user.getFollowerSignature());
        holder.mBtnAttention.setVisibility(View.VISIBLE);
        holder.mTvTime.setVisibility(View.GONE);
        //            holder.mTvTime.setText(getFriendlyTimeSpanByNow(((UserInfo) user).getCreatedAt()));
        holder.mBtnAttention.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ApiUtils.follow(user.getTid(), new BaseCallback<BaseModel<DefJsonResult>>() {

                    @Override
                    protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
                        holder.mBtnAttention.setVisibility(View.GONE);
                    }
                });
            }
        });
    } else {
        ImgLoader.getInstance().displayImage(user.getFollowedFaceUrl(), holder.mImgAvatar);
        holder.mTvName.setText(user.getFollowedUsername());
        holder.mTvSignature.setText(user.getFollowedSignature());
        holder.mBtnAttention.setVisibility(View.GONE);
        holder.mTvTime.setVisibility(View.VISIBLE);
    //            holder.mTvTime.setText(getFriendlyTimeSpanByNow(((UserInfo) user).getCreatedAt()));
    }
    holder.mImgAvatar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Bundle bundle = new Bundle();
            bundle.putInt(UserMomentsActivity.SELECTED_UID, 0 != user.getTid() ? user.getTid() : user.getFid());
            bundle.putString(UserMomentsActivity.SELECTED_USERNAME, 0 != user.getTid() ? user.getFollowerUsername() : user.getFollowedUsername());
            mActivity.gotoActivity(UserMomentsActivity.class, bundle);
        }
    });
//        holder.setIsRecyclable(false);
}
Also used : DefJsonResult(com.rideread.rideread.data.result.DefJsonResult) BaseModel(com.rideread.rideread.function.net.retrofit.BaseModel) Bundle(android.os.Bundle) UserMomentsActivity(com.rideread.rideread.module.profile.view.UserMomentsActivity) FollowUser(com.rideread.rideread.data.result.FollowUser) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) BaseCallback(com.rideread.rideread.function.net.retrofit.BaseCallback)

Aggregations

Bundle (android.os.Bundle)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 BindView (butterknife.BindView)2 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)2 DefJsonResult (com.rideread.rideread.data.result.DefJsonResult)2 FollowUser (com.rideread.rideread.data.result.FollowUser)2 BaseCallback (com.rideread.rideread.function.net.retrofit.BaseCallback)2 BaseModel (com.rideread.rideread.function.net.retrofit.BaseModel)2 UserMomentsActivity (com.rideread.rideread.module.profile.view.UserMomentsActivity)2