Explorar el Código

[添加]增加掌酷广告

zeki hace 5 años
padre
commit
1d5ec9c71b

+ 3 - 1
app/build.gradle

@@ -180,7 +180,9 @@ dependencies {
     implementation(name: 'alipaySdk-15.5.9', ext: 'aar')
     implementation(name: 'ad_dk_sdk', ext: 'aar')
     implementation(name: 'klevinSDK', ext: 'aar')
-    //implementation(name: 'lygamewrapper-sheep-release', ext: 'aar')
+    implementation(name: 'lygamewrapper-sheep-release', ext: 'aar'){
+        exclude group: 'com.google.android',module: 'exoplayer2'
+    }
 
     //其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.0
     implementation 'com.tencent.bugly:nativecrashreport:3.3.1'

BIN
app/libs/lygamewrapper-sheep-release.aar


+ 29 - 1
app/proguard-rules.pro

@@ -624,4 +624,32 @@
 -keep @android.support.annotation.Keep class **{
 @android.support.annotation.Keep <fields>;
 @android.support.annotation.Keep <methods>;
-}
+}
+-keep class com.lygame.wrapper.provider.* { public *; }
+-keep class com.lygame.wrapper.sdk.LySdk { *; }
+-keep class com.lygame.wrapper.strategy.DefaultStrategy { *; }
+-keep class com.lygame.wrapper.strategy.SdkStrategy { *; }
+-keep class com.lygame.wrapper.ad.LySplashAdBuilder { *; }
+-keep class com.lygame.wrapper.util.LySdkEventUtil { *; }
+-keep class com.lygame.wrapper.util.Base64Util { *; }
+-keep class com.lygame.wrapper.interfaces.* { *; }
+-keep class com.innerscore.rtlog.RuntimeLogManager{ *; }
+-keep class com.ksdk.** {*; }
+
+
+#OAID混淆
+-keep class XI.CA.XI.**{*;}
+-keep class XI.K0.XI.**{*;}
+-keep class XI.XI.K0.**{*;}
+-keep class XI.vs.K0.**{*;}
+-keep class XI.xo.XI.XI.**{*;}
+-keep class com.asus.msa.SupplementaryDID.**{*;}
+-keep class com.asus.msa.sdid.**{*;}
+-keep class com.bun.lib.**{*;}
+-keep class com.bun.miitmdid.**{*;}
+-keep class com.huawei.hms.ads.identifier.**{*;}
+-keep class com.samsung.android.deviceidservice.**{*;}
+-keep class org.json.**{*;}
+-keep public class com.netease.nis.sdkwrapper.Utils {public
+<methods>;}
+-keep class com.zk.deviceidentifier.** { *; }

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -66,6 +66,7 @@
             android:supportsRtl="true"
             android:theme="@style/AppTheme"
             android:usesCleartextTraffic="true">
+
         <activity
                 android:name="com.sheep.gamegroup.module.task.VideoTaskActivity"
                 android:configChanges="keyboardHidden|navigation|orientation|screenSize"

+ 2 - 5
app/src/main/java/com/sheep/gamegroup/module/task/VideoTaskActivity.java

@@ -12,10 +12,7 @@ import android.view.View;
 import android.view.WindowManager;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.model.entity.Release_task;
-import com.sheep.gamegroup.module.task.fragments.FgtVideoTaskBase;
-import com.sheep.gamegroup.module.task.fragments.FgtVideoTaskDK;
-import com.sheep.gamegroup.module.task.fragments.FgtVideoTaskYKY;
-import com.sheep.gamegroup.module.task.fragments.FgtVideoTaskZK;
+import com.sheep.gamegroup.module.task.fragments.*;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -100,7 +97,7 @@ public class VideoTaskActivity extends BaseActivity {
                 //游可盈
                 return new FgtVideoTaskYKY().setReleaseTaskId(releaseTask.getId()).setReleaseTask(releaseTask);
             case 4:
-                //优投
+                //优投 todo 优投暂时没有激励视频
                 return new FgtVideoTaskYKY().setReleaseTaskId(releaseTask.getId()).setReleaseTask(releaseTask);
             default:
                 finish();

+ 64 - 262
app/src/main/java/com/sheep/gamegroup/module/task/fragments/FgtVideoTaskZK.java

@@ -1,102 +1,29 @@
 package com.sheep.gamegroup.module.task.fragments;
 
-import android.text.TextUtils;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.kfzs.duanduan.cardview.ScreenUtil;
-import com.kfzs.duanduan.utils.ApkUtils;
-import com.sheep.gamegroup.module.task.helper.ADDownloader;
-import com.sheep.gamegroup.module.task.helper.ADVideoHelper;
-import com.sheep.gamegroup.module.task.helper.VideoAd;
-import com.sheep.gamegroup.util.GlideImageLoader;
-import com.sheep.gamegroup.util.Jump2View;
+import android.widget.Toast;
+import com.lygame.wrapper.interfaces.IRewardVideoController;
+import com.lygame.wrapper.interfaces.IRewardVideoLoadCallback;
+import com.lygame.wrapper.interfaces.IRewardVideoPlayCallback;
+import com.lygame.wrapper.sdk.LySdk;
 import com.sheep.gamegroup.util.LogUtil;
-import com.sheep.gamegroup.util.ViewUtil;
-import com.sheep.gamegroup.view.customview.SheepGSYVideoView;
-import com.sheep.gamegroup.view.dialog.DialogProgress;
-import com.sheep.jiuyan.samllsheep.R;
-import com.sheep.jiuyan.samllsheep.SheepApp;
-import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
-import com.shuyu.gsyvideoplayer.GSYVideoManager;
-import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
-import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack;
-import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
-
-import butterknife.BindView;
-import butterknife.OnClick;
+import java.util.concurrent.atomic.AtomicReference;
 
 /**
- * 掌酷广告视频
+ * 游可盈广告视频
  */
-public class FgtVideoTaskZK extends FgtVideoTaskBase {
-
-    @BindView(R.id.video_player_view)
-    SheepGSYVideoView videoPlayerView;
-    @BindView(R.id.mask_view)
-    View mask_view;
-    @BindView(R.id.desc_tv)
-    TextView desc_tv;
-    @BindView(R.id.name_tv)
-    TextView name_tv;
-    @BindView(R.id.action_btn)
-    Button action_btn;
-    @BindView(R.id.logo_iv)
-    ImageView logo_iv;
-    @BindView(R.id.countdown_view)
-    TextView countdown_view;
 
-    private VideoAd currentVideoAd;
-
-    @Override
-    public int getLayoutId() {
-        return R.layout.activity_video_task;
-    }
+public class FgtVideoTaskZK extends FgtVideoTaskBase {
+    private static final String TAG = "掌酷视频广告页";
 
-    @Override
-    public void onResume() {
-        super.onResume();
-        videoPlayerView.onVideoResume();
-        configActionBtn();
-    }
+    //是否领过奖了
+    boolean hasGetReward = false;
 
-    @Override
-    public void onPause() {
-        super.onPause();
-        videoPlayerView.onVideoPause();
-    }
+    private AtomicReference<IRewardVideoController> controllerRef = new AtomicReference<>();
 
-    @Override
-    public void onDestroy() {
-        if (currentVideoAd != null) {
-            currentVideoAd.trigger(VideoAd.TYPE_VIDEO_CLOSE);
-        }
-        super.onDestroy();
-    }
 
     @Override
     protected void initView() {
-        videoPlayerView.setShowControlView(false);
-        videoPlayerView.getBackButton().setVisibility(View.GONE);
-        videoPlayerView.getFullscreenButton().setVisibility(View.GONE);
-        videoPlayerView.getBottomProgressBar().setVisibility(View.GONE);
 
-        mask_view.setOnTouchListener((v, event) -> {
-            if (event.getAction() == MotionEvent.ACTION_UP && currentVideoAd != null) {
-                currentVideoAd.clickX = (int) event.getRawX();
-                currentVideoAd.clickY = (int) event.getRawY();
-                currentVideoAd.trigger(VideoAd.TYPE_CLICK);
-                if (videoPlayerView.getCurrentState() == GSYVideoView.CURRENT_STATE_PAUSE) {
-                    videoPlayerView.onVideoResume();
-                } else if (videoPlayerView.getCurrentState() == GSYVideoView.CURRENT_STATE_PLAYING) {
-                    videoPlayerView.onVideoPause();
-                }
-            }
-            return true;
-        });
     }
 
     @Override
@@ -109,197 +36,72 @@ public class FgtVideoTaskZK extends FgtVideoTaskBase {
         }
     }
 
+    //加载激励视频
+    @Override
     protected void loadAd() {
-        ADVideoHelper.loadVideoAD((ret, ad, msg) -> {
-            getActivity().runOnUiThread(() -> {
-                if (ret) {
-                    currentVideoAd = ad;
-                    desc_tv.setText(currentVideoAd.desc);
-                    name_tv.setText(currentVideoAd.title);
-                    GlideImageLoader.circleImage(logo_iv, currentVideoAd.logo);
-                    playVideo();
-                    configActionBtn();
-                } else {
-                    ViewUtil.showConfirmDialog(getContext(),
-                            "不好",
-                            "没获取到视频小片,需要再次获取吗?",
-                            "放弃", "重试",
-                            d -> giveUpTask(),
-                            d -> loadAd()).show();
-                }
-            });
-        });
-    }
+        int adId = 47906;
+
+        LySdk.loadRewardVideo(getActivity(), String.valueOf(adId), new IRewardVideoLoadCallback() {
+            @Override
+            public void onFailed(int i, String s) {
 
-    private void configActionBtn() {
-        if (getActivity() == null || getActivity().isDestroyed() || currentVideoAd == null || currentVideoAd.url == null)
-            return;
-        if (!currentVideoAd.url.endsWith(".apk")) {
-            action_btn.setText("查看详情");
-            action_btn.setTag(0);
-        } else {
-            String path = ADDownloader.getUrlPath(currentVideoAd.url);
-            if (PackageUtil.isAppInstalled(SheepApp.getInstance(), currentVideoAd.package_name)) {
-                action_btn.setText("打开应用");
-                action_btn.setTag(1);
-            } else if (!TextUtils.isEmpty(path)) {
-                action_btn.setText("立即安装");
-                action_btn.setTag(2);
-                currentVideoAd.path = path;
-            } else {
-                action_btn.setText("下载应用");
-                action_btn.setTag(3);
             }
-        }
-    }
 
-    @OnClick(R.id.action_btn)
-    public void onActionClick(View v) {
-        int action = (int) v.getTag();
-        switch (action) {
-            case 0:
-                jumpWeb();
-                break;
-            case 1:
-                openApp();
-                break;
-            case 2:
-                installApp();
-                break;
-            case 3:
-                downloadApp();
-                break;
-        }
+            @Override
+            public void onLoaded(IRewardVideoController iRewardVideoController) {
+                controllerRef.set(iRewardVideoController);
+                showAd();
+            }
+        });
     }
 
-    private void playVideo() {
-        GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder();
-        gsyVideoOption.setIsTouchWiget(false)
-                .setRotateViewAuto(true)
-                .setLockLand(true)
-                .setAutoFullWithSize(false)
-                .setShowFullAnimation(false)
-                .setUrl(currentVideoAd.videoUrl)
-                .setNeedLockFull(true)
-                .setCacheWithPlay(false)
-                .setGSYVideoProgressListener((progress, secProgress, currentPosition, duration) -> {
-                    countdown_view.setText("" + ((duration - currentPosition) / 1000));
-                })
-                .setVideoAllCallBack(new GSYSampleCallBack() {
-                    @Override
-                    public void onPrepared(String url, Object... objects) {
-                        super.onPrepared(url, objects);
-                        LogUtil.println("initPlay", "onPrepared", url, objects);
-                    }
-
-                    @Override
-                    public void onAutoComplete(String url, Object... objects) {
-                        super.onAutoComplete(url, objects);
-                        currentVideoAd.trigger(VideoAd.TYPE_VIDEO_END);
-                        tryGetReward();
-                    }
-
-                    @Override
-                    public void onPlayError(String url, Object... objects) {
-                        super.onPlayError(url, objects);
-                        long curPosition = GSYVideoManager.instance().getCurPlayerManager().getCurrentPosition();
-                        LogUtil.println("initPlay", "onPlayError", url, curPosition);
-                    }
-                }).build(videoPlayerView);
-        videoPlayerView.startPlayLogic();
-        currentVideoAd.trigger(VideoAd.TYPE_VIDEO_START);
-    }
+    //播放激励视频
+    private void showAd() {
+        IRewardVideoController controller;
+        if ((controller = controllerRef.getAndSet(null)) != null) {
+            controller.show(new IRewardVideoPlayCallback() {
+                @Override
+                public void onAdShow() {
 
-    private void jumpWeb() {
-        if (currentVideoAd == null) return;
-        Jump2View.getInstance().goWeb(getContext(), currentVideoAd.url);
-    }
+                }
 
-    private void openApp() {
-        if (currentVideoAd == null) return;
-        currentVideoAd.trigger(VideoAd.TYPE_ACTIVE);
-        currentVideoAd.trigger(VideoAd.TYPE_OPEN);
-        PackageUtil.startApp(getContext(), currentVideoAd.package_name);
-    }
+                @Override
+                public void onInterTriggered() {
+                    //Toast.makeText(getContext(), "广告点击了", Toast.LENGTH_SHORT).show();
+                }
 
-    private void downloadApp() {
-        if (currentVideoAd == null) return;
-        videoPlayerView.onVideoPause();
-        currentVideoAd.trigger(VideoAd.TYPE_DOWNLOAD);
-        showDownloadDialog();
-    }
+                @Override
+                public void onAdClose() {
+                    //用户点击关闭了界面
+                    if (!hasGetReward) {
+                        //未领奖,调用放弃任务接口
+                        giveUpTask();
+                    } else {
+                        if (getActivity() != null)
+                            getActivity().finish();
+                    }
+                }
 
-    private void installApp() {
-        if (currentVideoAd == null) return;
-        currentVideoAd.trigger(VideoAd.TYPE_INSTALL);
-        ApkUtils.installApk(getContext(), currentVideoAd.path);
-    }
+                @Override
+                public void onVideoComplete() {
 
-    private void installApp(VideoAd ad) {
-        if (ad == null) return;
-        ad.trigger(VideoAd.TYPE_INSTALL);
-        ApkUtils.installApk(getContext(), ad.path);
-    }
+                }
 
-    private void showAppConfirmDialog(String title, String btnText, ViewUtil.OnConfirmDialogListener listener) {
-        View rootView = View.inflate(getContext(), R.layout.video_ad_confirm, null);
-        ImageView app_logo_iv = rootView.findViewById(R.id.app_logo_iv);
-        TextView app_name_tv = rootView.findViewById(R.id.app_name_tv);
-        TextView app_desc_tv = rootView.findViewById(R.id.app_desc_tv);
-        int radius = ScreenUtil.dip2px(getActivity(), 8);
-        GlideImageLoader.roundedCornersImage(app_logo_iv, currentVideoAd.logo, radius);
-        app_name_tv.setText(currentVideoAd.title);
-        app_desc_tv.setText(currentVideoAd.desc);
-        videoPlayerView.onVideoPause();
-        ViewUtil.showConfirmDialog(getContext(), title, rootView, "取消", btnText,
-                d -> {
-                    d.dismiss();
-                    videoPlayerView.onVideoResume();
-                },
-                listener).show();
+                @Override
+                public void onRewarded() {
+                    //满足领奖条件,去领奖
+                    hasGetReward = true;
+                    tryGetReward();
+                }
+            });
+        } else {
+            Toast.makeText(getContext(), "广告未加载成功", Toast.LENGTH_SHORT).show();
+        }
     }
 
-    private void showDownloadDialog() {
-        final DialogProgress progress = DialogProgress.showDialog(getActivity(), true);
-        progress.getAlertDialog().setOnDismissListener(d -> {
-
-        });
-        final VideoAd thisAd = currentVideoAd.clone();
-        new ADDownloader()
-                .setListener(new ADDownloader.ProgressListener() {
-
-                    @Override
-                    public void onProgress(long offset, long total) {
-                        LogUtil.logE(offset + " /// " + total);
-                        long percent = offset * 100 / total;
-                        getActivity().runOnUiThread(() -> {
-                            if (progress.getAlertDialog().isShowing()) {
-                                progress.getTextView().setText(percent + "%");
-                            }
-                        });
-                    }
-
-                    @Override
-                    public void onStatus(String status, String msg) {
-                        getActivity().runOnUiThread(() -> {
-                            if (getActivity() == null || getActivity().isDestroyed()) return;
-                            if (progress.getAlertDialog().isShowing()) {
-                                progress.getAlertDialog().dismiss();
-                            }
-                            if ("COMPLETED".equals(status)) {
-                                thisAd.path = msg;
-                                configActionBtn();
-                                installApp(thisAd);
-                            } else {
-                                videoPlayerView.onVideoResume();
-                                LogUtil.logE(status + " /// " + msg);
-                            }
-                        });
-                    }
-                })
-                .init()
-                .start(currentVideoAd);
-
+    @Override
+    public int getLayoutId() {
+        return 0;
     }
 
 }

+ 305 - 0
app/src/main/java/com/sheep/gamegroup/module/task/fragments/FgtVideoTaskZKOld.java

@@ -0,0 +1,305 @@
+package com.sheep.gamegroup.module.task.fragments;
+
+import android.text.TextUtils;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.kfzs.duanduan.cardview.ScreenUtil;
+import com.kfzs.duanduan.utils.ApkUtils;
+import com.sheep.gamegroup.module.task.helper.ADDownloader;
+import com.sheep.gamegroup.module.task.helper.ADVideoHelper;
+import com.sheep.gamegroup.module.task.helper.VideoAd;
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.view.customview.SheepGSYVideoView;
+import com.sheep.gamegroup.view.dialog.DialogProgress;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
+import com.shuyu.gsyvideoplayer.GSYVideoManager;
+import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
+import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack;
+import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+/**
+ * 掌酷广告视频(未使用,已改为SDK方式接入))
+ */
+public class FgtVideoTaskZKOld extends FgtVideoTaskBase {
+
+    @BindView(R.id.video_player_view)
+    SheepGSYVideoView videoPlayerView;
+    @BindView(R.id.mask_view)
+    View mask_view;
+    @BindView(R.id.desc_tv)
+    TextView desc_tv;
+    @BindView(R.id.name_tv)
+    TextView name_tv;
+    @BindView(R.id.action_btn)
+    Button action_btn;
+    @BindView(R.id.logo_iv)
+    ImageView logo_iv;
+    @BindView(R.id.countdown_view)
+    TextView countdown_view;
+
+    private VideoAd currentVideoAd;
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_video_task;
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        videoPlayerView.onVideoResume();
+        configActionBtn();
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        videoPlayerView.onVideoPause();
+    }
+
+    @Override
+    public void onDestroy() {
+        if (currentVideoAd != null) {
+            currentVideoAd.trigger(VideoAd.TYPE_VIDEO_CLOSE);
+        }
+        super.onDestroy();
+    }
+
+    @Override
+    protected void initView() {
+        videoPlayerView.setShowControlView(false);
+        videoPlayerView.getBackButton().setVisibility(View.GONE);
+        videoPlayerView.getFullscreenButton().setVisibility(View.GONE);
+        videoPlayerView.getBottomProgressBar().setVisibility(View.GONE);
+
+        mask_view.setOnTouchListener((v, event) -> {
+            if (event.getAction() == MotionEvent.ACTION_UP && currentVideoAd != null) {
+                currentVideoAd.clickX = (int) event.getRawX();
+                currentVideoAd.clickY = (int) event.getRawY();
+                currentVideoAd.trigger(VideoAd.TYPE_CLICK);
+                if (videoPlayerView.getCurrentState() == GSYVideoView.CURRENT_STATE_PAUSE) {
+                    videoPlayerView.onVideoResume();
+                } else if (videoPlayerView.getCurrentState() == GSYVideoView.CURRENT_STATE_PLAYING) {
+                    videoPlayerView.onVideoPause();
+                }
+            }
+            return true;
+        });
+    }
+
+    @Override
+    protected void initData() {
+        if (releaseTask.getH5_accepted_task_id() > 0) {
+            loadAcceptedTask();
+        } else {
+            LogUtil.logI("---------------没有接受任务---------------");
+            acceptTask();
+        }
+    }
+
+    protected void loadAd() {
+        ADVideoHelper.loadVideoAD((ret, ad, msg) -> {
+            getActivity().runOnUiThread(() -> {
+                if (ret) {
+                    currentVideoAd = ad;
+                    desc_tv.setText(currentVideoAd.desc);
+                    name_tv.setText(currentVideoAd.title);
+                    GlideImageLoader.circleImage(logo_iv, currentVideoAd.logo);
+                    playVideo();
+                    configActionBtn();
+                } else {
+                    ViewUtil.showConfirmDialog(getContext(),
+                            "不好",
+                            "没获取到视频小片,需要再次获取吗?",
+                            "放弃", "重试",
+                            d -> giveUpTask(),
+                            d -> loadAd()).show();
+                }
+            });
+        });
+    }
+
+    private void configActionBtn() {
+        if (getActivity() == null || getActivity().isDestroyed() || currentVideoAd == null || currentVideoAd.url == null)
+            return;
+        if (!currentVideoAd.url.endsWith(".apk")) {
+            action_btn.setText("查看详情");
+            action_btn.setTag(0);
+        } else {
+            String path = ADDownloader.getUrlPath(currentVideoAd.url);
+            if (PackageUtil.isAppInstalled(SheepApp.getInstance(), currentVideoAd.package_name)) {
+                action_btn.setText("打开应用");
+                action_btn.setTag(1);
+            } else if (!TextUtils.isEmpty(path)) {
+                action_btn.setText("立即安装");
+                action_btn.setTag(2);
+                currentVideoAd.path = path;
+            } else {
+                action_btn.setText("下载应用");
+                action_btn.setTag(3);
+            }
+        }
+    }
+
+    @OnClick(R.id.action_btn)
+    public void onActionClick(View v) {
+        int action = (int) v.getTag();
+        switch (action) {
+            case 0:
+                jumpWeb();
+                break;
+            case 1:
+                openApp();
+                break;
+            case 2:
+                installApp();
+                break;
+            case 3:
+                downloadApp();
+                break;
+        }
+    }
+
+    private void playVideo() {
+        GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder();
+        gsyVideoOption.setIsTouchWiget(false)
+                .setRotateViewAuto(true)
+                .setLockLand(true)
+                .setAutoFullWithSize(false)
+                .setShowFullAnimation(false)
+                .setUrl(currentVideoAd.videoUrl)
+                .setNeedLockFull(true)
+                .setCacheWithPlay(false)
+                .setGSYVideoProgressListener((progress, secProgress, currentPosition, duration) -> {
+                    countdown_view.setText("" + ((duration - currentPosition) / 1000));
+                })
+                .setVideoAllCallBack(new GSYSampleCallBack() {
+                    @Override
+                    public void onPrepared(String url, Object... objects) {
+                        super.onPrepared(url, objects);
+                        LogUtil.println("initPlay", "onPrepared", url, objects);
+                    }
+
+                    @Override
+                    public void onAutoComplete(String url, Object... objects) {
+                        super.onAutoComplete(url, objects);
+                        currentVideoAd.trigger(VideoAd.TYPE_VIDEO_END);
+                        tryGetReward();
+                    }
+
+                    @Override
+                    public void onPlayError(String url, Object... objects) {
+                        super.onPlayError(url, objects);
+                        long curPosition = GSYVideoManager.instance().getCurPlayerManager().getCurrentPosition();
+                        LogUtil.println("initPlay", "onPlayError", url, curPosition);
+                    }
+                }).build(videoPlayerView);
+        videoPlayerView.startPlayLogic();
+        currentVideoAd.trigger(VideoAd.TYPE_VIDEO_START);
+    }
+
+    private void jumpWeb() {
+        if (currentVideoAd == null) return;
+        Jump2View.getInstance().goWeb(getContext(), currentVideoAd.url);
+    }
+
+    private void openApp() {
+        if (currentVideoAd == null) return;
+        currentVideoAd.trigger(VideoAd.TYPE_ACTIVE);
+        currentVideoAd.trigger(VideoAd.TYPE_OPEN);
+        PackageUtil.startApp(getContext(), currentVideoAd.package_name);
+    }
+
+    private void downloadApp() {
+        if (currentVideoAd == null) return;
+        videoPlayerView.onVideoPause();
+        currentVideoAd.trigger(VideoAd.TYPE_DOWNLOAD);
+        showDownloadDialog();
+    }
+
+    private void installApp() {
+        if (currentVideoAd == null) return;
+        currentVideoAd.trigger(VideoAd.TYPE_INSTALL);
+        ApkUtils.installApk(getContext(), currentVideoAd.path);
+    }
+
+    private void installApp(VideoAd ad) {
+        if (ad == null) return;
+        ad.trigger(VideoAd.TYPE_INSTALL);
+        ApkUtils.installApk(getContext(), ad.path);
+    }
+
+    private void showAppConfirmDialog(String title, String btnText, ViewUtil.OnConfirmDialogListener listener) {
+        View rootView = View.inflate(getContext(), R.layout.video_ad_confirm, null);
+        ImageView app_logo_iv = rootView.findViewById(R.id.app_logo_iv);
+        TextView app_name_tv = rootView.findViewById(R.id.app_name_tv);
+        TextView app_desc_tv = rootView.findViewById(R.id.app_desc_tv);
+        int radius = ScreenUtil.dip2px(getActivity(), 8);
+        GlideImageLoader.roundedCornersImage(app_logo_iv, currentVideoAd.logo, radius);
+        app_name_tv.setText(currentVideoAd.title);
+        app_desc_tv.setText(currentVideoAd.desc);
+        videoPlayerView.onVideoPause();
+        ViewUtil.showConfirmDialog(getContext(), title, rootView, "取消", btnText,
+                d -> {
+                    d.dismiss();
+                    videoPlayerView.onVideoResume();
+                },
+                listener).show();
+    }
+
+    private void showDownloadDialog() {
+        final DialogProgress progress = DialogProgress.showDialog(getActivity(), true);
+        progress.getAlertDialog().setOnDismissListener(d -> {
+
+        });
+        final VideoAd thisAd = currentVideoAd.clone();
+        new ADDownloader()
+                .setListener(new ADDownloader.ProgressListener() {
+
+                    @Override
+                    public void onProgress(long offset, long total) {
+                        LogUtil.logE(offset + " /// " + total);
+                        long percent = offset * 100 / total;
+                        getActivity().runOnUiThread(() -> {
+                            if (progress.getAlertDialog().isShowing()) {
+                                progress.getTextView().setText(percent + "%");
+                            }
+                        });
+                    }
+
+                    @Override
+                    public void onStatus(String status, String msg) {
+                        getActivity().runOnUiThread(() -> {
+                            if (getActivity() == null || getActivity().isDestroyed()) return;
+                            if (progress.getAlertDialog().isShowing()) {
+                                progress.getAlertDialog().dismiss();
+                            }
+                            if ("COMPLETED".equals(status)) {
+                                thisAd.path = msg;
+                                configActionBtn();
+                                installApp(thisAd);
+                            } else {
+                                videoPlayerView.onVideoResume();
+                                LogUtil.logE(status + " /// " + msg);
+                            }
+                        });
+                    }
+                })
+                .init()
+                .start(currentVideoAd);
+
+    }
+
+}

+ 152 - 84
app/src/main/java/com/sheep/gamegroup/view/activity/SplashAct.java

@@ -19,6 +19,11 @@ import android.widget.*;
 import com.bumptech.glide.Glide;
 import com.jasmine.cantaloupe.engine.SplashEngine;
 import com.jasmine.cantaloupe.ui.widget.AdFrameLayout;
+import com.lygame.wrapper.ad.LySplashAdBuilder;
+import com.lygame.wrapper.interfaces.ISplashAdCallback;
+import com.lygame.wrapper.interfaces.ISplashAdController;
+import com.lygame.wrapper.interfaces.ISplashAdLoadCallback;
+import com.lygame.wrapper.sdk.LySdk;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.greendao.DDProviderHelper;
 import com.sheep.gamegroup.greendao.download.SheepAd;
@@ -42,6 +47,7 @@ import com.tencent.klevin.base.callback.KleinResponseCallback;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
 
 import butterknife.BindView;
 import butterknife.OnClick;
@@ -65,6 +71,9 @@ public class SplashAct extends BaseActivity {
         // doNothing
     }
 
+
+    @BindView(R.id.fl_root)
+    FrameLayout zk_root;
     @BindView(R.id.fv_splash_yt)
     AdFrameLayout flSplashYT;
     @BindView(R.id.splash_image_view)
@@ -77,6 +86,10 @@ public class SplashAct extends BaseActivity {
     VideoView splash_video_view;
     @BindView(R.id.ad_flag)
     View ad_flag;
+
+    //掌酷广告控制器
+    private AtomicReference<ISplashAdController> controllerRef = new AtomicReference<>();
+
     private boolean goLink;//跳转到了广告对应的页面
     //是否强制跳转到主页面
     private boolean mForceGoMain = false;
@@ -175,7 +188,11 @@ public class SplashAct extends BaseActivity {
             Log.d("!!!!!!", "加载优投广告");
             //优投
             launchYTSplash();
-        }else {
+        } else if (adType == AD_SPLASH_TYPE_ZK) {
+            Log.d("!!!!!!", "加载掌酷广告");
+            //掌酷
+            launchZKSplash();
+        } else {
             sendHandlerMessages(0);
         }
     }
@@ -183,108 +200,159 @@ public class SplashAct extends BaseActivity {
 
     //展示游可盈广告
     private void launchYKYSplash() {
-            String data = "{\"placements\":[{\"pos_id\":" + ad.getThird_ad_id() + ",\"ad_count\":1}]}";
-            //"{\"placements\":[{\"pos_id\":" + posId + ",\"ad_count\":1}]}";
-            KleinManager.getInstance().prepareAD(
-                    getApplicationContext(),
-                    data,
-                    5000,
-                    true,
-                    new KleinResponseCallback() {
-                        @Override
-                        public void onSuccess(int i) {
-                            if (BuildConfig.DEBUG)
-                                Log.d("!!!!!Success", String.valueOf(i));
-                        }
+        String data = "{\"placements\":[{\"pos_id\":" + ad.getThird_ad_id() + ",\"ad_count\":1}]}";
+        //"{\"placements\":[{\"pos_id\":" + posId + ",\"ad_count\":1}]}";
+        KleinManager.getInstance().prepareAD(
+                getApplicationContext(),
+                data,
+                5000,
+                true,
+                new KleinResponseCallback() {
+                    @Override
+                    public void onSuccess(int i) {
+                        if (BuildConfig.DEBUG)
+                            Log.d("!!!!!Success", String.valueOf(i));
+                    }
 
-                        @Override
-                        public void onFail(int i) {
-                            if (BuildConfig.DEBUG)
-                                Log.d("!!!!!Fail", String.valueOf(i));
-                            //拉取广告错误或超时,直接跳过
-                            sendHandlerMessages(0);
-                        }
+                    @Override
+                    public void onFail(int i) {
+                        if (BuildConfig.DEBUG)
+                            Log.d("!!!!!Fail", String.valueOf(i));
+                        //拉取广告错误或超时,直接跳过
+                        sendHandlerMessages(0);
+                    }
 
-                        @Override
-                        public void onEvent(int i) {
-                            if (BuildConfig.DEBUG)
-                                Log.d("!!!!!Event", String.valueOf(i));
-                            switch (i) {
-                                case KLSplashAdEvent_AdShowSucc:
-                                    if (!aded && ad != null) {
-                                        AdHelper.stat(ad.getAd_id(), 1, ad.getAd_type());
-                                        aded = true;
-                                    }
-                                    break;
-                                case KLSplashAdEvent_AdTap:
-                                    AdHelper.stat(ad.getAd_id(), 2, ad.getAd_type());
-                                    break;
-                                case KLSplashAdEvent_AdPlayCompletion:
-                                case KLSplashAdEvent_AdShowFinish:
-                                case KLSplashAdEvent_AdSkip:
-                                    sendHandlerMessages(0);
-                                    break;
-                            }
+                    @Override
+                    public void onEvent(int i) {
+                        if (BuildConfig.DEBUG)
+                            Log.d("!!!!!Event", String.valueOf(i));
+                        switch (i) {
+                            case KLSplashAdEvent_AdShowSucc:
+                                if (!aded && ad != null) {
+                                    AdHelper.stat(ad.getAd_id(), 1, ad.getAd_type());
+                                    aded = true;
+                                }
+                                break;
+                            case KLSplashAdEvent_AdTap:
+                                AdHelper.stat(ad.getAd_id(), 2, ad.getAd_type());
+                                break;
+                            case KLSplashAdEvent_AdPlayCompletion:
+                            case KLSplashAdEvent_AdShowFinish:
+                            case KLSplashAdEvent_AdSkip:
+                                sendHandlerMessages(0);
+                                break;
                         }
                     }
-            );
+                }
+        );
     }
 
     //展示优投开屏广告(新增boolean state:false----定值) 重要 mForceGoMain跳转主页 请参照此方法调用,否则可能导致广告展示链路断开 导致收益下降!!!
     private void launchYTSplash() {
-            if (flSplashYT != null)
-                flSplashYT.setVisibility(View.VISIBLE);
-            new SplashEngine(SplashAct.this, false, new SplashEngine.SplashAdCallBack() {
-                @Override
-                public void onSplashClick() {
-                    Log.i("jasmine-ad", "点击广告");
-                    AdHelper.stat(ad.getAd_id(), 2, ad.getAd_type());
-                    //sendHandlerMessages(0);
-                }
+        if (flSplashYT != null)
+            flSplashYT.setVisibility(View.VISIBLE);
+        new SplashEngine(SplashAct.this, false, new SplashEngine.SplashAdCallBack() {
+            @Override
+            public void onSplashClick() {
+                Log.i("jasmine-ad", "点击广告");
+                AdHelper.stat(ad.getAd_id(), 2, ad.getAd_type());
+                //sendHandlerMessages(0);
+            }
 
-                @Override
-                public void onSplashDismissed() {
-                    Log.i("jasmine-ad", "广告关闭");
-                    next();
-                }
+            @Override
+            public void onSplashDismissed() {
+                Log.i("jasmine-ad", "广告关闭");
+                next();
+            }
 
-                @Override
-                public void onSplashError(String err, boolean isTimeout) {
-                    Log.i("jasmine-ad", "展示广告异常:" + err);
-                    next();
-                }
+            @Override
+            public void onSplashError(String err, boolean isTimeout) {
+                Log.i("jasmine-ad", "展示广告异常:" + err);
+                next();
+            }
 
-                @Override
-                public void onSplashShow() {
-                    Log.i("jasmine-ad", "展示广告");
-                    yt_splash_skip_view.setVisibility(View.VISIBLE);
-                    if (!aded && ad != null) {
-                        AdHelper.stat(ad.getAd_id(), 1, ad.getAd_type());
-                        aded = true;
-                    }
-                    //mHasLoaded = true;
-                    //mHandler.removeCallbacksAndMessages(null);
+            @Override
+            public void onSplashShow() {
+                Log.i("jasmine-ad", "展示广告");
+                yt_splash_skip_view.setVisibility(View.VISIBLE);
+                if (!aded && ad != null) {
+                    AdHelper.stat(ad.getAd_id(), 1, ad.getAd_type());
+                    aded = true;
                 }
+                //mHasLoaded = true;
+                //mHandler.removeCallbacksAndMessages(null);
+            }
 
-                @Override
-                public void onSplashPresent() {
-                    Log.i("jasmine-ad", "广告数据加载");
-                    if (splash_image_view != null)
-                        splash_image_view.setVisibility(View.GONE); // 广告展示后一定要把预设的开屏图片隐藏起来
-                }
+            @Override
+            public void onSplashPresent() {
+                Log.i("jasmine-ad", "广告数据加载");
+                if (splash_image_view != null)
+                    splash_image_view.setVisibility(View.GONE); // 广告展示后一定要把预设的开屏图片隐藏起来
+            }
 
-                @Override
-                public void onSplashLoad() {
-                    Log.i("Jasmine-ad", "拉取广告");
-                }
+            @Override
+            public void onSplashLoad() {
+                Log.i("Jasmine-ad", "拉取广告");
+            }
 
-            }).launchSplash(flSplashYT, 5 * 1000);
+        }).launchSplash(flSplashYT, 5 * 1000);
 
     }
 
     //展示掌酷广告
-    private void launchZKSplash(){
+    private void launchZKSplash() {
+        LySdk.loadSplashAd(this, new LySplashAdBuilder(zk_root, ad.getThird_ad_id()), new ISplashAdLoadCallback() {
+            @Override
+            public void onFailed(int i, String s) {
+                Log.d("!!!!掌酷开屏广告加载失败", s);
+            }
+
+            @Override
+            public void onLoaded(ISplashAdController iSplashAdController) {
+                controllerRef.set(iSplashAdController);
+                ISplashAdController controller;
+                if ((controller = controllerRef.getAndSet(null)) != null) {
+                    zk_root.setVisibility(View.VISIBLE);
+                    controller.show(new ISplashAdCallback() {
+                        @Override
+                        public void onLoadFail(int i, String s) {
+                            zk_root.setVisibility(View.INVISIBLE);
+                            sendHandlerMessages(0);
+                        }
 
+                        @Override
+                        public void onAdClick() {
+                            zk_root.setVisibility(View.INVISIBLE);
+                            AdHelper.stat(ad.getAd_id(), 2, ad.getAd_type());
+                        }
+
+                        @Override
+                        public void onAdShow() {
+                            Log.d("!!!!!!", "掌酷show");
+                            if (!aded && ad != null) {
+                                AdHelper.stat(ad.getAd_id(), 1, ad.getAd_type());
+                                aded = true;
+                            }
+                        }
+
+                        @Override
+                        public void onAdSkip() {
+                            zk_root.setVisibility(View.INVISIBLE);
+                            sendHandlerMessages(0);
+                        }
+
+                        @Override
+                        public void onAdTimeOver() {
+                            //zk_root.setVisibility(View.INVISIBLE);
+                            sendHandlerMessages(0);
+                        }
+                    });
+                } else {
+                    Toast.makeText(SplashAct.this, "掌酷广告未加载", Toast.LENGTH_SHORT).show();
+                    sendHandlerMessages(0);
+                }
+            }
+        });
     }
 
     /**
@@ -479,7 +547,7 @@ public class SplashAct extends BaseActivity {
             sendHandlerMessages(10);
         }
         //判断是否该跳转到主页面
-        if (mForceGoMain && ad != null && ad.getAd_type() == AD_SPLASH_TYPE_YT) {
+        if (mForceGoMain && ad != null && (ad.getAd_type() == AD_SPLASH_TYPE_YT || ad.getAd_type() == AD_SPLASH_TYPE_ZK)) {
             next();
         }
         mForceGoMain = true;

+ 6 - 1
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -26,6 +26,8 @@ import com.jasmine.cantaloupe.utils.LogUtils2;
 import com.kfzs.cfyl.share_library.util.ContextHolder;
 import com.liulishuo.okdownload.OkDownload;
 import com.liulishuo.okdownload.core.dispatcher.DownloadDispatcher;
+import com.lygame.wrapper.sdk.LySdk;
+import com.lygame.wrapper.strategy.DefaultStrategy;
 import com.sheep.gamegroup.di.components.DaggerNetComponent;
 import com.sheep.gamegroup.di.components.NetComponent;
 import com.sheep.gamegroup.di.modules.NetModule;
@@ -292,6 +294,7 @@ public class SheepApp extends MultiDexApplication {
                         ThirdAdsConfigEntity thirdAdsConfigEntity = baseMessage.getData(ThirdAdsConfigEntity.class);
                         initYKYAd(thirdAdsConfigEntity.getYkyConfig().getAppid());
                         initYTAd(thirdAdsConfigEntity.getYtConfig().getAppid(), thirdAdsConfigEntity.getYtConfig().getAd_id());
+                        initZKAd();
                     }
                 });
 
@@ -365,7 +368,9 @@ public class SheepApp extends MultiDexApplication {
 
     //初始化掌酷广告
     private void initZKAd() {
-
+        //sdk策略配置
+        DefaultStrategy defaultStrategy = new DefaultStrategy(this);
+        LySdk.setSdkStrategy(defaultStrategy);
     }
 
     /**

+ 7 - 1
app/src/main/res/layout/splash_activity.xml

@@ -77,4 +77,10 @@
 
     </com.jasmine.cantaloupe.ui.widget.AdFrameLayout>
 
-</FrameLayout>
+    <FrameLayout
+            android:id="@+id/zk_root"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical"/>
+
+    </FrameLayout>