I am using glide and once the image is retrieved it is put into a view, the view is extended and I use the below code in the constructor. The code returns null. Is there a way to wait until it returns the drawable? It works in the listeners and that's why I am asking if there's a way to wait so it can be in the constructors.
Code:
Glide:
Glide
.with(activity).asBitmap()
.load(imageURL)
.into(new SimpleTarget<Bitmap>(currentMap.getWidth(), currentMap.getHeight()) {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
currentMap.setUpMap()
});
}
Drawable in view:
drawable = this.getDrawable();
Error:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.drawable.Drawable.getIntrinsicWidth()' on a null object reference