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

修复快手闪退

parent be803ec4
......@@ -109,12 +109,10 @@ public class AdManager
#endif
break;
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);
}
#endif
break;
default:
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,37 +49,42 @@ public class KsUnityFeedAd {
public void ShowFeedAd(Activity activity, KsUnityFeedShowListener listener) {
if (feedAd != null) {
feedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() {
activity.runOnUiThread(new Runnable() {
@Override
public void onAdClicked() {
listener.onAdClicked();
}
public void run() {
feedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() {
@Override
public void onAdClicked() {
listener.onAdClicked();
}
@Override
public void onAdShow() {
listener.onAdShow();
}
@Override
public void onAdShow() {
listener.onAdShow();
}
@Override
public void onDislikeClicked() {
removeAdView(activity, feedlinearLayout);
listener.onDislikeClicked();
@Override
public void onDislikeClicked() {
removeAdView(activity, feedlinearLayout);
listener.onDislikeClicked();
}
});
feedVidw = feedAd.getFeedView(activity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.BOTTOM;
feedVidw.setLayoutParams(lp);
if (feedVidw != null) {
feedlinearLayout = new LinearLayout(activity);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
feedlinearLayout.setLayoutParams(layoutParams);
feedlinearLayout.addView(feedVidw);
ViewGroup root = getRootLayout(activity);
if (feedVidw != null) {
root.addView(feedlinearLayout);
}
}
}
});
feedVidw = feedAd.getFeedView(activity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.BOTTOM;
feedVidw.setLayoutParams(lp);
if (feedVidw != null) {
feedlinearLayout = new LinearLayout(activity);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
feedlinearLayout.setLayoutParams(layoutParams);
feedlinearLayout.addView(feedVidw);
ViewGroup root = getRootLayout(activity);
if (feedVidw != null) {
root.addView(feedlinearLayout);
}
}
} else {
listener.onShowError(-1, "没有大图广告数据");
}
......
......@@ -7,6 +7,7 @@ public class KsAdSDK
{
public static void InitKsAdSDK(string AppId, string AppName)
{
Debug.unityLogger.Log("快手Appid"+AppId+ "AppName"+ AppName);
#if UNITY_ANDROID&&!UNITY_EDITOR
AndroidJavaClass splashAd = new AndroidJavaClass("com.ym.unitykssdk.KsAdSDKInitUtil");
splashAd.CallStatic("initSDK", Utils.GetActivity(), AppId, AppName);
......
......@@ -5,7 +5,7 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
- enabled: 0
path: Assets/AdSDK/AD/CSJ/Example/Example.unity
guid: 1e4f8457b1266154e80399e42b932ceb
- enabled: 0
......@@ -17,7 +17,7 @@ EditorBuildSettings:
- enabled: 0
path: Assets/AdSDK/SplashDemo/Splash.unity
guid: 37af8cf3fb373478ab04e3ee2f3b700a
- enabled: 0
- enabled: 1
path: Assets/AdSDK/AD/Demo/AdDemo.unity
guid: ef80a35d44f809e4a8957d1ed9571fd2
- enabled: 0
......
......@@ -175,7 +175,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.ym.wdlc
Android: com.ym.wyymf
Lumin: com.DefaultCompany.com.unity.template.mobile2D
Standalone: 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