use of com.rideread.rideread.function.net.retrofit.BaseModel in project ride-read-android by Ride-Read.
the class MomentDetailActivity method refreshView.
private void refreshView() {
View momentHeader = initMomentHeader();
mCurMomentUser = mCurMoment.getUser();
if (null != mCurMomentUser) {
ImgLoader.getInstance().displayImage(mCurMoment.getUser().getFaceUrl(), mImgAvatar);
mTvName.setText(mCurMomentUser.getUsername());
mTvTime.setText(TimeUtils.getFriendlyTimeSpanByNow(mCurMoment.getCreatedAt()));
int isFollowInt = mCurMomentUser.getIsFollowed();
isAttention = isFollowInt == 0 || isFollowInt == 1;
mBtnAttention.setBackgroundResource(isAttention ? R.drawable.icon_attented : R.drawable.icon_attention);
mTvMomentText.setText(mCurMoment.getMsg());
mTvCommentCount.setText("评论 " + mCurMoment.getComment().size());
mThumbUpCount = mCurMoment.getThumbsUp().size();
mTvThumbCount.setText(Integer.toString(mThumbUpCount));
if (mCurMomentUser.getUid() == UserUtils.getUid())
mBtnAttention.setVisibility(View.GONE);
mImgAvatar.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(UserMomentsActivity.SELECTED_UID, mCurMomentUser.getUid());
bundle.putString(UserMomentsActivity.SELECTED_USERNAME, mCurMomentUser.getUsername());
gotoActivity(UserMomentsActivity.class, bundle);
});
mBtnAttention.setOnClickListener(v -> {
if (isAttention) {
ApiUtils.unfollow(mCurMomentUser.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
mBtnAttention.setBackgroundResource(R.drawable.icon_attention);
isAttention = !isAttention;
}
});
} else {
ApiUtils.follow(mCurMomentUser.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
mBtnAttention.setBackgroundResource(R.drawable.icon_attented);
isAttention = !isAttention;
}
});
}
});
List<String> pictures = mCurMoment.getPictures();
if (!ListUtils.isEmpty(pictures)) {
mNineGridImgView.setAdapter(nineGridAdapter);
mNineGridImgView.setImagesData(pictures);
mNineGridImgView.setVisibility(View.VISIBLE);
} else {
mNineGridImgView.setVisibility(View.GONE);
}
}
List<ThumbsUpUser> thumbsUpUsers = mCurMoment.getThumbsUp();
SimpleDraweeView thumbUpUserAvatar;
RoundingParams roundingParams = RoundingParams.fromCornersRadius(4f);
roundingParams.setRoundAsCircle(true);
for (ThumbsUpUser thumbsUpUser : thumbsUpUsers) {
thumbUpUserAvatar = new SimpleDraweeView(this);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams((int) ScreenUtils.dp2px(28f), (int) ScreenUtils.dp2px(28f));
thumbUpUserAvatar.setLayoutParams(params);
thumbUpUserAvatar.getHierarchy().setRoundingParams(roundingParams);
ImgLoader.getInstance().displayImage(thumbsUpUser.getFaceUrl(), thumbUpUserAvatar);
mHllThumpUps.addView(thumbUpUserAvatar);
if (UserUtils.getUid() == thumbsUpUser.getUid()) {
myAvatar = thumbUpUserAvatar;
}
if (!mHllThumpUps.canAddView()) {
break;
}
}
if (!ListUtils.isEmpty(thumbsUpUsers)) {
mHllThumpUps.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(ThumbsUpUserActivity.MOMENT_ID, mCurMoment.getMid());
gotoActivity(ThumbsUpUserActivity.class, bundle);
});
}
for (ThumbsUpUser thumbsUpUser : thumbsUpUsers) {
if (thumbsUpUser.getUid() == UserUtils.getUid()) {
isThumbsUp = true;
break;
}
}
mBtnThumbsUp.setBackgroundResource(isThumbsUp ? R.drawable.ic_thumb_up_on : R.drawable.ic_thumb_up_off);
mLvComments.addHeaderView(momentHeader);
mAdapter = new CommentsAdapter(this);
mCommentList = mCurMoment.getComment();
mAdapter.setItems(mCommentList);
mLvComments.setAdapter(mAdapter);
}
use of com.rideread.rideread.function.net.retrofit.BaseModel in project ride-read-android by Ride-Read.
the class UserInfoActivity method saveCurInfo.
private void saveCurInfo() {
UserInfo curInfo = new UserInfo(mFaceUrl, mNick, mCurSexIndex + 1, mLabels, mSignature, mSchool, mLocation, mHomeTown, mCareer);
ApiUtils.update(curInfo, mBirthday, new BaseCallback<BaseModel<UserInfo>>() {
@Override
protected void onSuccess(BaseModel<UserInfo> model) throws Exception {
UserInfo userInfo = model.getData();
if (null != userInfo) {
UserUtils.saveUserInfo(userInfo);
finish();
EventBus.getDefault().postSticky(new RefreshProfileEvent());
}
}
});
}
Aggregations