use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class CommentHeaderItemView method onBindData.
@Override
public void onBindData(View convertView, StatusComment comment, int position) {
WeiBoUser user = statusContent.getUser();
// userInfo
setUserInfo(user, txtName, imgPhoto, imgVerified);
// desc
String createAt = "";
if (!TextUtils.isEmpty(statusContent.getCreated_at()))
createAt = AisenUtils.convDate(statusContent.getCreated_at());
String from = "";
if (!TextUtils.isEmpty(statusContent.getSource()))
from = String.format("%s", Html.fromHtml(statusContent.getSource()));
String desc = String.format("%s %s", createAt, from);
txtDesc.setText(desc);
// 文本
txtContent.setContent(statusContent.getText());
setTextSize(txtContent, textSize);
// reContent
StatusContent reContent = statusContent.getRetweeted_status();
if (reContent == null) {
layRe.setVisibility(View.GONE);
} else {
layRe.setVisibility(View.VISIBLE);
layRe.setTag(reContent);
WeiBoUser reUser = reContent.getUser();
String reUserName = "";
if (reUser != null && !TextUtils.isEmpty(reUser.getScreen_name()))
reUserName = String.format("@%s :", reUser.getScreen_name());
txtReContent.setContent(reUserName + reContent.getText());
// 正文
setTextSize(txtReContent, textSize);
}
// pictures
final StatusContent s = statusContent.getRetweeted_status() != null ? statusContent.getRetweeted_status() : statusContent;
if (s.isVideo()) {
layPicturs.setVisibility(View.GONE);
layPicturs.release();
txtPics.setVisibility(View.GONE);
if (AppSettings.isPicNone() || s.getVideoUrl() == null) {
imgVideo.setVisibility(View.GONE);
} else {
imgVideo.setVisibility(View.VISIBLE);
if (imgVideo.getWidth() > 0) {
imgVideo.display(fragment, s.getVideoUrl());
} else {
imgVideo.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
imgVideo.getViewTreeObserver().removeOnPreDrawListener(this);
imgVideo.display(fragment, s.getVideoUrl());
return true;
}
});
}
}
} else {
imgVideo.setVisibility(View.GONE);
imgVideo.release();
// pictures
if (AppSettings.isPicNone() && !(fragment instanceof TimelineDetailPagerFragment)) {
layPicturs.setVisibility(View.GONE);
if (s.getPic_urls() != null && s.getPic_urls().length > 0) {
txtPics.setText(String.format("%dPics", s.getPic_urls().length));
txtPics.setVisibility(View.VISIBLE);
txtPics.setTag(s);
txtPics.setOnClickListener(this);
} else
txtPics.setVisibility(View.GONE);
} else {
txtPics.setVisibility(View.GONE);
layPicturs.setPics(s, fragment);
}
}
// group visiable
txtVisiable.setVisibility(View.GONE);
if (statusContent.getVisible() != null && groupMap != null) {
String name = groupMap.get(statusContent.getVisible().getList_id());
if (!TextUtils.isEmpty(name)) {
txtVisiable.setText(String.format(fragment.getString(R.string.publish_group_visiable), name));
txtVisiable.setVisibility(View.VISIBLE);
if (layPicturs.getVisibility() == View.GONE) {
txtVisiable.setPadding(0, 0, 0, 0);
} else {
txtVisiable.setPadding(0, vPadding, 0, 0);
}
}
}
// 有转发微博时,设置查看原微博评论的事件
if (statusContent.getRetweeted_status() != null && statusContent.getRetweeted_status().getUser() != null) {
layReStatusContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TimelineDetailPagerFragment.launch(fragment.getActivity(), statusContent.getRetweeted_status());
}
});
}
// 如果没有原微博和图片,把bottom的间隙都去掉
if (statusContent.getRetweeted_status() == null && (statusContent.getPic_urls() == null || statusContent.getPic_urls().length == 0)) {
txtContent.setPadding(txtContent.getPaddingLeft(), txtContent.getPaddingTop(), txtContent.getPaddingRight(), 0);
if (!s.isVideo()) {
layReStatusContainer.setVisibility(View.GONE);
}
}
// 如果没有图片,有原微博,底部加点空隙
if (statusContent.getRetweeted_status() != null && (statusContent.getPic_urls() == null || statusContent.getPic_urls().length == 0)) {
txtReContent.setPadding(txtReContent.getPaddingLeft(), txtReContent.getPaddingTop(), txtReContent.getPaddingRight(), Utils.dip2px(getContext(), 8));
}
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class MenuHeaderView method setupHeaderView.
public void setupHeaderView(FrameLayout parent) {
LayoutInflater inflater = LayoutInflater.from(menuFragment.getActivity());
// 初始化View
if (mHeaderView == null) {
mHeaderView = inflater.inflate(R.layout.layout_menu_header, parent, false);
int height = GlobalContext.getInstance().getResources().getDimensionPixelSize(R.dimen.material_drawer_account_header_height);
if (Build.VERSION.SDK_INT >= 19) {
height += SystemUtils.getStatusBarHeight(menuFragment.getActivity());
}
parent.addView(mHeaderView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, height));
// 绑定视图
InjectUtility.initInjectedView(GlobalContext.getInstance(), this, mHeaderView);
}
View view = mHeaderView.findViewById(R.id.material_drawer_account_header);
if (Build.VERSION.SDK_INT >= 19) {
view.setPadding(view.getPaddingStart(), SystemUtils.getStatusBarHeight(menuFragment.getActivity()), view.getPaddingRight(), view.getPaddingBottom());
}
final WeiBoUser user = AppContext.getAccount().getUser();
// 头像
ImageView imgPhoto = (ImageView) mHeaderView.findViewById(R.id.material_drawer_account_header_current);
imgPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (txtFollowersNewHint != null && txtFollowersNewHint.getVisibility() == View.VISIBLE) {
((MainActivity) menuFragment.getActivity()).closeDrawer();
FriendshipPagerFragment.launch(menuFragment.getActivity(), AppContext.getAccount().getUser(), 1);
} else {
BizFragment.createBizFragment(menuFragment).launchProfile(AppContext.getAccount().getUser());
}
}
});
BitmapLoader.getInstance().display(menuFragment, user.getAvatar_large(), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
// 名字
TextView txtName = (TextView) mHeaderView.findViewById(R.id.material_drawer_account_header_name);
txtName.setText(user.getScreen_name());
// 背景
final ImageView imgCover = (ImageView) mHeaderView.findViewById(R.id.material_drawer_account_header_background);
new WorkTask<Void, Void, Bitmap>() {
@Override
public Bitmap workInBackground(Void... params) throws TaskException {
try {
BitmapLoader.BitmapBytesAndFlag bitmapBytesAndFlag = BitmapLoader.getInstance().doDownload(user.getCover_image_phone(), new ImageConfig());
return BitmapFactory.decodeByteArray(bitmapBytesAndFlag.bitmapBytes, 0, bitmapBytesAndFlag.bitmapBytes.length);
} catch (Exception e) {
}
throw new TaskException("", "");
}
@Override
protected void onSuccess(Bitmap bitmap) {
super.onSuccess(bitmap);
new FadeInDisplayer().loadCompletedisplay(imgCover, new BitmapDrawable(GlobalContext.getInstance().getResources(), bitmap));
}
@Override
protected void onFailure(TaskException exception) {
super.onFailure(exception);
imgCover.setImageDrawable(new BitmapDrawable(GlobalContext.getInstance().getResources(), BitmapFactory.decodeResource(GlobalContext.getInstance().getResources(), R.drawable.bg_banner_dialog)));
}
}.execute();
// 显示账号
mHeaderView.findViewById(R.id.material_drawer_account_header_text_section).setOnClickListener(this);
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class TimelineItemView method onBindData.
@Override
public void onBindData(View convertView, StatusContent data, int position) {
this.data = data;
WeiBoUser user = data.getUser();
// userInfo
setUserInfo(user, txtName, imgPhoto, imgVerified);
// desc
String createAt = "";
if (!TextUtils.isEmpty(data.getCreated_at()))
createAt = AisenUtils.convDate(data.getCreated_at());
String from = "";
if (!TextUtils.isEmpty(data.getSource()))
from = String.format("%s", Html.fromHtml(data.getSource()));
String desc = String.format("%s %s", createAt, from);
txtDesc.setText(desc);
// counter
if (data.getReposts_count() == 0) {
txtRepost.setVisibility(View.GONE);
} else {
txtRepost.setVisibility(View.VISIBLE);
txtRepost.setText(AisenUtils.getCounter(data.getReposts_count()));
}
if (btnRepost != null) {
btnRepost.setTag(data);
btnRepost.setOnClickListener(this);
if (data.getVisible() == null || "0".equals(data.getVisible().getType()))
btnRepost.setVisibility(View.VISIBLE);
else
btnRepost.setVisibility(View.GONE);
}
if (data.getComments_count() == 0) {
txtComment.setVisibility(View.GONE);
} else {
txtComment.setVisibility(View.VISIBLE);
txtComment.setText(AisenUtils.getCounter(data.getComments_count()));
}
if (btnComment != null) {
btnComment.setTag(data);
btnComment.setOnClickListener(this);
}
setLikeView();
// 文本
String text = data.getText();
txtContent.setContent(text);
setTextSize(txtContent, textSize);
// reContent
StatusContent reContent = data.getRetweeted_status();
if (reContent == null) {
layRe.setVisibility(View.GONE);
} else {
layRe.setVisibility(View.VISIBLE);
layRe.setTag(reContent);
WeiBoUser reUser = reContent.getUser();
String reUserName = "";
if (reUser != null && !TextUtils.isEmpty(reUser.getScreen_name()))
reUserName = String.format("@%s :", reUser.getScreen_name());
txtReContent.setContent(reUserName + reContent.getText());
// 正文
setTextSize(txtReContent, textSize);
}
// pictures
StatusContent s = data.getRetweeted_status() != null ? data.getRetweeted_status() : data;
if (s.isVideo()) {
layPicturs.setVisibility(View.GONE);
layPicturs.release();
txtPics.setVisibility(View.GONE);
if (AppSettings.isPicNone() || s.getVideoUrl() == null) {
imgVideo.setVisibility(View.GONE);
} else {
imgVideo.setVisibility(View.VISIBLE);
imgVideo.display(fragment, s.getVideoUrl());
}
} else {
imgVideo.setVisibility(View.GONE);
imgVideo.release();
if (AppSettings.isPicNone() && !(fragment instanceof TimelineCommentFragment)) {
layPicturs.setVisibility(View.GONE);
if (s.getPic_urls() != null && s.getPic_urls().length > 0) {
txtPics.setText(String.format("%dPics", s.getPic_urls().length));
txtPics.setVisibility(View.VISIBLE);
txtPics.setTag(s);
txtPics.setOnClickListener(this);
} else
txtPics.setVisibility(View.GONE);
} else {
txtPics.setVisibility(View.GONE);
layPicturs.setPics(s, fragment);
}
}
// group visiable
txtVisiable.setVisibility(View.GONE);
if (data.getVisible() != null && groupMap != null) {
String name = groupMap.get(data.getVisible().getList_id());
if (!TextUtils.isEmpty(name)) {
txtVisiable.setText(String.format(fragment.getString(R.string.publish_group_visiable), name));
txtVisiable.setVisibility(View.VISIBLE);
if (layPicturs.getVisibility() == View.GONE) {
txtVisiable.setPadding(0, 0, 0, 0);
} else {
txtVisiable.setPadding(0, vPadding, 0, 0);
}
}
}
btnMenus.setTag(data);
btnMenus.setOnClickListener(this);
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class MentionCmtItemView method onBindData.
@Override
public void onBindData(View convertView, StatusComment data, int position) {
WeiBoUser user = data.getUser();
if (user != null) {
BitmapLoader.getInstance().display(fragment, AisenUtils.getUserPhoto(user), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
bizFragment.userShow(imgPhoto, user);
txtName.setText(AisenUtils.getUserScreenName(user));
} else {
bizFragment.userShow(imgPhoto, null);
txtName.setText(R.string.error_cmts);
imgPhoto.setImageResource(R.drawable.user_placeholder);
}
txtContent.setContent(AisenUtils.getCommentText(data.getText()));
AisenUtils.setTextSize(txtContent);
String createAt = AisenUtils.convDate(data.getCreated_at());
String from = String.format("%s", Html.fromHtml(data.getSource()));
String desc = String.format("%s %s", createAt, from);
txtDesc.setText(desc);
// 源评论
if (data.getReply_comment() != null) {
layRe.setVisibility(View.VISIBLE);
txtReContent.setContent(AisenUtils.getCommentText(data.getReply_comment().getText()));
AisenUtils.setTextSize(txtReContent);
if (data.getReply_comment().getUser() != null) {
BitmapLoader.getInstance().display(fragment, AisenUtils.getUserPhoto(data.getReply_comment().getUser()), imgRePhoto, ImageConfigUtils.getLargePhotoConfig());
bizFragment.userShow(imgRePhoto, data.getReply_comment().getUser());
} else {
bizFragment.userShow(imgRePhoto, null);
}
} else {
layRe.setVisibility(View.GONE);
}
if (layStatus != null) {
if (data.getStatus() != null) {
layDivider.setVisibility(View.VISIBLE);
layStatus.setVisibility(View.VISIBLE);
layStatus.setTag(data.getStatus());
layStatus.setOnClickListener(this);
txtStatusContent.setContent(data.getStatus().getText());
AisenUtils.setTextSize(txtStatusContent);
String image = null;
// 先取微博的第一张图
StatusContent status = data.getStatus();
if (status != null && status.getRetweeted_status() != null)
status = status.getRetweeted_status();
if (status == null || status.getPic_urls() == null || status.getPic_urls().length == 0) {
} else {
image = status.getPic_urls()[0].getThumbnail_pic();
}
// 没图就取头像
if (TextUtils.isEmpty(image) && status.getUser() != null) {
image = status.getUser().getAvatar_large();
}
if (!TextUtils.isEmpty(image)) {
imgView.setVisibility(View.VISIBLE);
ImageConfig config = new ImageConfig();
config.setId("comments");
config.setLoadfaildRes(R.drawable.bg_timeline_loading);
config.setLoadingRes(R.drawable.bg_timeline_loading);
config.setMaxWidth(300);
config.setMaxHeight(300);
config.setBitmapCompress(TimelineThumbBitmapCompress.class);
BitmapLoader.getInstance().display(fragment, image, imgView, config);
} else {
imgView.setVisibility(View.GONE);
}
bizFragment.bindOnTouchListener(txtStatusContent);
} else {
layDivider.setVisibility(View.GONE);
layStatus.setVisibility(View.GONE);
}
}
if (btnMenus != null) {
btnMenus.setTag(data);
btnMenus.setOnClickListener(this);
}
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class MenuHeaderView method setupHeaderView.
public void setupHeaderView(Context context, FrameLayout parent) {
LayoutInflater inflater = LayoutInflater.from(menuFragment.getActivity());
// 初始化View
if (mHeaderView == null) {
mHeaderView = inflater.inflate(R.layout.layout_menu_header, parent, false);
int height = GlobalContext.getInstance().getResources().getDimensionPixelSize(R.dimen.material_drawer_account_header_height);
if (Build.VERSION.SDK_INT >= 19) {
height += SystemUtils.getStatusBarHeight(menuFragment.getActivity());
}
parent.addView(mHeaderView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, height));
// 绑定视图
InjectUtility.initInjectedView(context, this, mHeaderView);
}
View view = mHeaderView.findViewById(R.id.material_drawer_account_header);
if (Build.VERSION.SDK_INT >= 19) {
view.setPadding(view.getPaddingStart(), SystemUtils.getStatusBarHeight(menuFragment.getActivity()), view.getPaddingRight(), view.getPaddingBottom());
}
final WeiBoUser user = AppContext.getAccount().getUser();
// 头像
ImageView imgPhoto = (ImageView) mHeaderView.findViewById(R.id.material_drawer_account_header_current);
imgPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (txtFollowersNewHint != null && txtFollowersNewHint.getVisibility() == View.VISIBLE) {
((MainActivity) menuFragment.getActivity()).closeDrawer();
FriendshipPagerFragment.launch(menuFragment.getActivity(), AppContext.getAccount().getUser(), 1);
} else {
BizFragment.createBizFragment(menuFragment).launchProfile(AppContext.getAccount().getUser());
}
}
});
BitmapLoader.getInstance().display(menuFragment, user.getAvatar_large(), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
// 名字
TextView txtName = (TextView) mHeaderView.findViewById(R.id.material_drawer_account_header_name);
txtName.setText(user.getScreen_name());
// 背景
final ImageView imgCover = (ImageView) mHeaderView.findViewById(R.id.material_drawer_account_header_background);
new WorkTask<Void, Void, Bitmap>() {
@Override
public Bitmap workInBackground(Void... params) throws TaskException {
try {
BitmapLoader.BitmapBytesAndFlag bitmapBytesAndFlag = BitmapLoader.getInstance().doDownload(user.getCover_image_phone(), new ImageConfig());
return BitmapFactory.decodeByteArray(bitmapBytesAndFlag.bitmapBytes, 0, bitmapBytesAndFlag.bitmapBytes.length);
} catch (Exception e) {
}
throw new TaskException("", "");
}
@Override
protected void onSuccess(Bitmap bitmap) {
super.onSuccess(bitmap);
new FadeInDisplayer().loadCompletedisplay(imgCover, new BitmapDrawable(GlobalContext.getInstance().getResources(), bitmap));
}
@Override
protected void onFailure(TaskException exception) {
super.onFailure(exception);
imgCover.setImageDrawable(new BitmapDrawable(GlobalContext.getInstance().getResources(), BitmapFactory.decodeResource(GlobalContext.getInstance().getResources(), R.drawable.bg_banner_dialog)));
}
}.execute();
// 显示账号
mHeaderView.findViewById(R.id.material_drawer_account_header_text_section).setOnClickListener(this);
}
Aggregations