소스 검색

[修改]登录页加入直接开启激励视频的按钮,仅供测试使用

zeki 5 년 전
부모
커밋
6839389f9b
2개의 변경된 파일70개의 추가작업 그리고 7개의 파일을 삭제
  1. 55 0
      app/src/main/java/com/sheep/gamegroup/module/login/LoginAct.java
  2. 15 7
      app/src/main/res/layout/activity_login.xml

+ 55 - 0
app/src/main/java/com/sheep/gamegroup/module/login/LoginAct.java

@@ -11,6 +11,9 @@ import android.text.TextUtils;
 import android.util.Log;
 import android.view.Menu;
 
+import android.view.View;
+import android.widget.Button;
+import butterknife.BindView;
 import com.alibaba.fastjson.JSONObject;
 import com.kfzs.duanduan.utils.StatusBarUtils;
 import com.sheep.gamegroup.absBase.BaseUMActivity;
@@ -44,6 +47,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;
@@ -64,11 +70,60 @@ public class LoginAct extends BaseUMActivity implements LoginController {
 
     private Stack<String> titleStack = new Stack<>();
 
+    @BindView(R.id.btn_courage_video)
+    Button btn_courage_video;
+
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         StatusBarUtils.setTranslucent(this);
         super.onCreate(savedInstanceState);
         EventBus.getDefault().register(this);
+        btn_courage_video.setOnClickListener(v -> preAndPlayAd());
+    }
+
+    //预加载激励视频
+    private void preAndPlayAd( ) {
+        showProgress();
+        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) {
+                hideProgress();
+                //播放激励视频
+                KleinManager.getInstance().showAD(LoginAct.this, AdUtils.TYPE_AD_REWARD,
+                        new KleinResponseCallback() {
+                            @Override
+                            public void onSuccess(int i) {
+
+                            }
+
+                            @Override
+                            public void onFail(int i) {
+
+                            }
+
+                            @Override
+                            public void onEvent(int i) {
+
+                            }
+                        });
+            }
+
+            @Override
+            public void onFail(int i) {
+
+            }
+
+            @Override
+            public void onEvent(int i) {
+
+            }
+        });
     }
 
     @Override

+ 15 - 7
app/src/main/res/layout/activity_login.xml

@@ -1,11 +1,19 @@
 <?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">
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical">
     <FrameLayout
-        android:id="@+id/fragment_container"
-        android:background="@color/white"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
+            android:id="@+id/fragment_container"
+            android:background="@color/white"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"/>
+
+    <Button
+            android:id="@+id/btn_courage_video"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="开启激励视频"/>
+
 </LinearLayout>