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


Java ImageLoader.ImageContainer方法代码示例

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


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

示例1: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {

    if (killed)
        return;

    // If response was not immidate, i.e  image was cached we show the default image while loading
    if (isImmediate && response.getBitmap() == null)
    {
        setDefaultImg(threadListItem);
        return;
    }

    // Set the response to the image.
    if (response.getBitmap() != null) {
        if (DEBUG) Timber.i("Loading thread picture from url");

        // load image into imageview
        imgIcon.setImageBitmap(response.getBitmap());
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:22,代码来源:ChatSDKAbstractThreadsListAdapter.java

示例2: handleResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
private void handleResponse(ImageLoader.ImageContainer response,
                            boolean isCached,
                            boolean allowFadeIn) {
    if (response.getBitmap() != null) {
        Bitmap bitmap = response.getBitmap();

        // Apply circular rounding to avatars in a background task
        if (mImageType == ImageType.AVATAR) {
            new CircularizeBitmapTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, bitmap);
            return;
        }

        setImageBitmap(bitmap);

        // fade in photos/videos if not cached (not used for other image types since animation can be expensive)
        if (!isCached && allowFadeIn && canFadeInImageType(mImageType))
            fadeIn();

        if (mImageListener != null) {
            mImageListener.onImageLoaded(true);
        }
    } else {
        showDefaultImage();
    }
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:26,代码来源:WPNetworkImageView.java

示例3: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {
    if (isImmediate)
    {
        if (loadDone != null)
            loadDone.immediate(response.getBitmap() != null);
    }

    if (response.getBitmap() != null) {

        if (isCachedWithSize)
        {
            if (isKilled)
                return;

            image = new WeakReference<Bitmap>(response.getBitmap());
            invalidate();

            if (loadDone != null)
                loadDone.onDone();
        }
        else
        {
            // If the image was already in the cache that means that there is a task to fix the image.
            if (isImmediate)
                return;

            // Create a new task to fix the image size.
            fixImageAsyncTask = new FixImageAsyncTask(loadDone, this.imageUrl, width, height, isKilled);
            fixImageAsyncTask.execute(response.getBitmap());
        }
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:34,代码来源:ChatBubbleImageView.java

示例4: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
    if (isImmediate && response.getBitmap() == null)
    {
        profilePic.setImageResource(com.braunster.chatsdk.R.drawable.ic_profile);
        return;
    }

    if (response.getBitmap() != null && !killed) {
        // load image into imageview
        profilePic.setImageBitmap(response.getBitmap());
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:14,代码来源:ChatSDKAbstractUsersListAdapter.java

示例5: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {

    if (killed)
        return;

    if (response.getBitmap() != null) {
        setProfilePic(response.getBitmap());

        if (saveAfterLoad)
            createTempFileAndSave(response.getBitmap());
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:14,代码来源:ChatSDKProfileHelper.java

示例6: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(ImageLoader.ImageContainer imageContainer, boolean isImmediate) {
    if (imageContainer.getBitmap() != null) {
        imageView.setImageBitmap(imageContainer.getBitmap());
    } else if (errorImage != 0) {
        imageView.setImageResource(errorImage);
    }
}
 
开发者ID:Rabbit00,项目名称:MeifuGO,代码行数:9,代码来源:HttpImage.java

示例7: getImageListener

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static ImageLoader.ImageListener getImageListener(
        final Resources r, final ImageView iv, final Drawable defDrawable, final Drawable errorDrawable) {

    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorDrawable != null) {
                iv.setImageDrawable(errorDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defDrawable,
                                    new BitmapDrawable(r, response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    iv.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    iv.setImageBitmap(response.getBitmap());
                }
            } else if (defDrawable != null) {
                iv.setImageDrawable(defDrawable);
            }
        }
    };
}
 
开发者ID:duanze,项目名称:Meizitu,代码行数:34,代码来源:ImageCacheManager.java

示例8: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {

    final Bitmap bitmap = response.getBitmap();

    // Set image and update view
    markerImage.setImageBitmap(bitmap);
    updateView();
}
 
开发者ID:oguzbabaoglu,项目名称:android-custom-markers,代码行数:10,代码来源:NetworkMarker.java

示例9: getImageListener

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static ImageLoader.ImageListener getImageListener(final ImageView view,
                                                         final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageDrawable != null) {
                view.setImageDrawable(errorImageDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defaultImageDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defaultImageDrawable,
                                    new BitmapDrawable(App.getContext().getResources(),
                                            response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    view.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    view.setImageBitmap(response.getBitmap());
                }
            } else if (defaultImageDrawable != null) {
                view.setImageDrawable(defaultImageDrawable);
            }
        }
    };
}
 
开发者ID:SparkYuan,项目名称:Material-9GAG,代码行数:34,代码来源:ImageCacheManager.java

示例10: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
    final Bitmap bitmap = response.getBitmap();
    if (null != bitmap) {
        mImageView.setImageBitmap(bitmap);

        new Thread() {
            @Override
            public void run() {
                blur(bitmap);
            }
        }.start();
    }
}
 
开发者ID:chenjishi,项目名称:wiping,代码行数:15,代码来源:GlassWipeActivity.java

示例11: display

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
/**
 * 发起图片网络请求
 *
 * @param requestUrl The url of the remote image
 * @param maxWidth   The maximum width of the returned image.
 * @param maxHeight  The maximum height of the returned image.
 * @param scaleType  The ImageViews ScaleType used to calculate the needed image size.
 * @return A container object that contains all of the properties of the request, as well as
 * the currently available image (default if remote is not loaded).
 */
public void display(final ImageView view, String requestUrl, final int defaultImageResId, final int errorImageResId, int maxWidth, int maxHeight, ImageView.ScaleType scaleType) {
    if (mImageContainers.containsKey(view)) {//如果已经在给该View请求一张网络图片
        mImageContainers.get(view).cancelRequest();//那么就把之前的取消掉,保证一个ImageView身上只有一个任务。
    }
    ImageLoader.ImageContainer imageContainer = mImageLoader.get(requestUrl, new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageResId != 0) {
                view.setImageResource(errorImageResId);
                ObjectAnimator.ofFloat(view, "alpha", 0f, 1f).setDuration(800).start();//渐变动画
            }
            mImageContainers.remove(view);//请求失败,移除
        }

        @Override
        public void onResponse(final ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                view.setImageBitmap(response.getBitmap());
                ObjectAnimator.ofFloat(view, "alpha", 0f, 1f).setDuration(800).start();//渐变动画
                mImageContainers.remove(view);//请求成功,移除
            } else if (defaultImageResId != 0) {
                view.setImageResource(defaultImageResId);
            }
        }
    }, maxWidth, maxHeight, scaleType);
    mImageContainers.put(view, imageContainer);//将View身上的请求任务进行保存
}
 
开发者ID:aoenang,项目名称:seny-devpkg,代码行数:38,代码来源:HttpLoader.java

示例12: onResponse

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void onResponse(ImageLoader.ImageContainer imageContainer, boolean b) {
    if (imageContainer == null || imageContainer.getBitmap() == null) {
        return;
    }
    if (("" + imageView.getTag()).equals(imageContainer.getRequestUrl())) {
        imageView.setImageBitmap(imageContainer.getBitmap());
    }
}
 
开发者ID:likebamboo,项目名称:AndroidBlog,代码行数:10,代码来源:ImageLoaderListener.java

示例13: getImageListener

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public static ImageLoader.ImageListener getImageListener(final ImageView view, final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageDrawable != null) {
                view.setImageDrawable(errorImageDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defaultImageDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defaultImageDrawable,
                                    new BitmapDrawable(App.getContext().getResources(),
                                            response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    view.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    view.setImageBitmap(response.getBitmap());
                }
            } else if (defaultImageDrawable != null) {
                view.setImageDrawable(defaultImageDrawable);
            }
        }
    };
}
 
开发者ID:iQuick,项目名称:VolleyManager,代码行数:33,代码来源:ImageCacheManager.java

示例14: bind

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
@Override
public void bind(Checkin checkin, ImageLoader imageLoader) {
    mName.setText(checkin.getAttendeeName());
    Context context = mDescription.getContext();
    long timestamp = checkin.getTimestamp();
    if (System.currentTimeMillis() - timestamp * 1000 < 60 * 1000) {
        mDescription.setText(R.string.just_now);
    } else {
        mDescription.setText(
                DateUtils.getRelativeDateTimeString(context, timestamp * 1000,
                        DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0));
    }
    // Load the icon
    ImageLoader.ImageContainer container = (ImageLoader.ImageContainer) mIcon.getTag();
    if (container != null) {
        container.cancelRequest();
    }
    String imageUrl = checkin.getAttendeeImageUrl();
    if (!TextUtils.isEmpty(imageUrl) && Patterns.WEB_URL.matcher(imageUrl).matches()) {
        mIcon.setTag(imageLoader.get(imageUrl,
                new RoundedImageListener(mIcon, R.drawable.ic_person,
                        R.drawable.ic_person)));
    } else {
        mIcon.setImageResource(R.drawable.ic_person);
    }
    if (mWillAnimate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mCheckin.setImageResource(R.drawable.checkin_anim);
    } else {
        mCheckin.setImageResource(R.drawable.checkin);
    }
}
 
开发者ID:googlesamples,项目名称:attendee-checkin,代码行数:32,代码来源:CheckinHolder.java

示例15: bind

import com.android.volley.toolbox.ImageLoader; //导入方法依赖的package包/类
public void bind(Cursor cursor, ImageLoader imageLoader) {
    itemView.setBackgroundDrawable(null);
    ViewCompat.setTranslationZ(itemView, 0.f);
    mName.setText(cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.NAME)));
    mEmail.setText(cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.EMAIL)));
    String note = cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.NOTE));
    mNote.setVisibility(TextUtils.isEmpty(note) ? View.GONE : View.VISIBLE);
    mNote.setText(note);
    mEventId = cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.EVENT_ID));
    mAttendeeId = cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.ID));
    mAttendeeCheckedIn = !cursor.isNull(cursor.getColumnIndexOrThrow(Table.Attendee.CHECKIN));
    mCheckin.setVisibility(mAttendeeCheckedIn ? View.VISIBLE : View.INVISIBLE);
    mActionCheck.setImageResource(mAttendeeCheckedIn ?
            R.drawable.ic_check_green : R.drawable.ic_check_gray);
    boolean modified = 0 != cursor.getInt(cursor.getColumnIndexOrThrow(Table.Attendee.CHECKIN_MODIFIED));
    mSyncInProcess.setVisibility(modified && BuildConfig.DEBUG ?
            View.VISIBLE : View.INVISIBLE);
    mActions.setVisibility(View.GONE);
    itemView.setOnClickListener(this);
    mActionCheck.setOnClickListener(this);
    mActionEdit.setOnClickListener(this);
    // Icon
    ImageLoader.ImageContainer container = (ImageLoader.ImageContainer)
            mIcon.getTag();
    if (container != null) {
        container.cancelRequest();
    }
    int columnIndexImageUrl = cursor.getColumnIndexOrThrow(Table.Attendee.IMAGE_URL);
    if (!cursor.isNull(columnIndexImageUrl)) {
        mIcon.setTag(imageLoader.get(cursor.getString(columnIndexImageUrl),
                new RoundedImageListener(mIcon,
                        R.drawable.ic_person, R.drawable.ic_person)));
    } else {
        mIcon.setImageResource(R.drawable.ic_person);
    }
}
 
开发者ID:googlesamples,项目名称:attendee-checkin,代码行数:37,代码来源:AttendeeListFragment.java


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