本文整理匯總了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());
}
}
示例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();
}
}
示例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());
}
}
}
示例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());
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
}
};
}
示例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();
}
示例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);
}
}
};
}
示例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();
}
}
示例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身上的請求任務進行保存
}
示例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());
}
}
示例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);
}
}
};
}
示例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);
}
}
示例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);
}
}