Search in sources :

Example 6 with ImageConfig

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);
    }
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)

Example 7 with ImageConfig

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);
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) FadeInDisplayer(org.aisen.android.component.bitmaploader.display.FadeInDisplayer) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TaskException(org.aisen.android.network.task.TaskException) Bitmap(android.graphics.Bitmap) TaskException(org.aisen.android.network.task.TaskException) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 8 with ImageConfig

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);
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) PictureSize(org.aisen.weibo.sina.support.bean.PictureSize) PicsActivity(org.aisen.weibo.sina.ui.activity.picture.PicsActivity) ImageView(android.widget.ImageView) File(java.io.File) PhotosActivity(org.aisen.weibo.sina.ui.activity.picture.PhotosActivity)

Example 9 with ImageConfig

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;
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) DefaultDisplayer(org.aisen.android.component.bitmaploader.display.DefaultDisplayer)

Example 10 with ImageConfig

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;
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) DefaultDisplayer(org.aisen.android.component.bitmaploader.display.DefaultDisplayer)

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