Java 类com.bumptech.glide.load.model.LazyHeaders 实例源码

项目:letscorp    文件:PhotoView.java   
public void setUrl(String url, boolean loading) {
    mUrl = url;
    if (mUrl.isEmpty()) {
        return;
    }

    Log.d("url", mUrl);
    GlideUrl glideUrl = new GlideUrl(mUrl, new LazyHeaders.Builder()
            .addHeader("User-Agent", Const.HTTP_USER_AGENT)
            .build());
    BitmapTypeRequest req = Glide.with(Application.getApplication()).load(glideUrl).asBitmap();
    if (loading) {
        req.placeholder(R.mipmap.ic_photo_black);
    }
    req.error(R.mipmap.ic_broken_image_black)
            .fitCenter()
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .into(this);
}
项目:letscorp    文件:ImageViewer.java   
public void setUrl(String url, boolean loading) {
    mUrl = url;
    if (mUrl.isEmpty()) {
        return;
    }

    Log.d("url", mUrl);
    GlideUrl glideUrl = new GlideUrl(mUrl, new LazyHeaders.Builder()
            .addHeader("User-Agent", Const.HTTP_USER_AGENT)
            .build());
    BitmapTypeRequest req = Glide.with(Application.getApplication()).load(glideUrl).asBitmap();
    if (loading) {
        req.placeholder(R.mipmap.ic_photo_black);
    }
    req.error(R.mipmap.ic_broken_image_black)
            .fitCenter()
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .into(this);
}
项目:noefinderlein    文件:GlideImageLoader.java   
@Override
public View showThumbnail(BigImageView parent, Uri thumbnail, int scaleType) {
    ImageView thumbnailView = (ImageView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.ui_glide_thumbnail, parent, false);
    switch (scaleType) {
        case BigImageView.INIT_SCALE_TYPE_CENTER_CROP:
            thumbnailView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            break;
        case BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE:
            thumbnailView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        default:
            break;
    }
    GlideUrl glideUrl = new GlideUrl(thumbnail.toString(), new LazyHeaders.Builder()
            .addHeader("Referer", "https://noecard.reitschmied.at")
            .build());
    mRequestManager
            .load(glideUrl)
            .into(thumbnailView);
    return thumbnailView;
}
项目:MoeGallery    文件:ImageFragment.java   
private void cacheImage(final Image image, final LazyHeaders.Builder header) {
    mName = image.getName();
    mUri = image.getFileUrl();

    saveImage(image);

    mRequestManager.load(new GlideUrl(image.getFileUrl(), header.build()))
            .downloadOnly(new SimpleTarget<File>() {
                @Override
                public void onResourceReady(File resource,
                        GlideAnimation<? super File> glideAnimation) {
                    if (mSetting.autoDownload()) {
                        File dir = new File(
                                Environment.getExternalStorageDirectory().getPath(),
                                "MoeGallery");
                        String fileName = image.getName().replace('/', '-');
                        Utils.copy(resource, dir, fileName);
                        mImageDataSource.cacheImageUri(mImage.getFileUrl(),
                                Uri.fromFile(new File(dir, fileName)));
                    }
                    loadImage(image, header);
                }
            });
    mImageDataSource.cacheDetail(mImage.getFileUrl(), image);
}
项目:browser    文件:GlideUtil.java   
public static void displayImageReferer(String url,ImageView imageView,String referer) {
    if(url==null){
        return;
    }
    LazyHeaders.Builder builder=new LazyHeaders.Builder().addHeader("User-Agent", UserAgent);
    if(referer!=null){
        builder.addHeader("Referer", referer);
    }

    /*
            .addHeader("key2", new LazyHeaderFactory() {
                @Override
                public String buildHeader() {
                    String expensiveAuthHeader = computeExpensiveAuthHeader();
                    return expensiveAuthHeader;
                }
            })
            */

    GlideUrl glideUrl = new GlideUrl(url,builder.build());

    Glide.with(MainApp.getContext())
            .load(glideUrl)
            .placeholder(R.drawable.pictures_no)
            .thumbnail(0.2f)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(imageView);

}
项目:OSchina_resources_android    文件:AppOperator.java   
public static GlideUrl getGlideUrlByUser(String url) {
    if (AccountHelper.isLogin()) {
        return new GlideUrl(url,
                new LazyHeaders
                        .Builder()
                        .addHeader("Cookie", AccountHelper.getCookie())
                        .build());
    } else {
        return new GlideUrl(url);
    }
}
项目:youkes_browser    文件:GlideUtil.java   
public static void displayImageReferer(String url,ImageView imageView,String referer) {
    if(url==null){
        return;
    }
    LazyHeaders.Builder builder=new LazyHeaders.Builder().addHeader("User-Agent", UserAgent);
    if(referer!=null){
        builder.addHeader("Referer", referer);
    }

    /*
            .addHeader("key2", new LazyHeaderFactory() {
                @Override
                public String buildHeader() {
                    String expensiveAuthHeader = computeExpensiveAuthHeader();
                    return expensiveAuthHeader;
                }
            })
            */

    GlideUrl glideUrl = new GlideUrl(url,builder.build());

    Glide.with(MainApp.getContext())
            .load(glideUrl)
            .placeholder(R.drawable.pictures_no)
            .thumbnail(0.2f)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(imageView);

}
项目:youkes_vr    文件:GlideUtil.java   
public static void displayImageReferer(String url,ImageView imageView,String referer) {
    if(url==null){
        return;
    }
    LazyHeaders.Builder builder=new LazyHeaders.Builder().addHeader("User-Agent", UserAgent);
    if(referer!=null){
        builder.addHeader("Referer", referer);
    }

    /*
            .addHeader("key2", new LazyHeaderFactory() {
                @Override
                public String buildHeader() {
                    String expensiveAuthHeader = computeExpensiveAuthHeader();
                    return expensiveAuthHeader;
                }
            })
            */

   try{
       GlideUrl glideUrl = new GlideUrl(url, builder.build());

       Glide.with(MainApp.getContext())
               .load(glideUrl)
               .placeholder(R.drawable.pictures_no)
               //.thumbnail(0.2f)
               .diskCacheStrategy(DiskCacheStrategy.ALL)
               .dontTransform()
               .into(imageView);
   }catch (Exception e){

   }

}
项目:noefinderlein    文件:GlideImageLoader.java   
@Override
public void loadImage(final Uri uri, final Callback callback) {
    GlideUrl glideUrl = new GlideUrl(uri.toString(), new LazyHeaders.Builder()
            .addHeader("Referer", "https://noecard.reitschmied.at")
            .build());
    mRequestManager
            .load(glideUrl)
            .downloadOnly(new ImageDownloadTarget(uri.toString()) {
                @Override
                public void onResourceReady(File image,
                        GlideAnimation<? super File> glideAnimation) {
                    // we don't need delete this image file, so it behaves live cache hit
                    callback.onCacheHit(image);
                }

                @Override
                public void onDownloadStart() {
                    callback.onStart();
                }

                @Override
                public void onProgress(int progress) {
                    callback.onProgress(progress);
                }

                @Override
                public void onDownloadFinish() {
                    callback.onFinish();
                }
            });
}
项目:noefinderlein    文件:GlideImageLoader.java   
@Override
public void prefetch(Uri uri) {
    GlideUrl glideUrl = new GlideUrl(uri.toString(), new LazyHeaders.Builder()
            .addHeader("Referer", "https://noecard.reitschmied.at")
            .build());
    mRequestManager
            .load(glideUrl)
            .downloadOnly(new SimpleTarget<File>() {
                @Override
                public void onResourceReady(File resource,
                        GlideAnimation<? super File> glideAnimation) {
                    // not interested in result
                }
            });
}
项目:MoeGallery    文件:ImageFragment.java   
private void loadImage(Image image, LazyHeaders.Builder header) {

        if (mUri != null && mUri.toLowerCase().endsWith("gif")) {
            mGifRequestBuilder.load(new GlideUrl(image.getFileUrl(), header.build()))
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .listener(new MediaRequestListener<GlideUrl, GifDrawable>())
                    .into(mPhotoView);
        } else {
            mRequestManager.load(new GlideUrl(image.getFileUrl(), header.build()))
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .listener(new MediaRequestListener<GlideUrl, GlideDrawable>())
                    .into(mPhotoView);
        }
    }
项目:moebooru-android    文件:GetGlideUrl.java   
public GlideUrl makeGlideUrl(String url){
    LazyHeaders.Builder builder = new LazyHeaders.Builder()
            .addHeader(AppConfig.HEADER_USER_AGENT, AppConfig.HEADER_USER_AGENT_INFO);
    return new GlideUrl(url, builder.build());
}
项目:ButterySlack    文件:SlackUtils.java   
public static GlideUrl getUrl(Context context, String url) {
    ButterySlack butterySlack = (ButterySlack) context.getApplicationContext();
    return new GlideUrl(url, new LazyHeaders.Builder().addHeader("Authorization", "Bearer " + butterySlack.getToken()).build());
}
项目:GComic    文件:GlideUrlFactory.java   
public static GlideUrl newGlideUrlInstance(String url) {
    // @formatter:off
    return new GlideUrl(url, new LazyHeaders.Builder().addHeader("Referer", GComicApi.REFERER).build());
}
项目:noefinderlein    文件:ArrayAdapter_Pictures.java   
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final ViewHolder innerVH = holder;

    holder.imageView.setParallaxStyles(parallaxStyle);
    CloudPicture upload = uploads.get(position);
    final String photoreference = upload.getPhotoreference();
    final String locationName = upload.getLocationname();
    final String locationUrl = upload.getPictureurl();
    String url;
    if(locationUrl == null) {
        url = "https://maps.googleapis.com/maps/api/place/photo?maxheight=" + this.height + "&photoreference=" + photoreference + "&key=" + context.getString(R.string.google_photo_key);
    } else {
        url = locationUrl;
    }

    GlideUrl glideUrl = new GlideUrl(url, new LazyHeaders.Builder()
            .addHeader("Referer", "https://noecard.reitschmied.at")
            .build());
    Glide.with(context)
        .load(glideUrl)
        .asBitmap()
        .into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {

                //Bitmap googleBM = BitmapFactory.decodeResource(context.getResources(), R.mipmap.powered_by_google_on_non_white);
                int width = (height* resource.getWidth())/resource.getHeight();
                Bitmap newBit = Bitmap.createScaledBitmap(resource, width, height, false);
                Drawable shape =  context.getResources().getDrawable(R.drawable.detailmenubackground);
                Canvas c = new Canvas(newBit);
                //c.drawBitmap(googleBM, ((newBit.getWidth()/2)-(googleBM.getWidth()/2)), (newBit.getHeight()-googleBM.getHeight()-50), null);
                shape.setBounds( 0, 0, newBit.getWidth(), getActionBarHeight()*3 );
                shape.draw(c);
                innerVH.imageView.setImageBitmap(newBit);
                innerVH.imageView.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {

                        Intent myIntent = new Intent(context, Activity_Picture.class);
                        myIntent.putExtra(Activity_Picture.ARG_LOCATION_NAME, locationName);
                        myIntent.putExtra(Activity_Picture.ARG_PICTURE_REFERENCE, photoreference);
                        if(locationUrl != null) {
                            myIntent.putExtra(Activity_Picture.ARG_LOCATIONURL, locationUrl);
                        }
                        context.startActivity(myIntent);
                    }
                });

            }
        });//.into(holder.imageView);
}
项目:MoeGallery    文件:ImageFragment.java   
private static LazyHeaders.Builder header() {
    return new LazyHeaders.Builder().addHeader("User-Agent", OkHttp.USER_AGENT);
}
项目:mage-android    文件:AttachmentLoader.java   
@Override
protected Headers getHeaders(Attachment model, int width, int height) {
    String token = PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(mil.nga.giat.mage.sdk.R.string.tokenKey), null);
    return new LazyHeaders.Builder().addHeader("Authorization", "Bearer " + token).build();
}