Search in sources :

Example 11 with ImageConfig

use of org.aisen.android.component.bitmaploader.core.ImageConfig in project AisenWeiBo by wangdan.

the class ProfilePagerFragment method setProfile.

private void setProfile() {
    // 封面
    ImageConfig coverConfig = new ImageConfig();
    coverConfig.setLoadfaildRes(R.drawable.bg_banner_dialog);
    coverConfig.setLoadingRes(R.drawable.bg_banner_dialog);
    coverConfig.setDisplayer(new DefaultDisplayer());
    BitmapLoader.getInstance().display(this, mUser.getCover_image_phone(), imgCover, coverConfig);
    // 名字
    // fuck 2014-09-04 当名字过长大于10个字时,截取部分文字
    //        int maxLength = AisenUtils.getStrLength("一二三四五六七八九十");
    int maxLength = AisenUtils.getStrLength("一二三四五");
    if (AisenUtils.getStrLength(mUser.getName()) > maxLength) {
        StringBuffer sb = new StringBuffer();
        int index = 0;
        while (AisenUtils.getStrLength(sb.toString()) < maxLength) {
            if (index >= mUser.getName().length())
                break;
            sb.append(mUser.getName().charAt(index));
            index++;
        }
        sb.append("...");
        txtName.setText(sb.toString());
    } else {
        txtName.setText(mUser.getScreen_name());
    }
    // 头像
    File avatarFile = BitmapLoader.getInstance().getCacheFile(AisenUtils.getUserPhoto(mUser));
    if (avatarFile.exists()) {
        Bitmap bitmap = BitmapFactory.decodeFile(avatarFile.getAbsolutePath());
        imgAvatar.setImageBitmap(bitmap);
        collapsingToolbarLayout.setAvatarBitmap(bitmap);
    } else {
        ImageConfig config = new ImageConfig();
        config.setId("large");
        config.setDisplayer(new DefaultDisplayer());
        config.setLoadingRes(R.drawable.user_placeholder);
        config.setLoadfaildRes(R.drawable.user_placeholder);
        config.setProgress(new DownloadProcess() {

            @Override
            public void finishedDownload(byte[] bytes) {
                super.finishedDownload(bytes);
                collapsingToolbarLayout.setAvatarBitmap(BitmapFactory.decodeByteArray(bytes, 0, bytes.length));
            }
        });
        BitmapLoader.getInstance().display(this, AisenUtils.getUserPhoto(mUser), imgAvatar, config);
    }
    // 性别
    imgGender.setVisibility(View.VISIBLE);
    if ("m".equals(mUser.getGender()))
        imgGender.setImageResource(R.drawable.list_male);
    else if ("f".equals(mUser.getGender()))
        imgGender.setImageResource(R.drawable.list_female);
    else
        imgGender.setVisibility(View.GONE);
    // 认证
    AisenUtils.setImageVerified(imgVerified, mUser);
    // 关注数
    txtFriendsCounter.setText(String.format(getString(R.string.profile_friends), AisenUtils.getCounter(mUser.getFriends_count())));
    // 粉丝数
    txtFollowersCounter.setText(String.format(getString(R.string.profile_followers), AisenUtils.getCounter(mUser.getFollowers_count())));
    // 简介
    txtDesc.setText(mUser.getDescription());
    // 简介
    if (!TextUtils.isEmpty(mUser.getDescription()))
        txtDesc.setText(mUser.getDescription());
    else
        txtDesc.setText(getString(R.string.profile_des_none));
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) Bitmap(android.graphics.Bitmap) DefaultDisplayer(org.aisen.android.component.bitmaploader.display.DefaultDisplayer) DownloadProcess(org.aisen.android.component.bitmaploader.download.DownloadProcess) File(java.io.File)

Aggregations

ImageConfig (org.aisen.android.component.bitmaploader.core.ImageConfig)11 DefaultDisplayer (org.aisen.android.component.bitmaploader.display.DefaultDisplayer)5 File (java.io.File)4 View (android.view.View)3 ImageView (android.widget.ImageView)3 WeiBoUser (org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)3 Bitmap (android.graphics.Bitmap)2 TextView (android.widget.TextView)2 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 SpannableString (android.text.SpannableString)1 LayoutInflater (android.view.LayoutInflater)1 FrameLayout (android.widget.FrameLayout)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 LinearLayout (android.widget.LinearLayout)1 FadeInDisplayer (org.aisen.android.component.bitmaploader.display.FadeInDisplayer)1 DownloadProcess (org.aisen.android.component.bitmaploader.download.DownloadProcess)1 SdcardDownloader (org.aisen.android.component.bitmaploader.download.SdcardDownloader)1 TaskException (org.aisen.android.network.task.TaskException)1 PictureSize (org.aisen.weibo.sina.support.bean.PictureSize)1