コード例 #1
0
class KivMobDemo(MDApp):

    def __init__(self,**kwargs):
        self.theme_cls.theme_style = "Dark"
        super().__init__(**kwargs)
        self.rewards = Rewards_Handler(self)

    Points = NumericProperty(0)
    show_banner = False

    def build(self):
        self.ads = KivMob(TestIds.APP)
        self.ads.new_banner(TestIds.BANNER, False)
        self.ads.new_interstitial(TestIds.INTERSTITIAL)
        self.ads.request_banner()
        self.ads.request_interstitial()
        self.ads.set_rewarded_ad_listener(self.rewards)
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
        self.toggled = False
        return KivMobDemoUI()

    def toggle_banner(self):
        self.show_banner = not self.show_banner
        if self.show_banner:
            self.ads.show_banner()
        else:
            self.ads.hide_banner()

    def load_video(self):
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
コード例 #2
0
class KivMobDemo(App):

    theme_cls = ThemeManager()

    show_banner = False

    def build(self):
        self.ads = KivMob(TestIds.APP)
        self.ads.new_banner(TestIds.BANNER, False)
        self.ads.new_interstitial(TestIds.INTERSTITIAL)
        self.ads.request_banner()
        self.ads.request_interstitial()
        self.ads.set_rewarded_ad_listener(RewardedListenerInterface())
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
        self.toggled = False
        return KivMobDemoUI()

    def toggle_banner(self):
        self.show_banner = not self.show_banner
        if self.show_banner:
            self.ads.show_banner()
        else:
            self.ads.hide_banner()
コード例 #3
0
ファイル: main.py プロジェクト: clevermindgames/KivMob27
class KivMobDemo(App):

    APP_ID = "ca-app-pub-COPY APP ID HERE"
    BANNER_ID = "ca-app-pub-COPY BANNER ID HERE"
    INTERSTITIAL_ID = "ca-app-pub-COPY INTERSTITIAL ID HERE"
    TEST_DEVICE_ID = "COPY DEVICE ID HERE"

    def build(self):
        self.ads = KivMob(APP_ID)
        self.ads.add_test_device(TEST_DEVICE_ID)
        self.ads.new_banner({"unitID": BANNER_ID})
        self.ads.new_interstitial(INTERSTITIAL_ID)
        self.ads.request_banner()
        self.ads.request_interstitial()
        self.toggled = False
        return KivMobDemoUI()

    def on_start(self):
        """Called on application start.
        """
        if platform not in ("android", "ios"):
            self.desktop_warning()

    def desktop_warning(self):
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(Label(text='KivMob will not display ads on ' +\
                          'nonmobile platforms. You must build an ' +\
                          'Android project to demo ads. (iOS not yet ' +\
                          'supported)',
                          size_hint_y=1,
                          text_size=(250,  None),
                          halign='left',
                          valign='middle'))
        button_layout = BoxLayout()
        button1 = Button(text="Open Build Steps", size_hint=(0.8, 0.2))
        button1.bind(
            on_release=lambda x: webbrowser.open("https://www.google.com"))
        button_layout.add_widget(button1)
        button2 = Button(text="Close", size_hint=(0.8, 0.2))
        button2.bind(on_release=lambda x: popup.dismiss())
        button_layout.add_widget(button2)
        layout.add_widget(button_layout)
        popup = Popup(title='KivMob Demo Alert',
                      content=layout,
                      size_hint=(0.9, 0.9))
        popup.open()

    def interstitial_warning(self):
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(Label(text="Ad has not loaded. " +\
                                    "Wait a few seconds and then " +\
                                    "try again.",
                                    size_hint_y=1,
                                    text_size=(250,  None),
                                    halign='left',
                                    valign='middle'))
        button_layout = BoxLayout()
        close = Button(text="Close", size_hint=(0.8, 0.2))
        close.bind(on_release=lambda x: popup.dismiss())
        button_layout.add_widget(close)
        layout.add_widget(button_layout)
        popup = Popup(title='KivMob Demo Alert',
                      content=layout,
                      size_hint=(0.9, 0.9))
        popup.open()

    def on_pause(self):
        """Android specific method. Save important app data on pause.
        """
        return True

    def on_resume(self):
        """Android specific method. Resume paused app.
        """
        self.ads.request_interstitial()

    def toggle_banner(self):
        if not self.toggled:
            self.ads.show_banner()
        else:
            self.ads.hide_banner()
        self.toggled = not self.toggled

    def show_interstitial(self):
        if self.ads.is_interstitial_loaded():
            self.ads.show_interstitial()
        else:
            self.interstitial_warning()