Java Question Adiquity Source Request

NFOBoy

Active Member
Licensed User
Longtime User
Erel,

while I am trying to do the Game Services wrapper, when I hit my head enough times with whatever my current problem is, and would like to take a break, I would like to continue making progress in other areas.

One of those is the Adiquity SDK which has been updated since the library here was done over a year ago.

Was wondering if I could get the source that you did the first time, and I will gladly continue my training by (trying to) updating the current SDK.

(The final library will be made available to other users, along with the source code, unless you would have other restrictions)

Ross
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here is the code:
B4X:
package anywheresoftware.b4a.objects;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Events;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

import com.adiquity.android.AdIquityAdListener;
import com.adiquity.android.AdIquityAdView;

@Version(1.0f)
@DependsOn(values={"AdiquityAndroidSDK"})
@ShortName("AdiquityAdView")
@Permissions(values={"android.permission.INTERNET"})
@Events(values={"AdRequestCompleted", "AdRequestCompletedNoAd", "AdRequestFailed"})
@ActivityObject
public class AdWrapper extends ViewWrapper<AdIquityAdView>{
   public static final String ADSIZE_300x50 = AdIquityAdView.ADIQUITY_AD_UNIT_300_50;
   public static final String ADSIZE_320x48 = AdIquityAdView.ADIQUITY_AD_UNIT_320_48;
   public void Initialize(final BA ba, String EventName, String SiteId, String AdSize) {
      AdIquityAdView ad = new AdIquityAdView(ba.context);
      ad.init(SiteId, ba.activity, AdSize);
      setObject(ad);
      final String eventName = EventName.toLowerCase(BA.cul);
      ad.setAdListener(new AdIquityAdListener() {

         @Override
         public void adRequestCompleted(AdIquityAdView arg0) {
            ba.raiseEvent(getObject(), eventName + "_adrequestcompleted");
         }

         @Override
         public void adRequestCompletedNoAd(AdIquityAdView arg0) {
            ba.raiseEvent(getObject(), eventName + "_adrequestcompletednoad");
         
         }

         @Override
         public void adRequestFailed(AdIquityAdView arg0) {
            ba.raiseEvent(getObject(), eventName + "_adrequestfailed");

         }
         
      });
   }
   /**
    * A test ad will be shown instead of a real ad.
    */
   public void SetTestMode(){
      getObject().setTestMode();      
   }
   /**
    * Sets the refresh rate (in seconds). The default value is 30. Set to -1 to disable automatic refreshing.
    */
   public void setRefreshRate(long value) {
      getObject().setRefreshTime(value);
   }
   /**
    * Starts showing ads.
    */
   public void StartAds() {
      getObject().startAds();
   }
   /**
    * Pauses the ad requests. Should be called from Activity_Pause.
    */
   public void PauseAds() {
      getObject().onPause();
   }
   /**
    * Resumes ad requests. Should be called from Activity_Resume.
    */
   public void ResumeAds() {
      getObject().onResume();
   }
   

}
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…