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); }
@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; }
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); }
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); }
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); } }
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){ } }
@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(); } }); }
@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 } }); }
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); } }
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()); }
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()); }
public static GlideUrl newGlideUrlInstance(String url) { // @formatter:off return new GlideUrl(url, new LazyHeaders.Builder().addHeader("Referer", GComicApi.REFERER).build()); }
@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); }
private static LazyHeaders.Builder header() { return new LazyHeaders.Builder().addHeader("User-Agent", OkHttp.USER_AGENT); }
@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(); }