当前位置: 首页>>代码示例>>Java>>正文


Java BitmapLoadCallBack.setDrawable方法代码示例

本文整理汇总了Java中com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack.setDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapLoadCallBack.setDrawable方法的具体用法?Java BitmapLoadCallBack.setDrawable怎么用?Java BitmapLoadCallBack.setDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack的用法示例。


在下文中一共展示了BitmapLoadCallBack.setDrawable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: display

import com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack; //导入方法依赖的package包/类
public <T extends View> void display(T container, String uri, BitmapDisplayConfig displayConfig, BitmapLoadCallBack<T> callBack) {
    if (container == null) {
        return;
    }

    if (callBack == null) {
        callBack = new DefaultBitmapLoadCallBack<T>();  //默认的回调
    }

    if (displayConfig == null || displayConfig == defaultDisplayConfig) {
        displayConfig = defaultDisplayConfig.cloneNew();// 默认展示图片的设置
    }

    // Optimize Max Size
    BitmapSize size = displayConfig.getBitmapMaxSize();
    //配置显示控件的大小
    displayConfig.setBitmapMaxSize(BitmapCommonUtils.optimizeMaxSizeByView(container, size.getWidth(), size.getHeight()));

    container.clearAnimation();

    if (TextUtils.isEmpty(uri)) {
        callBack.onLoadFailed(container, uri, displayConfig.getLoadFailedDrawable());
        return;
    }

    // start loading
    callBack.onPreLoad(container, uri, displayConfig);

    // find bitmap from mem cache. 优先从运行内存的缓存中读取
    Bitmap bitmap = globalConfig.getBitmapCache().getBitmapFromMemCache(uri, displayConfig);

    if (bitmap != null) {
        callBack.onLoadStarted(container, uri, displayConfig);
        callBack.onLoadCompleted(
                container,
                uri,
                bitmap,
                displayConfig,
                BitmapLoadFrom.MEMORY_CACHE);
    } else if (!bitmapLoadTaskExist(container, uri, callBack)) { //这里判断任务是否正在加载中

        final BitmapLoadTask<T> loadTask = new BitmapLoadTask<T>(container, uri, displayConfig, callBack);

        // get executor
        PriorityExecutor executor = globalConfig.getBitmapLoadExecutor();
        File diskCacheFile = this.getBitmapFileFromDiskCache(uri);
        boolean diskCacheExist = diskCacheFile != null && diskCacheFile.exists();
        if (diskCacheExist && executor.isBusy()) {
        	//如果闪存中有缓存,而且BitmapLoadExecutor线程池不够用就使用DiskCacheExecutor的线程池
            executor = globalConfig.getDiskCacheExecutor();  
        }
        // set loading image
        Drawable loadingDrawable = displayConfig.getLoadingDrawable();
        callBack.setDrawable(container, new AsyncDrawable<T>(loadingDrawable, loadTask));

        loadTask.setPriority(displayConfig.getPriority());
        loadTask.executeOnExecutor(executor);
    }
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:60,代码来源:BitmapUtils.java

示例2: display

import com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack; //导入方法依赖的package包/类
public <T extends View> void display(T container, String uri, BitmapDisplayConfig displayConfig, BitmapLoadCallBack<T> callBack) {
    if (container == null) {
        return;
    }

    if (callBack == null) {
        callBack = new DefaultBitmapLoadCallBack<T>();
    }

    if (displayConfig == null || displayConfig == defaultDisplayConfig) {
        displayConfig = defaultDisplayConfig.cloneNew();
    }

    // Optimize Max Size
    BitmapSize size = displayConfig.getBitmapMaxSize();
    displayConfig.setBitmapMaxSize(BitmapCommonUtils.optimizeMaxSizeByView(container, size.getWidth(), size.getHeight()));

    container.clearAnimation();

    if (TextUtils.isEmpty(uri)) {
        callBack.onLoadFailed(container, uri, displayConfig.getLoadFailedDrawable());
        return;
    }

    // start loading
    callBack.onPreLoad(container, uri, displayConfig);

    // find bitmap from mem cache.
    Bitmap bitmap = globalConfig.getBitmapCache().getBitmapFromMemCache(uri, displayConfig);

    if (bitmap != null) {
        callBack.onLoadStarted(container, uri, displayConfig);
        callBack.onLoadCompleted(
                container,
                uri,
                bitmap,
                displayConfig,
                BitmapLoadFrom.MEMORY_CACHE);
    } else if (!bitmapLoadTaskExist(container, uri, callBack)) {

        final BitmapLoadTask<T> loadTask = new BitmapLoadTask<T>(container, uri, displayConfig, callBack);

        // get executor
        PriorityExecutor executor = globalConfig.getBitmapLoadExecutor();
        File diskCacheFile = this.getBitmapFileFromDiskCache(uri);
        boolean diskCacheExist = diskCacheFile != null && diskCacheFile.exists();
        if (diskCacheExist && executor.isBusy()) {
            executor = globalConfig.getDiskCacheExecutor();
        }
        // set loading image
        Drawable loadingDrawable = displayConfig.getLoadingDrawable();
        callBack.setDrawable(container, new AsyncDrawable<T>(loadingDrawable, loadTask));

        loadTask.setPriority(displayConfig.getPriority());
        loadTask.executeOnExecutor(executor);
    }
}
 
开发者ID:android-quick-dev,项目名称:AndroidDevFramework,代码行数:58,代码来源:BitmapUtils.java


注:本文中的com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack.setDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。