本文整理汇总了Java中com.bumptech.glide.load.model.LazyHeaders类的典型用法代码示例。如果您正苦于以下问题:Java LazyHeaders类的具体用法?Java LazyHeaders怎么用?Java LazyHeaders使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LazyHeaders类属于com.bumptech.glide.load.model包,在下文中一共展示了LazyHeaders类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUrl
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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);
}
示例2: showThumbnail
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
@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;
}
示例3: cacheImage
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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);
}
示例4: displayImageReferer
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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);
}
示例5: getGlideUrlByUser
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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);
}
}
示例6: getUrl
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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());
}
示例7: displayImageReferer
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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){
}
}
示例8: loadImage
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
@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();
}
});
}
示例9: prefetch
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
@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
}
});
}
示例10: loadImage
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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);
}
}
示例11: makeGlideUrl
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
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());
}
示例12: newGlideUrlInstance
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
public static GlideUrl newGlideUrlInstance(String url) {
// @formatter:off
return new GlideUrl(url, new LazyHeaders.Builder().addHeader("Referer", GComicApi.REFERER).build());
}
示例13: onBindViewHolder
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
@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);
}
示例14: header
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
private static LazyHeaders.Builder header() {
return new LazyHeaders.Builder().addHeader("User-Agent", OkHttp.USER_AGENT);
}
示例15: getHeaders
import com.bumptech.glide.load.model.LazyHeaders; //导入依赖的package包/类
@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();
}