當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。