Skip to content

Commit

Permalink
[interactive_media_ads] Adds internal wrapper for Android native `Com…
Browse files Browse the repository at this point in the history
…panionAdSlot` and `CompanionAdSlot.ClickListener` (#8131)
  • Loading branch information
bparrishMines authored Nov 22, 2024
1 parent 35f9c6e commit 0be7cbe
Show file tree
Hide file tree
Showing 12 changed files with 1,168 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/interactive_media_ads/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.3+3

* Adds internal wrapper for Android native `CompanionAdSlot` and `CompanionAdSlot.ClickListener`.

## 0.2.3+2

* Bumps `com.google.ads.interactivemedia.v3:interactivemedia` from 3.35.1 to 3.36.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
*
* This must match the version in pubspec.yaml.
*/
const val pluginVersion = "0.2.3+2"
const val pluginVersion = "0.2.3+3"
}

override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package dev.flutter.packages.interactive_media_ads

import com.google.ads.interactivemedia.v3.api.CompanionAdSlot.ClickListener

/**
* ProxyApi implementation for [ClickListener].
*
* <p>This class may handle instantiating native object instances that are attached to a Dart
* instance or handle method calls on the associated native class or an instance of that class.
*/
class CompanionAdSlotClickListenerProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiCompanionAdSlotClickListener(pigeonRegistrar) {
internal class ClickListenerImpl(val api: CompanionAdSlotClickListenerProxyApi) : ClickListener {
override fun onCompanionAdClick() {
api.pigeonRegistrar.runOnMainThread { api.onCompanionAdClick(this) {} }
}
}

override fun pigeon_defaultConstructor(): ClickListener {
return ClickListenerImpl(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package dev.flutter.packages.interactive_media_ads

import android.view.ViewGroup
import com.google.ads.interactivemedia.v3.api.CompanionAdSlot
import com.google.ads.interactivemedia.v3.api.CompanionAdSlot.ClickListener

/**
* ProxyApi implementation for [CompanionAdSlot].
*
* <p>This class may handle instantiating native object instances that are attached to a Dart
* instance or handle method calls on the associated native class or an instance of that class.
*/
class CompanionAdSlotProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
PigeonApiCompanionAdSlot(pigeonRegistrar) {
override fun addClickListener(pigeon_instance: CompanionAdSlot, clickListener: ClickListener) {
return pigeon_instance.addClickListener(clickListener)
}

override fun getContainer(pigeon_instance: CompanionAdSlot): ViewGroup {
return pigeon_instance.container
}

override fun getHeight(pigeon_instance: CompanionAdSlot): Long {
return pigeon_instance.height.toLong()
}

override fun getWidth(pigeon_instance: CompanionAdSlot): Long {
return pigeon_instance.width.toLong()
}

override fun isFilled(pigeon_instance: CompanionAdSlot): Boolean {
return pigeon_instance.isFilled
}

override fun removeClickListener(pigeon_instance: CompanionAdSlot, clickListener: ClickListener) {
pigeon_instance.removeClickListener(clickListener)
}

override fun setContainer(pigeon_instance: CompanionAdSlot, container: ViewGroup) {
pigeon_instance.container = container
}

override fun setSize(pigeon_instance: CompanionAdSlot, width: Long, height: Long) {
pigeon_instance.setSize(width.toInt(), height.toInt())
}
}
Loading

0 comments on commit 0be7cbe

Please sign in to comment.