Search in sources :

Example 16 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project Habba18 by chiragsastry1996.

the class HomeFragment method setUpViews.

private void setUpViews() {
    MainActivity parentActivity = (MainActivity) getActivity();
    try {
        FirebaseMessaging.getInstance().subscribeToTopic("news");
        String token = FirebaseInstanceId.getInstance().getToken();
        Log.d("token", token);
        registerToken(token);
    } catch (Exception e) {
        System.out.println("Token Error");
    }
    left = (Button) parentView.findViewById(R.id.left);
    right = (Button) parentView.findViewById(R.id.right);
    left.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            resideMenu.openMenu(ResideMenu.DIRECTION_LEFT);
        }
    });
    right.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            resideMenu.openMenu(ResideMenu.DIRECTION_RIGHT);
        }
    });
    carouselView = (CarouselView) parentView.findViewById(R.id.carouselView);
    carouselView.setPageCount(sampleImages.length);
    carouselView.setImageListener(new ImageListener() {

        @Override
        public void setImageForPosition(int position, ImageView imageView) {
            Glide.with(getContext()).load(sampleImages[position]).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.drawable.slider1)).into(imageView);
        }
    });
    imageView1 = (ImageView) parentView.findViewById(R.id.imageView11);
    try {
        final pl.droidsonroids.gif.GifDrawable gifFromResource = new pl.droidsonroids.gif.GifDrawable(getResources(), R.drawable.landing);
        imageView1.setImageDrawable(gifFromResource);
    } catch (IOException e) {
        e.printStackTrace();
    }
    imageView1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
        // do nothing
        }
    });
}
Also used : ImageListener(com.synnapps.carouselview.ImageListener) RequestOptions(com.bumptech.glide.request.RequestOptions) IOException(java.io.IOException) ImageView(android.widget.ImageView) View(android.view.View) TapTargetView(com.getkeepsafe.taptargetview.TapTargetView) CarouselView(com.synnapps.carouselview.CarouselView) IOException(java.io.IOException) ImageView(android.widget.ImageView)

Example 17 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project ring-client-android by savoirfairelinux.

the class CallFragment method updateContactBubble.

@Override
public void updateContactBubble(@NonNull final CallContact contact) {
    String username = contact.getRingUsername();
    String displayName = contact.getDisplayName();
    String ringId = contact.getIds().get(0);
    Drawable contactPicture = AvatarFactory.getAvatar(getActivity(), contact.getPhoto(), username, ringId);
    Log.d(TAG, "updateContactBubble: username=" + username + ", ringId=" + ringId);
    RequestOptions glideOptions = AvatarFactory.getGlideOptions(true, false);
    getActivity().runOnUiThread(() -> {
        boolean hasProfileName = displayName != null && !displayName.contentEquals(username);
        if (hasProfileName) {
            contactBubbleNumTxt.setVisibility(View.VISIBLE);
            contactBubbleTxt.setText(displayName);
            contactBubbleNumTxt.setText(username);
        } else {
            contactBubbleNumTxt.setVisibility(View.GONE);
            contactBubbleTxt.setText(username);
        }
        if (firstUpdate) {
            firstUpdate = false;
            Glide.with(getActivity()).load(contactPicture).apply(glideOptions).into(contactBubbleView);
        }
    });
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable)

Example 18 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project Zom-Android by zom.

the class GalleryMediaViewHolder method setThumbnail.

/**
 * @param contentResolver
 * @param mediaUri
 */
private void setThumbnail(ContentResolver contentResolver, Uri mediaUri) {
    RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).placeholder(R.drawable.ic_photo_library_white_36dp);
    if (SecureMediaStore.isVfsUri(mediaUri)) {
        try {
            info.guardianproject.iocipher.File fileMedia = new info.guardianproject.iocipher.File(mediaUri.getPath());
            if (fileMedia.exists()) {
                Log.d("Gallery", "VFS loading: " + mediaUri.toString());
                Glide.with(context).asBitmap().load(new info.guardianproject.iocipher.FileInputStream(fileMedia)).apply(options).into(mMediaThumbnail);
            } else {
                Log.d("Gallery", "VFS file not found: " + mediaUri.toString());
                Glide.with(context).asBitmap().load(R.drawable.broken_image_large).apply(options).into(mMediaThumbnail);
            }
        } catch (Exception e) {
            Log.e(ImApp.LOG_TAG, "unable to load thumbnail: " + e.getMessage());
        }
    } else if (mediaUri.getScheme() != null && mediaUri.getScheme().equals("asset")) {
        String assetPath = "file:///android_asset/" + mediaUri.getPath().substring(1);
        Glide.with(context).asBitmap().load(assetPath).apply(options).into(mMediaThumbnail);
    } else {
        Glide.with(context).asBitmap().load(mediaUri).apply(options).into(mMediaThumbnail);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) File(java.io.File)

Example 19 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project TicktockMusic by Lauzy.

the class GlideImageLoaderStrategy method display.

@Override
public void display(Context context, ImageConfig imageConfig) {
    RequestOptions options = getOptions(context, imageConfig);
    Object url = getPath(imageConfig);
    if (!imageConfig.isAsBitmap()) {
        RequestBuilder<Drawable> requestBuilder = Glide.with(context).load(url).apply(options);
        if (!imageConfig.isRound() && imageConfig.getDuration() != 0) {
            requestBuilder = requestBuilder.transition(new DrawableTransitionOptions().crossFade(imageConfig.getDuration()));
        }
        requestBuilder.into(imageConfig.getImageView());
    } else {
        RequestBuilder<Bitmap> requestBuilder = Glide.with(context).asBitmap().load(url).apply(options);
        if (!imageConfig.isRound() && imageConfig.getDuration() != 0) {
            requestBuilder = requestBuilder.transition(new BitmapTransitionOptions().crossFade(imageConfig.getDuration()));
        }
        requestBuilder.into(imageConfig.getTarget());
    }
}
Also used : DrawableTransitionOptions(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions) Bitmap(android.graphics.Bitmap) RequestOptions(com.bumptech.glide.request.RequestOptions) Drawable(android.graphics.drawable.Drawable) BitmapTransitionOptions(com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions)

Example 20 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project TicktockMusic by Lauzy.

the class GlideImageLoaderStrategy method getOptions.

/**
 * Glide 配置
 *
 * @param context     context
 * @param imageConfig 配置
 * @return Glide配置
 */
private RequestOptions getOptions(Context context, ImageConfig imageConfig) {
    RequestOptions options = new RequestOptions().placeholder(imageConfig.getDefaultRes()).error(imageConfig.getErrorRes());
    if (imageConfig.isRound()) {
        if (imageConfig.getCornerSize() == 0) {
            options.transform(new GlideCornerTransformation(context));
        } else {
            options.transform(new GlideCornerTransformation(context, imageConfig.getCornerSize()));
        }
    }
    // 默认无缓存
    DiskCacheStrategy strategy = DiskCacheStrategy.RESOURCE;
    switch(imageConfig.getCacheStrategy()) {
        case ImageConfig.CACHE_NONE:
            strategy = DiskCacheStrategy.NONE;
            break;
        case ImageConfig.CACHE_ALL:
            strategy = DiskCacheStrategy.ALL;
            break;
        case // 加载后缓存
        ImageConfig.CACHE_RESULT:
            strategy = DiskCacheStrategy.RESOURCE;
            break;
        case // 源数据缓存
        ImageConfig.CACHE_SOURCE:
            strategy = DiskCacheStrategy.DATA;
            break;
        case ImageConfig.CACHE_AUTO:
            strategy = DiskCacheStrategy.AUTOMATIC;
            break;
    }
    options.diskCacheStrategy(strategy);
    options.skipMemoryCache(imageConfig.isSkipMemoryCache());
    return options;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy)

Aggregations

RequestOptions (com.bumptech.glide.request.RequestOptions)104 ImageView (android.widget.ImageView)23 Drawable (android.graphics.drawable.Drawable)18 View (android.view.View)18 TextView (android.widget.TextView)13 Bitmap (android.graphics.Bitmap)11 File (java.io.File)10 BitmapDrawable (android.graphics.drawable.BitmapDrawable)9 ColorDrawable (android.graphics.drawable.ColorDrawable)7 Uri (android.net.Uri)7 DataSource (com.bumptech.glide.load.DataSource)6 GlideException (com.bumptech.glide.load.engine.GlideException)6 Context (android.content.Context)5 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)5 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)5 Test (org.junit.Test)5 Activity (android.app.Activity)3 LayoutInflater (android.view.LayoutInflater)3