Skip to content

Commit

Permalink
Fixed a bug where ads would still show up if showAd() and removeAd() …
Browse files Browse the repository at this point in the history
…were called quickly successively on Android.
  • Loading branch information
ataugeron committed Nov 6, 2012
1 parent 5c5c8af commit 8c0aec8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
Binary file removed android/libs/AdMob-6.2.0.jar
Binary file not shown.
Binary file modified android/libs/FlurryAgent-3.0.4.jar
100755 → 100644
Binary file not shown.
37 changes: 36 additions & 1 deletion android/src/com/freshplanet/flurry/ExtensionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class ExtensionContext extends FREContext implements FlurryAdListener
private RelativeLayout _adLayout = null;

private Map<String, String> _userCookies = null;
private Map<String, Boolean> _spacesStatus = null;


public ExtensionContext()
Expand Down Expand Up @@ -129,6 +130,28 @@ public Map<String, String> getUserCookies()
return _userCookies;
}

// Spaces status (true when a space should be displayed, false otherwise)

private Map<String, Boolean> spacesStatus()
{
if (_spacesStatus == null)
{
_spacesStatus = new HashMap<String, Boolean>();
}

return _spacesStatus;
}

public Boolean getStatusForSpace(String space)
{
return this.spacesStatus().containsKey(space) ? this.spacesStatus().get(space) : false;
}

public void setStatusForSpace(Boolean status, String space)
{
this.spacesStatus().put(space, status);
}


// Flurry IListener

Expand All @@ -143,7 +166,7 @@ public void onRenderFailed(String myAdSpaceName)
@Override
public boolean shouldDisplayAd(String myAdSpaceName, FlurryAdType type)
{
return true;
return getStatusForSpace(myAdSpaceName);
}

@Override
Expand Down Expand Up @@ -175,4 +198,16 @@ public void spaceDidFailToReceiveAd(String myAdSpaceName)

dispatchStatusEventAsync("SPACE_DID_FAIL_TO_RENDER", myAdSpaceName);
}

@Override
public void onAdClicked(String myAdSpaceName)
{
Log.d(TAG, "Space was clicked: " + myAdSpaceName);
}

@Override
public void onAdOpened(String myAdSpaceName)
{
Log.d(TAG, "Space was opened: " + myAdSpaceName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public FREObject call(FREContext arg0, FREObject[] arg1)
return null;
}

// Update space status
ExtensionContext context = (ExtensionContext)arg0;
context.setStatusForSpace(false, space);

// Remove the ad
RelativeLayout adLayout = ((ExtensionContext)arg0).getCurrentAdLayout();
FlurryAgent.removeAd(arg0.getActivity(), space, adLayout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ else if (sizeString == "BANNER_BOTTOM")
timeout = 0;
}

// Update space status
ExtensionContext context = (ExtensionContext)arg0;
context.setStatusForSpace(true, space);

// Try to show an ad
RelativeLayout adLayout = ((ExtensionContext)arg0).getNewAdLayout();
Boolean result = FlurryAgent.getAd(arg0.getActivity(), space, adLayout, size, timeout);
Expand Down
Binary file modified bin/AirFlurry.ane
Binary file not shown.

0 comments on commit 8c0aec8

Please sign in to comment.