diff --git a/android/manifest b/android/manifest index 6355df6..416cb18 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 4.1.0 +version: 5.0.1 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: av.imageview diff --git a/android/src/av/imageview/AvImageView.java b/android/src/av/imageview/AvImageView.java index ff9e282..726fb02 100644 --- a/android/src/av/imageview/AvImageView.java +++ b/android/src/av/imageview/AvImageView.java @@ -15,6 +15,7 @@ import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; +import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.TiBlob; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.util.TiConvert; @@ -31,7 +32,6 @@ public class AvImageView extends TiUIView private static final String LCAT = "AvImageView"; private WeakReference proxy; - private Activity context; private ImageView imageView; private ProgressIndicator progressBar; private RelativeLayout layout; @@ -40,7 +40,6 @@ public class AvImageView extends TiUIView public AvImageView(Activity context, TiViewProxy proxy) { super(proxy); - this.context = context; this.proxy = new WeakReference<>(proxy); this.layout = new RelativeLayout(context); this.imageView = new ImageView(context); @@ -87,13 +86,14 @@ public void processProperties(KrollDict properties) public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { super.propertyChanged(key, oldValue, newValue, proxy); - this.processProperty(key, this.proxy.get().getProperties()); + this.processProperty(key, proxy.getProperties()); } @Override public void release() { - if (!this.context.isFinishing() && !this.context.isDestroyed()) { - Glide.with(this.context).clear(this.imageView); + Activity act = TiApplication.getAppCurrentActivity(); + if (!act.isFinishing() && !act.isDestroyed()) { + Glide.with(act).clear(this.imageView); } super.release(); @@ -165,14 +165,14 @@ public void setImageAsURL(String uri) { } // Creating request builder - builder = ImageViewHelper.prepareGlideClientFor(this.context, url); + builder = ImageViewHelper.prepareGlideClientFor(TiApplication.getAppCurrentActivity(), url); builder = builder.listener(this.requestListener); builder = builder.apply(options); builder = builder.load(url); if (signature != null && !signature.equals("")) { builder.signature(new ObjectKey(signature)); } - builder.into(new DrawableImageViewTarget(this.imageView, true)); + builder.into(this.imageView); } public void setImageAsLocalUri(String filename) { @@ -191,7 +191,7 @@ public void setImageAsLocalUri(String filename) { } // Creating request builder - builder = Glide.with(context).asDrawable(); + builder = Glide.with(TiApplication.getAppCurrentActivity()).asDrawable(); builder = builder.listener(this.requestListener); builder = builder.apply(options); builder = builder.load(imageDrawable); diff --git a/android/src/av/imageview/ImageViewHelper.java b/android/src/av/imageview/ImageViewHelper.java index 91f8228..68c6500 100644 --- a/android/src/av/imageview/ImageViewHelper.java +++ b/android/src/av/imageview/ImageViewHelper.java @@ -10,6 +10,7 @@ import com.bumptech.glide.load.model.LazyHeaders; import org.appcelerator.kroll.KrollDict; +import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiDrawableReference; @@ -35,7 +36,7 @@ public static Drawable getDrawableFromProxyProperty(String propertyName, TiViewP return null; } - return TiDrawableReference.fromUrl(proxy, proxy.getProperties().getString(propertyName)).getDrawable(); + return TiDrawableReference.fromUrl(TiApplication.getAppCurrentActivity(), proxy.getProperties().getString(propertyName)).getDrawable(); } public static RequestBuilder prepareGlideClientFor(Context context, GlideUrl url) {