Commit 3d69bb09 authored by 王雪伟's avatar 王雪伟

修复快手闪退

parent be803ec4
...@@ -109,12 +109,10 @@ public class AdManager ...@@ -109,12 +109,10 @@ public class AdManager
#endif #endif
break; break;
case ZXADConfig.PLANTFORM_AD_KUS: case ZXADConfig.PLANTFORM_AD_KUS:
#if UNITUY_ANDROD
if (id.codeAppId != null && id.codeAppId != "") if (id.codeAppId != null && id.codeAppId != "")
{ {
KsAdSDK.InitKsAdSDK(id.codeAppId,Application.identifier); KsAdSDK.InitKsAdSDK(id.codeAppId,Application.identifier);
} }
#endif
break; break;
default: default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持初始化" + id.adPlatform + "的广告"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持初始化" + id.adPlatform + "的广告");
......
using System;
using System.Collections.Generic;
using UnityEngine;
public class AdUtils
{
private AdUtils() { }
private static readonly AdUtils singleInstance = new AdUtils();
public static AdUtils Instance
{
get
{
return singleInstance;
}
}
private void InitAd()
{
AdManager.Instance.InitAd(new Action<bool>((cb)=> {
if (cb)
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
}));
}
/// <summary>
/// 播放开屏广告
/// </summary>
public void ShowSplashAd(Action<bool> callback)
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(callback));
}
/// <summary>
/// 播放激励视频广告
/// </summary>
public void ShowRewardAd(string action,Action<bool> callback)
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(callback));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private Action<bool> callback;
public SplshAdListener(Action<bool> callback)
{
this.callback = callback;
}
public void onAdShow()
{
}
public void onAdSkip()
{
callback(true);
}
public void onError(string errorMsg)
{
}
public void onLastError()
{
callback(true);
}
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private Action<bool> callback;
public RewardAdListener(Action<bool> callback)
{
this.callback = callback;
}
public void onAdClose(AdEntity entity)
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
callback(true);
}
public void onAdShow()
{
}
public void onAdVideoBarClick()
{
}
public void onError(string errorMsg)
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
callback(false);
}
public void onSuccess()
{
}
}
}
fileFormatVersion: 2
guid: 7254c6703a47f6f438d80ec0dc944695
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -49,6 +49,9 @@ public class KsUnityFeedAd { ...@@ -49,6 +49,9 @@ public class KsUnityFeedAd {
public void ShowFeedAd(Activity activity, KsUnityFeedShowListener listener) { public void ShowFeedAd(Activity activity, KsUnityFeedShowListener listener) {
if (feedAd != null) { if (feedAd != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
feedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() { feedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() {
@Override @Override
public void onAdClicked() { public void onAdClicked() {
...@@ -80,6 +83,8 @@ public class KsUnityFeedAd { ...@@ -80,6 +83,8 @@ public class KsUnityFeedAd {
root.addView(feedlinearLayout); root.addView(feedlinearLayout);
} }
} }
}
});
} else { } else {
listener.onShowError(-1, "没有大图广告数据"); listener.onShowError(-1, "没有大图广告数据");
} }
......
...@@ -7,6 +7,7 @@ public class KsAdSDK ...@@ -7,6 +7,7 @@ public class KsAdSDK
{ {
public static void InitKsAdSDK(string AppId, string AppName) public static void InitKsAdSDK(string AppId, string AppName)
{ {
Debug.unityLogger.Log("快手Appid"+AppId+ "AppName"+ AppName);
#if UNITY_ANDROID&&!UNITY_EDITOR #if UNITY_ANDROID&&!UNITY_EDITOR
AndroidJavaClass splashAd = new AndroidJavaClass("com.ym.unitykssdk.KsAdSDKInitUtil"); AndroidJavaClass splashAd = new AndroidJavaClass("com.ym.unitykssdk.KsAdSDKInitUtil");
splashAd.CallStatic("initSDK", Utils.GetActivity(), AppId, AppName); splashAd.CallStatic("initSDK", Utils.GetActivity(), AppId, AppName);
......
...@@ -5,7 +5,7 @@ EditorBuildSettings: ...@@ -5,7 +5,7 @@ EditorBuildSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Scenes: m_Scenes:
- enabled: 1 - enabled: 0
path: Assets/AdSDK/AD/CSJ/Example/Example.unity path: Assets/AdSDK/AD/CSJ/Example/Example.unity
guid: 1e4f8457b1266154e80399e42b932ceb guid: 1e4f8457b1266154e80399e42b932ceb
- enabled: 0 - enabled: 0
...@@ -17,7 +17,7 @@ EditorBuildSettings: ...@@ -17,7 +17,7 @@ EditorBuildSettings:
- enabled: 0 - enabled: 0
path: Assets/AdSDK/SplashDemo/Splash.unity path: Assets/AdSDK/SplashDemo/Splash.unity
guid: 37af8cf3fb373478ab04e3ee2f3b700a guid: 37af8cf3fb373478ab04e3ee2f3b700a
- enabled: 0 - enabled: 1
path: Assets/AdSDK/AD/Demo/AdDemo.unity path: Assets/AdSDK/AD/Demo/AdDemo.unity
guid: ef80a35d44f809e4a8957d1ed9571fd2 guid: ef80a35d44f809e4a8957d1ed9571fd2
- enabled: 0 - enabled: 0
......
...@@ -175,7 +175,7 @@ PlayerSettings: ...@@ -175,7 +175,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1 androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1 androidMaxAspectRatio: 2.1
applicationIdentifier: applicationIdentifier:
Android: com.ym.wdlc Android: com.ym.wyymf
Lumin: com.DefaultCompany.com.unity.template.mobile2D Lumin: com.DefaultCompany.com.unity.template.mobile2D
Standalone: com.DefaultCompany.com.unity.template.mobile2D Standalone: com.DefaultCompany.com.unity.template.mobile2D
iPhone: com.DefaultCompany.com.unity.template.mobile2D iPhone: com.DefaultCompany.com.unity.template.mobile2D
......
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