Prechádzať zdrojové kódy

switch user and jump ad

billyyoyo 5 rokov pred
rodič
commit
77d009d1bf

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

@@ -336,6 +336,12 @@
             android:screenOrientation="behind"
             android:theme="@style/AppThemeTransparent" />
         <activity
+            android:name="com.sheep.gamegroup.module.ActAdJumper"
+            android:exported="true"
+            android:launchMode="singleTask"
+            android:screenOrientation="behind"
+            android:theme="@style/AppThemeTransparent" />
+        <activity
             android:name="com.sheep.gamegroup.view.activity.ActBindMobileRegister"
             android:launchMode="singleTask"
             android:screenOrientation="portrait"

+ 34 - 0
app/src/main/java/com/sheep/gamegroup/module/ActAdJumper.java

@@ -0,0 +1,34 @@
+package com.sheep.gamegroup.module;
+
+import android.app.Activity;
+
+import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.view.activity.helper.AdHelper;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+
+public class ActAdJumper extends BaseActivity {
+
+    @Override
+    protected int getLayoutId() {
+        return 0;
+    }
+
+    @Override
+    public void initView() {
+        int adId = getIntent().getIntExtra("ad_id", 0);
+        if (adId == 0) {
+            finish();
+            return;
+        }
+        CommonUtil.getInstance().getAd(adId, (ad) -> {
+            if (ad == null) {
+                finish();
+                return;
+            }
+            ad.setAd_id(ad.getId());
+            AdHelper.goAdLink(SheepApp.getInstance().getCurrentActivity(), ad);
+            finish();
+        });
+    }
+}

+ 4 - 1
app/src/main/java/com/sheep/gamegroup/module/login/AccountConsistenceAct.java

@@ -15,6 +15,7 @@ import com.sheep.gamegroup.greendao.download.SdkLoginUser;
 import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
@@ -39,7 +40,7 @@ public class AccountConsistenceAct extends BaseActivity {
 
     private int sdkAction;
 
-    private String gameCode, sheepCode, resultToken;
+    private String gameCode, sheepCode, resultToken, extra;
     private UserEntity user;
 
     @Override
@@ -54,6 +55,7 @@ public class AccountConsistenceAct extends BaseActivity {
         sdkAction = getIntent().getIntExtra("sdk_action", 0);
         TitleBarUtils.getInstance().setShowOrHide(this, false);
         String game_token = getIntent().getStringExtra("game_token");
+        extra = getIntent().getStringExtra("extra");
         if (TextUtils.isEmpty(game_token)) {
             finishWithResult(-1, null);
             return;
@@ -133,6 +135,7 @@ public class AccountConsistenceAct extends BaseActivity {
         Intent intent = new Intent();
         intent.putExtra("code", resultCode);
         intent.putExtra("action", sdkAction);
+        intent.putExtra("extra", extra);
         if (TextUtils.isEmpty(token)) {
             intent.putExtra("token", token);
         }

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -2353,6 +2353,7 @@ public class CommonUtil {
                             }
 
                         } catch (Exception e) {
+                            e.printStackTrace();
                             if (action != null)
                                 action.call(null);
                         }

+ 5 - 5
app/src/main/java/com/sheep/gamegroup/view/activity/MiddleSchemeAct.java

@@ -15,6 +15,7 @@ import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.HomeListEntity;
 import com.sheep.gamegroup.model.entity.SlideshowEty;
 import com.sheep.gamegroup.model.entity.WebParams;
+import com.sheep.gamegroup.module.ActAdJumper;
 import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.ConfigUtil;
@@ -247,11 +248,10 @@ public class MiddleSchemeAct extends Activity {
                 Jump2View.getInstance().goH5Game(SheepApp.getInstance(), json);
                 break;
             case "clickad":
-                CommonUtil.getInstance().getAd(Integer.parseInt(json), (ad) -> {
-                    if (ad == null) return;
-                    ad.setAd_id(ad.getId());
-                    AdHelper.goAdLink(SheepApp.getInstance().getCurrentActivity(), ad);
-                });
+                Intent intent = new Intent(SheepApp.getInstance(), ActAdJumper.class);
+                intent.putExtra("ad_id", Integer.parseInt(json));
+                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                SheepApp.getInstance().startActivity(intent);
                 break;
         }
     }

+ 8 - 8
app/src/main/java/com/sheep/gamegroup/view/activity/helper/AdHelper.java

@@ -38,19 +38,19 @@ import static com.sheep.jiuyan.samllsheep.utils.ClassFileHelper.DIR;
 public class AdHelper {
 
     // 返回true 为apk下载
-    public static boolean goAdLink(Context activity, SheepAd advertising) {
+    public static boolean goAdLink(Context context, SheepAd advertising) {
         if (TextUtils.isEmpty(SpUtils.getToken(SheepApp.getInstance()))) {
-            Jump2View.getInstance().goLoginView(activity, null);
-            if (activity instanceof SplashAct) {
-                ((Activity) activity).finish();
+            Jump2View.getInstance().goLoginView(context, null);
+            if (context instanceof SplashAct) {
+                ((Activity) context).finish();
             }
             return false;
         }
         if (advertising.getJump_type() == 1) {
             if (advertising.getJump_form() == 1) {
-                Jump2View.getInstance().goWeb(activity, advertising.getJump_url(), advertising.getName());
+                Jump2View.getInstance().goWeb(context, advertising.getJump_url(), advertising.getName());
             } else {
-                Jump2View.getInstance().goWeb(activity, advertising.getJump_url());
+                Jump2View.getInstance().goWeb(context, advertising.getJump_url());
             }
             AdHelper.stat(advertising.getAd_id(), 2);
             return false;
@@ -61,12 +61,12 @@ public class AdHelper {
                 Jump2View.getInstance().startDownloadService(advertising.getJump_url(), filePath);
                 G.showToast("开始下载...");
             } else {
-                Jump2View.getInstance().goWeb(activity, advertising.getJump_url());
+                Jump2View.getInstance().goWeb(context, advertising.getJump_url());
             }
             AdHelper.stat(advertising.getAd_id(), 3);
             return advertising.getJump_form() == 1;
         }
-        CommonUtil.getInstance().clickAd(activity, advertising.getAd_id(), advertising.getLink_type(), advertising.getLink_id());
+        CommonUtil.getInstance().clickAd(context, advertising.getAd_id(), advertising.getLink_type(), advertising.getLink_id());
         return false;
     }