-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: move ad configuration in source
- Loading branch information
Showing
14 changed files
with
171 additions
and
76 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
android/src/main/java/com/brentvatne/common/api/AdsProps.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.brentvatne.common.api | ||
|
||
import android.net.Uri | ||
import android.text.TextUtils | ||
import com.brentvatne.common.toolbox.DebugLog | ||
import com.brentvatne.common.toolbox.ReactBridgeUtils | ||
import com.facebook.react.bridge.ReadableMap | ||
|
||
class AdsProps { | ||
var adTagUrl: Uri? = null | ||
var adLanguage: String? = null | ||
|
||
/** return true if this and src are equals */ | ||
override fun equals(other: Any?): Boolean { | ||
if (other == null || other !is AdsProps) return false | ||
return ( | ||
adTagUrl == other.adTagUrl && | ||
adLanguage == other.adLanguage | ||
) | ||
} | ||
|
||
companion object { | ||
private const val PROP_AD_TAG_URL = "adTagUrl" | ||
private const val PROP_AD_LANGUAGE = "adLanguage" | ||
|
||
@JvmStatic | ||
fun parse(src: ReadableMap?): AdsProps { | ||
val adsProps = AdsProps() | ||
DebugLog.w("olivier", "uri: parse AdsProps") | ||
|
||
if (src != null) { | ||
val uriString = ReactBridgeUtils.safeGetString(src, PROP_AD_TAG_URL) | ||
if (TextUtils.isEmpty(uriString)) { | ||
adsProps.adTagUrl = null | ||
} else { | ||
adsProps.adTagUrl = Uri.parse(uriString) | ||
} | ||
val languageString = ReactBridgeUtils.safeGetString(src, PROP_AD_LANGUAGE) | ||
if (!TextUtils.isEmpty(languageString)) { | ||
adsProps.adLanguage = languageString | ||
} | ||
} | ||
return adsProps | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
struct AdParams { | ||
let adTagUrl: String? | ||
let adLanguage: String? | ||
|
||
let json: NSDictionary? | ||
|
||
init(_ json: NSDictionary!) { | ||
guard json != nil else { | ||
self.json = nil | ||
adTagUrl = nil | ||
adLanguage = nil | ||
return | ||
} | ||
self.json = json | ||
adTagUrl = json["adTagUrl"] as? String | ||
adLanguage = json["adLanguage"] as? String | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.