Search in sources :

Example 1 with PhotosActivity

use of org.aisen.weibo.sina.ui.activity.picture.PhotosActivity 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)

Aggregations

ImageView (android.widget.ImageView)1 File (java.io.File)1 ImageConfig (org.aisen.android.component.bitmaploader.core.ImageConfig)1 PictureSize (org.aisen.weibo.sina.support.bean.PictureSize)1 PhotosActivity (org.aisen.weibo.sina.ui.activity.picture.PhotosActivity)1 PicsActivity (org.aisen.weibo.sina.ui.activity.picture.PicsActivity)1