Pārlūkot izejas kodu

[修改]数据优化包,包含掌酷、游可盈激励视频快捷入口

zeki 5 gadi atpakaļ
vecāks
revīzija
2b0f4cb939

+ 120 - 1
app/src/main/java/com/sheep/gamegroup/module/login/LoginAct.java

@@ -11,8 +11,14 @@ import android.text.TextUtils;
 import android.util.Log;
 import android.view.Menu;
 
+import android.view.View;
+import android.widget.Toast;
 import com.alibaba.fastjson.JSONObject;
 import com.kfzs.duanduan.utils.StatusBarUtils;
+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.absBase.BaseUMActivity;
 import com.sheep.gamegroup.event.WXLoginAuthEvent;
 import com.sheep.gamegroup.greendao.DDProviderHelper;
@@ -44,6 +50,9 @@ import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 import com.sheep.jiuyan.samllsheep.wxutil.WXAPIUtil;
+import com.tencent.klevin.KleinManager;
+import com.tencent.klevin.base.callback.KleinResponseCallback;
+import com.tencent.klevin.util.AdUtils;
 import com.umeng.socialize.UMAuthListener;
 import com.umeng.socialize.UMShareAPI;
 import com.umeng.socialize.bean.SHARE_MEDIA;
@@ -54,14 +63,19 @@ import org.greenrobot.eventbus.Subscribe;
 import java.util.List;
 import java.util.Map;
 import java.util.Stack;
+import java.util.concurrent.atomic.AtomicReference;
 
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.schedulers.Schedulers;
 
+import static com.tencent.klevin.base.okhttp.ErrorCode.KLSplashAdEvent_CreativeDownloadSuccess;
+
 public class LoginAct extends BaseUMActivity implements LoginController {
 
     private boolean isLogined = false;
 
+    private AtomicReference<IRewardVideoController> controllerRef = new AtomicReference<>();
+
     private Stack<String> titleStack = new Stack<>();
 
     @Override
@@ -69,6 +83,111 @@ public class LoginAct extends BaseUMActivity implements LoginController {
         StatusBarUtils.setTranslucent(this);
         super.onCreate(savedInstanceState);
         EventBus.getDefault().register(this);
+        findViewById(R.id.btn_yky_courage_video).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                launchYKYVideo();
+            }
+        });
+        findViewById(R.id.btn_zk_courage_video).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                launchZKVideo();
+            }
+        });
+    }
+
+    private void launchYKYVideo() {
+        int posId = 30113;
+        int duration = 0;
+        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) {
+                if (i == KLSplashAdEvent_CreativeDownloadSuccess) {
+                    //下载激励视频素材成功
+                    KleinManager.getInstance().showAD(
+                            LoginAct.this,
+                            AdUtils.TYPE_AD_REWARD,
+                            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) {
+                                    G.showToast("onEvent" + i);
+                                }
+                            });
+                }
+            }
+
+            @Override
+            public void onFail(int i) {
+                G.showToast("onFail" + i);
+            }
+
+            @Override
+            public void onEvent(int i) {
+                G.showToast("onEvent" + i);
+            }
+        });
+    }
+
+    private void launchZKVideo() {
+        int adId = 52917;
+
+        LySdk.loadRewardVideo(LoginAct.this, String.valueOf(adId), new IRewardVideoLoadCallback() {
+            @Override
+            public void onFailed(int i, String s) {
+                G.showToast("ZK onFail " + i + ": " + s);
+            }
+
+            @Override
+            public void onLoaded(IRewardVideoController iRewardVideoController) {
+                controllerRef.set(iRewardVideoController);
+                IRewardVideoController controller;
+                if ((controller = controllerRef.getAndSet(null)) != null) {
+                    controller.show(new IRewardVideoPlayCallback() {
+                        @Override
+                        public void onAdShow() {
+
+                        }
+
+                        @Override
+                        public void onInterTriggered() {
+                            //Toast.makeText(getContext(), "广告点击了", Toast.LENGTH_SHORT).show();
+                        }
+
+                        @Override
+                        public void onAdClose() {
+
+                        }
+
+                        @Override
+                        public void onVideoComplete() {
+
+                        }
+
+                        @Override
+                        public void onRewarded() {
+
+                        }
+                    });
+                } else {
+                    Toast.makeText(LoginAct.this, "掌酷广告未加载成功", Toast.LENGTH_SHORT).show();
+                }
+            }
+        });
     }
 
     @Override
@@ -162,7 +281,7 @@ public class LoginAct extends BaseUMActivity implements LoginController {
         }
         TestUtil.saveUser(loginResult);
         if (platform == LoginController.PLATFORM_ACCOUNT || platform == LoginController.PLATFORM_PHONE) {
-            DDProviderHelper.getInstance().saveAccount(Account.generateByUser(loginResult.getUser()),platform);
+            DDProviderHelper.getInstance().saveAccount(Account.generateByUser(loginResult.getUser()), platform);
         }
         //登录成功记录设备信息
         ApiJSONUtil.postUserDeviceLog();

+ 32 - 9
app/src/main/res/layout/activity_login.xml

@@ -1,11 +1,34 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-    <FrameLayout
-        android:id="@+id/fragment_container"
-        android:background="@color/white"
+<android.support.constraint.ConstraintLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
-</LinearLayout>
+        android:layout_height="match_parent"
+        xmlns:app="http://schemas.android.com/apk/res-auto"
+        android:orientation="vertical">
+
+    <FrameLayout
+            android:id="@+id/fragment_container"
+            android:background="@color/white"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+
+    <Button
+            android:id="@+id/btn_yky_courage_video"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_margin="32dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            android:text="游可盈激励视频"/>
+
+    <Button
+            android:id="@+id/btn_zk_courage_video"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="8dp"
+            app:layout_constraintStart_toStartOf="@+id/btn_yky_courage_video"
+            android:text="掌酷激励视频"
+            app:layout_constraintTop_toBottomOf="@+id/btn_yky_courage_video" app:layout_constraintEnd_toEndOf="@+id/btn_yky_courage_video"/>
+
+
+</android.support.constraint.ConstraintLayout>

+ 2 - 2
gradle.properties

@@ -17,8 +17,8 @@
 # org.gradle.parallel=true
 #android.injected.build.model.only.versioned = 3
 
-VERSION_NAME=3.8.4
-VERSION_CODE=3008004
+VERSION_NAME=3.8.5
+VERSION_CODE=3008005
 ANDROID_COMPILE_SDK_VERSION=30
 ANDROID_MIN_SDK_VERSION=19
 ANDORID_TARGET_SDK_VERSION=28