Commit 6ee673d6 authored by 王志伟's avatar 王志伟

海外sdkbug修改

parent 0e7249b9
...@@ -2,6 +2,7 @@ apply plugin: 'com.android.application' ...@@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.gms.google-services'
android { android {
signingConfigs { signingConfigs {
...@@ -15,15 +16,14 @@ android { ...@@ -15,15 +16,14 @@ android {
storeFile file("C:\\Users\\EDZ\\android\\debug.keystore") storeFile file("C:\\Users\\EDZ\\android\\debug.keystore")
} }
} }
compileSdkVersion 33 compileSdkVersion 34
buildToolsVersion "33.0.2"
defaultConfig { defaultConfig {
applicationId "com.jjmillion.summer.game" applicationId "com.legame.bubbleshooter"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 33 targetSdkVersion 32
versionCode 516 versionCode 100
versionName "5.1.6" versionName "1.0.0"
multiDexEnabled true multiDexEnabled true
flavorDimensions "versionCode" flavorDimensions "versionCode"
ndk { ndk {
...@@ -51,15 +51,6 @@ android { ...@@ -51,15 +51,6 @@ android {
} }
} }
android.applicationVariants.all {
variant ->
variant.outputs.all {
//这里修改apk文件名
outputFileName = "fkkq-v${variant.versionName}.apk"
// outputFileName = "${variant.productFlavors[0].name}_v${variant.versionName}.apk"
}
}
packagingOptions { packagingOptions {
exclude 'META-INF.**' exclude 'META-INF.**'
exclude "**.module-info.class" exclude "**.module-info.class"
...@@ -89,14 +80,21 @@ repositories { ...@@ -89,14 +80,21 @@ repositories {
dependencies { dependencies {
// implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') // implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'androidx.media:media:1.4.0'
implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.6.0' implementation 'com.google.android.material:material:1.6.0'
implementation("com.guolindev.permissionx:permissionx:1.7.1") implementation("com.guolindev.permissionx:permissionx:1.7.1")
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'com.applovin:applovin-sdk:12.0.0' implementation("com.google.android.gms:play-services-ads:20.6.0")
implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.6.7' implementation 'com.google.android.gms:play-services-base:18.0.1'
// implementation (name:'halomobi_juhe_sdk_v1.0.0',ext:'aar') implementation("com.applovin:applovin-sdk:13.0.1")
implementation 'com.applovin.mediation:google-adapter:23.5.0.0'
implementation 'com.applovin.mediation:mintegral-adapter:16.8.71.0'
implementation("com.applovin.mediation:bytedance-adapter:6.3.0.4.0")
implementation 'com.applovin.mediation:unityads-adapter:4.12.4.0'
// implementation (name:'halomobi_juhe_sdk_v1.1.2',ext:'aar')
// implementation (name:'halomobi_sdk_v1.1.0',ext:'aar')
implementation project(':haloJuheSdk') implementation project(':haloJuheSdk')
} }
{
"project_info": {
"project_number": "443220660668",
"project_id": "scores-387808",
"storage_bucket": "scores-387808.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:443220660668:android:6709001bb41c513c8a5bb9",
"android_client_info": {
"package_name": "com.legame.bubbleshooter"
}
},
"oauth_client": [
{
"client_id": "443220660668-3pa7svoi1j82h842gpvv9d9j53h418b9.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBuaAF_fQMcDSakzz-BD8sOHmQ95OSthVY"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "443220660668-3pa7svoi1j82h842gpvv9d9j53h418b9.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "443220660668-gvvsmajs7fafd7qejv1pihcgej7d2098.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.legame.bubbleshooter",
"app_store_id": "6449077229"
}
}
]
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
...@@ -18,4 +18,6 @@ ...@@ -18,4 +18,6 @@
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
\ No newline at end of file -keep public class com.halo.halojuhesdk.sdk.**{*;}
-keep public class com.halomobi.**{*;}
\ No newline at end of file
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
...@@ -21,8 +24,12 @@ ...@@ -21,8 +24,12 @@
android:theme="@style/Theme.HaloMobiSdk"> android:theme="@style/Theme.HaloMobiSdk">
<meta-data <meta-data
android:name="applovin.sdk.key" android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="TAVI1U8OIXyhL9egaWLlPirxWNem6hJ82OivKgwNQcvKoUT_XkgPvx3qUGk42s1tXmHQvd6OTLoRl5QaxLdIyU" /> android:value="true"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
<uses-library <uses-library
android:name="org.apache.http.legacy" android:name="org.apache.http.legacy"
...@@ -44,10 +51,12 @@ ...@@ -44,10 +51,12 @@
<activity android:name="com.halo.halomobisdk.BannerActivity"/> <activity android:name="com.halo.halomobisdk.BannerActivity"/>
<activity android:name="com.halo.halomobisdk.InsertActivity"/> <activity android:name="com.halo.halomobisdk.InsertActivity"/>
<activity android:name="com.halo.halomobisdk.NativeActivity"/> <activity android:name="com.halo.halomobisdk.NativeActivity"/>
<activity android:name="com.halo.halomobisdk.NativeUnifiedActivity"/>
<activity android:name="com.halo.halomobisdk.RewardActivity"/> <activity android:name="com.halo.halomobisdk.RewardActivity"/>
<activity android:name="com.halomobi.sdk.RewardVideoActivity" <activity android:name="com.halomobi.sdk.RewardVideoActivity"
android:configChanges="orientation|screenSize|keyboardHidden"/> android:configChanges="orientation|screenSize|keyboardHidden"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.halo.halomobisdk package com.halo.halomobisdk
import android.content.Context
import android.graphics.Point
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.View import android.view.View
import android.view.WindowManager
import android.widget.Button
import android.widget.RelativeLayout
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.applovin.impl.wm
import com.halo.halojuhesdk.sdk.HlBannerAd
import com.halo.halojuhesdk.sdk.listener.HlBannerListener
import com.halomobi.halomobisdk.R import com.halomobi.halomobisdk.R
class BannerActivity : AppCompatActivity() { class BannerActivity : AppCompatActivity() {
private val TAG: String = "BannerActivity"
private var bannerContainer: RelativeLayout? = null
private var hlBannerAd: HlBannerAd? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_banner) setContentView(R.layout.activity_banner)
bannerContainer = findViewById(R.id.bannerContainer)
findViewById<Button>(R.id.load).setOnClickListener {
loadBannerAd()
}
findViewById<Button>(R.id.show).visibility = View.GONE
}
private fun loadBannerAd() {
hlBannerAd = HlBannerAd(this, "2931001", 300, 250, object : HlBannerListener {
override fun onDisplayAd(adType: String?) {
}
override fun onClickAd(adType: String?) {
}
override fun onCloseAd() {
}
override fun onAdReady(adType: String?) {
hlBannerAd?.showView(bannerContainer)
}
override fun onAdError(msg: String, code: Int) {
Log.e(TAG, "onAdError$msg$code")
Toast.makeText(this@BannerActivity, msg, Toast.LENGTH_SHORT).show()
}
})
hlBannerAd?.loadAd()
}
override fun onDestroy() {
super.onDestroy()
hlBannerAd?.release()
} }
} }
\ No newline at end of file
package com.halo.halomobisdk package com.halo.halomobisdk
import android.os.Bundle import android.os.Bundle
import android.widget.Button
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
...@@ -16,17 +17,17 @@ class InsertActivity : AppCompatActivity(){ ...@@ -16,17 +17,17 @@ class InsertActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_banner) setContentView(R.layout.activity_banner)
findViewById<TextView>(R.id.load).setOnClickListener { findViewById<Button>(R.id.load).setOnClickListener {
loadInsertAd() loadInsertAd()
} }
findViewById<TextView>(R.id.show).setOnClickListener { findViewById<Button>(R.id.show).setOnClickListener {
hlInsertAd?.show() hlInsertAd?.show()
} }
} }
private fun loadInsertAd() { private fun loadInsertAd() {
hlInsertAd = HlInsertAd(this, "2720709", object : hlInsertAd = HlInsertAd(this, "2931701", 480, 320, object :
HlInsertAdListener { HlInsertAdListener {
override fun onDisplayAd() { override fun onDisplayAd() {
} }
......
package com.halo.halomobisdk package com.halo.halomobisdk
import android.bluetooth.BluetoothDevice
import android.content.Intent import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.View import android.view.View
...@@ -21,7 +23,6 @@ class MainActivity : AppCompatActivity(), OnClickListener { ...@@ -21,7 +23,6 @@ class MainActivity : AppCompatActivity(), OnClickListener {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
// Initialize the AppLovin SDK // Initialize the AppLovin SDK
Thread {
val ifa: String? = getIfa() val ifa: String? = getIfa()
Log.e("11111", "===ifa===$ifa") Log.e("11111", "===ifa===$ifa")
val jsonObject = JSONObject() val jsonObject = JSONObject()
...@@ -32,8 +33,7 @@ class MainActivity : AppCompatActivity(), OnClickListener { ...@@ -32,8 +33,7 @@ class MainActivity : AppCompatActivity(), OnClickListener {
} catch (e: JSONException) { } catch (e: JSONException) {
e.printStackTrace() e.printStackTrace()
} }
HlAdClient.init(this, "27207",jsonObject.toString(), false, true) HlAdClient.init(this, "29317",jsonObject.toString(), false, true)
}.start()
val mTvSplash = findViewById<TextView>(R.id.tv_splash) val mTvSplash = findViewById<TextView>(R.id.tv_splash)
mTvSplash.setOnClickListener(this) mTvSplash.setOnClickListener(this)
val mTvBanner = findViewById<TextView>(R.id.tv_banner) val mTvBanner = findViewById<TextView>(R.id.tv_banner)
...@@ -42,11 +42,12 @@ class MainActivity : AppCompatActivity(), OnClickListener { ...@@ -42,11 +42,12 @@ class MainActivity : AppCompatActivity(), OnClickListener {
mTvInsert.setOnClickListener(this) mTvInsert.setOnClickListener(this)
val mTvNative = findViewById<TextView>(R.id.tv_native) val mTvNative = findViewById<TextView>(R.id.tv_native)
mTvNative.setOnClickListener(this) mTvNative.setOnClickListener(this)
val mTvUnifiedNative = findViewById<TextView>(R.id.tv_unified_native)
mTvUnifiedNative.setOnClickListener(this)
val mTvVideo = findViewById<TextView>(R.id.tv_video) val mTvVideo = findViewById<TextView>(R.id.tv_video)
mTvVideo.setOnClickListener(this) mTvVideo.setOnClickListener(this)
val mTvSelect = findViewById<TextView>(R.id.tv_select) val mTvSelect = findViewById<TextView>(R.id.tv_select)
mTvSelect.setOnClickListener(this) mTvSelect.setOnClickListener(this)
} }
override fun onClick(v: View) { override fun onClick(v: View) {
...@@ -63,6 +64,9 @@ class MainActivity : AppCompatActivity(), OnClickListener { ...@@ -63,6 +64,9 @@ class MainActivity : AppCompatActivity(), OnClickListener {
R.id.tv_native -> { R.id.tv_native -> {
startActivity(Intent(this, NativeActivity::class.java)) startActivity(Intent(this, NativeActivity::class.java))
} }
R.id.tv_unified_native -> {
startActivity(Intent(this, NativeUnifiedActivity::class.java))
}
R.id.tv_video -> { R.id.tv_video -> {
startActivity(Intent(this, RewardActivity::class.java)) startActivity(Intent(this, RewardActivity::class.java))
} }
......
...@@ -2,6 +2,7 @@ package com.halo.halomobisdk ...@@ -2,6 +2,7 @@ package com.halo.halomobisdk
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.widget.Button
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
...@@ -18,7 +19,7 @@ class NativeActivity : AppCompatActivity() { ...@@ -18,7 +19,7 @@ class NativeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_native) setContentView(R.layout.activity_native)
findViewById<TextView>(R.id.load).setOnClickListener { findViewById<Button>(R.id.load).setOnClickListener {
loadNativeAd() loadNativeAd()
} }
mConstraintLayout = findViewById(R.id.constraint) mConstraintLayout = findViewById(R.id.constraint)
...@@ -26,8 +27,8 @@ class NativeActivity : AppCompatActivity() { ...@@ -26,8 +27,8 @@ class NativeActivity : AppCompatActivity() {
} }
private fun loadNativeAd() { private fun loadNativeAd() {
hlNativeAd = HlNativeAd(this, "2686404", object : HlNativeAdListener { hlNativeAd = HlNativeAd(this, "2909703", 500, 500, 1, object : HlNativeAdListener {
override fun onADLoadView(view: View?, adTypeStr: String, ratio: Float) { override fun onADLoadView(view: View?, adTypeStr: String) {
mConstraintLayout?.removeAllViews() mConstraintLayout?.removeAllViews()
mConstraintLayout?.addView(view) mConstraintLayout?.addView(view)
val ecpmMap = hlNativeAd?.ecpmMap val ecpmMap = hlNativeAd?.ecpmMap
...@@ -54,4 +55,12 @@ class NativeActivity : AppCompatActivity() { ...@@ -54,4 +55,12 @@ class NativeActivity : AppCompatActivity() {
}) })
hlNativeAd?.loadData() hlNativeAd?.loadData()
} }
override fun onDestroy() {
super.onDestroy()
if (hlNativeAd != null) {
hlNativeAd?.release()
hlNativeAd = null
}
}
} }
\ No newline at end of file
...@@ -2,48 +2,59 @@ package com.halo.halomobisdk ...@@ -2,48 +2,59 @@ package com.halo.halomobisdk
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.widget.Button
import android.widget.RelativeLayout
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import com.applovin.mediation.nativeAds.MaxNativeAdView import com.applovin.mediation.nativeAds.MaxNativeAdView
import com.halo.halojuhesdk.sdk.HlNativeUnifiedAd import com.halo.halojuhesdk.sdk.HlNativeUnifiedAd
import com.halo.halojuhesdk.sdk.HlUnifiedAdParameter
import com.halo.halojuhesdk.sdk.listener.HlNativeAdListener
import com.halo.halojuhesdk.sdk.listener.HlNativeResponse import com.halo.halojuhesdk.sdk.listener.HlNativeResponse
import com.halo.halojuhesdk.sdk.listener.HlUnifiedNativeAdListener import com.halo.halojuhesdk.sdk.listener.HlUnifiedNativeAdListener
import com.halomobi.halomobisdk.R import com.halomobi.halomobisdk.R
class NativeUnifiedActivity : AppCompatActivity() { class NativeUnifiedActivity : AppCompatActivity() {
private var mConstraintLayout: RelativeLayout? = null
private var hlUnifiedNativeAd: HlNativeUnifiedAd? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_native) setContentView(R.layout.activity_untified_native)
val mConstraintLayout = findViewById<ConstraintLayout>(R.id.constraint) mConstraintLayout = findViewById(R.id.constraint)
findViewById<Button>(R.id.load).setOnClickListener {
// val hlNativeAd = HlNativeUnifiedAd(this, "2864604", object : HlUnifiedNativeAdListener { loadNativeAd()
// override fun onAdLoadSuccess(response: HlNativeResponse?) { }
// if (response != null) {
// val selfView =
// View.inflate(this@NativeUnifiedActivity, R.layout.item_unified_native, null)
//// val adView: MaxNativeAdView = createNativeAdView()
//
// // Check if ad is expired before rendering
//
// // Check if ad is expired before rendering
//// if (nativeAd.getNativeAd() != null && nativeAd.getNativeAd().isExpired()) {
//// // Destroy expired ad and load a new one
//// nativeAdLoader.destroy(nativeAd)
//// nativeAdLoader.loadAd()
//// showAdButton.setEnabled(false)
//// return
//// }
////
//// // Render the ad separately
////
//// // Render the ad separately
//// nativeAdLoader.render(adView, nativeAd)
//// nativeAdLayout.addView(adView)
// }
// }
// override fun onAdLoadFail(msg: String?, cod: Int) {
// }
// })
// hlNativeAd.loadData()
} }
private fun loadNativeAd() {
val builder = HlUnifiedAdParameter.Builder()
builder.setAdLayoutId(R.layout.item_unified_normal_layout)
.setAdContentId(R.id.media_view_container).setAdTitleId(R.id.tv_title).setAdBodyTitleId(R.id.tv_sub_title)
.setAdOptionsId(R.id.options_view)
hlUnifiedNativeAd = HlNativeUnifiedAd(this, "2909703", builder.build(), 300, 300, object : HlNativeAdListener {
override fun onADLoadView(view: View, adTypeStr: String) {
mConstraintLayout?.addView(view)
}
override fun onADClick(view: View?, adTypeStr: String) {
}
override fun onADShow(view: View?, adTypeStr: String) {
}
override fun onADClose(view: View?) {
mConstraintLayout?.removeView(view)
}
override fun onADError(errorMsg: String?, errorCode: Int) {
Toast.makeText(this@NativeUnifiedActivity, errorMsg, Toast.LENGTH_SHORT).show()
}
})
hlUnifiedNativeAd?.loadData()
}
} }
\ No newline at end of file
package com.halo.halomobisdk package com.halo.halomobisdk
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
...@@ -16,16 +18,16 @@ class RewardActivity : AppCompatActivity() { ...@@ -16,16 +18,16 @@ class RewardActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_reward) setContentView(R.layout.activity_reward)
findViewById<TextView>(R.id.load).setOnClickListener { findViewById<Button>(R.id.load).setOnClickListener {
loadRewardAd() loadRewardAd()
} }
findViewById<TextView>(R.id.show).setOnClickListener { findViewById<Button>(R.id.show).setOnClickListener {
hlVideoAd?.show() hlVideoAd?.show()
} }
} }
private fun loadRewardAd() { private fun loadRewardAd() {
hlVideoAd = HlVideoAd(this, "2686403", object : HlVideoListener { hlVideoAd = HlVideoAd(this, "2946704", object : HlVideoListener {
override fun onSuccess() { override fun onSuccess() {
Toast.makeText(this@RewardActivity, "==onSuccess===${hlVideoAd?.ecpm}", Toast.LENGTH_SHORT).show() Toast.makeText(this@RewardActivity, "==onSuccess===${hlVideoAd?.ecpm}", Toast.LENGTH_SHORT).show()
val ecpmMap = hlVideoAd?.ecpmMap val ecpmMap = hlVideoAd?.ecpmMap
...@@ -41,21 +43,28 @@ class RewardActivity : AppCompatActivity() { ...@@ -41,21 +43,28 @@ class RewardActivity : AppCompatActivity() {
} }
override fun onAdShow() { override fun onAdShow() {
Log.e("11111","====onAdShow===")
} }
override fun onAdClose() { override fun onAdClose() {
Log.e("11111","====onAdClose===")
} }
override fun onAdClick() { override fun onAdClick() {
} }
override fun onPlayEnd() { override fun onPlayEnd() {
Log.e("11111","====onPlayEnd===")
Toast.makeText(this@RewardActivity, "==onPlayEnd===", Toast.LENGTH_SHORT).show()
} }
override fun onSkipped() { override fun onSkipped() {
Log.e("11111","====onSkipped===")
} }
override fun onRewardArrived() { override fun onRewardArrived() {
Log.e("11111","====onRewardArrived===")
Toast.makeText(this@RewardActivity, "==onRewardArrived===", Toast.LENGTH_SHORT).show()
} }
}) })
hlVideoAd?.loadAd() hlVideoAd?.loadAd()
......
package com.halo.halomobisdk package com.halo.halomobisdk
import android.os.Bundle import android.os.Bundle
import android.widget.Button
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.halo.halojuhesdk.sdk.HlSplashAd import com.halo.halojuhesdk.sdk.HlSplashAd
import com.halo.halojuhesdk.sdk.listener.HlSplashAdListener import com.halo.halojuhesdk.sdk.listener.HlSplashAdListener
...@@ -15,17 +17,17 @@ class SplashActivity : AppCompatActivity(){ ...@@ -15,17 +17,17 @@ class SplashActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash) setContentView(R.layout.activity_splash)
findViewById<TextView>(R.id.load).setOnClickListener { findViewById<Button>(R.id.load).setOnClickListener {
loadInsertAd() loadInsertAd()
} }
findViewById<TextView>(R.id.show).setOnClickListener { findViewById<Button>(R.id.show).setOnClickListener {
hlSplashAd?.showAd() hlSplashAd?.showAd()
} }
} }
private fun loadInsertAd() { private fun loadInsertAd() {
hlSplashAd = HlSplashAd(this, "2686401", findViewById(R.id.constraint), object :HlSplashAdListener { hlSplashAd = HlSplashAd(this, "2720701", findViewById(R.id.constraint), object :HlSplashAdListener {
override fun onReadyAd(adTypeStr: String) { override fun onReadyAd(adTypeStr: String) {
val ecpmMap = hlSplashAd?.ecpmMap val ecpmMap = hlSplashAd?.ecpmMap
val jsonObject = JSONObject() val jsonObject = JSONObject()
...@@ -45,6 +47,7 @@ class SplashActivity : AppCompatActivity(){ ...@@ -45,6 +47,7 @@ class SplashActivity : AppCompatActivity(){
} }
override fun onAdError(msg: String?, code: Int) { override fun onAdError(msg: String?, code: Int) {
Toast.makeText(this@SplashActivity, msg, Toast.LENGTH_SHORT).show()
} }
override fun onAdSkip() { override fun onAdSkip() {
......
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView <Button
android:id="@+id/load" android:id="@+id/load"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="60dp"
android:text="加载" android:text="加载"
android:textSize="20dp" android:textSize="20dp"
android:gravity="center" android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent"/>
<TextView <Button
android:id="@+id/show" android:id="@+id/show"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="60dp"
android:text="展示" android:text="展示"
android:textSize="20dp" android:textSize="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
...@@ -30,4 +30,10 @@ ...@@ -30,4 +30,10 @@
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:textSize="20dp" android:textSize="20dp"
app:layout_constraintTop_toBottomOf="@id/show"/> app:layout_constraintTop_toBottomOf="@id/show"/>
<RelativeLayout
android:id="@+id/bannerContainer"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
android:layout_height="60dp" android:layout_height="60dp"
android:text="横幅" android:text="横幅"
android:gravity="center" android:gravity="center"
android:visibility="gone"
android:textSize="20sp" android:textSize="20sp"
android:textColor="@color/black" android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_splash"/> app:layout_constraintTop_toBottomOf="@id/tv_splash"/>
...@@ -45,6 +44,16 @@ ...@@ -45,6 +44,16 @@
android:textColor="@color/black" android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_insert"/> app:layout_constraintTop_toBottomOf="@id/tv_insert"/>
<TextView
android:id="@+id/tv_unified_native"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="自渲染信息流"
android:gravity="center"
android:textSize="20sp"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_native"/>
<TextView <TextView
android:id="@+id/tv_video" android:id="@+id/tv_video"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -53,7 +62,7 @@ ...@@ -53,7 +62,7 @@
android:gravity="center" android:gravity="center"
android:textSize="20sp" android:textSize="20sp"
android:textColor="@color/black" android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_native"/> app:layout_constraintTop_toBottomOf="@id/tv_unified_native"/>
<TextView <TextView
android:id="@+id/tv_select" android:id="@+id/tv_select"
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView <Button
android:id="@+id/load" android:id="@+id/load"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="60dp"
android:text="加载" android:text="加载"
android:textSize="20dp" android:textSize="20dp"
android:gravity="center" android:gravity="center"
......
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView <Button
android:id="@+id/load" android:id="@+id/load"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="60dp"
android:text="加载" android:text="加载"
android:textSize="20dp" android:textSize="20dp"
android:gravity="center" android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent"/>
<TextView <Button
android:id="@+id/show" android:id="@+id/show"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="60dp"
android:text="展示" android:text="展示"
android:textSize="20dp" android:textSize="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView <Button
android:id="@+id/load" android:id="@+id/load"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="40dp"
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
android:gravity="center" android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent"/>
<TextView <Button
android:id="@+id/show" android:id="@+id/show"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Button
android:id="@+id/load"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="加载"
android:textSize="20dp"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/price_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textSize="20dp"
app:layout_constraintTop_toBottomOf="@id/load"/>
<RelativeLayout
android:id="@+id/constraint"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="@id/price_show"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
>
<FrameLayout
android:id="@+id/media_view_container"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="30dp"
app:layout_constraintTop_toBottomOf="@id/media_view_container"/>
<TextView
android:id="@+id/tv_sub_title"
android:layout_width="match_parent"
android:layout_height="30dp"
app:layout_constraintTop_toBottomOf="@id/tv_title"/>
<FrameLayout
android:id="@+id/options_view"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</LinearLayout>
...@@ -6,32 +6,29 @@ buildscript { ...@@ -6,32 +6,29 @@ buildscript {
jcenter() jcenter()
mavenCentral() mavenCentral()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com'}
maven { url "https://maven.aliyun.com/repository/public" } maven { url "https://maven.aliyun.com/repository/public" }
maven { url 'https://repo1.maven.org/maven2/' } maven { url 'https://repo1.maven.org/maven2/' }
maven { url 'https://artifact.bytedance.com/repository/pangle' } maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" }
maven { url "https://artifact.bytedance.com/repository/pangle" }
} }
dependencies { dependencies {
classpath "com.android.tools.build:gradle:4.2.2" classpath "com.android.tools.build:gradle:7.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
} }
} }
//plugins {
// id "com.hi.dhl.plugin" apply false
//}
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
mavenCentral() mavenCentral()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com'}
maven { url "https://maven.aliyun.com/repository/public" } maven { url "https://maven.aliyun.com/repository/public" }
maven { url 'https://repo1.maven.org/maven2/' } maven { url 'https://repo1.maven.org/maven2/' }
maven { url 'https://artifact.bytedance.com/repository/pangle' } maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" }
maven { url "https://artifact.bytedance.com/repository/pangle" }
} }
} }
......
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
...@@ -5,12 +5,10 @@ android { ...@@ -5,12 +5,10 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 33 targetSdkVersion 33
versionCode 1000
versionName "1.0.0.0"
} }
def SDK_CHANNEL = "halomobi_juhe_sdk" def SDK_CHANNEL = "halomobi_juhe_sdk"
def SDK_VERSION = "1.0.0" def SDK_VERSION = "1.1.2"
def SDK_BASENAME = SDK_CHANNEL + "_v" + SDK_VERSION def SDK_BASENAME = SDK_CHANNEL + "_v" + SDK_VERSION
repositories { repositories {
...@@ -41,10 +39,17 @@ android { ...@@ -41,10 +39,17 @@ android {
} }
dependencies { dependencies {
implementation("androidx.appcompat:appcompat:1.4.1") implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.6.0") implementation("com.google.android.material:material:1.6.0")
implementation("com.applovin:applovin-sdk:12.0.0") implementation 'com.github.bumptech.glide:glide:4.16.0'
implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.6.7' implementation("com.applovin:applovin-sdk:13.0.1")
// implementation (name:'halomobi_sdk_v1.0.0',ext:'aar') implementation 'com.google.android.gms:play-services-ads-identifier:18.1.0'
implementation project(':haloMobiSdk') implementation 'com.google.android.gms:play-services-base:18.5.0'
implementation("com.google.android.gms:play-services-ads:23.3.0")
implementation 'com.applovin.mediation:google-adapter:23.5.0.0'
implementation 'com.applovin.mediation:mintegral-adapter:16.8.71.0'
implementation("com.applovin.mediation:bytedance-adapter:6.3.0.4.0")
implementation 'com.applovin.mediation:unityads-adapter:4.12.4.0'
implementation (name:'halomobi_sdk_v1.1.0',ext:'aar')
// implementation project(':haloMobiSdk')
} }
...@@ -20,5 +20,5 @@ ...@@ -20,5 +20,5 @@
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
-keep public class com.halomobi.sdk.**{*;} -keep public class com.halo.halojuhesdk.sdk.**{*;}
-keep public class com.halo.halojuhesdk.sdk.**{*;} -keep public class com.halomobi.**{*;}
\ No newline at end of file \ No newline at end of file
...@@ -14,7 +14,7 @@ public interface INativeProxyListener { ...@@ -14,7 +14,7 @@ public interface INativeProxyListener {
/** /**
* 广告被展示(主线程回调) * 广告被展示(主线程回调)
*/ */
void onADLoadView(View view, String adType, SlotBean slotBean, double ecpm, String adSubType,float ratio); void onADLoadView(View view, String adType, SlotBean slotBean, double ecpm, String adSubType);
/** /**
* 广告被点击(主线程回调) * 广告被点击(主线程回调)
......
...@@ -32,7 +32,7 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener { ...@@ -32,7 +32,7 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener {
private boolean isShow = true; private boolean isShow = true;
private boolean isClick = false; private boolean isClick = false;
private MaxAd mMaxAd; private MaxAd mMaxAd;
private boolean isAppLovinAd; private boolean isAdLoad;
public AppLovinBanner(Activity activity, SlotBean bean, IBannerProxyListener listener) { public AppLovinBanner(Activity activity, SlotBean bean, IBannerProxyListener listener) {
mActivity = activity; mActivity = activity;
...@@ -41,7 +41,7 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener { ...@@ -41,7 +41,7 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener {
Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max"); Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max");
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
try { try {
InitDataProcessor.initAppLovin(activity); InitDataProcessor.initAppLovin(activity, bean.extendStr);
HlAdClient.initSuccessMap.put("max", true); HlAdClient.initSuccessMap.put("max", true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -60,9 +60,12 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener { ...@@ -60,9 +60,12 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener {
@Override @Override
public void loadAd() { public void loadAd() {
isShow = true; if (adBannerView != null) {
isClick = false; isShow = true;
adBannerView.loadAd(); isClick = false;
isAdLoad = false;
adBannerView.loadAd();
}
} }
@Override @Override
...@@ -70,9 +73,8 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener { ...@@ -70,9 +73,8 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener {
LogUtils.e("====bannerShowAd==="); LogUtils.e("====bannerShowAd===");
if (adBannerView != null && viewGroup != null) { if (adBannerView != null && viewGroup != null) {
viewGroup.addView(adBannerView); viewGroup.addView(adBannerView);
if (isShow && mBannerListener != null && mMaxAd != null && isAppLovinAd) { if (isShow && mBannerListener != null && mMaxAd != null) {
isShow = false; isShow = false;
LogUtils.e("====bannerShow11111===");
mBannerListener.onDisplayAd(mLovinBean, mMaxAd.getNetworkName()); mBannerListener.onDisplayAd(mLovinBean, mMaxAd.getNetworkName());
} }
} }
...@@ -82,29 +84,23 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener { ...@@ -82,29 +84,23 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener {
public void onAdLoaded(MaxAd maxAd) { public void onAdLoaded(MaxAd maxAd) {
mMaxAd = maxAd; mMaxAd = maxAd;
double ecpm = maxAd.getRevenue()*1000; double ecpm = maxAd.getRevenue()*1000;
Log.e("11111","====bannerAdLoaded====" + ecpm + "====netWork===" + maxAd.getNetworkName());
mLovinBean.setEp(ecpm); mLovinBean.setEp(ecpm);
EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm); EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm);
mLovinBean.setOp(bean.getEcpm()); mLovinBean.setOp(bean.getEcpm());
if (bean.getResult()) { if (bean.getResult()) {
isAdLoad = true;
mBannerListener.onAdReady(mLovinBean, InitDataProcessor.SDK_MAX, bean.getEcpm(), maxAd.getNetworkName()); mBannerListener.onAdReady(mLovinBean, InitDataProcessor.SDK_MAX, bean.getEcpm(), maxAd.getNetworkName());
} else { } else {
isAdLoad = false;
mBannerListener.onAdError("applovin: 竞价失败", 102, InitDataProcessor.SDK_MAX, mLovinBean); mBannerListener.onAdError("applovin: 竞价失败", 102, InitDataProcessor.SDK_MAX, mLovinBean);
} }
} }
@Override @Override
public void onAdDisplayed(MaxAd maxAd) { public void onAdDisplayed(MaxAd maxAd) {
String networkName = maxAd.getNetworkName(); if (isShow && mBannerListener != null && isAdLoad) {
if ("AppLovin".equals(networkName) || "APPLOVIN_EXCHANGE".equals(networkName)) { isShow = false;
isAppLovinAd = true; mBannerListener.onDisplayAd(mLovinBean, mMaxAd.getNetworkName());
} else {
isAppLovinAd = false;
if (isShow && mBannerListener != null) {
isShow = false;
LogUtils.e("====bannerShow11111===");
mBannerListener.onDisplayAd(mLovinBean, mMaxAd.getNetworkName());
}
} }
} }
...@@ -125,7 +121,6 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener { ...@@ -125,7 +121,6 @@ public class AppLovinBanner implements IBannerAd, MaxAdViewAdListener {
@Override @Override
public void onAdLoadFailed(String s, MaxError maxError) { public void onAdLoadFailed(String s, MaxError maxError) {
Log.e("11111","====onAdLoadFailed====" + maxError.getMessage());
if (mBannerListener != null) { if (mBannerListener != null) {
mBannerListener.onAdError("lovin:error===" + maxError.getMessage(), maxError.getCode(), InitDataProcessor.SDK_MAX, mLovinBean); mBannerListener.onAdError("lovin:error===" + maxError.getMessage(), maxError.getCode(), InitDataProcessor.SDK_MAX, mLovinBean);
} }
......
...@@ -16,18 +16,20 @@ import com.halo.halojuhesdk.core.request.SlotBean; ...@@ -16,18 +16,20 @@ import com.halo.halojuhesdk.core.request.SlotBean;
import com.halo.halojuhesdk.sdk.HlAdClient; import com.halo.halojuhesdk.sdk.HlAdClient;
public class AppLovinInsert implements IInsertAd, MaxAdListener { public class AppLovinInsert implements IInsertAd, MaxAdListener {
private Activity mContext;
private MaxInterstitialAd interstitialAd; private MaxInterstitialAd interstitialAd;
private SlotBean mLovinBean; private SlotBean mLovinBean;
private IInsertProxyListener mInsertListener; private IInsertProxyListener mInsertListener;
private boolean isShow = true; private boolean isShow = true;
private boolean isClick = false; private boolean isClick = false;
public AppLovinInsert(Activity activity, SlotBean bean, IInsertProxyListener listener) { public AppLovinInsert(Activity activity, SlotBean bean, IInsertProxyListener listener) {
this.mInsertListener = listener; mContext = activity;
this.mLovinBean = bean; mInsertListener = listener;
mLovinBean = bean;
Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max"); Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max");
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
try { try {
InitDataProcessor.initAppLovin(activity); InitDataProcessor.initAppLovin(activity, bean.extendStr);
HlAdClient.initSuccessMap.put("max", true); HlAdClient.initSuccessMap.put("max", true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -40,14 +42,18 @@ public class AppLovinInsert implements IInsertAd, MaxAdListener { ...@@ -40,14 +42,18 @@ public class AppLovinInsert implements IInsertAd, MaxAdListener {
@Override @Override
public void loadAd() { public void loadAd() {
isShow = true; if (interstitialAd != null) {
isClick = false; isShow = true;
interstitialAd.loadAd(); isClick = false;
interstitialAd.loadAd();
}
} }
@Override @Override
public void showAd() { public void showAd() {
interstitialAd.showAd(); if (interstitialAd != null) {
interstitialAd.showAd();
}
} }
@Override @Override
...@@ -58,19 +64,13 @@ public class AppLovinInsert implements IInsertAd, MaxAdListener { ...@@ -58,19 +64,13 @@ public class AppLovinInsert implements IInsertAd, MaxAdListener {
@Override @Override
public void onAdLoaded(MaxAd maxAd) { public void onAdLoaded(MaxAd maxAd) {
double ecpm = maxAd.getRevenue()*1000; double ecpm = maxAd.getRevenue()*1000;
Log.e("11111","====onInsertAdLoaded====" + ecpm + "====" + maxAd.getNetworkName()); mLovinBean.setEp(ecpm);
String networkName = maxAd.getNetworkName(); EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm);
if ("AppLovin".equals(networkName) || "APPLOVIN_EXCHANGE".equals(networkName)) { mLovinBean.setOp(bean.getEcpm());
mInsertListener.onAdError("applovin: 竞价失败", 102, InitDataProcessor.SDK_MAX, mLovinBean); if (bean.getResult()) {
mInsertListener.onAdReady(mLovinBean, InitDataProcessor.SDK_MAX, bean.getEcpm());
} else { } else {
mLovinBean.setEp(ecpm); mInsertListener.onAdError("applovin: 竞价失败", 102, InitDataProcessor.SDK_MAX, mLovinBean);
EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm);
mLovinBean.setOp(bean.getEcpm());
if (bean.getResult()) {
mInsertListener.onAdReady(mLovinBean, InitDataProcessor.SDK_MAX, bean.getEcpm());
} else {
mInsertListener.onAdError("applovin: 竞价失败", 102, InitDataProcessor.SDK_MAX, mLovinBean);
}
} }
} }
......
...@@ -31,7 +31,7 @@ public class AppLovinNative extends MaxNativeAdListener implements INativeAd, Ma ...@@ -31,7 +31,7 @@ public class AppLovinNative extends MaxNativeAdListener implements INativeAd, Ma
public AppLovinNative(Activity activity, SlotBean bean, final INativeProxyListener listener) { public AppLovinNative(Activity activity, SlotBean bean, final INativeProxyListener listener) {
this.mNativeListener = listener; this.mNativeListener = listener;
this.mLovinBean = bean; this.mLovinBean = bean;
InitDataProcessor.initAppLovin(activity); InitDataProcessor.initAppLovin(activity, bean.extendStr);
mLovinBean.setStartTime(System.currentTimeMillis()); mLovinBean.setStartTime(System.currentTimeMillis());
nativeAdLoader = new MaxNativeAdLoader(bean.adSlotId, activity); nativeAdLoader = new MaxNativeAdLoader(bean.adSlotId, activity);
nativeAdLoader.setNativeAdListener(this); nativeAdLoader.setNativeAdListener(this);
...@@ -41,26 +41,31 @@ public class AppLovinNative extends MaxNativeAdListener implements INativeAd, Ma ...@@ -41,26 +41,31 @@ public class AppLovinNative extends MaxNativeAdListener implements INativeAd, Ma
@Override @Override
public void loadAd() { public void loadAd() {
nativeAdLoader.loadAd(); if (nativeAdLoader != null) {
nativeAdLoader.loadAd();
}
} }
@Override @Override
public void onNativeAdLoaded(@Nullable final MaxNativeAdView nativeAdView, final MaxAd ad) { public void onNativeAdLoaded(@Nullable final MaxNativeAdView nativeAdView, final MaxAd ad) {
mLovinBean.setEndTime(System.currentTimeMillis()); mLovinBean.setEndTime(System.currentTimeMillis());
if (ad != null) { if (ad != null && nativeAdView != null) {
double ecpm = ad.getRevenue()*1000; double ecpm = ad.getRevenue()*1000;
Log.e("11111","====onNativeAdLoaded====" + ecpm + "===type===" + ad.getNetworkName());
mLovinBean.setEp(ecpm); mLovinBean.setEp(ecpm);
mNativeView = nativeAdView; mNativeView = nativeAdView;
EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm); EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm);
mLovinBean.setOp(bean.getEcpm()); mLovinBean.setOp(bean.getEcpm());
if (bean.getResult()) { if (bean.getResult()) {
mNativeListener.onADLoadView(nativeAdView, InitDataProcessor.SDK_MAX, mLovinBean, bean.getEcpm(), ad.getNetworkName(),0f); mNativeListener.onADLoadView(nativeAdView, InitDataProcessor.SDK_MAX, mLovinBean, bean.getEcpm(), ad.getNetworkName());
} else { } else {
if (mNativeListener != null) { if (mNativeListener != null) {
mNativeListener.onADError("max:竞价失败" , 102, InitDataProcessor.SDK_MAX, mLovinBean); mNativeListener.onADError("max:竞价失败" , 102, InitDataProcessor.SDK_MAX, mLovinBean);
} }
} }
} else {
if (mNativeListener != null) {
mNativeListener.onADError("数据空值", 102, InitDataProcessor.SDK_MAX, mLovinBean);
}
} }
} }
......
...@@ -10,6 +10,7 @@ import com.applovin.mediation.MaxReward; ...@@ -10,6 +10,7 @@ import com.applovin.mediation.MaxReward;
import com.applovin.mediation.MaxRewardedAdListener; import com.applovin.mediation.MaxRewardedAdListener;
import com.applovin.mediation.ads.MaxRewardedAd; import com.applovin.mediation.ads.MaxRewardedAd;
import com.halo.halojuhesdk.core.base.utils.CompareEcpmUtils; import com.halo.halojuhesdk.core.base.utils.CompareEcpmUtils;
import com.halo.halojuhesdk.core.base.utils.LogUtils;
import com.halo.halojuhesdk.core.channel.IVideoProxyListener; import com.halo.halojuhesdk.core.channel.IVideoProxyListener;
import com.halo.halojuhesdk.core.channel.IVideoAd; import com.halo.halojuhesdk.core.channel.IVideoAd;
import com.halo.halojuhesdk.core.request.EcpmCompareBean; import com.halo.halojuhesdk.core.request.EcpmCompareBean;
...@@ -31,7 +32,7 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener { ...@@ -31,7 +32,7 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener {
Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max"); Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max");
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
try { try {
InitDataProcessor.initAppLovin(activity); InitDataProcessor.initAppLovin(activity, bean.extendStr);
HlAdClient.initSuccessMap.put("max", true); HlAdClient.initSuccessMap.put("max", true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -44,14 +45,18 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener { ...@@ -44,14 +45,18 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener {
@Override @Override
public void loadAd() { public void loadAd() {
isShow = true; if (rewardedAd != null) {
isClick = false; isShow = true;
rewardedAd.loadAd(); isClick = false;
rewardedAd.loadAd();
}
} }
@Override @Override
public void showAd() { public void showAd() {
rewardedAd.showAd(); if (rewardedAd != null) {
rewardedAd.showAd();
}
} }
@Override @Override
...@@ -61,20 +66,9 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener { ...@@ -61,20 +66,9 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener {
} }
} }
@Override
public void onRewardedVideoStarted(MaxAd maxAd) {
HlStatisManager.getInstance().reportStatic(mLovinBean, HlStatisManager.STEPNAME_REPORT, HlStatisManager.STEPNAME_REPORT_VIDEO_START, mLovinBean.getReqId());
}
@Override
public void onRewardedVideoCompleted(MaxAd maxAd) {
HlStatisManager.getInstance().reportStatic(mLovinBean, HlStatisManager.STEPNAME_REPORT, HlStatisManager.STEPNAME_REPORT_VIDEO_END, mLovinBean.getReqId());
}
@Override @Override
public void onAdLoaded(MaxAd maxAd) { public void onAdLoaded(MaxAd maxAd) {
double ecpm = maxAd.getRevenue()*1000; double ecpm = maxAd.getRevenue()*1000;
Log.e("11111","====videoEcpm===" + ecpm + "====type===" + maxAd.getNetworkName());
mLovinBean.setEp(ecpm); mLovinBean.setEp(ecpm);
EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm); EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm);
mLovinBean.setOp(bean.getEcpm()); mLovinBean.setOp(bean.getEcpm());
...@@ -114,6 +108,7 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener { ...@@ -114,6 +108,7 @@ public class AppLovinReward implements IVideoAd, MaxRewardedAdListener {
@Override @Override
public void onAdLoadFailed(String s, MaxError maxError) { public void onAdLoadFailed(String s, MaxError maxError) {
LogUtils.e("====onAdLoadFailed===" + maxError.getMessage());
if (mVideoListener != null) { if (mVideoListener != null) {
mVideoListener.onAdFailed("lovin:error===" + maxError.getMessage(), maxError.getCode(), InitDataProcessor.SDK_MAX, mLovinBean); mVideoListener.onAdFailed("lovin:error===" + maxError.getMessage(), maxError.getCode(), InitDataProcessor.SDK_MAX, mLovinBean);
} }
......
...@@ -30,8 +30,7 @@ public class AppLovinSplash implements ISplashAd, MaxAdListener { ...@@ -30,8 +30,7 @@ public class AppLovinSplash implements ISplashAd, MaxAdListener {
this.mLovinBean = bean; this.mLovinBean = bean;
isShow = true; isShow = true;
isClick = false; isClick = false;
LogUtils.e("====AppLovinSplash==="); InitDataProcessor.initAppLovin(activity, bean.extendStr);
InitDataProcessor.initAppLovin(activity);
mLovinBean.setStartTime(System.currentTimeMillis()); mLovinBean.setStartTime(System.currentTimeMillis());
appOpenAd = new MaxAppOpenAd(bean.adSlotId, activity); appOpenAd = new MaxAppOpenAd(bean.adSlotId, activity);
appOpenAd.setListener(this); appOpenAd.setListener(this);
...@@ -40,14 +39,15 @@ public class AppLovinSplash implements ISplashAd, MaxAdListener { ...@@ -40,14 +39,15 @@ public class AppLovinSplash implements ISplashAd, MaxAdListener {
@Override @Override
public void LoadAndShowAd() { public void LoadAndShowAd() {
appOpenAd.showAd(); if (appOpenAd != null) {
appOpenAd.showAd();
}
} }
@Override @Override
public void onAdLoaded(MaxAd maxAd) { public void onAdLoaded(MaxAd maxAd) {
mLovinBean.setEndTime(System.currentTimeMillis()); mLovinBean.setEndTime(System.currentTimeMillis());
double ecpm = maxAd.getRevenue()*1000; double ecpm = maxAd.getRevenue()*1000;
Log.e("11111","====onSplashAdLoaded====" + ecpm);
mLovinBean.setEp(ecpm); mLovinBean.setEp(ecpm);
EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm); EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm);
mLovinBean.setOp(bean.getEcpm()); mLovinBean.setOp(bean.getEcpm());
...@@ -88,7 +88,6 @@ public class AppLovinSplash implements ISplashAd, MaxAdListener { ...@@ -88,7 +88,6 @@ public class AppLovinSplash implements ISplashAd, MaxAdListener {
@Override @Override
public void onAdLoadFailed(String s, MaxError maxError) { public void onAdLoadFailed(String s, MaxError maxError) {
mLovinBean.setEndTime(System.currentTimeMillis()); mLovinBean.setEndTime(System.currentTimeMillis());
Log.e("11111","====onSplashAdLoadFailed====" + maxError.getMessage());
if (mListener != null) { if (mListener != null) {
mListener.onAdError("lovin:error===" + maxError.getMessage(), maxError.getCode(), InitDataProcessor.SDK_MAX, mLovinBean); mListener.onAdError("lovin:error===" + maxError.getMessage(), maxError.getCode(), InitDataProcessor.SDK_MAX, mLovinBean);
} }
......
...@@ -50,7 +50,7 @@ public class AppLovinUnifiedNative extends MaxNativeAdListener implements INativ ...@@ -50,7 +50,7 @@ public class AppLovinUnifiedNative extends MaxNativeAdListener implements INativ
Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max"); Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max");
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
try { try {
InitDataProcessor.initAppLovin(activity); InitDataProcessor.initAppLovin(activity, bean.extendStr);
HlAdClient.initSuccessMap.put("max", true); HlAdClient.initSuccessMap.put("max", true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -78,7 +78,7 @@ public class AppLovinUnifiedNative extends MaxNativeAdListener implements INativ ...@@ -78,7 +78,7 @@ public class AppLovinUnifiedNative extends MaxNativeAdListener implements INativ
@Override @Override
public void loadAd() { public void loadAd() {
if (nativeAdView != null) { if (nativeAdView != null && nativeAdLoader != null) {
nativeAdLoader.loadAd(nativeAdView); nativeAdLoader.loadAd(nativeAdView);
} }
} }
...@@ -89,28 +89,11 @@ public class AppLovinUnifiedNative extends MaxNativeAdListener implements INativ ...@@ -89,28 +89,11 @@ public class AppLovinUnifiedNative extends MaxNativeAdListener implements INativ
mMaxAd = maxAd; mMaxAd = maxAd;
mLovinBean.setEndTime(System.currentTimeMillis()); mLovinBean.setEndTime(System.currentTimeMillis());
double ecpm = maxAd.getRevenue()*1000; double ecpm = maxAd.getRevenue()*1000;
Log.e("11111", "====onUnifiedLoaded====" + maxAd.getNetworkName() + "===ecpm===" + ecpm);
float ratio=0.0f;
// if(nativeAdView!=null&&maxAd.getNativeAd()!=null){
// try{
// ratio=maxAd.getNativeAd().getMediaContentAspectRatio();
//// if(ratio>0){
//// Log.e("11111", "====ratio==== " +ratio+"---"+ (int) (PxUtil.getDeviceWidthInPixel(mActivity) /ratio));
//// Log.e("11111", "====ratio==== " + PxUtil.getDeviceWidthInPixel(mActivity));
//// ViewGroup.LayoutParams layoutParams=nativeAdView.getLayoutParams();
//// layoutParams.height= 200;
//// nativeAdView.setLayoutParams(layoutParams);
//// }
// }catch (Exception e){
// e.printStackTrace();
// }
// }
mLovinBean.setEp(ecpm); mLovinBean.setEp(ecpm);
EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm); EcpmCompareBean bean = CompareEcpmUtils.compareEcpm(mLovinBean, ecpm);
Log.e("11111", "===ecp1111m===" + bean.getEcpm());
mLovinBean.setOp(bean.getEcpm()); mLovinBean.setOp(bean.getEcpm());
if (bean.getResult()) { if (bean.getResult()) {
mNativeListener.onADLoadView(nativeAdView, InitDataProcessor.SDK_MAX, mLovinBean, bean.getEcpm(), maxAd.getNetworkName(),ratio); mNativeListener.onADLoadView(nativeAdView, InitDataProcessor.SDK_MAX, mLovinBean, bean.getEcpm(), maxAd.getNetworkName());
} else { } else {
if (mNativeListener != null) { if (mNativeListener != null) {
mNativeListener.onADError("max:竞价失败", 102, InitDataProcessor.SDK_MAX, mLovinBean); mNativeListener.onADError("max:竞价失败", 102, InitDataProcessor.SDK_MAX, mLovinBean);
......
...@@ -27,7 +27,7 @@ public class HlApiBannerAd implements IBannerAd, BannerListener { ...@@ -27,7 +27,7 @@ public class HlApiBannerAd implements IBannerAd, BannerListener {
private boolean isFirstShow = true; private boolean isFirstShow = true;
private boolean isFirstClick = false; private boolean isFirstClick = false;
public HlApiBannerAd(Activity context, SlotBean hlApiBean, IBannerProxyListener listener) { public HlApiBannerAd(Activity context, SlotBean hlApiBean, int width, int height, IBannerProxyListener listener) {
mContext = context; mContext = context;
Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId); Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId);
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
...@@ -43,8 +43,8 @@ public class HlApiBannerAd implements IBannerAd, BannerListener { ...@@ -43,8 +43,8 @@ public class HlApiBannerAd implements IBannerAd, BannerListener {
mApiBean.setStartTime(System.currentTimeMillis()); mApiBean.setStartTime(System.currentTimeMillis());
HlAdParameter adParameter = new HlAdParameter.Builder() HlAdParameter adParameter = new HlAdParameter.Builder()
.setSlotAdId(hlApiBean.slotId) .setSlotAdId(hlApiBean.slotId)
.setAdWidth(PxUtil.getDeviceWidthInPixel(context)) .setAdWidth(width)
.setAdHeight(PxUtil.dpToPx(context, 50)) .setAdHeight(height)
.build(); .build();
hmBannerAd = new HMBannerAd(mContext, adParameter, this); hmBannerAd = new HMBannerAd(mContext, adParameter, this);
HlAdClient.containApiMap.put(mApiBean.slotId, true); HlAdClient.containApiMap.put(mApiBean.slotId, true);
...@@ -52,12 +52,16 @@ public class HlApiBannerAd implements IBannerAd, BannerListener { ...@@ -52,12 +52,16 @@ public class HlApiBannerAd implements IBannerAd, BannerListener {
@Override @Override
public void loadAd() { public void loadAd() {
hmBannerAd.loadAd(); if (hmBannerAd != null) {
hmBannerAd.loadAd();
}
} }
@Override @Override
public void showAd(ViewGroup viewGroup) { public void showAd(ViewGroup viewGroup) {
hmBannerAd.showView(viewGroup); if (hmBannerAd != null && viewGroup != null) {
hmBannerAd.showView(viewGroup);
}
} }
@Override @Override
......
...@@ -5,20 +5,20 @@ import android.app.Activity; ...@@ -5,20 +5,20 @@ import android.app.Activity;
import com.halo.halojuhesdk.core.channel.IInsertAd; import com.halo.halojuhesdk.core.channel.IInsertAd;
import com.halo.halojuhesdk.core.channel.IInsertProxyListener; import com.halo.halojuhesdk.core.channel.IInsertProxyListener;
import com.halo.halojuhesdk.core.common.utils.Config; import com.halo.halojuhesdk.core.common.utils.Config;
import com.halo.halojuhesdk.core.common.utils.PxUtil;
import com.halo.halojuhesdk.core.request.InitDataProcessor; import com.halo.halojuhesdk.core.request.InitDataProcessor;
import com.halo.halojuhesdk.core.request.SlotBean; import com.halo.halojuhesdk.core.request.SlotBean;
import com.halo.halojuhesdk.sdk.HlAdClient; import com.halo.halojuhesdk.sdk.HlAdClient;
import com.halomobi.sdk.HMInsertAd; import com.halomobi.sdk.HMInsertAd;
import com.halomobi.sdk.HlAdParameter; import com.halomobi.sdk.HlAdParameter;
import com.halomobi.sdk.listener.InsertListener; import com.halomobi.sdk.listener.InsertListener;
import com.halomobi.utils.PxUtil;
public class HlApiInsertAd implements IInsertAd, InsertListener { public class HlApiInsertAd implements IInsertAd, InsertListener {
private final SlotBean mApiBean; private final SlotBean mApiBean;
private final IInsertProxyListener mListener; private final IInsertProxyListener mListener;
private HMInsertAd insertAd; private HMInsertAd insertAd;
public HlApiInsertAd(Activity context, SlotBean apiBean, IInsertProxyListener listener) { public HlApiInsertAd(Activity context, SlotBean apiBean, int width, int height, IInsertProxyListener listener) {
Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId); Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId);
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
try { try {
...@@ -33,8 +33,8 @@ public class HlApiInsertAd implements IInsertAd, InsertListener { ...@@ -33,8 +33,8 @@ public class HlApiInsertAd implements IInsertAd, InsertListener {
mApiBean.setStartTime(System.currentTimeMillis()); mApiBean.setStartTime(System.currentTimeMillis());
HlAdParameter adParameter = new HlAdParameter.Builder() HlAdParameter adParameter = new HlAdParameter.Builder()
.setSlotAdId(apiBean.slotId) .setSlotAdId(apiBean.slotId)
// .setAdWidth(PxUtil.dpToPx(context, 260)) .setAdWidth(width)
// .setAdHeight(PxUtil.dpToPx(context, 400)) .setAdHeight(height)
.build(); .build();
insertAd = new HMInsertAd(context, adParameter, this); insertAd = new HMInsertAd(context, adParameter, this);
HlAdClient.containApiMap.put(apiBean.slotId, true); HlAdClient.containApiMap.put(apiBean.slotId, true);
...@@ -42,19 +42,15 @@ public class HlApiInsertAd implements IInsertAd, InsertListener { ...@@ -42,19 +42,15 @@ public class HlApiInsertAd implements IInsertAd, InsertListener {
@Override @Override
public void loadAd() { public void loadAd() {
try { if (insertAd != null) {
insertAd.loadAd(); insertAd.loadAd();
} catch (Exception e) {
e.getStackTrace();
} }
} }
@Override @Override
public void showAd() { public void showAd() {
try { if (insertAd != null) {
insertAd.showAd(); insertAd.showAd();
} catch (Exception e) {
e.getStackTrace();
} }
} }
......
...@@ -6,6 +6,7 @@ import android.view.ViewGroup; ...@@ -6,6 +6,7 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.halo.halojuhesdk.core.base.utils.LogUtils; import com.halo.halojuhesdk.core.base.utils.LogUtils;
import com.halo.halojuhesdk.core.channel.INativeAd; import com.halo.halojuhesdk.core.channel.INativeAd;
import com.halo.halojuhesdk.core.channel.INativeProxyListener; import com.halo.halojuhesdk.core.channel.INativeProxyListener;
...@@ -18,7 +19,6 @@ import com.halomobi.sdk.HMNativeAd; ...@@ -18,7 +19,6 @@ import com.halomobi.sdk.HMNativeAd;
import com.halomobi.sdk.HlAdParameter; import com.halomobi.sdk.HlAdParameter;
import com.halomobi.sdk.listener.NativeAdListener; import com.halomobi.sdk.listener.NativeAdListener;
import com.halomobi.sdk.listener.NativeResponse; import com.halomobi.sdk.listener.NativeResponse;
import com.halomobi.view.imageloader.ImageLoader;
import java.util.List; import java.util.List;
...@@ -33,7 +33,7 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener { ...@@ -33,7 +33,7 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener {
private boolean isShow = true; private boolean isShow = true;
private boolean isClick = false; private boolean isClick = false;
public HlApiNativeAd(Activity mActivity, SlotBean apiBean, HlUnifiedAdParameter parameter, INativeProxyListener listener) { public HlApiNativeAd(Activity mActivity, SlotBean apiBean, HlUnifiedAdParameter parameter, int width, int height, int type, INativeProxyListener listener) {
mContext = mActivity; mContext = mActivity;
Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId); Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId);
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
...@@ -50,13 +50,18 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener { ...@@ -50,13 +50,18 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener {
mApiBean.setStartTime(System.currentTimeMillis()); mApiBean.setStartTime(System.currentTimeMillis());
HlAdParameter adParameter = new HlAdParameter.Builder() HlAdParameter adParameter = new HlAdParameter.Builder()
.setSlotAdId(apiBean.slotId) .setSlotAdId(apiBean.slotId)
.setAdWidth(width)
.setAdHeight(height)
.setAdType(type)
.build(); .build();
nativeAd = new HMNativeAd(mActivity, adParameter, this); nativeAd = new HMNativeAd(mActivity, adParameter, this);
HlAdClient.containApiMap.put(apiBean.slotId, true); HlAdClient.containApiMap.put(apiBean.slotId, true);
} }
public void loadAd() { public void loadAd() {
nativeAd.loadAd(); if (nativeAd != null) {
nativeAd.loadAd();
}
} }
@Override @Override
...@@ -64,15 +69,13 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener { ...@@ -64,15 +69,13 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener {
mNativeView = view; mNativeView = view;
mApiBean.setEndTime(System.currentTimeMillis()); mApiBean.setEndTime(System.currentTimeMillis());
if (response != null && view != null) { if (response != null && view != null) {
View insertView = insertView(response);
double ecpm = response.getPrice(); double ecpm = response.getPrice();
LogUtils.e("===apiPrice===" + ecpm);
mApiBean.setOp(ecpm); mApiBean.setOp(ecpm);
mApiBean.setEp(ecpm); mApiBean.setEp(ecpm);
if (ecpm < mApiBean.minPrice && ecpm > 0) { if (ecpm < mApiBean.minPrice && ecpm > 0) {
mListener.onADError("apiSplash:价格低", 102, InitDataProcessor.SDK_API, mApiBean); mListener.onADError("apiSplash:价格低", 102, InitDataProcessor.SDK_API, mApiBean);
} else { } else {
mListener.onADLoadView(insertView, InitDataProcessor.SDK_API, mApiBean, ecpm, "api",0f); mListener.onADLoadView(mNativeView, InitDataProcessor.SDK_API, mApiBean, ecpm, "api");
} }
} }
} }
...@@ -107,30 +110,4 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener { ...@@ -107,30 +110,4 @@ public class HlApiNativeAd implements INativeAd, NativeAdListener {
@Override @Override
public void release() { public void release() {
} }
private View insertView(NativeResponse response) {
int adTitleId = mParameter.getAdTitleId();
int adSubTitleId = mParameter.getAdBodyTitleId();
int adContentId = mParameter.getAdContentId();
View inflate = View.inflate(mContext, mParameter.getAdLayoutId(), null);
if (adTitleId > 0) {
TextView mTitleAd = inflate.findViewById(adTitleId);
mTitleAd.setText(response.getTitle());
}
if (adSubTitleId > 0) {
TextView mSubTitle = inflate.findViewById(adSubTitleId);
mSubTitle.setText(response.getAdDescription());
}
ImageView imageView = new ImageView(mContext);
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
List<String> imgList = response.getImgList();
if (imgList != null && !imgList.isEmpty()) {
ImageLoader.load(imageView, imgList.get(0));
}
if (adContentId > 0) {
ViewGroup mAdContentId = inflate.findViewById(adContentId);
mAdContentId.addView(imageView);
}
return inflate;
}
} }
...@@ -44,14 +44,16 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener { ...@@ -44,14 +44,16 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener {
public void loadAd() { public void loadAd() {
isClick = false; isClick = false;
isShow = true; isShow = true;
mHmRewardVideoAd.loadAd(); if (mHmRewardVideoAd != null) {
mHmRewardVideoAd.loadAd();
}
} }
@Override @Override
public void showAd() { public void showAd() {
// if (mHmRewardVideoAd.isReady()) { if (mHmRewardVideoAd != null) {
mHmRewardVideoAd.showAd(); mHmRewardVideoAd.showAd();
// } }
} }
@Override @Override
...@@ -77,7 +79,7 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener { ...@@ -77,7 +79,7 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener {
public void onAdShow() { public void onAdShow() {
if (isShow) { if (isShow) {
isShow = false; isShow = false;
// mListener.onAdShow(mApiBean); mListener.onAdShow(mApiBean);
} }
} }
...@@ -86,6 +88,11 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener { ...@@ -86,6 +88,11 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener {
mListener.onAdClose(); mListener.onAdClose();
} }
@Override
public void onAdSkip() {
mListener.onSkipped();
}
@Override @Override
public void onAdClick() { public void onAdClick() {
if (!isClick) { if (!isClick) {
...@@ -94,11 +101,18 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener { ...@@ -94,11 +101,18 @@ public class HlApiRewardVideo implements IVideoAd, RewardVideoListener {
} }
} }
@Override @Override
public void onPlayEnd() { public void onPlayEnd() {
mListener.onPlayEnd(); mListener.onPlayEnd();
} }
@Override
public void onRewardArrived() {
mListener.onRewardArrived();
}
public void onDestroy() { public void onDestroy() {
if (mHmRewardVideoAd != null) { if (mHmRewardVideoAd != null) {
mHmRewardVideoAd = null; mHmRewardVideoAd = null;
......
package com.halo.halojuhesdk.core.channel.hlapi; package com.halo.halojuhesdk.core.channel.hlapi;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.halo.halojuhesdk.core.base.utils.LogUtils; import com.halo.halojuhesdk.core.base.utils.LogUtils;
import com.halo.halojuhesdk.core.channel.INativeAd; import com.halo.halojuhesdk.core.channel.INativeAd;
import com.halo.halojuhesdk.core.channel.INativeProxyListener; import com.halo.halojuhesdk.core.channel.INativeProxyListener;
import com.halo.halojuhesdk.core.channel.IUnifiedNativeAd;
import com.halo.halojuhesdk.core.channel.IUnifiedNativeProxyListener;
import com.halo.halojuhesdk.core.common.utils.Config; import com.halo.halojuhesdk.core.common.utils.Config;
import com.halo.halojuhesdk.core.request.InitDataProcessor; import com.halo.halojuhesdk.core.request.InitDataProcessor;
import com.halo.halojuhesdk.core.request.SlotBean; import com.halo.halojuhesdk.core.request.SlotBean;
import com.halo.halojuhesdk.sdk.HlAdClient; import com.halo.halojuhesdk.sdk.HlAdClient;
import com.halo.halojuhesdk.sdk.HlUnifiedAdParameter; import com.halo.halojuhesdk.sdk.HlUnifiedAdParameter;
import com.halo.halojuhesdk.sdk.listener.HlNativeAdCallBackListener;
import com.halo.halojuhesdk.sdk.listener.HlNativeResponseImpl;
import com.halomobi.sdk.HMUnifiedNativeAd; import com.halomobi.sdk.HMUnifiedNativeAd;
import com.halomobi.sdk.HlAdParameter; import com.halomobi.sdk.HlAdParameter;
import com.halomobi.sdk.listener.NativeAdListener; import com.halomobi.sdk.listener.NativeAdListener;
import com.halomobi.sdk.listener.NativeResponse; import com.halomobi.sdk.listener.NativeResponse;
import com.halomobi.sdk.listener.NativeUnifiedBackAdListener;
import com.halomobi.sdk.listener.NativeUnifiedListener;
import com.halomobi.view.imageloader.ImageLoader;
import java.util.List;
public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener { public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener {
private boolean isShow = true; private boolean isShow = true;
...@@ -42,7 +26,7 @@ public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener { ...@@ -42,7 +26,7 @@ public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener {
private final HlUnifiedAdParameter mParameter; private final HlUnifiedAdParameter mParameter;
private View mNativeView; private View mNativeView;
public HlApiUnifiedNativeAd(Activity mActivity, SlotBean apiBean, HlUnifiedAdParameter parameter, INativeProxyListener listener) { public HlApiUnifiedNativeAd(Activity mActivity, SlotBean apiBean, HlUnifiedAdParameter parameter, int width, int height, INativeProxyListener listener) {
Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId); Boolean isInitSuccess = HlAdClient.initSuccessMap.get(Config.mAppId);
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
try { try {
...@@ -59,13 +43,17 @@ public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener { ...@@ -59,13 +43,17 @@ public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener {
mApiBean.setStartTime(System.currentTimeMillis()); mApiBean.setStartTime(System.currentTimeMillis());
HlAdParameter adParameter = new HlAdParameter.Builder() HlAdParameter adParameter = new HlAdParameter.Builder()
.setSlotAdId(apiBean.slotId) .setSlotAdId(apiBean.slotId)
.setAdWidth(width)
.setAdHeight(height)
.build(); .build();
nativeAd = new HMUnifiedNativeAd(mActivity, adParameter, this); nativeAd = new HMUnifiedNativeAd(mActivity, adParameter, this);
HlAdClient.containApiMap.put(apiBean.slotId, true); HlAdClient.containApiMap.put(apiBean.slotId, true);
} }
public void loadAd(){ public void loadAd(){
nativeAd.loadAd(); if (nativeAd != null) {
nativeAd.loadAd();
}
} }
@Override @Override
...@@ -79,8 +67,8 @@ public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener { ...@@ -79,8 +67,8 @@ public class HlApiUnifiedNativeAd implements INativeAd, NativeAdListener {
if (ecpm < mApiBean.minPrice && ecpm > 0) { if (ecpm < mApiBean.minPrice && ecpm > 0) {
mListener.onADError("apiSplash:价格低", 102, InitDataProcessor.SDK_API, mApiBean); mListener.onADError("apiSplash:价格低", 102, InitDataProcessor.SDK_API, mApiBean);
} else { } else {
mNativeView = nativeAd.showViewById(mParameter.getAdLayoutId(), mParameter.getAdContentId(), mParameter.getAdTitleId(), mParameter.getAdBodyTitleId()); mNativeView = nativeAd.showViewById(mParameter.getAdLayoutId(), mParameter.getAdContentId(), mParameter.getAdTitleId(), mParameter.getAdBodyTitleId(), mParameter.getAdOptionsId());
mListener.onADLoadView(mNativeView, InitDataProcessor.SDK_API, mApiBean, ecpm, "api",0f); mListener.onADLoadView(mNativeView, InitDataProcessor.SDK_API, mApiBean, ecpm, "api");
} }
} }
} }
......
...@@ -45,7 +45,7 @@ public class HttpUrlSettings { ...@@ -45,7 +45,7 @@ public class HttpUrlSettings {
* @return * @return
*/ */
public static String getReportApiStartUrl(String reqId) { public static String getReportApiStartUrl(String reqId) {
String str = getHost() + "ssp/sdkReportStat?req=0&sdk=147" + "&adid=" + HlStatisManager.getInstance().getConfigReqId() + "&reqId=" + reqId; String str = getHost() + "ssp/sdkReportStat?req=0&sdk=100" + "&adid=" + HlStatisManager.getInstance().getConfigReqId() + "&reqId=" + reqId;
// LogUtils.e("====getReportApiStartUrl====" + str); // LogUtils.e("====getReportApiStartUrl====" + str);
return str; return str;
} }
......
...@@ -9,6 +9,7 @@ import androidx.annotation.Nullable; ...@@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
import com.applovin.sdk.AppLovinMediationProvider; import com.applovin.sdk.AppLovinMediationProvider;
import com.applovin.sdk.AppLovinSdk; import com.applovin.sdk.AppLovinSdk;
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
import com.applovin.sdk.AppLovinSdkSettings; import com.applovin.sdk.AppLovinSdkSettings;
import com.halo.halojuhesdk.core.base.net.AbstractNetProcessor; import com.halo.halojuhesdk.core.base.net.AbstractNetProcessor;
import com.halo.halojuhesdk.core.base.net.AbstractNetTask; import com.halo.halojuhesdk.core.base.net.AbstractNetTask;
...@@ -20,7 +21,6 @@ import com.halo.halojuhesdk.core.common.utils.Config; ...@@ -20,7 +21,6 @@ import com.halo.halojuhesdk.core.common.utils.Config;
import com.halo.halojuhesdk.core.common.utils.MyUtils; import com.halo.halojuhesdk.core.common.utils.MyUtils;
import com.halo.halojuhesdk.sdk.HlAdClient; import com.halo.halojuhesdk.sdk.HlAdClient;
import com.halomobi.sdk.HaloAdSdk; import com.halomobi.sdk.HaloAdSdk;
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
...@@ -28,8 +28,6 @@ import org.json.JSONObject; ...@@ -28,8 +28,6 @@ import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.logging.Logger;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
/** /**
...@@ -46,6 +44,7 @@ public class InitDataProcessor extends AbstractNetProcessor { ...@@ -46,6 +44,7 @@ public class InitDataProcessor extends AbstractNetProcessor {
private static boolean mMaxInit; private static boolean mMaxInit;
private static Context mContext; private static Context mContext;
private static double bidfloor; private static double bidfloor;
private static String mMaxKey;
public InitDataProcessor(Context context,String appId) { public InitDataProcessor(Context context,String appId) {
HlStatisManager.getInstance().cConfigRequestid(); HlStatisManager.getInstance().cConfigRequestid();
...@@ -62,14 +61,12 @@ public class InitDataProcessor extends AbstractNetProcessor { ...@@ -62,14 +61,12 @@ public class InitDataProcessor extends AbstractNetProcessor {
public void finish(int code, String content) { public void finish(int code, String content) {
if (code == HttpsURLConnection.HTTP_OK) { if (code == HttpsURLConnection.HTTP_OK) {
try { try {
LogUtils.e("====finish===" + content); // LogUtils.e("====finish===" + content);
judgeCode(content); judgeCode(content);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
reportSensorsData(0, code, content);
} else { } else {
reportSensorsData(1, code, content);
addFailSp(); addFailSp();
} }
} }
...@@ -102,7 +99,6 @@ public class InitDataProcessor extends AbstractNetProcessor { ...@@ -102,7 +99,6 @@ public class InitDataProcessor extends AbstractNetProcessor {
if (code != -1) { if (code != -1) {
addFailSp(); addFailSp();
} }
reportSensorsData(1, code, content);
} }
//失败增加到sp中. //失败增加到sp中.
...@@ -232,7 +228,7 @@ public class InitDataProcessor extends AbstractNetProcessor { ...@@ -232,7 +228,7 @@ public class InitDataProcessor extends AbstractNetProcessor {
private static void initSlot() { private static void initSlot() {
if (mMaxInit) { if (mMaxInit) {
initAppLovin(mContext); initAppLovin(mContext, mMaxKey);
} }
} }
...@@ -259,6 +255,7 @@ public class InitDataProcessor extends AbstractNetProcessor { ...@@ -259,6 +255,7 @@ public class InitDataProcessor extends AbstractNetProcessor {
if (!adFrom.contains("sdk")) { if (!adFrom.contains("sdk")) {
mApiAppId = Config.mAppId; mApiAppId = Config.mAppId;
} else if (adFrom.contains(SDK_MAX)) { } else if (adFrom.contains(SDK_MAX)) {
mMaxKey = extendStr;
mMaxInit = true; mMaxInit = true;
} }
slotBean.setSlotId(slotId); slotBean.setSlotId(slotId);
...@@ -285,40 +282,24 @@ public class InitDataProcessor extends AbstractNetProcessor { ...@@ -285,40 +282,24 @@ public class InitDataProcessor extends AbstractNetProcessor {
} }
public static void initAppLovin(Context context) { public static void initAppLovin(Context context, String appKey) {
if (TextUtils.isEmpty(appKey)) {
appKey = "IMXfnKH7kVTokP4lhli1GS0pDHgZVouBSVkbRiUqHuDbbV1Ioh6xB3EW9GOGQOnbN2P4FPAtOpNqpPNO_nK8yF";
}
Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max"); Boolean isInitSuccess = HlAdClient.initSuccessMap.get("max");
if (isInitSuccess == null || !isInitSuccess) { if (isInitSuccess == null || !isInitSuccess) {
AppLovinSdkSettings sdkSettings = new AppLovinSdkSettings(context);
sdkSettings.setLocationCollectionEnabled(false);
AppLovinSdk instance = AppLovinSdk.getInstance(context); AppLovinSdk instance = AppLovinSdk.getInstance(context);
instance.getSettings().setMuted(true); instance.getSettings().setMuted(true);
instance.setMediationProvider(AppLovinMediationProvider.MAX); AppLovinSdkInitializationConfiguration.Builder initConfigBuilder = AppLovinSdkInitializationConfiguration.builder(appKey, context);
instance.initializeSdk( config -> { initConfigBuilder.setMediationProvider(AppLovinMediationProvider.MAX);
AppLovinSdk.getInstance(context).initialize( initConfigBuilder.build(), appLovinSdkConfiguration -> {
Log.e("11111","====initializeSdk===="); Log.e("11111","====initializeSdk====");
HlAdClient.initSuccessMap.put("max", true); HlAdClient.initSuccessMap.put("max", true);
} ); });
} }
} }
public static void initApi(Context context) { public static void initApi(Context context) {
HaloAdSdk.init(context, Config.mAppId, HlAdClient.mConfigInfo); HaloAdSdk.init(context, Config.mAppId, HlAdClient.mConfigInfo);
} }
private void reportSensorsData(int type, int code, String content) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("errorCode", code);
jsonObject.put("msgContent", content);
String eventIdStr = "";
if (type == 0) {
eventIdStr = "sdk_juhe_config_success";
} else if (type == 1){
eventIdStr = "sdk_juhe_config_error";
}
LogUtils.e("===reportConfigSensor===" + jsonObject);
SensorsDataAPI.sharedInstance().track(eventIdStr, jsonObject);
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
} }
...@@ -36,7 +36,7 @@ public class InitDataTask extends AbstractNetTask { ...@@ -36,7 +36,7 @@ public class InitDataTask extends AbstractNetTask {
+ mAppId + "&sdk=" + SDK_VERSION + mAppId + "&sdk=" + SDK_VERSION
+ "&versionCode=" + SystemUtils.getAppVer() + "&versionCode=" + SystemUtils.getAppVer()
+ "&adid=" + HlStatisManager.getInstance().getConfigReqId(); + "&adid=" + HlStatisManager.getInstance().getConfigReqId();
LogUtils.e("===1111====" + urlStr); // LogUtils.e("===1111====" + urlStr);
return urlStr; return urlStr;
} }
......
...@@ -6,12 +6,6 @@ import android.util.Log; ...@@ -6,12 +6,6 @@ import android.util.Log;
import com.halo.halojuhesdk.core.base.net.AbstractNetProcessor; import com.halo.halojuhesdk.core.base.net.AbstractNetProcessor;
import com.halo.halojuhesdk.core.base.net.AbstractNetTask; import com.halo.halojuhesdk.core.base.net.AbstractNetTask;
import com.halo.halojuhesdk.core.base.utils.LogUtils; import com.halo.halojuhesdk.core.base.utils.LogUtils;
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
/** /**
...@@ -38,7 +32,6 @@ public class StatProcessor extends AbstractNetProcessor { ...@@ -38,7 +32,6 @@ public class StatProcessor extends AbstractNetProcessor {
public void finish(int code, String content) { public void finish(int code, String content) {
if (code == HttpsURLConnection.HTTP_OK) { if (code == HttpsURLConnection.HTTP_OK) {
LogUtils.e("==StatProcessor===" + mPostjson); LogUtils.e("==StatProcessor===" + mPostjson);
reportSensorsData(0, code, content);
} }
} }
...@@ -46,30 +39,5 @@ public class StatProcessor extends AbstractNetProcessor { ...@@ -46,30 +39,5 @@ public class StatProcessor extends AbstractNetProcessor {
public void onError(int code, String content) { public void onError(int code, String content) {
//根据code 判断是否需要增加失败次数 //根据code 判断是否需要增加失败次数
Log.e("==StatProcessorError===", "code: " + code + " content: " + content); Log.e("==StatProcessorError===", "code: " + code + " content: " + content);
reportSensorsData(1, code, content);
}
private void reportSensorsData(int type, int code, String content) {
JSONObject jsonObject = new JSONObject();
try {
JSONArray jsonArray = new JSONArray(mPostjson);
if (jsonArray.length() > 0) {
String slotId = jsonArray.getJSONObject(0).optString("slotId");
jsonObject.put("slotId", slotId);
}
jsonObject.put("errorCode", code);
jsonObject.put("msgContent", content);
jsonObject.put("postJson", mPostjson);
String eventIdStr = "";
if (type == 0) {
eventIdStr = "sdk_juhe_request_success";
} else if (type == 1){
eventIdStr = "sdk_juhe_request_error";
}
LogUtils.e("===reportSensor===" + jsonObject);
SensorsDataAPI.sharedInstance().track(eventIdStr, jsonObject);
} catch (JSONException e) {
throw new RuntimeException(e);
}
} }
} }
...@@ -34,10 +34,10 @@ public class StatTask extends AbstractNetTask { ...@@ -34,10 +34,10 @@ public class StatTask extends AbstractNetTask {
@Override @Override
public String getURL() { public String getURL() {
if (isContainApiAd()) { if (isContainApiAd()) {
Log.e("11111","====getReportApiStartUrl====" + HttpUrlSettings.getReportApiStartUrl(mReqId)); // Log.e("11111","====getReportApiStartUrl====" + HttpUrlSettings.getReportApiStartUrl(mReqId));
return HttpUrlSettings.getReportApiStartUrl(mReqId); return HttpUrlSettings.getReportApiStartUrl(mReqId);
} }
Log.e("11111","====getReportStartUrl====" + mReqId); // Log.e("11111","====getReportStartUrl====" + mReqId);
return HttpUrlSettings.getReportStartUrl(mReqId); return HttpUrlSettings.getReportStartUrl(mReqId);
} }
......
...@@ -4,11 +4,6 @@ package com.halo.halojuhesdk.core.request; ...@@ -4,11 +4,6 @@ package com.halo.halojuhesdk.core.request;
import com.halo.halojuhesdk.core.base.net.AbstractNetProcessor; import com.halo.halojuhesdk.core.base.net.AbstractNetProcessor;
import com.halo.halojuhesdk.core.base.net.AbstractNetTask; import com.halo.halojuhesdk.core.base.net.AbstractNetTask;
import com.halo.halojuhesdk.core.base.utils.LogUtils; import com.halo.halojuhesdk.core.base.utils.LogUtils;
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
...@@ -47,7 +42,6 @@ public class StatisProcessor extends AbstractNetProcessor { ...@@ -47,7 +42,6 @@ public class StatisProcessor extends AbstractNetProcessor {
} }
} }
LogUtils.e("===reportStatis==" + mReqId + "===soltId===" + mBean.slotId); LogUtils.e("===reportStatis==" + mReqId + "===soltId===" + mBean.slotId);
reportSensorsData(0, code, content);
} }
...@@ -56,31 +50,10 @@ public class StatisProcessor extends AbstractNetProcessor { ...@@ -56,31 +50,10 @@ public class StatisProcessor extends AbstractNetProcessor {
if (mCallBack != null) { if (mCallBack != null) {
mCallBack.onError(); mCallBack.onError();
} }
reportSensorsData(1, code, content);
} }
public void callBack(RequestCallBack requestCallBack) { public void callBack(RequestCallBack requestCallBack) {
mCallBack = requestCallBack; mCallBack = requestCallBack;
} }
private void reportSensorsData(int type, int code, String content) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("errorCode", code);
jsonObject.put("msgContent", content);
jsonObject.put("slotId", mBean.slotId);
jsonObject.put("action", mAction);
jsonObject.put("stepName", mStepName);
String eventIdStr = "";
if (type == 0) {
eventIdStr = "sdk_juhe_report_success";
} else if (type == 1){
eventIdStr = "sdk_juhe_report_error";
}
LogUtils.e("===reportActionSensor===" + jsonObject);
SensorsDataAPI.sharedInstance().track(eventIdStr, jsonObject);
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
} }
...@@ -83,7 +83,7 @@ public class StatisTask extends AbstractNetTask { ...@@ -83,7 +83,7 @@ public class StatisTask extends AbstractNetTask {
jsonObject.put("msg", mErrorMsg); jsonObject.put("msg", mErrorMsg);
} }
jsonObject.put("cur","USD"); jsonObject.put("cur","USD");
LogUtils.e("====action===" + mAction +"===jsonObject===" + jsonObject); // LogUtils.e("====action===" + mAction +"===jsonObject===" + jsonObject);
outputStream.write(jsonObject.toString().getBytes()); outputStream.write(jsonObject.toString().getBytes());
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -37,6 +37,8 @@ import java.util.TimerTask; ...@@ -37,6 +37,8 @@ import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
public class HlBannerAd { public class HlBannerAd {
private int mWidth;
private int mHeight;
private String mSlotId; private String mSlotId;
private Activity mActivity; private Activity mActivity;
private HlBannerListener mAdListener; private HlBannerListener mAdListener;
...@@ -54,8 +56,14 @@ public class HlBannerAd { ...@@ -54,8 +56,14 @@ public class HlBannerAd {
private String mBannerReqId; private String mBannerReqId;
private String showAdSlotId; private String showAdSlotId;
public HlBannerAd(Activity context, String slotId, HlBannerListener listener) { public HlBannerAd(Activity context, String slotId, int width, int height, HlBannerListener listener) {
if (context == null) {
mAdListener.onAdError("横幅广告context不能为空", InitStatus.INIT_FAIL_CODE);
return;
}
MyUtils.init(context); MyUtils.init(context);
mWidth = width;
mHeight = height;
loadBanner(context, slotId, listener); loadBanner(context, slotId, listener);
} }
...@@ -122,7 +130,7 @@ public class HlBannerAd { ...@@ -122,7 +130,7 @@ public class HlBannerAd {
bannerMap.put(bean.adSlotId, appLovinInsert); bannerMap.put(bean.adSlotId, appLovinInsert);
} }
else if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) { else if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) {
HlApiBannerAd apiBanner = new HlApiBannerAd(context, bean, proxyListener); HlApiBannerAd apiBanner = new HlApiBannerAd(context, bean, mWidth, mHeight, proxyListener);
currentList.add(bean); currentList.add(bean);
bannerMap.put(bean.adSlotId, apiBanner); bannerMap.put(bean.adSlotId, apiBanner);
} }
......
...@@ -39,6 +39,8 @@ import java.util.UUID; ...@@ -39,6 +39,8 @@ import java.util.UUID;
* @description * @description
*/ */
public class HlInsertAd { public class HlInsertAd {
private int mWidth;
private int mHeight;
private String mSlotId; private String mSlotId;
private Activity mActivity; private Activity mActivity;
private HlInsertAdListener mAdListener; private HlInsertAdListener mAdListener;
...@@ -53,8 +55,15 @@ public class HlInsertAd { ...@@ -53,8 +55,15 @@ public class HlInsertAd {
private String mShowAdSlotId; private String mShowAdSlotId;
double currentPrice = 0; double currentPrice = 0;
private String mInsertReqId = UUID.randomUUID().toString(); private String mInsertReqId = UUID.randomUUID().toString();
public HlInsertAd(Activity context, String slotId, HlInsertAdListener adListener) {
public HlInsertAd(Activity context, String slotId, int width, int height, HlInsertAdListener adListener) {
if (context == null) {
mAdListener.onAdError("插屏广告context不能为空", InitStatus.INIT_FAIL_CODE);
return;
}
MyUtils.init(context); MyUtils.init(context);
mWidth = width;
mHeight = height;
mSlotId = slotId; mSlotId = slotId;
mPostJson = new JSONArray(); mPostJson = new JSONArray();
insertAdMap = new HashMap<>(); insertAdMap = new HashMap<>();
...@@ -94,7 +103,7 @@ public class HlInsertAd { ...@@ -94,7 +103,7 @@ public class HlInsertAd {
currentList.add(bean); currentList.add(bean);
insertViewMap.put(bean.adSlotId, appLovinInsert); insertViewMap.put(bean.adSlotId, appLovinInsert);
} else if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) { } else if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) {
HlApiInsertAd apiInsert = new HlApiInsertAd(context, bean, proxyListener); HlApiInsertAd apiInsert = new HlApiInsertAd(context, bean, mWidth, mHeight, proxyListener);
currentList.add(bean); currentList.add(bean);
insertViewMap.put(bean.adSlotId, apiInsert); insertViewMap.put(bean.adSlotId, apiInsert);
} }
......
...@@ -39,9 +39,10 @@ import java.util.TimerTask; ...@@ -39,9 +39,10 @@ import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
public class HlNativeAd { public class HlNativeAd {
private int mWidth;
private int mHeight;
private int mType = 1;
private String mSlotId; private String mSlotId;
private int mDirectionType;
private Activity mActivity; private Activity mActivity;
private HlNativeAdListener mHlNativeAdListener; private HlNativeAdListener mHlNativeAdListener;
private HlNativeVideoListener mVideoListener; private HlNativeVideoListener mVideoListener;
...@@ -58,14 +59,20 @@ public class HlNativeAd { ...@@ -58,14 +59,20 @@ public class HlNativeAd {
private JSONArray mPostJson; private JSONArray mPostJson;
double currentPrice = 0; double currentPrice = 0;
private String mNativeReqId = UUID.randomUUID().toString(); private String mNativeReqId = UUID.randomUUID().toString();
public HlNativeAd(Activity context, String slotId, HlNativeAdListener nativeAdListener) { public HlNativeAd(Activity context, String slotId, int width, int height, int type, HlNativeAdListener nativeAdListener) {
if (context == null) {
mHlNativeAdListener.onADError("模板渲染广告context不能为空", InitStatus.INIT_FAIL_CODE);
return;
}
MyUtils.init(context); MyUtils.init(context);
mWidth = width;
mHeight = height;
mType = type;
nativeViewAdMap = new HashMap<>(); nativeViewAdMap = new HashMap<>();
mPostJson = new JSONArray(); mPostJson = new JSONArray();
maxTime = Config.AD_TIME_OUT; maxTime = Config.AD_TIME_OUT;
isLoadAd = false; isLoadAd = false;
isAdClose = false; isAdClose = false;
mDirectionType = 3;
mSlotId = slotId; mSlotId = slotId;
nativeSelectMap = new HashMap<>(); nativeSelectMap = new HashMap<>();
nativeAdMap = new HashMap<>(); nativeAdMap = new HashMap<>();
...@@ -100,7 +107,7 @@ public class HlNativeAd { ...@@ -100,7 +107,7 @@ public class HlNativeAd {
currentList.add(bean); currentList.add(bean);
nativeAdMap.put(bean.adSlotId, appLovinNative); nativeAdMap.put(bean.adSlotId, appLovinNative);
} else if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) { } else if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) {
HlApiNativeAd apiNative = new HlApiNativeAd(context, bean,null, proxyListener); HlApiNativeAd apiNative = new HlApiNativeAd(context, bean,null, mWidth, mHeight, mType, proxyListener);
currentList.add(bean); currentList.add(bean);
nativeAdMap.put(bean.adSlotId, apiNative); nativeAdMap.put(bean.adSlotId, apiNative);
} }
...@@ -175,7 +182,7 @@ public class HlNativeAd { ...@@ -175,7 +182,7 @@ public class HlNativeAd {
LogUtils.e("hlsdk====mNativeShowFrom====" + mAdFrom + "===adSlotId===" + adSlotId); LogUtils.e("hlsdk====mNativeShowFrom====" + mAdFrom + "===adSlotId===" + adSlotId);
View view = nativeViewAdMap.get(adSlotId); View view = nativeViewAdMap.get(adSlotId);
String adType = adSubTypeMap.get(adSlotId); String adType = adSubTypeMap.get(adSlotId);
mHlNativeAdListener.onADLoadView(view, adType,0f); mHlNativeAdListener.onADLoadView(view, adType);
}); });
analyseBeanObj(bean, true, true, ecpmNum); analyseBeanObj(bean, true, true, ecpmNum);
} else { } else {
...@@ -225,7 +232,7 @@ public class HlNativeAd { ...@@ -225,7 +232,7 @@ public class HlNativeAd {
private INativeProxyListener proxyListener = new INativeProxyListener() { private INativeProxyListener proxyListener = new INativeProxyListener() {
@Override @Override
public void onADLoadView(View view, String adType, SlotBean slotBean, double ecpm, String adSubType,float ratio) { public void onADLoadView(View view, String adType, SlotBean slotBean, double ecpm, String adSubType) {
LogUtils.e("====onADLoadView===" + adType + "====slotBean===" + slotBean.adSlotId + "==ecpm==" + ecpm); LogUtils.e("====onADLoadView===" + adType + "====slotBean===" + slotBean.adSlotId + "==ecpm==" + ecpm);
nativeSelectMap.put(slotBean.adSlotId, true); nativeSelectMap.put(slotBean.adSlotId, true);
nativeViewAdMap.put(slotBean.adSlotId, view); nativeViewAdMap.put(slotBean.adSlotId, view);
......
...@@ -39,7 +39,9 @@ import java.util.TimerTask; ...@@ -39,7 +39,9 @@ import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
public class HlNativeUnifiedAd { public class HlNativeUnifiedAd {
private final HlUnifiedAdParameter mParameter; private int mWidth;
private int mHeight;
private HlUnifiedAdParameter mParameter;
private String mSlotId; private String mSlotId;
private Activity mActivity; private Activity mActivity;
private HlNativeAdListener mHlNativeAdListener; private HlNativeAdListener mHlNativeAdListener;
...@@ -49,7 +51,6 @@ public class HlNativeUnifiedAd { ...@@ -49,7 +51,6 @@ public class HlNativeUnifiedAd {
private Map<String, SlotBean> nativePriceAdMap; private Map<String, SlotBean> nativePriceAdMap;
private HashMap<String, Double> ecpmAdMap; private HashMap<String, Double> ecpmAdMap;
private Map<String, String> adSubTypeMap; private Map<String, String> adSubTypeMap;
private Map<String, Float> adRatioMap;
private int maxTime; private int maxTime;
private boolean isLoadAd; private boolean isLoadAd;
private String mAdFrom; private String mAdFrom;
...@@ -58,8 +59,14 @@ public class HlNativeUnifiedAd { ...@@ -58,8 +59,14 @@ public class HlNativeUnifiedAd {
private boolean isAdClose; private boolean isAdClose;
private String mNativeUnifiedReqId = UUID.randomUUID().toString(); private String mNativeUnifiedReqId = UUID.randomUUID().toString();
public HlNativeUnifiedAd(Activity context, String slotId, HlUnifiedAdParameter parameter, HlNativeAdListener nativeAdListener) { public HlNativeUnifiedAd(Activity context, String slotId, HlUnifiedAdParameter parameter, int width, int height, HlNativeAdListener nativeAdListener) {
if (context == null) {
mHlNativeAdListener.onADError("自渲染广告context不能为空", InitStatus.INIT_FAIL_CODE);
return;
}
MyUtils.init(context); MyUtils.init(context);
mWidth = width;
mHeight = height;
mParameter = parameter; mParameter = parameter;
nativeViewAdMap = new HashMap<>(); nativeViewAdMap = new HashMap<>();
mPostJson = new JSONArray(); mPostJson = new JSONArray();
...@@ -71,7 +78,6 @@ public class HlNativeUnifiedAd { ...@@ -71,7 +78,6 @@ public class HlNativeUnifiedAd {
nativePriceAdMap = new HashMap<>(); nativePriceAdMap = new HashMap<>();
ecpmAdMap = new HashMap<>(); ecpmAdMap = new HashMap<>();
adSubTypeMap = new HashMap<>(); adSubTypeMap = new HashMap<>();
adRatioMap = new HashMap<>();
mHlNativeAdListener = nativeAdListener; mHlNativeAdListener = nativeAdListener;
mActivity = context; mActivity = context;
List<SlotBean> slotBeanList = RequestAdManager.requestChannel(slotId); List<SlotBean> slotBeanList = RequestAdManager.requestChannel(slotId);
...@@ -102,7 +108,7 @@ public class HlNativeUnifiedAd { ...@@ -102,7 +108,7 @@ public class HlNativeUnifiedAd {
nativeAdMap.put(bean.adSlotId, appLovinNative); nativeAdMap.put(bean.adSlotId, appLovinNative);
} else } else
if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) { if (adFrom.equals(InitDataProcessor.SDK_API) && HlAdClient.mTypeList.contains(Config.JuHeAdType.API)) {
HlApiUnifiedNativeAd apiNative = new HlApiUnifiedNativeAd(mActivity, bean, mParameter, proxyListener); HlApiUnifiedNativeAd apiNative = new HlApiUnifiedNativeAd(mActivity, bean, mParameter, mWidth, mHeight, proxyListener);
currentList.add(bean); currentList.add(bean);
nativeAdMap.put(bean.adSlotId, apiNative); nativeAdMap.put(bean.adSlotId, apiNative);
} }
...@@ -177,8 +183,7 @@ public class HlNativeUnifiedAd { ...@@ -177,8 +183,7 @@ public class HlNativeUnifiedAd {
LogUtils.e("hlsdk====mNativeShowFrom====" + mAdFrom + "===adSlotId===" + adSlotId); LogUtils.e("hlsdk====mNativeShowFrom====" + mAdFrom + "===adSlotId===" + adSlotId);
View view = nativeViewAdMap.get(adSlotId); View view = nativeViewAdMap.get(adSlotId);
String adType = adSubTypeMap.get(adSlotId); String adType = adSubTypeMap.get(adSlotId);
Float ratio = adRatioMap.get(adSlotId); mHlNativeAdListener.onADLoadView(view, adType);
mHlNativeAdListener.onADLoadView(view, adType, ratio);
}); });
analyseBeanObj(bean, true, true, ecpmNum); analyseBeanObj(bean, true, true, ecpmNum);
} else { } else {
...@@ -232,13 +237,12 @@ public class HlNativeUnifiedAd { ...@@ -232,13 +237,12 @@ public class HlNativeUnifiedAd {
private INativeProxyListener proxyListener = new INativeProxyListener() { private INativeProxyListener proxyListener = new INativeProxyListener() {
@Override @Override
public void onADLoadView(View view, String adType, SlotBean slotBean, double ecpm, String adSubType,float ratio) { public void onADLoadView(View view, String adType, SlotBean slotBean, double ecpm, String adSubType) {
LogUtils.e("====onADLoadView===" + adType + "====adSlotId===" + slotBean.adSlotId); LogUtils.e("====onADLoadView===" + adType + "====adSlotId===" + slotBean.adSlotId);
nativeSelectMap.put(slotBean.adSlotId, true); nativeSelectMap.put(slotBean.adSlotId, true);
nativeViewAdMap.put(slotBean.adSlotId, view); nativeViewAdMap.put(slotBean.adSlotId, view);
ecpmAdMap.put(slotBean.adSlotId, ecpm); ecpmAdMap.put(slotBean.adSlotId, ecpm);
adSubTypeMap.put(slotBean.adSlotId, adSubType); adSubTypeMap.put(slotBean.adSlotId, adSubType);
adRatioMap.put(slotBean.adSlotId, ratio);
} }
@Override @Override
......
...@@ -33,7 +33,7 @@ import java.util.TimerTask; ...@@ -33,7 +33,7 @@ import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
public class HlSplashAd { public class HlSplashAd {
private final Activity mContext; private Activity mContext;
private HlSplashAdListener mListener; private HlSplashAdListener mListener;
private Activity mActivity; private Activity mActivity;
private ViewGroup mAdContainer; private ViewGroup mAdContainer;
...@@ -61,6 +61,10 @@ public class HlSplashAd { ...@@ -61,6 +61,10 @@ public class HlSplashAd {
private TimerTask timerLooperTask; private TimerTask timerLooperTask;
public HlSplashAd(Activity context, String slotId, ViewGroup adContainer, HlSplashAdListener listener) { public HlSplashAd(Activity context, String slotId, ViewGroup adContainer, HlSplashAdListener listener) {
if (context == null) {
mListener.onAdError("开屏广告context不能为空", InitStatus.INIT_FAIL_CODE);
return;
}
MyUtils.init(context); MyUtils.init(context);
mContext = context; mContext = context;
maxTime = Config.AD_TIME_OUT; maxTime = Config.AD_TIME_OUT;
......
...@@ -34,7 +34,7 @@ import java.util.TimerTask; ...@@ -34,7 +34,7 @@ import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
public class HlVideoAd { public class HlVideoAd {
private final HashMap<String, SlotBean> videoPriceMap; private HashMap<String, SlotBean> videoPriceMap;
private String mSlotId; private String mSlotId;
private Map<String, Double> ecpmAdMap; private Map<String, Double> ecpmAdMap;
private HlVideoListener mVideoListener; private HlVideoListener mVideoListener;
...@@ -49,6 +49,10 @@ public class HlVideoAd { ...@@ -49,6 +49,10 @@ public class HlVideoAd {
double currentPrice = 0; double currentPrice = 0;
private String mVideoReqId = UUID.randomUUID().toString(); private String mVideoReqId = UUID.randomUUID().toString();
public HlVideoAd(Activity context, String slotId, HlVideoListener mVideoListener) { public HlVideoAd(Activity context, String slotId, HlVideoListener mVideoListener) {
if (context == null) {
mVideoListener.onAdFailed("视频广告context不能为空", InitStatus.INIT_FAIL_CODE);
return;
}
MyUtils.init(context); MyUtils.init(context);
mPostJson = new JSONArray(); mPostJson = new JSONArray();
videoSelectMap = new HashMap<>(); videoSelectMap = new HashMap<>();
......
...@@ -4,7 +4,7 @@ package com.halo.halojuhesdk.sdk.listener; ...@@ -4,7 +4,7 @@ package com.halo.halojuhesdk.sdk.listener;
import android.view.View; import android.view.View;
public interface HlNativeAdListener { public interface HlNativeAdListener {
void onADLoadView(View view, String adTypeStr,float ratio); void onADLoadView(View view, String adTypeStr);
void onADClick(View view, String adTypeStr); void onADClick(View view, String adTypeStr);
void onADShow(View view, String adTypeStr); void onADShow(View view, String adTypeStr);
void onADClose(View view); void onADClose(View view);
......
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
def SDK_CHANNEL = "halomobi" def SDK_CHANNEL = "halomobi"
def SDK_VERSION = "1.0.0" def SDK_VERSION = "1.1.0"
def SDK_BASENAME = SDK_CHANNEL + "_sdk_v" + SDK_VERSION def SDK_BASENAME = SDK_CHANNEL + "_sdk_v" + SDK_VERSION
def sdkDestinationPath = "build/outputs/jar/" def sdkDestinationPath = "build/outputs/jar/"
...@@ -31,8 +31,6 @@ android { ...@@ -31,8 +31,6 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 33 targetSdkVersion 33
versionCode 1
versionName "1.0"
} }
buildTypes { buildTypes {
release { release {
......
...@@ -45,4 +45,4 @@ public void *(android.view.View); ...@@ -45,4 +45,4 @@ public void *(android.view.View);
-keep public class * extends android.app.Activity -keep public class * extends android.app.Activity
-keep public class * extends android.content.BroadcastReceiver {*;} -keep public class * extends android.content.BroadcastReceiver {*;}
-keep public class com.halomobi.sdk.**{*;} -keep public class com.halomobi.**{*;}
\ No newline at end of file \ No newline at end of file
...@@ -176,6 +176,8 @@ public class RequestAdProcessor extends AbsNetProcessor { ...@@ -176,6 +176,8 @@ public class RequestAdProcessor extends AbsNetProcessor {
ad.nurl = jsonAd.optString("nurl"); ad.nurl = jsonAd.optString("nurl");
ad.burl = jsonAd.optString("burl"); ad.burl = jsonAd.optString("burl");
ad.adm = jsonAd.optString("adm"); ad.adm = jsonAd.optString("adm");
ad.w = jsonAd.optInt("w");
ad.h = jsonAd.optInt("h");
ad.crid = jsonAd.optString("crid"); ad.crid = jsonAd.optString("crid");
ad.landing_url = jsonAd.optString("lurl"); ad.landing_url = jsonAd.optString("lurl");
// ad.imp_tracks = add2List(jsonAd, "imp_tracks"); // ad.imp_tracks = add2List(jsonAd, "imp_tracks");
......
...@@ -47,10 +47,10 @@ public class AdRequest { ...@@ -47,10 +47,10 @@ public class AdRequest {
public static byte[] getParams(AdParameter parameter) { public static byte[] getParams(AdParameter parameter) {
AdRequest jParam = new AdRequest(parameter); AdRequest jParam = new AdRequest(parameter);
return serializeJson(jParam); return serializeJson(jParam, parameter);
} }
private static byte[] serializeJson(AdRequest parameter) { private static byte[] serializeJson(AdRequest parameter, AdParameter currentParameter) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
try { try {
jsonObject.put("id",Config.getUUID()); jsonObject.put("id",Config.getUUID());
...@@ -81,11 +81,23 @@ public class AdRequest { ...@@ -81,11 +81,23 @@ public class AdRequest {
int slotType = adSlot.slot_type; int slotType = adSlot.slot_type;
if (slotType == ConstantPool.AdType.BANNER.getType()) { if (slotType == ConstantPool.AdType.BANNER.getType()) {
if (currentParameter.adViewSize.length == 2) {
adObject.put("w", currentParameter.adViewSize[0]);
adObject.put("h", currentParameter.adViewSize[1]);
}
impObject.put("banner",adObject); impObject.put("banner",adObject);
} else if (slotType == ConstantPool.AdType.INSERT.getType()) { } else if (slotType == ConstantPool.AdType.INSERT.getType()) {
if (currentParameter.adViewSize.length == 2) {
adObject.put("w", currentParameter.adViewSize[0]);
adObject.put("h", currentParameter.adViewSize[1]);
}
impObject.put("banner",adObject); impObject.put("banner",adObject);
impObject.put("instl", 1); impObject.put("instl", 1);
} else if (slotType == ConstantPool.AdType.REWARDVIDEO.getType()) { } else if (slotType == ConstantPool.AdType.REWARDVIDEO.getType()) {
if (currentParameter.adViewSize.length == 2) {
adObject.put("w", currentParameter.adViewSize[0]);
adObject.put("h", currentParameter.adViewSize[1]);
}
impObject.put("video",adObject); impObject.put("video",adObject);
} else if (slotType == ConstantPool.AdType.NATIVE.getType()) { } else if (slotType == ConstantPool.AdType.NATIVE.getType()) {
JSONObject requestObj = new JSONObject(); JSONObject requestObj = new JSONObject();
...@@ -95,8 +107,14 @@ public class AdRequest { ...@@ -95,8 +107,14 @@ public class AdRequest {
assetsSubObj.put("required", 1); assetsSubObj.put("required", 1);
JSONObject assetsImgObj = new JSONObject(); JSONObject assetsImgObj = new JSONObject();
assetsImgObj.put("type", 3); assetsImgObj.put("type", 3);
assetsImgObj.put("w", Utils.getScreenSize(Utils.getContext(),true)[0]); if (currentParameter.adViewSize.length == 2) {
assetsImgObj.put("h", 450); assetsImgObj.put("w", currentParameter.adViewSize[0]);
assetsImgObj.put("h", currentParameter.adViewSize[1]);
assetsImgObj.put("wmin", currentParameter.adViewSize[0]);
assetsImgObj.put("hmin", currentParameter.adViewSize[1]);
}
// assetsImgObj.put("w", Utils.getScreenSize(Utils.getContext(),true)[0]);
// assetsImgObj.put("h", 450);
// JSONArray mimesImgArr = new JSONArray(); // JSONArray mimesImgArr = new JSONArray();
List<String> imgList = new ArrayList<>(); List<String> imgList = new ArrayList<>();
imgList.add("image/jpg"); imgList.add("image/jpg");
...@@ -107,10 +125,12 @@ public class AdRequest { ...@@ -107,10 +125,12 @@ public class AdRequest {
assetsImgObj.put("mimes", mimesImgArr); assetsImgObj.put("mimes", mimesImgArr);
assetsSubObj.put("img", assetsImgObj); assetsSubObj.put("img", assetsImgObj);
assetsArr.put(assetsSubObj); assetsArr.put(assetsSubObj);
requestObj.put("assets", assetsArr);
requestObj.put("ver", "1.0"); requestObj.put("ver", "1.0");
String requestStr = "{\"assets\":[{\"id\":1,\"required\":1,\"img\":{\"type\":3,\"w\":720,\"h\":1280,\"mimes\":[\"image/jpg\",\"image/png\"]}}],\"ver\":\"1.0\"}"; requestObj.put("assets", assetsArr);
adObject.put("request", requestObj.toString()); JSONObject subNativeObj = new JSONObject();
subNativeObj.put("native", requestObj);
// String requestStr = "{\"assets\":[{\"id\":1,\"required\":1,\"img\":{\"type\":3,\"w\":720,\"h\":1280,\"mimes\":[\"image/jpg\",\"image/png\"]}}],\"ver\":\"1.0\"}";
adObject.put("request", subNativeObj.toString());
impObject.put("native",adObject); impObject.put("native",adObject);
} }
impArray.put(impObject); impArray.put(impObject);
...@@ -169,7 +189,7 @@ public class AdRequest { ...@@ -169,7 +189,7 @@ public class AdRequest {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
jsonObject.put("test", 1); jsonObject.put("test", 1);
} }
Log.e("11111","===js===" + jsonObject); // Log.e("11111","===js===" + jsonObject);
} catch (JSONException e) { } catch (JSONException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
......
package com.halomobi.sdk; package com.halomobi.sdk;
import static com.halomobi.common.ConstantPool.TrackerType.CLICK;
import static com.halomobi.common.ConstantPool.TrackerType.DEEP_LINK_OPEN;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -17,6 +24,7 @@ import android.widget.ImageView; ...@@ -17,6 +24,7 @@ import android.widget.ImageView;
import com.halomobi.common.ConstantPool; import com.halomobi.common.ConstantPool;
import com.halomobi.network.listeners.AdStateChangListener; import com.halomobi.network.listeners.AdStateChangListener;
import com.halomobi.network.listeners.ClickAdStateChangListener;
import com.halomobi.network.request.ad.bean.Ad; import com.halomobi.network.request.ad.bean.Ad;
import com.halomobi.network.request.ad.bean.AdParameter; import com.halomobi.network.request.ad.bean.AdParameter;
import com.halomobi.sdk.listener.BannerListener; import com.halomobi.sdk.listener.BannerListener;
...@@ -25,6 +33,7 @@ import com.halomobi.utils.LogUtils; ...@@ -25,6 +33,7 @@ import com.halomobi.utils.LogUtils;
import com.halomobi.utils.PxUtil; import com.halomobi.utils.PxUtil;
import com.halomobi.utils.WebViewUtils; import com.halomobi.utils.WebViewUtils;
import java.net.URISyntaxException;
import java.util.List; import java.util.List;
public class HMBannerAd { public class HMBannerAd {
...@@ -88,6 +97,12 @@ public class HMBannerAd { ...@@ -88,6 +97,12 @@ public class HMBannerAd {
String adm = adInfo.adm.replace("${AUCTION_BID_ID}", adid); String adm = adInfo.adm.replace("${AUCTION_BID_ID}", adid);
View inflate = LayoutInflater.from(activity).inflate(R.layout.hl_dialog_banner, null, false); View inflate = LayoutInflater.from(activity).inflate(R.layout.hl_dialog_banner, null, false);
final WebView mWebView = inflate.findViewById(R.id.webView); final WebView mWebView = inflate.findViewById(R.id.webView);
ViewGroup.LayoutParams layoutParams = mWebView.getLayoutParams();
if (mHlParameter.getAdWidth() > 0 && mHlParameter.getAdHeight() > 0) {
layoutParams.width = mHlParameter.getAdWidth();
layoutParams.height = mHlParameter.getAdHeight();
mWebView.setLayoutParams(layoutParams);
}
WebViewUtils utils = new WebViewUtils(); WebViewUtils utils = new WebViewUtils();
utils.initWebView(activity, mWebView, adInfo); utils.initWebView(activity, mWebView, adInfo);
mWebView.loadData(adm, "text/html", "UTF-8"); mWebView.loadData(adm, "text/html", "UTF-8");
...@@ -96,15 +111,12 @@ public class HMBannerAd { ...@@ -96,15 +111,12 @@ public class HMBannerAd {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
Log.e("11111", "===shouldOverrideUrlLoading===" + request.getUrl()); Log.e("11111", "===shouldOverrideUrlLoading===" + request.getUrl());
if (request.getUrl().toString().contains("halomobi.com/api/cpi/click")) { String url = request.getUrl().toString();
final Intent intent = new Intent(); boolean isGoToApp = gotoQuickApp(url);
intent.setAction(Intent.ACTION_VIEW); if(!isGoToApp) {
intent.setData(request.getUrl()); Intent intent = new Intent(mActivity, WebViewActivity.class);
// 注意此处的判断intent.resolveActivity()可以返回显示该Intent的Activity对应的组件名 intent.putExtra("urlStr", url);
// 官方解释 : Name of the component implementing an activity that can display the intent mActivity.startActivity(intent);
if (intent.resolveActivity(mActivity.getPackageManager()) != null) {
mActivity.startActivity(Intent.createChooser(intent, "请选择浏览器"));
}
} }
return true; return true;
} }
...@@ -128,6 +140,24 @@ public class HMBannerAd { ...@@ -128,6 +140,24 @@ public class HMBannerAd {
}); });
} }
private boolean gotoQuickApp(String deepLink) {
try {
Intent deepLinkIntent = Intent.parseUri(deepLink, Intent.URI_INTENT_SCHEME);
deepLinkIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ResolveInfo resolveInfo = mActivity.getPackageManager().resolveActivity(deepLinkIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo != null) {
mActivity.startActivity(deepLinkIntent);
return true;
}
} catch (ActivityNotFoundException e) {
LogUtils.w("DeepLink NotFound : " + deepLink);
} catch (URISyntaxException e) {
e.printStackTrace();
LogUtils.w("DeepLink NotFound : " + deepLink);
}
return false;
}
public double getEcpm() { public double getEcpm() {
return currentPrice; return currentPrice;
} }
......
...@@ -2,8 +2,11 @@ package com.halomobi.sdk; ...@@ -2,8 +2,11 @@ package com.halomobi.sdk;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
...@@ -26,6 +29,15 @@ import com.halomobi.utils.LogUtils; ...@@ -26,6 +29,15 @@ import com.halomobi.utils.LogUtils;
import com.halomobi.utils.PxUtil; import com.halomobi.utils.PxUtil;
import com.halomobi.utils.WebViewUtils; import com.halomobi.utils.WebViewUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class HMInsertAd{ public class HMInsertAd{
...@@ -68,6 +80,7 @@ public class HMInsertAd{ ...@@ -68,6 +80,7 @@ public class HMInsertAd{
@Override @Override
public void onAdReach(Ad adInfo) { public void onAdReach(Ad adInfo) {
currentAd = adInfo; currentAd = adInfo;
currentPrice = adInfo.price;
mListener.onAdReady(); mListener.onAdReady();
} }
...@@ -83,20 +96,29 @@ public class HMInsertAd{ ...@@ -83,20 +96,29 @@ public class HMInsertAd{
} }
private void showInsertAd(Activity activity, Ad adInfo, HlAdParameter hlParameter) { private void showInsertAd(Activity activity, Ad adInfo, HlAdParameter hlParameter) {
LogUtils.e("===adInfo===" + adInfo.adm); LogUtils.e("===adInfo===" + adInfo.adm + "====w===" + adInfo.w);
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
currentPrice = adInfo.price;
String adid = adInfo.adid; String adid = adInfo.adid;
String adm = adInfo.adm.replace("${AUCTION_BID_ID}",adid); String adm = adInfo.adm.replace("${AUCTION_BID_ID}",adid);
adDialog.show(); adDialog.show();
// Window window = adDialog.getWindow(); Window window = adDialog.getWindow();
// if (window != null) { if (adInfo.w > 10 && adInfo.h > 10) {
// WindowManager.LayoutParams lp = window.getAttributes(); if (window != null) {
// lp.width = hlParameter.getAdWidth(); WindowManager.LayoutParams lp = window.getAttributes();
// lp.height = hlParameter.getAdHeight(); lp.width = adInfo.w;
// lp.gravity = Gravity.CENTER; lp.height = adInfo.h;
// adDialog.getWindow().setAttributes(lp); lp.gravity = Gravity.CENTER;
// } adDialog.getWindow().setAttributes(lp);
}
} else {
if (window != null) {
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = hlParameter.getAdWidth();
lp.height = hlParameter.getAdHeight();
lp.gravity = Gravity.CENTER;
adDialog.getWindow().setAttributes(lp);
}
}
View inflate = LayoutInflater.from(activity).inflate(R.layout.hl_dialog_insert, null, false); View inflate = LayoutInflater.from(activity).inflate(R.layout.hl_dialog_insert, null, false);
ImageView mImageClose = inflate.findViewById(R.id.image_close); ImageView mImageClose = inflate.findViewById(R.id.image_close);
final WebView mWebView = inflate.findViewById(R.id.webView); final WebView mWebView = inflate.findViewById(R.id.webView);
...@@ -115,11 +137,13 @@ public class HMInsertAd{ ...@@ -115,11 +137,13 @@ public class HMInsertAd{
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
Log.e("11111","===shouldOverrideUrlLoading===" + request.getUrl()); Log.e("11111","===shouldOverrideUrlLoading===" + request.getUrl());
Intent intent = new Intent(); String url = request.getUrl().toString();
intent.setAction(Intent.ACTION_VIEW); boolean isGoToApp = gotoQuickApp(url);
intent.setData(request.getUrl()); if(!isGoToApp) {
if (intent.resolveActivity(mActivity.getPackageManager()) != null) { adDialog.dismiss();
mActivity.startActivity(Intent.createChooser(intent, "请选择浏览器")); Intent intent = new Intent(mActivity, WebViewActivity.class);
intent.putExtra("urlStr", url);
mActivity.startActivity(intent);
} }
return false; return false;
} }
...@@ -147,6 +171,25 @@ public class HMInsertAd{ ...@@ -147,6 +171,25 @@ public class HMInsertAd{
}); });
} }
private boolean gotoQuickApp(String deepLink) {
try {
Intent deepLinkIntent = Intent.parseUri(deepLink, Intent.URI_INTENT_SCHEME);
deepLinkIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ResolveInfo resolveInfo = mActivity.getPackageManager().resolveActivity(deepLinkIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo != null) {
mActivity.startActivity(deepLinkIntent);
adDialog.dismiss();
return true;
}
} catch (ActivityNotFoundException e) {
LogUtils.w("DeepLink NotFound : " + deepLink);
} catch (URISyntaxException e) {
e.printStackTrace();
LogUtils.w("DeepLink NotFound : " + deepLink);
}
return false;
}
public double getEcpm() { public double getEcpm() {
return currentPrice; return currentPrice;
} }
......
...@@ -6,6 +6,7 @@ import android.text.TextUtils; ...@@ -6,6 +6,7 @@ import android.text.TextUtils;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
...@@ -25,6 +26,10 @@ import com.halomobi.view.imageloader.ImageLoader; ...@@ -25,6 +26,10 @@ import com.halomobi.view.imageloader.ImageLoader;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -40,7 +45,7 @@ public class HMNativeAd { ...@@ -40,7 +45,7 @@ public class HMNativeAd {
mActivity = activity; mActivity = activity;
mParameter = parameter; mParameter = parameter;
mNativeListener = listener; mNativeListener = listener;
mDirectionType = 3; mDirectionType = parameter.getType();
adController = new AdController(activity); adController = new AdController(activity);
} }
...@@ -101,6 +106,14 @@ public class HMNativeAd { ...@@ -101,6 +106,14 @@ public class HMNativeAd {
String imgUrl = imgObject.optString("url"); String imgUrl = imgObject.optString("url");
int type = imgObject.optInt("type"); int type = imgObject.optInt("type");
if (type == 3) { if (type == 3) {
int w = imgObject.optInt("w");
if (w > 0) {
hlNativeResponse.setImageWidth(w);
}
int h = imgObject.optInt("h");
if (h > 0) {
hlNativeResponse.setImageHeight(h);
}
imgList.add(imgUrl); imgList.add(imgUrl);
} }
if (type == 1) { if (type == 1) {
...@@ -187,6 +200,12 @@ public class HMNativeAd { ...@@ -187,6 +200,12 @@ public class HMNativeAd {
TextView title = inflate.findViewById(R.id.tv_item_title); TextView title = inflate.findViewById(R.id.tv_item_title);
TextView subTitle = inflate.findViewById(R.id.tv_item_details); TextView subTitle = inflate.findViewById(R.id.tv_item_details);
ImageView mImageSource = inflate.findViewById(R.id.image_item_source); ImageView mImageSource = inflate.findViewById(R.id.image_item_source);
if (hlResponse.getImageWidth() > 0 && hlResponse.getImageHeight() > 0) {
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
layoutParams.width = hlResponse.getImageWidth();
layoutParams.height = hlResponse.getImageHeight();
imageView.setLayoutParams(layoutParams);
}
String logoUrl = hlResponse.getLogoUrl(); String logoUrl = hlResponse.getLogoUrl();
if (!TextUtils.isEmpty(logoUrl)) { if (!TextUtils.isEmpty(logoUrl)) {
mImageSource.setVisibility(View.VISIBLE); mImageSource.setVisibility(View.VISIBLE);
...@@ -198,8 +217,14 @@ public class HMNativeAd { ...@@ -198,8 +217,14 @@ public class HMNativeAd {
if (imgList != null && !imgList.isEmpty()) { if (imgList != null && !imgList.isEmpty()) {
ImageLoader.load(imageView, imgList.get(0)); ImageLoader.load(imageView, imgList.get(0));
} }
title.setText(hlResponse.getTitle()); if (!TextUtils.isEmpty(hlResponse.getTitle())) {
subTitle.setText(hlResponse.getAdDescription()); title.setVisibility(View.VISIBLE);
title.setText(hlResponse.getTitle());
}
if (!TextUtils.isEmpty(hlResponse.getAdDescription())) {
subTitle.setVisibility(View.VISIBLE);
subTitle.setText(hlResponse.getAdDescription());
}
inflate.setOnClickListener(v -> { inflate.setOnClickListener(v -> {
hlResponse.handleClick(v, !isClick); hlResponse.handleClick(v, !isClick);
if (!isClick) { if (!isClick) {
......
package com.halomobi.sdk; package com.halomobi.sdk;
import android.app.Activity; import android.app.Activity;
import android.graphics.Color;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
...@@ -16,12 +19,17 @@ import com.halomobi.sdk.listener.NativeUnifiedListener; ...@@ -16,12 +19,17 @@ import com.halomobi.sdk.listener.NativeUnifiedListener;
import com.halomobi.network.listeners.AdStateChangListener; import com.halomobi.network.listeners.AdStateChangListener;
import com.halomobi.network.request.ad.bean.Ad; import com.halomobi.network.request.ad.bean.Ad;
import com.halomobi.network.request.ad.bean.AdParameter; import com.halomobi.network.request.ad.bean.AdParameter;
import com.halomobi.utils.PxUtil;
import com.halomobi.utils.Utils; import com.halomobi.utils.Utils;
import com.halomobi.view.imageloader.ImageLoader; import com.halomobi.view.imageloader.ImageLoader;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -153,25 +161,51 @@ public class HMUnifiedNativeAd { ...@@ -153,25 +161,51 @@ public class HMUnifiedNativeAd {
return null; return null;
} }
public View showViewById(int adLayoutId, int adContentId, int adTitleId, int adSubTitleId) { public View showViewById(int adLayoutId, int adContentId, int adTitleId, int adSubTitleId, int adOptionsId) {
View inflate = View.inflate(mActivity, adLayoutId, null); View inflate = View.inflate(mActivity, adLayoutId, null);
if (adTitleId > 0) { RelativeLayout relativeLayout = new RelativeLayout(mActivity);
TextView mTitleAd = inflate.findViewById(adTitleId);
mTitleAd.setText(nativeResponse.getTitle());
}
if (adSubTitleId > 0) {
TextView mSubTitle = inflate.findViewById(adSubTitleId);
mSubTitle.setText(nativeResponse.getAdDescription());
}
ImageView imageView = new ImageView(mActivity); ImageView imageView = new ImageView(mActivity);
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); imageView.setScaleType(ImageView.ScaleType.FIT_XY);
List<String> imgList = nativeResponse.getImgList(); View mAdOptionsId = inflate.findViewById(adOptionsId);
if (imgList != null && !imgList.isEmpty()) { if (mAdOptionsId != null) {
ImageLoader.load(imageView, imgList.get(0)); mAdOptionsId.setVisibility(View.GONE);
} }
if (adContentId > 0) { if (adContentId > 0) {
ViewGroup mAdContentId = inflate.findViewById(adContentId); ViewGroup mAdContentId = inflate.findViewById(adContentId);
mAdContentId.addView(imageView); if (mAdContentId != null) {
mAdContentId.post(() -> {
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
if (mAdContentId.getWidth() > 0) {
layoutParams.width = mAdContentId.getWidth();
} else {
layoutParams.width = PxUtil.getDeviceWidthInPixel(mActivity);
}
layoutParams.height = mAdContentId.getHeight();
relativeLayout.setLayoutParams(layoutParams);
imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mActivity.runOnUiThread(() -> {
List<String> imgList = nativeResponse.getImgList();
if (imgList != null && !imgList.isEmpty()) {
ImageLoader.load(imageView, imgList.get(0));
}
relativeLayout.addView(imageView);
mAdContentId.addView(relativeLayout);
if (adTitleId > 0) {
TextView mTitleAd = inflate.findViewById(adTitleId);
if (mTitleAd != null) {
mTitleAd.setText(nativeResponse.getTitle());
}
}
if (adSubTitleId > 0) {
TextView mSubTitle = inflate.findViewById(adSubTitleId);
if (mSubTitle != null) {
mSubTitle.setText(nativeResponse.getAdDescription());
}
}
});
});
}
} }
inflate.setOnClickListener(v -> { inflate.setOnClickListener(v -> {
......
...@@ -36,6 +36,7 @@ import java.util.Date; ...@@ -36,6 +36,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Logger;
public class HMVideoAd { public class HMVideoAd {
private RewardVideoListener mListener; private RewardVideoListener mListener;
...@@ -67,6 +68,7 @@ public class HMVideoAd { ...@@ -67,6 +68,7 @@ public class HMVideoAd {
@Override @Override
public void onAdReach(Ad adInfo) { public void onAdReach(Ad adInfo) {
String adm = adInfo.adm; String adm = adInfo.adm;
LogUtils.e("===adInfo===" + adInfo.adm);
currentPrice = adInfo.price; currentPrice = adInfo.price;
adInfo.adm = adm.replace("${AUCTION_BID_ID}", adInfo.adid); adInfo.adm = adm.replace("${AUCTION_BID_ID}", adInfo.adid);
adInfo.reward_video = new Ad.RewardVideoAds(); adInfo.reward_video = new Ad.RewardVideoAds();
......
...@@ -4,10 +4,12 @@ public class HlAdParameter { ...@@ -4,10 +4,12 @@ public class HlAdParameter {
private int mWidth; private int mWidth;
private int mHeight; private int mHeight;
private String mSlotAdId; private String mSlotAdId;
private int mType;
private HlAdParameter(Builder builder) { private HlAdParameter(Builder builder) {
this.mWidth = builder.width; this.mWidth = builder.width;
this.mHeight = builder.height; this.mHeight = builder.height;
this.mType = builder.type;
this.mSlotAdId = builder.slotAdId; this.mSlotAdId = builder.slotAdId;
} }
...@@ -23,10 +25,15 @@ public class HlAdParameter { ...@@ -23,10 +25,15 @@ public class HlAdParameter {
return mSlotAdId; return mSlotAdId;
} }
public int getType() {
return mType;
}
public static class Builder { public static class Builder {
private int width; private int width;
private int height; private int height;
private String slotAdId; private String slotAdId;
private int type;
public Builder() { public Builder() {
...@@ -47,6 +54,11 @@ public class HlAdParameter { ...@@ -47,6 +54,11 @@ public class HlAdParameter {
return this; return this;
} }
public Builder setAdType(int type) {
this.type = type;
return this;
}
public HlAdParameter build() { public HlAdParameter build() {
return new HlAdParameter(this); return new HlAdParameter(this);
} }
......
...@@ -139,7 +139,7 @@ public class HlCustomView extends Jzvd { ...@@ -139,7 +139,7 @@ public class HlCustomView extends Jzvd {
tipsDialog.setonDialogClickListener(new HlTipsDialog.OnDialogClickListener() { tipsDialog.setonDialogClickListener(new HlTipsDialog.OnDialogClickListener() {
@Override @Override
public void onCancelClick() { public void onCancelClick() {
mRewardVideoListener.onAdClose(); mRewardVideoListener.onAdSkip();
reportTracker(ConstantPool.TrackerType.CLOSE); reportTracker(ConstantPool.TrackerType.CLOSE);
mContext.finish(); mContext.finish();
} }
...@@ -208,6 +208,7 @@ public class HlCustomView extends Jzvd { ...@@ -208,6 +208,7 @@ public class HlCustomView extends Jzvd {
isCallOnAdShow = true; isCallOnAdShow = true;
} }
reportTracker(ConstantPool.TrackerType.DISPLAY); reportTracker(ConstantPool.TrackerType.DISPLAY);
LogUtils.e("===reportTracker===DISPLAY");
reportTracker(ConstantPool.TrackerType.VIDEO_PLAYING_0_TRACKER); reportTracker(ConstantPool.TrackerType.VIDEO_PLAYING_0_TRACKER);
mProgressBar.setVisibility(GONE); mProgressBar.setVisibility(GONE);
} }
...@@ -317,6 +318,8 @@ public class HlCustomView extends Jzvd { ...@@ -317,6 +318,8 @@ public class HlCustomView extends Jzvd {
} }
// onDestroy(); // onDestroy();
if (mRewardVideoListener != null) { if (mRewardVideoListener != null) {
LogUtils.e("fza" + "onPlayEnd");
mRewardVideoListener.onRewardArrived();
mRewardVideoListener.onPlayEnd(); mRewardVideoListener.onPlayEnd();
} }
super.onAutoCompletion(); super.onAutoCompletion();
......
...@@ -18,6 +18,8 @@ public class NativeResponseImpl implements NativeResponse { ...@@ -18,6 +18,8 @@ public class NativeResponseImpl implements NativeResponse {
private String adTitle; private String adTitle;
private String adSubTitle; private String adSubTitle;
private String logoUrl; private String logoUrl;
private int imageWidth;
private int imageHeight;
private double price; private double price;
private boolean isShow = true; private boolean isShow = true;
private boolean isClick; private boolean isClick;
...@@ -40,6 +42,22 @@ public class NativeResponseImpl implements NativeResponse { ...@@ -40,6 +42,22 @@ public class NativeResponseImpl implements NativeResponse {
logoUrl = logoUrlStr; logoUrl = logoUrlStr;
} }
public void setImageWidth(int width) {
imageWidth = width;
}
public void setImageHeight(int height) {
imageHeight = height;
}
public int getImageWidth() {
return imageWidth;
}
public int getImageHeight() {
return imageHeight;
}
public void setImgUrlList(List<String> imgList) { public void setImgUrlList(List<String> imgList) {
mImageList = imgList; mImageList = imgList;
} }
......
...@@ -50,7 +50,6 @@ public class RewardVideoActivity extends Activity { ...@@ -50,7 +50,6 @@ public class RewardVideoActivity extends Activity {
@Override @Override
public void videoClose() { public void videoClose() {
videoClose = true; videoClose = true;
mRewardVideoListener.onPlayEnd();
} }
}); });
} }
...@@ -95,13 +94,9 @@ public class RewardVideoActivity extends Activity { ...@@ -95,13 +94,9 @@ public class RewardVideoActivity extends Activity {
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
HlRewardVideoManager.getInstance().onDestroy(); HlRewardVideoManager.getInstance().onDestroy();
if (mRewardVideoListener != null) {
mRewardVideoListener.onAdClose();
}
Utils.showNavKey(this); Utils.showNavKey(this);
mAd = null; mAd = null;
HlCustomView.releaseAllVideos(); HlCustomView.releaseAllVideos();
Log.e("11111","===onDestroy===");
} }
} }
...@@ -85,15 +85,6 @@ public class WebViewActivity extends Activity { ...@@ -85,15 +85,6 @@ public class WebViewActivity extends Activity {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent tel = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(tel);
return true;
} else if (url.startsWith("smsto:") || url.startsWith("sms:")) {
Intent sms = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(sms);
return true;
}
if (url.startsWith("http://") || url.startsWith("https://")) { if (url.startsWith("http://") || url.startsWith("https://")) {
try { try {
WebView.HitTestResult hit = view.getHitTestResult(); WebView.HitTestResult hit = view.getHitTestResult();
......
...@@ -17,6 +17,10 @@ public interface NativeResponse { ...@@ -17,6 +17,10 @@ public interface NativeResponse {
public String getLogoUrl(); public String getLogoUrl();
public int getImageWidth();
public int getImageHeight();
public void handleShow(); public void handleShow();
public void handleClick(View view, boolean click); public void handleClick(View view, boolean click);
......
...@@ -9,7 +9,11 @@ public interface RewardVideoListener { ...@@ -9,7 +9,11 @@ public interface RewardVideoListener {
void onAdClose(); void onAdClose();
void onAdSkip();
void onAdClick(); void onAdClick();
void onPlayEnd(); void onPlayEnd();
void onRewardArrived();
} }
...@@ -39,6 +39,7 @@ public class VASTModel implements Serializable { ...@@ -39,6 +39,7 @@ public class VASTModel implements Serializable {
// Tracking xpath expressions // Tracking xpath expressions
private static final String inlineLinearTrackingXPATH = "/VAST/Ad/InLine/Creatives/Creative/Linear/TrackingEvents/Tracking"; private static final String inlineLinearTrackingXPATH = "/VAST/Ad/InLine/Creatives/Creative/Linear/TrackingEvents/Tracking";
private static final String inlineLinearMEDIAFILESXPATH = "/VAST/Ad/InLine/Creatives/Creative/Linear/MediaFiles";
private static final String inlineNonLinearTrackingXPATH = "/VAST/Ad/InLine/Creatives/Creative/NonLinearAds/TrackingEvents/Tracking"; private static final String inlineNonLinearTrackingXPATH = "/VAST/Ad/InLine/Creatives/Creative/NonLinearAds/TrackingEvents/Tracking";
private static final String wrapperLinearTrackingXPATH = "/VAST/Ad/Wrapper/Creatives/Creative/Linear/TrackingEvents/Tracking"; private static final String wrapperLinearTrackingXPATH = "/VAST/Ad/Wrapper/Creatives/Creative/Linear/TrackingEvents/Tracking";
private static final String wrapperNonLinearTrackingXPATH = "/VAST/Ad/Wrapper/Creatives/Creative/NonLinearAds/TrackingEvents/Tracking"; private static final String wrapperNonLinearTrackingXPATH = "/VAST/Ad/Wrapper/Creatives/Creative/NonLinearAds/TrackingEvents/Tracking";
...@@ -178,7 +179,7 @@ public class VASTModel implements Serializable { ...@@ -178,7 +179,7 @@ public class VASTModel implements Serializable {
mediaFile = new VASTMediaFile(); mediaFile = new VASTMediaFile();
node = childNodes.item(i); node = childNodes.item(i);
NamedNodeMap attributes = node.getAttributes(); NamedNodeMap attributes = node.getAttributes();
if (attributes == null) continue;
attributeNode = attributes.getNamedItem("apiFramework"); attributeNode = attributes.getNamedItem("apiFramework");
mediaFile.setApiFramework((attributeNode == null) ? "" mediaFile.setApiFramework((attributeNode == null) ? ""
: attributeNode.getNodeValue()); : attributeNode.getNodeValue());
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
<WebView <WebView
android:id="@+id/webView" android:id="@+id/webView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp"/> android:layout_height="wrap_content"/>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -25,15 +25,11 @@ ...@@ -25,15 +25,11 @@
android:id="@+id/tv_item_title" android:id="@+id/tv_item_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignTop="@+id/iv_cion1" android:layout_below="@id/iv_cion1"
android:layout_marginStart="10dp" android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_toStartOf="@id/iv_close"
android:layout_toLeftOf="@id/iv_close"
android:layout_toEndOf="@+id/iv_cion1"
android:layout_toRightOf="@+id/iv_cion1"
android:includeFontPadding="false" android:includeFontPadding="false"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end"
android:textColor="#333333" android:textColor="#333333"
android:visibility="gone" android:visibility="gone"
android:textSize="16sp" android:textSize="16sp"
...@@ -44,16 +40,13 @@ ...@@ -44,16 +40,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/tv_item_title" android:layout_below="@+id/tv_item_title"
android:layout_alignStart="@id/tv_item_title"
android:layout_alignLeft="@id/tv_item_title"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_toStartOf="@id/iv_close"
android:layout_toLeftOf="@id/iv_close"
android:includeFontPadding="false" android:includeFontPadding="false"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end"
android:textColor="#555555" android:textColor="#555555"
android:textSize="14sp"
android:visibility="gone" android:visibility="gone"
android:textSize="14sp"
android:text="111111111111" /> android:text="111111111111" />
<LinearLayout <LinearLayout
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment