Skip to content

Commit

Permalink
added logging for admob
Browse files Browse the repository at this point in the history
  • Loading branch information
xamantra committed Aug 21, 2021
1 parent 33468e1 commit 71ab15c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/src/components/admob/admob.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AdmobController extends MomentumController<AdmobModel> {
int lastActiveTab = -1;

Future<void> initialize() async {
print(['QUANTZ', 'AdmobController.initialize()', 'subscribed = $subscribed']);
if (subscribed) {
model.update(initialized: false);
} else {
Expand All @@ -45,6 +46,7 @@ class AdmobController extends MomentumController<AdmobModel> {
}

void loadAdForActiveTab() {
print(['QUANTZ', 'loadAdForActiveTab() : $lastActiveTab']);
switch (lastActiveTab) {
case 0:
loadLibraryTabAd();
Expand Down Expand Up @@ -78,20 +80,23 @@ class AdmobController extends MomentumController<AdmobModel> {
lastActiveTab = 0;
if (!ready) return;
model.update(showLibraryTabAd: false);
print(['QUANTZ', 'loadLibraryTabAd()']);
await model.libraryTabAd.load();
}

void loadFeedTabAd() async {
lastActiveTab = 1;
if (!ready) return;
model.update(showFeedTabAd: false);
print(['QUANTZ', 'loadFeedTabAd()']);
await model.feedTabAd.load();
}

void loadSourcesTabAd() async {
lastActiveTab = 2;
if (!ready) return;
model.update(showSourcesTabAd: false);
print(['QUANTZ', 'loadSourcesTabAd()']);
await model.sourcesTabAd.load();
}

Expand All @@ -117,6 +122,7 @@ class AdmobController extends MomentumController<AdmobModel> {
request: AdRequest(),
listener: BannerAdListener(
onAdLoaded: (ad) {
print(['QUANTZ', 'onAdLoaded() : $adUnitId']);
callback();
},
onAdFailedToLoad: (ad, error) {
Expand Down
1 change: 1 addition & 0 deletions lib/src/components/google-flow/google-flow.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class GoogleFlowController extends MomentumController<GoogleFlowModel> {

/// Only call this when in-app-purchase has finish checking purchase status for supporter subscription.
Future<void> initializeAdmob() async {
print(['QUANTZ', 'initializeAdmob()']);
await admobController.initialize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ class SupporterSubscriptionController extends MomentumController<SupporterSubscr
}

void _checkPurchaseUpdated(PurchaseDetails purchaseDetails) async {
print(['QUANTZ', '_checkPurchaseUpdated($purchaseDetails)']);
model.update(loading: true);
final status = await google.processPurchaseUpdated(purchaseDetails);
print(['QUANTZ', '_checkPurchaseUpdated($purchaseDetails)', status]);
switch (status) {
case UpdatedPurchaseStatus.none:
break;
Expand All @@ -83,6 +85,7 @@ class SupporterSubscriptionController extends MomentumController<SupporterSubscr
Future<void> checkStore() async {
model.update(loading: true);
final bool available = await google.checkStore();
print(['QUANTZ', 'checkStore()', 'available = $available']);
model.update(storeIsAvailable: available, loading: false);
}

Expand All @@ -106,6 +109,7 @@ class SupporterSubscriptionController extends MomentumController<SupporterSubscr
}

void initializedAds() {
print(['QUANTZ', 'initializedAds()']);
controller<GoogleFlowController>().initializeAdmob();
}
}

0 comments on commit 71ab15c

Please sign in to comment.