If you follow Glide sample usage it comes up with that get() method belongs to java.util.concurrent.Future object. And Future class definition is given by the official doc as below.
public interface Future<V>
A Future represents the result of an
asynchronous computation. Methods are provided to check if the
computation is complete, to wait for its completion, and to retrieve
the result of the computation. The result can only be retrieved using
method get when the computation has completed, blocking if necessary
until it is ready. Cancellation is performed by the cancel method.
Additional methods are provided to determine if the task completed
normally or was cancelled. Once a computation has completed, the
computation cannot be cancelled. If you would like to use a Future for
the sake of cancellability but not provide a usable result, you can
declare types of the form Future and return null as a result of the
underlying task.
Sample Usage (Note that the following classes are all made-up.)
interface ArchiveSearcher { String search(String target); }
class App {
ExecutorService executor = ...
ArchiveSearcher searcher = ...
void showSearch(final String target)
throws InterruptedException {
Future<String> future
= executor.submit(new Callable<String>() {
public String call() {
return searcher.search(target);
}});
displayOtherThings(); // do other things while searching
try {
displayText(future.get()); // use future
} catch (ExecutionException ex) { cleanup(); return; }
}
}
Lets see what happens step by step:
Bitmap theBitmap = Glide.
with(this). //in Glide class and returns RequestManager
load(image_url). // in RequestManager and returns RequestBuilder<Drawable>
asBitmap(). //in RequestBuilder and returns RequestBuilder<Bitmap>
submit(). // in RequestBuilder and returns FutureTarget<TranscodeType> which extends Future<>
get(); // this belongs to Future object which is the result of async computation
public static RequestManager with(Context context) {
return getRetriever(context).get(context);
}
public RequestBuilder<Drawable> load(@Nullable Object model) {
return asDrawable().load(model);
}
public RequestBuilder<Bitmap> asBitmap() {
return as(Bitmap.class).transition(new GenericTransitionOptions<Bitmap>())
.apply(DECODE_TYPE_BITMAP);
}
public FutureTarget<TranscodeType> submit() {
return submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);
}
public interface FutureTarget<R> extends Future<R>, Target<R> {
}
But more proper and secure solution is by using callback
Glide
.with(this)
.load(image_url)
.asBitmap()
.into(new SimpleTarget<Bitmap>(100,100) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
//resource is the resulting bitmap
}
});