How to make Clicked Leadbolt Ads in WebView open bigger

170 views
Skip to first unread message

Regis Silva

unread,
Dec 17, 2015, 4:52:34 PM12/17/15
to DroidScript
Hi everyone !

I follow all everybody here told about Leadbolt and for my happyness I was approved and app is working now with production Leadbolt account  :D Thank you for that!

But, one thing is really annoyng me...  I choose the HTML Ad 320x60  and when the Ad is showed and I click on I the result is opening in the same 320x60 pixels box (so by example Google Play page for install a ad-game).  It does not seem right to me because user cannot see what he clicked !

Any tip or clue what should I do to make it better? Intercept the WebView event click and maximize it, or anything???

Please, I kindly ask you guys to give me your wonderfull suggestions, I really appreciate them !

Thanks a lot since now!

Steve Garman

unread,
Dec 17, 2015, 6:24:08 PM12/17/15
to DroidScript
This is the nearest I have been able to get:


var myId="771240583";

var script='<script type="text/javascript" src="http://ad.leadbolt.net/show_app_ad.js?section_id='+myId+'"></script>'
var layTop,layMid,layBot,ads,lastUrl;

//Called when application is started.
function OnStart()
{
    app.SetOrientation("Portrait");
    //Create a layout with objects vertically centered.
  var layMain = app.CreateLayout( "absolute", "" );    
  
  layTop = app.CreateLayout( "linear", "Horizontal,Top,Center" );    ;
  layMid = app.CreateLayout( "linear", "VCenter" );    
  layBot = app.CreateLayout( "linear", "Horizontal,Bottom,Center" );    
  layMain.AddChild(layTop);
  layMain.AddChild(layMid);
  layMain.AddChild(layBot);
  layPos();

  var txtT=app.CreateText("Text Top");
  layTop.AddChild(txtT);
  var btnT=app.CreateButton("Top");
  layTop.AddChild(btnT);

  var txtM=app.CreateText("Middle",-1,-1,"AutoScale");
  layMid.AddChild(txtM);

  ads=app.CreateWebView(0.8,0.1,"IgnoreErrors,NoScrollbars");
  ads.SetOnProgress(adsOnProgress);


ads.LoadHtml(script)

      //ads.LoadUrl("http://www.google.com");
  layBot.AddChild(ads);
  var btn=app.CreateButton("[fa-arrows-alt]",-1,-1,"fontawesome");
  btn.SetOnTouch(bigger);
  layBot.AddChild(btn);
       
  //Add layout to app.    
  app.AddLayout( layMain );

  layTop.SetBackGradient("#ff222266","#ff2222aa");
  layMid.SetBackColor("#ff666666");
  layBot.SetBackColor("#ff222288");
}

function adsOnProgress()
{
    var schemes=["market","https","http"]
    var url=this.GetUrl();
    var schemePos=url.indexOf("://");
    var scheme;
    // don't check the same url again 
    // or a url with no scheme
    if(url===lastUrl||schemePos === -1) return;
    lastUrl=url;
    scheme=url.slice(0,schemePos);
    //check schene is in our list
    if(schemes.indexOf(scheme) > -1)
    {
         //reload webview to clear error message
         //this.LoadHtml(script);

         //send url to browser
         app.OpenUrl(url);
    }
    else app.ShowPopup(url)
}

function layPos()
{
   var high=110/app.GetScreenHeight();;
   layTop.SetPosition(0,0,1,high);
   layMid.SetPosition(0,high,1,1-high*2.5);
   layBot.SetPosition(0,1-high*1.5,1,high*1.5);
}

function bigger()
{
     if(ads.GetHeight()<0.7)
     {
       layBot.SetPosition(0,0.05,1,0.8);
       ads.SetSize(0.8,0.8);
     }
     else
     {
       ads.SetSize(0.8,0.1);
       layPos();
     }
}

Regis Silva

unread,
Dec 17, 2015, 7:12:02 PM12/17/15
to DroidScript
Steve, thanks for share it.

I will try and post here about the result. Tks again :)

Regis Silva

unread,
Dec 18, 2015, 7:20:15 AM12/18/15
to DroidScript
Great Steve, it worked as a sharp ! :D  

Tks a lot !!!
Reply all
Reply to author
Forward
0 new messages