use of org.aisen.android.component.bitmaploader.display.FadeInDisplayer 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);
}
Aggregations