use of com.rideread.rideread.function.net.retrofit.BaseModel 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);
}
use of com.rideread.rideread.function.net.retrofit.BaseModel in project ride-read-android by Ride-Read.
the class MomentsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder tHolder, int position) {
if (TYPE_ITEM == tHolder.getItemViewType()) {
Moment moment = mMomentList.get(position);
MomentUser user = moment.getUser();
boolean isAttent = 0 == user.getIsFollowed();
MomentViewHolder holder = (MomentViewHolder) tHolder;
holder.mClMomentLayout.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(MomentDetailActivity.SELECTED_MOMENT_MID, moment.getMid());
bundle.putInt(MomentDetailActivity.USER_TYPE, isAttent ? MomentDetailActivity.USER_TYPE_ATTENTED : MomentDetailActivity.USER_TYPE_NEARBY);
mActivity.gotoActivity(MomentDetailActivity.class, bundle);
});
ImgLoader.getInstance().displayImage(user.getFaceUrl(), holder.mImgAvatar);
holder.mTvName.setText(user.getUsername());
holder.mImgAvatar.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(UserMomentsActivity.SELECTED_UID, user.getUid());
bundle.putString(UserMomentsActivity.SELECTED_USERNAME, user.getUsername());
mActivity.gotoActivity(UserMomentsActivity.class, bundle);
});
String msg = moment.getMsg();
if (!TextUtils.isEmpty(msg)) {
holder.mTvMomentText.setText(msg);
holder.mTvMomentText.setVisibility(View.VISIBLE);
} else {
holder.mTvMomentText.setVisibility(View.GONE);
}
List<String> pictures = moment.getPictures();
if (!ListUtils.isEmpty(pictures)) {
holder.mNineGridImgView.setAdapter(adapter);
holder.mNineGridImgView.setImagesData(pictures);
holder.mNineGridImgView.setVisibility(View.VISIBLE);
} else {
holder.mNineGridImgView.setVisibility(View.GONE);
}
holder.mBtnAttention.setBackgroundResource(isAttent ? R.drawable.icon_attented : R.drawable.icon_attention);
holder.mBtnAttention.setOnClickListener(v -> {
if (isAttent) {
ApiUtils.unfollow(user.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
holder.mBtnAttention.setBackgroundResource(R.drawable.icon_attention);
user.setIsFollowed(-1);
}
});
} else {
ApiUtils.follow(user.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
holder.mBtnAttention.setBackgroundResource(R.drawable.icon_attented);
user.setIsFollowed(1);
}
});
}
});
List<ThumbsUpUser> thumbsUp = moment.getThumbsUp();
int likeCount = ListUtils.isEmpty(thumbsUp) ? 0 : thumbsUp.size();
holder.mBtnLike.setOnClickListener(v -> ApiUtils.updateThumbsUp(moment.getMid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
ToastUtils.show("成功点赞");
holder.mTvLikeCount.setText((likeCount + 1) + "");
}
}));
holder.mTvTime.setText(getFriendlyTimeSpanByNow(moment.getCreatedAt()));
holder.mTvLikeCount.setText(likeCount + "");
List<Comment> comments = moment.getComment();
int commentSize = ListUtils.isEmpty(comments) ? 0 : comments.size();
holder.mTvCommentCount.setText(commentSize + "");
// TODO
holder.mTvLocInfo.setText(moment.getMomentLocation() + " 距离我" + moment.getDistanceString());
holder.setIsRecyclable(false);
} else if (TYPE_HEADER == tHolder.getItemViewType()) {
} else {
// 最后一个位置
}
}
use of com.rideread.rideread.function.net.retrofit.BaseModel in project ride-read-android by Ride-Read.
the class UserMomentsActivity method followUser.
private void followUser() {
if (isFollow) {
ConfirmDialogFragment unFollowDialog = ConfirmDialogFragment.newInstance(R.string.sure2unfollow);
unFollowDialog.show(getSupportFragmentManager(), "dialog");
} else {
ApiUtils.follow(mSelectedUid, new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
isFollow = true;
refreshFollowAction(isFollow);
UserInfo myInfo = UserUtils.getCurUser();
int curFollowing = myInfo.getFollowing() + 1;
myInfo.setFollowing(curFollowing);
UserUtils.saveUserInfo(myInfo);
}
});
}
}
use of com.rideread.rideread.function.net.retrofit.BaseModel in project ride-read-android by Ride-Read.
the class RegisterFragment method verifyInviteId.
private void verifyInviteId() {
mInvitedId = mEdtInviteId.getText().toString();
if (TextUtils.isEmpty(mInvitedId)) {
ToastUtils.show("骑阅邀请号不能为空");
return;
}
ApiUtils.verifyRideReadId(mInvitedId, new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
showCodeView();
// 申请发送短信权限
PermissionUtils permission = new PermissionUtils(getActivity());
permission.grantPermission(getActivity(), Manifest.permission.READ_PHONE_STATE);
// permission.grantPermission(getActivity(), Manifest.permission.SEND_SMS);
}
});
}
use of com.rideread.rideread.function.net.retrofit.BaseModel 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);
}
Aggregations