package Ġio . cg is ca . godot ad mob library . ad format Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . util . Log Ċ import Ġandroidx . annotation . NonNull Ċ import Ġcom . google . android . gms . ads . Ad Request Ċ import Ġcom . google . android . gms . ads . re warded . Reward Item Ċ import Ġcom . google . android . gms . ads . re warded . Rew arded Ad Ċ import Ġcom . google . android . gms . ads . re warded . Rew arded Ad Callback Ċ import Ġcom . google . android . gms . ads . re warded . Rew arded Ad Load Callback Ċ import Ġio . cg is ca . godot ad mob library . Ad State Ċ import Ġio . cg is ca . godot ad mob library . Build Config Ċ Ċ class ĠRew arded Ad Controller ( ĊĠ Ġprivate Ġval Ġactivity : ĠActivity , ĊĠ Ġprivate Ġval Ġad Request : ĠAd Request , ĊĠ Ġprivate Ġval Ġad State : ĠAd State , ĊĠ Ġprivate Ġval Ġlistener : ĠRew arded Ad Listener Ċ ) Ġ{ ĊĊĠ Ġprivate Ġval Ġre warded Ads Ġ= Ġmutable Map Of < String , ĠRew arded Ad >() ĊĊĠ Ġprivate Ġfun Ġcreate And Load Rew arded Ad ( ad Unit Id : ĠString ): ĠRew arded Ad Ġ{ ĊĠĠĠ Ġval Ġre warded Ad Ġ= ĠRew arded Ad ( activity , Ġad Unit Id ) ĊĠĠĠ Ġval Ġad Load Callback Ġ= Ġobject Ġ: ĠRew arded Ad Load Callback () Ġ{ ĊĊĠĠĠĠĠ Ġoverride Ġfun Ġon Rew arded Ad Loaded () Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Reward Ġwith Ġunit Id Ġ$ ad Unit Id Ġloaded ") ĊĠĠĠĠĠĠĠ Ġlistener . on Rew arded Ad Loaded ( ad Unit Id ) ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġoverride Ġfun Ġon Rew arded Ad Failed To Load ( errorCode : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Reward Ġwith Ġunit Id Ġ$ ad Unit Id Ġfailed Ġto Ġload . ĠError Ġcode : Ġ$ errorCode ") ĊĠĠĠĠĠĠĠ Ġlistener . on Rew arded Ad Failed To Load ( ad Unit Id , ĠerrorCode ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġre warded Ad . load Ad ( ad Request , Ġad Load Callback ) ĊĠĠĠ Ġreturn Ġre warded Ad ĊĠ Ġ} ĊĊĠ Ġfun Ġload Rew arded Ads ( ad Unit Ids : ĠArray < String >) Ġ{ ĊĠĠĠ Ġad Unit Ids . forEach Ġ{ ĊĠĠĠĠĠ Ġval Ġre warded Ad Ġ= Ġcreate And Load Rew arded Ad ( it ) ĊĠĠĠĠĠ Ġre warded Ads [ it ] Ġ= Ġre warded Ad ĊĠĠĠ Ġ} ĊĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Loaded Ġre warded Ġads Ġwith Ġunit Ids : Ġ${ re warded Ads . keys }") ĊĠ Ġ} ĊĊĠ Ġfun Ġshow Rew arded Ad ( ad Unit Id : ĠString ) Ġ{ ĊĠĠĠ Ġval Ġre warded Ad Ġ= Ġre warded Ads [ ad Unit Id ] ĊĠĠĠ Ġif Ġ( re warded Ad Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( re warded Ad . is Loaded Ġ&& Ġad State . is Ad Enabled ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġad Callback Ġ= Ġobject Ġ: ĠRew arded Ad Callback () Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Rew arded Ad Opened () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Reward Ġwith Ġunit Id Ġ$ ad Unit Id Ġopened ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlistener . on Rew arded Ad Opened ( ad Unit Id ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Rew arded Ad Closed () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Reward Ġwith Ġunit Id Ġ$ ad Unit Id Ġclosed ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlistener . on Rew arded Ad Closed ( ad Unit Id ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon User E arn ed Reward (@ NonNull Ġreward : ĠRew ard Item ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . d ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBuild Config . LIBRARY _ NAME , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" User Ġe arn ed Ġreward Ġ( Type : Ġ${ reward . type }, ĠAmount : Ġ${ reward . amount }) Ġfor Ġad Ġwith Ġunit Id Ġ$ ad Unit Id " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlistener . on User E arn ed Reward ( ad Unit Id , Ġreward ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Rew arded Ad Failed To Show ( errorCode : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Reward Ġwith Ġunit Id Ġ$ ad Unit Id Ġfailed Ġto Ġshow . ĠError Ġcode : Ġ$ errorCode ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlistener . on Rew arded Ad Failed To Show ( ad Unit Id , ĠerrorCode ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġre warded Ad . show ( activity , Ġad Callback ) ĊĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Reward Ġwith Ġunit Id Ġ$ ad Unit Id Ġnot Ġloaded Ġor Ġad Ġnot Ġenabled ") ĊĠĠĠĠĠĠĠ Ġlistener . on Rew arded Ad Not Loaded ( ad Unit Id ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ ĠLog . d ( Build Config . LIBRARY _ NAME , Ġ" Reward Ġwith Ġunit Id Ġ$ ad Unit Id Ġnot Ġloaded ") ĊĠĠĠĠĠ Ġlistener . on Rew arded Ad Not Loaded ( ad Unit Id ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ }