ソースを参照

[增加]数据优化开启界面

zeki 4 年 前
コミット
63b30a91d7
共有3 個のファイルを変更した465 個の追加0 個の削除を含む
  1. 7 0
      app/src/main/AndroidManifest.xml
  2. 329 0
      app/src/main/java/com/sheep/gamegroup/view/activity/DataGoAct.java
  3. 129 0
      app/src/main/res/layout/act_data_go.xml

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

@@ -196,12 +196,19 @@
                 android:name="com.sheep.gamegroup.view.activity.SplashAct"
                 android:screenOrientation="portrait"
                 android:theme="@style/SplashTheme">
+        </activity>
+
+        <activity
+                android:name="com.sheep.gamegroup.view.activity.DataGoAct"
+                android:screenOrientation="portrait"
+                android:theme="@style/SplashTheme">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
 
                 <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter>
         </activity>
+
         <activity
                 android:name="com.sheep.gamegroup.view.activity.ActYfX5"
                 android:enabled="false"

+ 329 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/DataGoAct.java

@@ -0,0 +1,329 @@
+package com.sheep.gamegroup.view.activity;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+import com.jasmine.cantaloupe.engine.SplashEngine;
+import com.jasmine.cantaloupe.ui.widget.AdFrameLayout;
+import com.lygame.wrapper.ad.LySplashAdBuilder;
+import com.lygame.wrapper.interfaces.*;
+import com.lygame.wrapper.sdk.LySdk;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.tencent.klevin.KleinManager;
+import com.tencent.klevin.base.callback.KleinResponseCallback;
+import com.tencent.klevin.base.view.BaseActivity;
+import com.tencent.klevin.util.AdUtils;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import static com.tencent.klevin.base.okhttp.ErrorCode.*;
+
+/**
+ * @Author: ZEKI https://github.com/ZYF99
+ * @Date: 2021/6/1 3:56 下午
+ */
+public class DataGoAct extends BaseActivity {
+
+
+    FrameLayout zk_root;
+    AdFrameLayout flSplashYT;
+    TextView yt_splash_skip_view;
+
+    @Override
+    public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView(R.layout.act_data_go);
+        zk_root = findViewById(R.id.zk_root);
+        flSplashYT = findViewById(R.id.fv_splash_yt);
+        yt_splash_skip_view = findViewById(R.id.splash_skip_view);
+        findViewById(R.id.btn_yky_splash).setOnClickListener(v -> {
+            launchYKYSplash();
+        });
+        findViewById(R.id.btn_yt_splash).setOnClickListener(v -> {
+            launchYTSplash();
+        });
+        findViewById(R.id.btn_zk_splash).setOnClickListener(v -> {
+            launchZKSplash();
+        });
+        findViewById(R.id.btn_yky_courage).setOnClickListener(v -> {
+            showYKYCourage();
+        });
+        findViewById(R.id.btn_zk_courage).setOnClickListener(v -> {
+            showZKCourage();
+        });
+    }
+
+    //展示游可盈广告
+    private void launchYKYSplash() {
+        String data = "{\"placements\":[{\"pos_id\":" + 30112 + ",\"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) {
+                        G.showToast("游可盈-onSuccess" + i);
+                    }
+
+                    @Override
+                    public void onFail(int i) {
+                        //拉取广告错误或超时,直接跳过
+                        G.showToast("游可盈-onFail" + i);
+                    }
+
+                    @Override
+                    public void onEvent(int i) {
+                        switch (i) {
+                            case KLSplashAdEvent_AdShowSucc:
+                                G.showToast("游可盈-广告展示成功");
+                                break;
+                            case KLSplashAdEvent_AdTap:
+                                G.showToast("游可盈-点击广告");
+                                break;
+                            case KLSplashAdEvent_AdPlayCompletion:
+                            case KLSplashAdEvent_AdShowFinish:
+                            case KLSplashAdEvent_AdSkip:
+                                G.showToast("游可盈-跳过广告");
+                                break;
+                        }
+                    }
+                }
+        );
+    }
+
+    //展示优投开屏广告(新增boolean state:false----定值) 重要 mForceGoMain跳转主页 请参照此方法调用,否则可能导致广告展示链路断开 导致收益下降!!!
+    private void launchYTSplash() {
+        if (flSplashYT != null)
+            flSplashYT.setVisibility(View.VISIBLE);
+        new SplashEngine(DataGoAct.this, false, new SplashEngine.SplashAdCallBack() {
+            @Override
+            public void onSplashClick() {
+                G.showToast("优投-点击广告");
+            }
+
+            @Override
+            public void onSplashDismissed() {
+                G.showToast("优投-广告消失");
+                if (flSplashYT != null)
+                    flSplashYT.setVisibility(View.INVISIBLE);
+            }
+
+            @Override
+            public void onSplashError(String err, boolean isTimeout) {
+                G.showToast("优投-开屏广告" + err);
+            }
+
+            @Override
+            public void onSplashShow() {
+                yt_splash_skip_view.setVisibility(View.VISIBLE);
+                G.showToast("优投-广告展示成功");
+                //mHasLoaded = true;
+                //mHandler.removeCallbacksAndMessages(null);
+            }
+
+            @Override
+            public void onSplashPresent() {
+
+            }
+
+            @Override
+            public void onSplashLoad() {
+                G.showToast("优投-广告加载");
+            }
+
+        }).launchSplash(flSplashYT, 5 * 1000);
+
+    }
+
+    //掌酷广告控制器
+    private AtomicReference<ISplashAdController> splashControllerRef = new AtomicReference<>();
+
+    //展示掌酷广告
+    private void launchZKSplash() {
+        LySdk.loadSplashAd(this, new LySplashAdBuilder(zk_root, "52916"), new ISplashAdLoadCallback() {
+            @Override
+            public void onFailed(int i, String s) {
+
+            }
+
+            @Override
+            public void onLoaded(ISplashAdController iSplashAdController) {
+                splashControllerRef.set(iSplashAdController);
+                ISplashAdController controller;
+                if ((controller = splashControllerRef.getAndSet(null)) != null) {
+                    if (zk_root != null)
+                        zk_root.setVisibility(View.VISIBLE);
+                    controller.show(new ISplashAdCallback() {
+                        @Override
+                        public void onLoadFail(int i, String s) {
+                            zk_root.setVisibility(View.INVISIBLE);
+                            G.showToast("掌酷-开屏广告加载onFail" + i + "  " + s);
+                        }
+
+                        @Override
+                        public void onAdClick() {
+                            zk_root.setVisibility(View.INVISIBLE);
+                            G.showToast("掌酷-开屏广告点击");
+                        }
+
+                        @Override
+                        public void onAdShow() {
+                            G.showToast("掌酷-开屏广告展示成功");
+                        }
+
+                        @Override
+                        public void onAdSkip() {
+                            zk_root.setVisibility(View.INVISIBLE);
+                            G.showToast("掌酷-开屏广告跳过");
+                        }
+
+                        @Override
+                        public void onAdTimeOver() {
+                            //zk_root.setVisibility(View.INVISIBLE);
+                            G.showToast("掌酷-开屏广告倒计时完成");
+                        }
+                    });
+                } else {
+                    Toast.makeText(DataGoAct.this, "掌酷广告未加载", Toast.LENGTH_SHORT).show();
+                }
+            }
+        });
+    }
+
+    //展示游可盈激励视频
+    private void showYKYCourage() {
+        preAd(true);
+    }
+
+    //预加载激励视频
+    private void preAd(boolean shouldShow) {
+        int posId = 30113;
+        int duration = 0;
+        //String data = "{\"placements\":[{\"pos_id\":" + posId + ",\"ad_count\":" + releaseTask.getTask().getVideo_num() + "}],\"ad_reward_trigger\":1, \"ad_reward_duration\":" + duration + ", \"ad_reward_automute\":1}";
+        String data = "{\"placements\":[{\"pos_id\":" + posId + ",\"ad_count\":1}],\"ad_reward_trigger\":1, \"ad_reward_duration\":" + duration + ", \"ad_reward_automute\":1}";
+
+        KleinManager.getInstance().loadEncourageAD(SheepApp.getInstance().getApplicationContext(), data, new KleinResponseCallback() {
+
+            @Override
+            public void onSuccess(int i) {
+                handleSuccess(i, shouldShow);
+            }
+
+            @Override
+            public void onFail(int i) {
+                G.showToast("游可盈激励视频加载onFail" + i);
+            }
+
+            @Override
+            public void onEvent(int i) {
+                handleEvent(i);
+            }
+        });
+    }
+
+    //播放激励视频
+    private void showAd() {
+        KleinManager.getInstance().showAD(DataGoAct.this, AdUtils.TYPE_AD_REWARD,
+                new KleinResponseCallback() {
+
+                    @Override
+                    public void onSuccess(int i) {
+                        handleSuccess(i, false);
+                    }
+
+                    @Override
+                    public void onFail(int i) {
+                        G.showToast("游可盈激励视频onFail" + i);
+                    }
+
+                    @Override
+                    public void onEvent(int i) {
+                        handleEvent(i);
+                    }
+                });
+    }
+
+    private void handleSuccess(int i, boolean shouldShow) {
+        if (i == KLSplashAdEvent_CreativeDownloadSuccess) {
+            if (shouldShow) showAd();
+        }
+    }
+
+    private void handleEvent(int i) {
+        switch (i) {
+            case KLSplashAdEvent_MeetTheRewardConditions:
+                //满足领奖条件,去领奖
+                G.showToast("游可盈激励视频触发奖励(未真正获取)");
+                break;
+            case KLSplashAdEvent_AdPlayCompletion:
+                //一个视频播放结束
+                G.showToast("游可盈激励视频播放结束");
+                break;
+            case KLSplashAdEvent_AdSkip:
+                //用户点击关闭了界面
+                G.showToast("游可盈激励视频关闭");
+                break;
+        }
+    }
+
+
+    private AtomicReference<IRewardVideoController> videoControllerRef = new AtomicReference<>();
+
+    //展示掌酷激励视频
+    private void showZKCourage() {
+        int adId = 52917;
+
+        LySdk.loadRewardVideo(DataGoAct.this, String.valueOf(adId), new IRewardVideoLoadCallback() {
+            @Override
+            public void onFailed(int i, String s) {
+                G.showToast("掌酷激励视频onFailed" + i + "  " + s);
+            }
+
+            @Override
+            public void onLoaded(IRewardVideoController iRewardVideoController) {
+                videoControllerRef.set(iRewardVideoController);
+                IRewardVideoController controller;
+                if ((controller = videoControllerRef.getAndSet(null)) != null) {
+                    controller.show(new IRewardVideoPlayCallback() {
+                        @Override
+                        public void onAdShow() {
+                            G.showToast("掌酷激励视频展示成功");
+                        }
+
+                        @Override
+                        public void onInterTriggered() {
+                            G.showToast("掌酷激励视频点击");
+                        }
+
+                        @Override
+                        public void onAdClose() {
+                            G.showToast("掌酷激励视频关闭");
+                        }
+
+                        @Override
+                        public void onVideoComplete() {
+                            G.showToast("掌酷激励视频播放完成");
+                        }
+
+                        @Override
+                        public void onRewarded() {
+                            G.showToast("掌酷激励视频触发奖励(未真正获取)");
+                        }
+                    });
+                } else {
+                    Toast.makeText(DataGoAct.this, "广告未加载成功", Toast.LENGTH_SHORT).show();
+                }
+            }
+        });
+    }
+
+
+}

+ 129 - 0
app/src/main/res/layout/act_data_go.xml

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             android:id="@+id/fl_root"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             android:background="@android:color/black"
+             android:orientation="vertical">
+
+    <VideoView
+            android:id="@+id/splash_video_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:visibility="gone"/>
+
+    <ImageView
+            android:id="@+id/splash_image_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:scaleType="centerCrop"/>
+    <TextView
+            android:id="@+id/splash_skip"
+            android:layout_width="wrap_content"
+            android:layout_height="24dp"
+            android:layout_gravity="top|end"
+            android:gravity="center"
+            android:paddingStart="10dp"
+            android:paddingEnd="10dp"
+            android:layout_margin="@dimen/content_padding_20"
+            android:textColor="#ffffff"
+            android:textSize="13sp"
+            android:background="@drawable/shape_ash_solid_rectangle_small_tra30"
+            android:visibility="gone"/>
+
+    <TextView
+            android:id="@+id/ad_flag"
+            android:visibility="gone"
+            android:text="广告"
+            android:textSize="12sp"
+            android:textColor="@color/white"
+            android:layout_margin="12dp"
+            android:background="#50000000"
+            android:gravity="center"
+            android:layout_width="36dp"
+            android:layout_height="20dp"/>
+
+    <com.jasmine.cantaloupe.ui.widget.AdFrameLayout
+            android:id="@+id/fv_splash_yt"
+            android:layout_height="match_parent"
+            android:layout_width="match_parent"
+            android:visibility="invisible">
+
+        <!-- 2.开屏广告容器区域:-->
+        <!-- 注意:该区域高度不得小于400dp。在本示例中没有写死splash_container的高度值,是因为第1部分的app_logo区域是一个高度很小的图片。 -->
+        <FrameLayout
+                android:id="@+id/splash_container"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"/>
+
+        <!-- 3.自定义跳过按钮区域:开发者可以根据需要自己实现不同样式的跳过按钮 -->
+        <!-- 注意1:根据广告法规定,跳过按钮必须在屏幕当中出现。因此广告展示的时候,必须让将SkipView显示出来,即visible,否则将SDK将不展示广告。 -->
+        <!-- 注意2:SDK除了会检查跳过按钮的可见性,还将检测它的尺寸,其尺寸不得小于3dp*3dp,否则将SDK将不展示广告。 -->
+        <TextView
+                android:id="@+id/splash_skip_view"
+                android:layout_width="96dp"
+                android:layout_height="wrap_content"
+                android:paddingTop="@dimen/content_padding_4"
+                android:paddingBottom="@dimen/content_padding_4"
+                android:layout_gravity="right"
+                android:layout_margin="16dp"
+                android:background="@drawable/jasmine_common_button"
+                android:gravity="center"
+                android:textColor="@android:color/white"
+                android:textSize="14sp"
+                android:visibility="visible"/>
+
+    </com.jasmine.cantaloupe.ui.widget.AdFrameLayout>
+
+    <FrameLayout
+            android:id="@+id/zk_root"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical"/>
+
+    <LinearLayout
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="center"
+            android:orientation="vertical">
+
+        <Button
+                android:id="@+id/btn_yky_splash"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="游可盈开屏广告"/>
+
+        <Button
+                android:id="@+id/btn_yt_splash"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="8dp"
+                android:text="优投开屏广告"/>
+
+        <Button
+                android:id="@+id/btn_zk_splash"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="8dp"
+                android:text="掌酷开屏广告"/>
+
+        <Button
+                android:id="@+id/btn_yky_courage"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="8dp"
+                android:text="游可盈激励视频"/>
+
+        <Button
+                android:id="@+id/btn_zk_courage"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="8dp"
+                android:text="掌酷激励视频"/>
+
+    </LinearLayout>
+
+</FrameLayout>
+