本文整理汇总了Java中com.bumptech.glide.Priority类的典型用法代码示例。如果您正苦于以下问题:Java Priority类的具体用法?Java Priority怎么用?Java Priority使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Priority类属于com.bumptech.glide包,在下文中一共展示了Priority类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadData
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public InputStream loadData(Priority priority) throws Exception {
Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());
for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
String key = headerEntry.getKey();
requestBuilder.addHeader(key, headerEntry.getValue());
}
Request request = requestBuilder.build();
Response response;
call = client.newCall(request);
response = call.execute();
responseBody = response.body();
if (!response.isSuccessful()) {
throw new IOException("Request failed with code: " + response.code());
}
long contentLength = responseBody.contentLength();
stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
return stream;
}
示例2: getResourceFetcher
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public DataFetcher<InputStream> getResourceFetcher(final String model, int width, int height) {
return new DataFetcher<InputStream>() {
@Override
public InputStream loadData(Priority priority) throws Exception {
throw new IOException("Forced Glide network failure");
}
@Override
public void cleanup() {
}
@Override
public String getId() {
return model;
}
@Override
public void cancel() {
}
};
}
示例3: loadData
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public void loadData(Priority priority,
final DataCallback<? super InputStream> callback) {
mStreamTask = mRef.getStream();
mStreamTask
.addOnSuccessListener(new OnSuccessListener<StreamDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(StreamDownloadTask.TaskSnapshot snapshot) {
mInputStream = snapshot.getStream();
callback.onDataReady(mInputStream);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
callback.onLoadFailed(e);
}
});
}
示例4: instantiateItem
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public View instantiateItem(ViewGroup container, int position) {
View view=inflater.inflate(R.layout.adapter_album,container,false);
ImageView image= ButterKnife.findById(view,R.id.image);
Glide.with(container.getContext())
.load(albums.get(position).getArtworkUrl())
.asBitmap()
.priority(Priority.IMMEDIATE)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.into(new ImageViewTarget<Bitmap>(image) {
@Override
protected void setResource(Bitmap resource) {
image.setImageBitmap(resource);
if (position == current && !isLoaded) {
isLoaded = true;
if (callback != null) {
callback.onTransitionImageLoaded(image,resource);
}
}
}
});
container.addView(view);
return view;
}
示例5: loadData
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public InputStream loadData(Priority priority) throws Exception {
Request.Builder requestBuilder = new Request.Builder()
.url(url.toStringUrl());
for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
String key = headerEntry.getKey();
requestBuilder.addHeader(key, headerEntry.getValue());
}
Request request = requestBuilder.build();
Response response = client.newCall(request).execute();
responseBody = response.body();
if (!response.isSuccessful()) {
throw new IOException("Request failed with code: " + response.code());
}
long contentLength = responseBody.contentLength();
stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
return stream;
}
示例6: loadData
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public void loadData(Priority priority, DataCallback<? super File> callback) {
Cursor cursor = context.getContentResolver().query(uri, PROJECTION, null /*selection*/,
null /*selectionArgs*/, null /*sortOrder*/);
String filePath = null;
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA));
}
} finally {
cursor.close();
}
}
if (TextUtils.isEmpty(filePath)) {
callback.onLoadFailed(new FileNotFoundException("Failed to find file path for: " + uri));
} else {
callback.onDataReady(new File(filePath));
}
}
示例7: loadData
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public void loadData(Priority priority, DataCallback<? super InputStream> callback) {
long startTime = LogTime.getLogTime();
final InputStream result;
try {
result = loadDataWithRedirects(glideUrl.toURL(), 0 /*redirects*/, null /*lastUrl*/,
glideUrl.getHeaders());
} catch (IOException e) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Failed to load data for url", e);
}
callback.onLoadFailed(e);
return;
}
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Finished http url fetcher fetch in " + LogTime.getElapsedMillis(startTime)
+ " ms and loaded " + result);
}
callback.onDataReady(result);
}
示例8: testCanReRunCancelledRequests
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Test
public void testCanReRunCancelledRequests() {
doAnswer(new CallSizeReady(100, 100)).when(harness.target)
.getSize(any(SizeReadyCallback.class));
when(harness.engine
.load(eq(harness.glideContext), eq(harness.model), eq(harness.signature), eq(100), eq(100),
eq(Object.class), eq(List.class), any(Priority.class), any(DiskCacheStrategy.class),
eq(harness.transformations), anyBoolean(), any(Options.class),
anyBoolean(), anyBoolean(), anyBoolean(), any(ResourceCallback.class)))
.thenAnswer(new CallResourceCallback(harness.resource));
SingleRequest<List> request = harness.getRequest();
request.begin();
request.cancel();
request.begin();
verify(harness.target, times(2)).onResourceReady(eq(harness.result), anyTransition());
}
示例9: testHandlesUpToFiveRedirects
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Test
public void testHandlesUpToFiveRedirects() throws Exception {
int numRedirects = 4;
String expected = "redirectedData";
String redirectBase = "/redirect";
for (int i = 0; i < numRedirects; i++) {
mockWebServer.enqueue(new MockResponse().setResponseCode(301)
.setHeader("Location", mockWebServer.url(redirectBase + i).toString()));
}
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(expected));
getFetcher().loadData(Priority.NORMAL, callback);
verify(callback).onDataReady(streamCaptor.capture());
TestUtil.assertStreamOf(expected, streamCaptor.getValue());
assertThat(mockWebServer.takeRequest().getPath()).contains(DEFAULT_PATH);
for (int i = 0; i < numRedirects; i++) {
assertThat(mockWebServer.takeRequest().getPath()).contains(redirectBase + i);
}
}
示例10: convert
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
protected void convert(BaseViewHolder helper, LikeBean item) {
helper.setText(R.id.txt_like_title, item.getTitle());
if (item.getType() == Constants.TYPE_WEIXIN) {
helper.setText(R.id.txt_like_type, R.string.weixin);
}
else if(item.getType() == Constants.TYPE_GANK){
helper.setText(R.id.txt_like_type, R.string.gank);
}
helper.setText(R.id.txt_like_date, DateUtil.LongToString(item.getTime()));
GlideApp.with(mContext)
.load(item.getImageUrl())
.centerCrop()
.placeholder(R.drawable.ic_ali)
.priority(Priority.LOW)
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.into((ImageView) helper.getView(R.id.img_like));
}
示例11: replaceImage
import com.bumptech.glide.Priority; //导入依赖的package包/类
private void replaceImage(final String imageName) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
File imageFile = new File(mView.getActivity().getExternalFilesDir(mNoteId).getPath() + "/" + imageName);
BitmapFactory.decodeFile(imageFile.getPath(), options);
int imageRequestWidth = getRequestImeWidth();
int imageRequestHeight = setNeedHeight(options);
Glide.with(mView.getActivity())
.load(imageFile)
.asBitmap()
.override(imageRequestWidth, imageRequestHeight)
.fitCenter()
.priority(Priority.HIGH)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
mView.replaceImage(imageName, resource);
}
});
}
示例12: loadImage
import com.bumptech.glide.Priority; //导入依赖的package包/类
@BindingAdapter({"imageAddress"})
public static void loadImage(final ImageView imageView, final String imageAddress) {
if (imageAddress != null && imageAddress.startsWith("https://s3.amazonaws.com/bikedeboa/")) {
Context context = imageView.getContext();
// Hopefully the thumbnail is already disk cached and no requests are made
DrawableRequestBuilder<String> thumbnailRequest = Glide
.with(context)
.load(imageAddress.replace("images/", "images/thumbs/"))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.transform(new BlurTransformation(context));
Glide.with(context)
.load(imageAddress)
.thumbnail(thumbnailRequest)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.priority(Priority.HIGH)
.into(imageView);
}
}
示例13: loadData
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public void loadData(Priority priority, DataCallback<? super InputStream> callback) {
try {
mInputStream = openThumbInputStream();
} catch (FileNotFoundException e) {
LogUtils.d(TAG, "Failed to find thumbnail file," + e.toString());
callback.onLoadFailed(e);
return;
}
callback.onDataReady(mInputStream);
}
示例14: loadData
import com.bumptech.glide.Priority; //导入依赖的package包/类
@Override
public void loadData(Priority priority, DataCallback<? super Data> callback) {
try {
data = reader.decode(dataUri);
callback.onDataReady(data);
} catch (IllegalArgumentException e) {
callback.onLoadFailed(e);
}
}
示例15: glideToVolleyPriority
import com.bumptech.glide.Priority; //导入依赖的package包/类
private static Request.Priority glideToVolleyPriority(Priority priority) {
switch (priority) {
case LOW:
return Request.Priority.LOW;
case HIGH:
return Request.Priority.HIGH;
case IMMEDIATE:
return Request.Priority.IMMEDIATE;
default:
return Request.Priority.NORMAL;
}
}