Search in sources :

Example 1 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project Robot-Scouter by SUPERCILEX.

the class TeamDetailsDialog method updateUi.

private void updateUi() {
    if (mMedia != null && mName != null && mNameEditText != null && mMediaCapture != null && mWebsiteEditText != null) {
        Team team = mTeamHelper.getTeam();
        mMediaLoadProgress.setVisibility(View.VISIBLE);
        Glide.with(getContext()).load(team.getMedia()).apply(RequestOptions.circleCropTransform().error(R.drawable.ic_memory_grey_48dp).fallback(R.drawable.ic_memory_grey_48dp)).listener(new RequestListener<Drawable>() {

            @Override
            public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                mMediaLoadProgress.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                mMediaLoadProgress.setVisibility(View.GONE);
                return false;
            }
        }).into(mMedia);
        mName.setText(team.toString());
        mNameEditText.setText(team.getName());
        mMediaEditText.setText(team.getMedia());
        mWebsiteEditText.setText(team.getWebsite());
    }
}
Also used : Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) Team(com.supercilex.robotscouter.data.model.Team) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable) DataSource(com.bumptech.glide.load.DataSource)

Example 2 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project Rocket by mozilla-tw.

the class SingleRequest method begin.

@Override
public void begin() {
    assertNotCallingCallbacks();
    stateVerifier.throwIfRecycled();
    startTime = LogTime.getLogTime();
    if (model == null) {
        if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
            width = overrideWidth;
            height = overrideHeight;
        }
        // Only log at more verbose log levels if the user has set a fallback drawable, because
        // fallback Drawables indicate the user expects null models occasionally.
        int logLevel = getFallbackDrawable() == null ? Log.WARN : Log.DEBUG;
        onLoadFailed(new GlideException("Received null model"), logLevel);
        return;
    }
    if (status == Status.RUNNING) {
        throw new IllegalArgumentException("Cannot restart a running request");
    }
    // the new load.
    if (status == Status.COMPLETE) {
        onResourceReady(resource, DataSource.MEMORY_CACHE);
        return;
    }
    // Restarts for requests that are neither complete nor running can be treated as new requests
    // and can run again from the beginning.
    status = Status.WAITING_FOR_SIZE;
    if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
        onSizeReady(overrideWidth, overrideHeight);
    } else {
        target.getSize(this);
    }
    if ((status == Status.RUNNING || status == Status.WAITING_FOR_SIZE) && canNotifyStatusChanged()) {
        target.onLoadStarted(getPlaceholderDrawable());
    }
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        logV("finished run method in " + LogTime.getElapsedMillis(startTime));
    }
}
Also used : GlideException(com.bumptech.glide.load.engine.GlideException)

Example 3 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project WordPress-Login-Flow-Android by wordpress-mobile.

the class LoginMagicLinkRequestFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.login_magic_link_request_screen, container, false);
    mRequestMagicLinkButton = view.findViewById(R.id.login_request_magic_link);
    mRequestMagicLinkButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mLoginListener != null) {
                if (NetworkUtils.checkConnection(getActivity())) {
                    showMagicLinkRequestProgressDialog();
                    AuthEmailPayload authEmailPayload = new AuthEmailPayload(mEmail, false);
                    mDispatcher.dispatch(AuthenticationActionBuilder.newSendAuthEmailAction(authEmailPayload));
                }
            }
        }
    });
    view.findViewById(R.id.login_enter_password).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mLoginListener != null) {
                mLoginListener.usePasswordInstead(mEmail);
            }
        }
    });
    mAvatarProgressBar = view.findViewById(R.id.avatar_progress);
    ImageView avatarView = view.findViewById(R.id.gravatar);
    Glide.with(this).load(GravatarUtils.gravatarFromEmail(mEmail, getContext().getResources().getDimensionPixelSize(R.dimen.avatar_sz_login))).apply(RequestOptions.circleCropTransform()).apply(RequestOptions.placeholderOf(R.drawable.ic_gridicons_user_circle_100dp)).apply(RequestOptions.errorOf(R.drawable.ic_gridicons_user_circle_100dp)).listener(new RequestListener<Drawable>() {

        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
            mAvatarProgressBar.setVisibility(View.GONE);
            return false;
        }

        @Override
        public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
            mAvatarProgressBar.setVisibility(View.GONE);
            return false;
        }
    }).into(avatarView);
    return view;
}
Also used : Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable) AuthEmailPayload(org.wordpress.android.fluxc.store.AccountStore.AuthEmailPayload) DataSource(com.bumptech.glide.load.DataSource)

Example 4 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project Simple-Dilbert by smarek.

the class WidgetProvider method updateAppWidget.

private static void updateAppWidget(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId) {
    final DilbertPreferences prefs = new DilbertPreferences(context);
    final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
    views.setOnClickPendingIntent(R.id.widget_previous, getPendingIntent(INTENT_PREVIOUS, context, appWidgetId));
    views.setOnClickPendingIntent(R.id.widget_next, getPendingIntent(INTENT_NEXT, context, appWidgetId));
    views.setOnClickPendingIntent(R.id.widget_latest, getPendingIntent(INTENT_LATEST, context, appWidgetId));
    views.setOnClickPendingIntent(R.id.widget_random, getPendingIntent(INTENT_RANDOM, context, appWidgetId));
    views.setOnClickPendingIntent(R.id.widget_image, getPendingIntent(INTENT_DISPLAY, context, appWidgetId));
    views.setOnClickPendingIntent(R.id.widget_refresh, getPendingIntent(INTENT_REFRESH, context, appWidgetId));
    views.setOnClickPendingIntent(R.id.widget_full_layout, getPendingIntent(INTENT_DISPLAY, context, appWidgetId));
    final LocalDate currentDate = prefs.getDateForWidgetId(appWidgetId);
    views.setViewVisibility(R.id.widget_next, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
    views.setViewVisibility(R.id.widget_previous, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
    views.setViewVisibility(R.id.widget_random, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
    views.setViewVisibility(R.id.widget_latest, prefs.isWidgetAlwaysShowLatest() ? View.GONE : View.VISIBLE);
    final String cachedUrl = prefs.getCachedUrl(currentDate);
    final String cachedTitle = prefs.getCachedTitle(currentDate);
    views.setViewVisibility(R.id.widget_progress, View.VISIBLE);
    views.setTextViewText(R.id.widget_title, prefs.getDateForWidgetId(appWidgetId).toString(DilbertPreferences.NICE_DATE_FORMATTER));
    if (prefs.isWidgetShowTitle() && cachedTitle != null && !cachedTitle.isEmpty()) {
        views.setViewVisibility(R.id.widget_strip_title, View.VISIBLE);
        views.setTextViewText(R.id.widget_strip_title, cachedTitle);
    } else {
        views.setViewVisibility(R.id.widget_strip_title, View.GONE);
    }
    appWidgetManager.updateAppWidget(appWidgetId, views);
    if (cachedUrl == null) {
        new GetStripUrl(new GetStripUrlInterface() {

            @Override
            public void imageLoadFailed(String url, Throwable reason) {
                currentToast = Toast.makeText(context, "Image Loading failed", Toast.LENGTH_SHORT);
                currentToast.show();
                views.setImageViewResource(R.id.widget_image, R.drawable.cancel);
                views.setViewVisibility(R.id.widget_progress, View.GONE);
                appWidgetManager.updateAppWidget(appWidgetId, views);
            }

            @Override
            public void displayImage(String url, String title) {
                updateAppWidget(context, appWidgetManager, appWidgetId);
            }
        }, prefs, currentDate).execute();
    } else {
        Glide.with(context).asBitmap().load(cachedUrl).apply(new RequestOptions().dontAnimate()).listener(new RequestListener<Bitmap>() {

            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
                updateAppWidget(context, appWidgetManager, appWidgetId);
                return false;
            }

            @Override
            public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
                views.setViewVisibility(R.id.widget_progress, View.GONE);
                appWidgetManager.updateAppWidget(appWidgetId, views);
                Glide.with(context).asBitmap().load(cachedUrl).apply(new RequestOptions().dontAnimate()).into(new AppWidgetTarget(context, R.id.widget_image, views, appWidgetId));
                return false;
            }
        }).into(new AppWidgetTarget(context, R.id.widget_image, views, appWidgetId));
    }
}
Also used : RequestListener(com.bumptech.glide.request.RequestListener) RequestOptions(com.bumptech.glide.request.RequestOptions) LocalDate(org.joda.time.LocalDate) GetStripUrl(com.mareksebera.simpledilbert.utilities.GetStripUrl) DataSource(com.bumptech.glide.load.DataSource) RemoteViews(android.widget.RemoteViews) Target(com.bumptech.glide.request.target.Target) AppWidgetTarget(com.bumptech.glide.request.target.AppWidgetTarget) Bitmap(android.graphics.Bitmap) AppWidgetTarget(com.bumptech.glide.request.target.AppWidgetTarget) GetStripUrlInterface(com.mareksebera.simpledilbert.utilities.GetStripUrlInterface) DilbertPreferences(com.mareksebera.simpledilbert.preferences.DilbertPreferences) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable)

Example 5 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project Camera-Roll-Android-App by kollerlukas.

the class ItemViewUtil method bindTransitionView.

public static void bindTransitionView(final ImageView imageView, final AlbumItem albumItem) {
    // handle timeOut
    if (albumItem.isSharedElement && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        new Handler().postDelayed(new Runnable() {

            @Override
            @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
            public void run() {
                albumItem.isSharedElement = false;
                ((AppCompatActivity) imageView.getContext()).startPostponedEnterTransition();
            }
        }, 100);
    }
    ViewCompat.setTransitionName(imageView, albumItem.getPath());
    Context context = imageView.getContext();
    Glide.with(context).asBitmap().load(albumItem.getUri(context)).listener(new RequestListener<Bitmap>() {

        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
            albumItem.error = true;
            if (albumItem.isSharedElement && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                albumItem.isSharedElement = false;
                ((AppCompatActivity) imageView.getContext()).startPostponedEnterTransition();
            }
            return false;
        }

        @Override
        public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
            if (albumItem.isSharedElement && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                albumItem.isSharedElement = false;
                ((AppCompatActivity) imageView.getContext()).startPostponedEnterTransition();
            }
            return false;
        }
    }).apply(albumItem.getGlideRequestOptions(imageView.getContext())).into(imageView);
}
Also used : Context(android.content.Context) Bitmap(android.graphics.Bitmap) RequiresApi(android.support.annotation.RequiresApi) Handler(android.os.Handler) GlideException(com.bumptech.glide.load.engine.GlideException) DataSource(com.bumptech.glide.load.DataSource)

Aggregations

GlideException (com.bumptech.glide.load.engine.GlideException)35 DataSource (com.bumptech.glide.load.DataSource)22 Drawable (android.graphics.drawable.Drawable)19 RequestListener (com.bumptech.glide.request.RequestListener)17 Target (com.bumptech.glide.request.target.Target)17 Nullable (android.support.annotation.Nullable)10 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Test (org.junit.Test)8 Bitmap (android.graphics.Bitmap)6 View (android.view.View)6 ImageView (android.widget.ImageView)6 Nullable (androidx.annotation.Nullable)6 RequestOptions (com.bumptech.glide.request.RequestOptions)5 Context (android.content.Context)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 GradientDrawable (android.graphics.drawable.GradientDrawable)2 Handler (android.os.Handler)2 CircleGradientDrawable (com.amaze.filemanager.ui.views.CircleGradientDrawable)2