use of org.aisen.android.component.bitmaploader.core.ImageConfig 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.android.component.bitmaploader.core.ImageConfig 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.android.component.bitmaploader.core.ImageConfig in project AisenWeiBo by wangdan.
the class PictureFragment method loadPicture.
void loadPicture(View v) {
// 下载路径
String url = null;
ImageConfig config = new ImageConfig();
File file = origFile;
// 原图存在,就下载原图
if (file.exists()) {
url = getOrigImage();
} else // 原图不存在,就下载中图
{
file = BitmapLoader.getInstance().getCacheFile(getImage());
config.setId("Picture");
url = getImage();
pictureSize = SinaDB.getDB().selectById(null, PictureSize.class, getOrigImage());
if (pictureSize == null)
new LoadPictureSizeTask().execute();
}
if (!file.exists()) {
progressView.setVisibility(View.VISIBLE);
// 如果网络不是WIFI,且原图和中图都没缓存,那么只加载当前看的那个图片
if (SystemUtils.NetWorkType.wifi != SystemUtils.getNetworkType(getActivity())) {
if (getActivity() instanceof PicsActivity) {
PicsActivity picsActivity = (PicsActivity) getActivity();
if (!picsActivity.getCurrent().getThumbnail_pic().equalsIgnoreCase(image.getThumbnail_pic()))
return;
} else if (getActivity() instanceof PhotosActivity) {
PhotosActivity picsActivity = (PhotosActivity) getActivity();
if (!picsActivity.getCurrent().getThumbnail_pic().equalsIgnoreCase(image.getThumbnail_pic()))
return;
}
}
}
viewFailure.setVisibility(View.GONE);
ImageView imgView = new ImageView(getActivity());
config.setProgress(new PictureDownloadProgress(file));
BitmapLoader.getInstance().display(null, url, imgView, config);
}
use of org.aisen.android.component.bitmaploader.core.ImageConfig in project AisenWeiBo by wangdan.
the class ImageConfigUtils method getPhotoConfig.
public static ImageConfig getPhotoConfig() {
ImageConfig config = new ImageConfig();
config.setLoadingRes(R.drawable.user_placeholder);
config.setLoadfaildRes(R.drawable.user_placeholder);
config.setDisplayer(new DefaultDisplayer());
return config;
}
use of org.aisen.android.component.bitmaploader.core.ImageConfig in project AisenWeiBo by wangdan.
the class ImageConfigUtils method getLargePhotoConfig.
public static ImageConfig getLargePhotoConfig() {
ImageConfig config = new ImageConfig();
config.setId("large");
config.setDisplayer(new DefaultDisplayer());
config.setLoadingRes(R.drawable.user_placeholder);
config.setLoadfaildRes(R.drawable.user_placeholder);
return config;
}
Aggregations