Skip to content

Commit

Permalink
Updated SDK version 7.18
Browse files Browse the repository at this point in the history
* commit 'd718b6a37acedc9cc992db50f13af376c98522c2':
  Updated SDK version
  Fix: issues in merged develop
  • Loading branch information
avohraa committed Sep 30, 2021
2 parents ca77c83 + d718b6a commit 5274b89
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sdk/src/com/appnexus/opensdk/VisibilityDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private boolean remove(List<WeakReference<View>> list, View reference)
for (Iterator<WeakReference<View>> iterator = list.iterator(); iterator.hasNext(); ) {
WeakReference<View> weakRef = iterator.next();
if (weakRef.get() == reference) {
if (!(reference instanceof BannerAdView)) {
if (reference != null && !(reference instanceof BannerAdView)) {
reference.setTag(R.string.native_view_tag, null);
}
iterator.remove();
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/com/appnexus/opensdk/utils/ImageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public void execute() {
return;
}
if (imageUrlMap != null && !imageUrlMap.isEmpty()) {
for (Map.Entry pairs : imageUrlMap.entrySet()) {
HashMap<String, String> imageUrlMapCopy = new HashMap<>(imageUrlMap);
for (Map.Entry pairs : imageUrlMapCopy.entrySet()) {
ImageDownloader downloader = new ImageDownloader(imageReceiver, (String) pairs.getKey(), (String) pairs.getValue(), this);
Clog.d(Clog.baseLogTag, "Downloading " + pairs.getKey() + " from url: " + pairs.getValue());
downloader.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.View
import java.lang.ref.WeakReference
import org.junit.Assert

class Utility {
companion object {
Expand All @@ -14,21 +14,26 @@ class Utility {

Handler(Looper.getMainLooper()).post({
val vDetector = Class.forName("com.appnexus.opensdk.VisibilityDetector")
val create = vDetector.getDeclaredMethod("create", WeakReference::class.java)
create.isAccessible = true
val weakReference = WeakReference(View(context))
val vDetInst = create.invoke(null, weakReference)
val getInstance = vDetector.getDeclaredMethod("getInstance")

getInstance.isAccessible = true
val viewReference = View(context)
val vDetInst = getInstance.invoke(null)

val destroy = vDetector.getDeclaredMethod("destroy", WeakReference::class.java)
val addVisibilityListener = vDetector.getDeclaredMethod("addVisibilityListener", View::class.java)
addVisibilityListener.isAccessible = true
addVisibilityListener.invoke(vDetInst, viewReference)

val destroy = vDetector.getDeclaredMethod("destroy", View::class.java)
destroy.isAccessible = true
destroy.invoke(vDetInst, weakReference)
destroy.invoke(vDetInst, viewReference)

val declaredField = vDetector.getDeclaredField("viewListenerMap")
val declaredField = vDetector.getDeclaredField("viewList")
declaredField.isAccessible = true
var map = declaredField.get(vDetInst) as HashMap<Object, Object>
Log.e("VISIBILITY", " Size: ${checkZero} ${map.size}");
var list = declaredField.get(vDetInst) as List<Object>
Log.e("VISIBILITY", " Size: ${checkZero} ${list.size}");

junit.framework.Assert.assertTrue(map.size == checkZero)
Assert.assertEquals(checkZero, list.size)

})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class MARLoadAndDisplayActivity : Activity() {
idlingResource.decrement()
}

override fun onAdFailed(errorcode: ResultCode, adResponseInfo: ANAdResponseInfo) {
override fun onAdFailed(errorcode: ResultCode, adResponseInfo: ANAdResponseInfo?) {
msg += "Native Ad Failed:$errorcode\n"
toast()
if (!idlingResource.isIdleNow)
Expand Down Expand Up @@ -313,7 +313,9 @@ class MARLoadAndDisplayActivity : Activity() {
onLazyAdLoaded = true
arrayListAd.add(adView)
if (displayAd)
recyclerListAdView.adapter!!.notifyDataSetChanged()
Handler(Looper.getMainLooper()).post({
recyclerListAdView.adapter!!.notifyDataSetChanged()
})
if (!idlingResource.isIdleNow)
idlingResource.decrement()
}
Expand Down

0 comments on commit 5274b89

Please sign in to comment.