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


Java ANImageLoader.ImageContainer方法代码示例

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


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

示例1: loadImageIfNecessary

import com.androidnetworking.internal.ANImageLoader; //导入方法依赖的package包/类
void loadImageIfNecessary(final boolean isInLayoutPass) {
    int width = getWidth();
    int height = getHeight();
    ScaleType scaleType = getScaleType();

    boolean wrapWidth = false, wrapHeight = false;
    if (getLayoutParams() != null) {
        wrapWidth = getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT;
        wrapHeight = getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT;
    }

    boolean isFullyWrapContent = wrapWidth && wrapHeight;
    if (width == 0 && height == 0 && !isFullyWrapContent) {
        return;
    }

    if (TextUtils.isEmpty(mUrl)) {
        if (mImageContainer != null) {
            mImageContainer.cancelRequest();
            mImageContainer = null;
        }
        setDefaultImageOrNull();
        return;
    }

    if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
        if (mImageContainer.getRequestUrl().equals(mUrl)) {
            return;
        } else {
            mImageContainer.cancelRequest();
            setDefaultImageOrNull();
        }
    }

    int maxWidth = wrapWidth ? 0 : width;
    int maxHeight = wrapHeight ? 0 : height;

    ANImageLoader.ImageContainer newContainer = ANImageLoader.getInstance().get(mUrl,
            new ANImageLoader.ImageListener() {
                @Override
                public void onResponse(final ANImageLoader.ImageContainer response,
                                       boolean isImmediate) {
                    if (isImmediate && isInLayoutPass) {
                        post(new Runnable() {
                            @Override
                            public void run() {
                                onResponse(response, false);
                            }
                        });
                        return;
                    }

                    if (response.getBitmap() != null) {
                        setImageBitmap(response.getBitmap());
                    } else if (mDefaultImageId != 0) {
                        setImageResource(mDefaultImageId);
                    }
                }

                @Override
                public void onError(ANError error) {
                    if (mErrorImageId != 0) {
                        setImageResource(mErrorImageId);
                    }
                }
            }, maxWidth, maxHeight, scaleType);

    mImageContainer = newContainer;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:70,代码来源:ANImageView.java

示例2: loadImageIfNecessary

import com.androidnetworking.internal.ANImageLoader; //导入方法依赖的package包/类
void loadImageIfNecessary(final boolean isInLayoutPass) {
    int width = getWidth();
    int height = getHeight();
    ImageView.ScaleType scaleType = getScaleType();

    boolean wrapWidth = false, wrapHeight = false;
    if (getLayoutParams() != null) {
        wrapWidth = getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT;
        wrapHeight = getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT;
    }

    boolean isFullyWrapContent = wrapWidth && wrapHeight;
    if (width == 0 && height == 0 && !isFullyWrapContent) {
        return;
    }

    if (TextUtils.isEmpty(mUrl)) {
        if (mImageContainer != null) {
            mImageContainer.cancelRequest();
            mImageContainer = null;
        }
        setDefaultImageOrNull();
        return;
    }

    if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
        if (mImageContainer.getRequestUrl().equals(mUrl)) {
            return;
        } else {
            mImageContainer.cancelRequest();
            setDefaultImageOrNull();
        }
    }

    int maxWidth = wrapWidth ? 0 : width;
    int maxHeight = wrapHeight ? 0 : height;

    ANImageLoader.ImageContainer newContainer = ANImageLoader.getInstance().get(mUrl,
            new ANImageLoader.ImageListener() {
                @Override
                public void onResponse(final ANImageLoader.ImageContainer response,
                                       boolean isImmediate) {
                    if (isImmediate && isInLayoutPass) {
                        post(new Runnable() {
                            @Override
                            public void run() {
                                onResponse(response, false);
                            }
                        });
                        return;
                    }

                    if (response.getBitmap() != null) {
                        setImageBitmap(response.getBitmap());
                    } else if (mDefaultImageId != 0) {
                        setImageResource(mDefaultImageId);
                    }
                }

                @Override
                public void onError(ANError error) {
                    if (mErrorImageId != 0) {
                        setImageResource(mErrorImageId);
                    }
                }
            }, maxWidth, maxHeight, scaleType);

    mImageContainer = newContainer;
}
 
开发者ID:amitshekhariitbhu,项目名称:Fast-Android-Networking,代码行数:70,代码来源:ANImageView.java


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