ソースを参照

[修改]调整

ZEKI 5 年 前
コミット
09461ce8c9

+ 38 - 3
app/src/main/java/com/sheep/gamegroup/greendao/download/SheepAd.java

@@ -65,13 +65,20 @@ public class SheepAd {
     private long create_time;
     @Property(nameInDb = "update_time")
     private long update_time;
-
-    @Generated(hash = 973022081)
+    @Property(nameInDb = "ad_type") //广告类型: 1:小绵羊平台;2:游可盈;3:优投
+    private int ad_type;
+    @Property(nameInDb = "third_app_id") //第三方平台需要的appId
+    private String third_app_id;
+    @Property(nameInDb = "third_ad_id") //第三方平台需要的开屏广告id
+    private String third_ad_id;
+
+    @Generated(hash = 957244860)
     public SheepAd(Long id, long ad_id, String name, String ad_img, int form,
             int jump_form, int jump_type, String jump_url, long link_id,
             int link_type, long start_time, long end_time, int platform,
             int status, long user_id, String user_name, int user_type,
-            long create_time, long update_time) {
+            long create_time, long update_time, int ad_type, String third_app_id,
+            String third_ad_id) {
         this.id = id;
         this.ad_id = ad_id;
         this.name = name;
@@ -91,6 +98,9 @@ public class SheepAd {
         this.user_type = user_type;
         this.create_time = create_time;
         this.update_time = update_time;
+        this.ad_type = ad_type;
+        this.third_app_id = third_app_id;
+        this.third_ad_id = third_ad_id;
     }
 
     @Generated(hash = 1653842457)
@@ -257,4 +267,29 @@ public class SheepAd {
         return 5;
     }
 
+    public int getAd_type() {
+        return ad_type;
+    }
+
+    public void setAd_type(int ad_type) {
+        this.ad_type = ad_type;
+    }
+
+    public String getThird_app_id() {
+        return third_app_id;
+    }
+
+    public void setThird_app_id(String third_app_id) {
+        this.third_app_id = third_app_id;
+    }
+
+    public String getThird_ad_id() {
+        return third_ad_id;
+    }
+
+    public void setThird_ad_id(String third_ad_id) {
+        this.third_ad_id = third_ad_id;
+    }
+
+
 }

+ 36 - 2
app/src/main/java/com/sheep/gamegroup/greendao/download/SheepAdDao.java

@@ -41,6 +41,9 @@ public class SheepAdDao extends AbstractDao<SheepAd, Long> {
         public final static Property User_type = new Property(16, int.class, "user_type", false, "user_type");
         public final static Property Create_time = new Property(17, long.class, "create_time", false, "create_time");
         public final static Property Update_time = new Property(18, long.class, "update_time", false, "update_time");
+        public final static Property Ad_type = new Property(19, int.class, "ad_type", false, "ad_type");
+        public final static Property Third_app_id = new Property(20, String.class, "third_app_id", false, "third_app_id");
+        public final static Property Third_ad_id = new Property(21, String.class, "third_ad_id", false, "third_ad_id");
     }
 
 
@@ -74,7 +77,10 @@ public class SheepAdDao extends AbstractDao<SheepAd, Long> {
                 "\"user_name\" TEXT," + // 15: user_name
                 "\"user_type\" INTEGER NOT NULL ," + // 16: user_type
                 "\"create_time\" INTEGER NOT NULL ," + // 17: create_time
-                "\"update_time\" INTEGER NOT NULL );"); // 18: update_time
+                "\"update_time\" INTEGER NOT NULL ," + // 18: update_time
+                "\"ad_type\" INTEGER NOT NULL ," + // 19: ad_type
+                "\"third_app_id\" TEXT," + // 20: third_app_id
+                "\"third_ad_id\" TEXT);"); // 21: third_ad_id
     }
 
     /** Drops the underlying database table. */
@@ -125,6 +131,17 @@ public class SheepAdDao extends AbstractDao<SheepAd, Long> {
         stmt.bindLong(17, entity.getUser_type());
         stmt.bindLong(18, entity.getCreate_time());
         stmt.bindLong(19, entity.getUpdate_time());
+        stmt.bindLong(20, entity.getAd_type());
+ 
+        String third_app_id = entity.getThird_app_id();
+        if (third_app_id != null) {
+            stmt.bindString(21, third_app_id);
+        }
+ 
+        String third_ad_id = entity.getThird_ad_id();
+        if (third_ad_id != null) {
+            stmt.bindString(22, third_ad_id);
+        }
     }
 
     @Override
@@ -169,6 +186,17 @@ public class SheepAdDao extends AbstractDao<SheepAd, Long> {
         stmt.bindLong(17, entity.getUser_type());
         stmt.bindLong(18, entity.getCreate_time());
         stmt.bindLong(19, entity.getUpdate_time());
+        stmt.bindLong(20, entity.getAd_type());
+ 
+        String third_app_id = entity.getThird_app_id();
+        if (third_app_id != null) {
+            stmt.bindString(21, third_app_id);
+        }
+ 
+        String third_ad_id = entity.getThird_ad_id();
+        if (third_ad_id != null) {
+            stmt.bindString(22, third_ad_id);
+        }
     }
 
     @Override
@@ -197,7 +225,10 @@ public class SheepAdDao extends AbstractDao<SheepAd, Long> {
             cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // user_name
             cursor.getInt(offset + 16), // user_type
             cursor.getLong(offset + 17), // create_time
-            cursor.getLong(offset + 18) // update_time
+            cursor.getLong(offset + 18), // update_time
+            cursor.getInt(offset + 19), // ad_type
+            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // third_app_id
+            cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21) // third_ad_id
         );
         return entity;
     }
@@ -223,6 +254,9 @@ public class SheepAdDao extends AbstractDao<SheepAd, Long> {
         entity.setUser_type(cursor.getInt(offset + 16));
         entity.setCreate_time(cursor.getLong(offset + 17));
         entity.setUpdate_time(cursor.getLong(offset + 18));
+        entity.setAd_type(cursor.getInt(offset + 19));
+        entity.setThird_app_id(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
+        entity.setThird_ad_id(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
      }
     
     @Override

+ 12 - 15
app/src/main/java/com/sheep/gamegroup/view/activity/SplashAct.java

@@ -111,18 +111,18 @@ public class SplashAct extends BaseActivity {
     private void handleResult(boolean isNewSmallSheep) {
         DataUtil.getInstance().setIsNewSmallSheep(isNewSmallSheep);
         if (SysAppUtil.isNewSmallSheep()) {//新版本只显示引导页面,不展示弹窗和开屏广告
-            initSelfAdvertisement(false);//只更新,不加载,下次加载上次的数据
+            fetchAdvertisement(false);//只更新,不加载,下次加载上次的数据
             sendHandlerMessages(2000);
         } else {
             ad = DDProviderHelper.getInstance().getSheepAd(SheepAd.FORM_SPLASH);
             if (ad != null) {
                 //有自己的广告,先加载自己的广告,再拉取一次广告并保存
                 loadAdvertising();
-                initSelfAdvertisement(false);//只更新,不加载,下次加载上次的数据
+                fetchAdvertisement(false);//只更新,不加载,下次加载上次的数据
             } else {
                 //没有自己的广告,展示SDK的广告,并拉取一次广告并保存
                 initSdkAdvertising();
-                initSelfAdvertisement(false);
+                fetchAdvertisement(false);
             }
         }
     }
@@ -191,9 +191,9 @@ public class SplashAct extends BaseActivity {
     }
 
     /**
-     * 加载自己的广告
+     * 从服务端拉取广告信息
      */
-    private void initSelfAdvertisement(boolean isLoad) {
+    private void fetchAdvertisement(boolean isLoad) {
         CommonUtil.getInstance().refreshAds((ret, list) -> {
             if (ret) {
                 if (isLoad) {
@@ -225,17 +225,14 @@ public class SplashAct extends BaseActivity {
             Uri uri = Uri.parse(ad.getAd_img());
             if (splash_video_view != null) {
                 splash_video_view.setVisibility(View.VISIBLE);
-                splash_video_view.setOnInfoListener(new MediaPlayer.OnInfoListener() {
-                    @Override
-                    public boolean onInfo(MediaPlayer mediaPlayer, int what, int extra) {
-                        if (!mediaPlayer.isLooping())
-                            mediaPlayer.setLooping(true);
-                        LogUtil.println("onInfo what = " + what + " extra = " + extra);
-                        if (MediaPlayer.MEDIA_INFO_BUFFERING_START == what) {
-                            splash_image_view.setVisibility(View.GONE);
-                        }
-                        return false;
+                splash_video_view.setOnInfoListener((mediaPlayer, what, extra) -> {
+                    if (!mediaPlayer.isLooping())
+                        mediaPlayer.setLooping(true);
+                    LogUtil.println("onInfo what = " + what + " extra = " + extra);
+                    if (MediaPlayer.MEDIA_INFO_BUFFERING_START == what) {
+                        splash_image_view.setVisibility(View.GONE);
                     }
+                    return false;
                 });
                 splash_video_view.setVideoURI(uri);
                 splash_video_view.start();

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

@@ -1,42 +1,33 @@
 package com.sheep.gamegroup.view.activity.helper;
 
-import android.Manifest;
 import android.app.Activity;
 import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
 import android.text.TextUtils;
-
 import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.greendao.download.SheepAd;
-import com.sheep.gamegroup.model.entity.Advertising;
 import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.FileUtil;
-import com.sheep.gamegroup.util.IDConstant;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
-import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.activity.SplashAct;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
-
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
-
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.schedulers.Schedulers;
-
 import static com.sheep.jiuyan.samllsheep.utils.ClassFileHelper.DIR;
 
 public class AdHelper {
 
+    public static int AD_TYPE_SHEEP = 1; //广告类型:小绵羊平台自己的广告
+    public static int AD_TYPE_YKY = 2; //广告类型:游可盈的广告
+    public static int AD_TYPE_YT = 3; //广告类型:优投的广告
+
     // 返回true 为apk下载
     public static boolean goAdLink(Context context, SheepAd advertising) {
         if (TextUtils.isEmpty(SpUtils.getToken(SheepApp.getInstance()))) {

+ 0 - 20
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtFindChild.java

@@ -1,34 +1,26 @@
 package com.sheep.gamegroup.view.fragment;
 
-import android.content.Intent;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
-
 import com.kfzs.android.view.tag.FlowLayout;
 import com.kfzs.android.view.tag.TagAdapter;
 import com.kfzs.android.view.tag.TagFlowLayout;
-import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.greendao.DDProviderHelper;
-import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 import com.sheep.gamegroup.greendao.download.SheepAd;
 import com.sheep.gamegroup.model.api.ApiService;
-import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.Article;
 import com.sheep.gamegroup.model.entity.ArticleTag;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.Lp;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
-import com.sheep.gamegroup.util.DownloadUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
-import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewHolder;
 import com.sheep.gamegroup.util.ViewUtil;
@@ -38,26 +30,14 @@ import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
-import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
-
 import org.afinal.simplecache.ApiKey;
-import org.greenrobot.eventbus.EventBus;
-import org.greenrobot.eventbus.Subscribe;
-
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Locale;
-import java.util.Map;
 import java.util.Set;
-
 import io.reactivex.Observable;
 import rx.functions.Action1;
 
-import static android.content.Intent.ACTION_PACKAGE_ADDED;
-import static android.content.Intent.ACTION_PACKAGE_REMOVED;
-
 /**
  * Created by realicing on 2018/9/7.
  * realicing@sina.com

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

@@ -1,19 +1,17 @@
 package com.sheep.jiuyan.samllsheep;
 
-import android.Manifest;
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.StrictMode;
 import android.support.multidex.MultiDex;
 import android.support.multidex.MultiDexApplication;
-import android.support.v4.app.ActivityCompat;
 import android.text.TextUtils;
 import android.util.DisplayMetrics;
+import android.util.Log;
 
 import com.baidu.idl.face.platform.FaceSDKManager;
 import com.baidu.location.BDAbstractLocationListener;
@@ -23,11 +21,8 @@ import com.baidu.location.LocationClientOption;
 import com.bumptech.glide.Glide;
 import com.bun.miitmdid.core.JLibrary;
 import com.danikula.videocache.HttpProxyCacheServer;
-//import com.didi.virtualapk.PluginManager;
-import com.google.gson.JsonParser;
 import com.kfzs.cfyl.share_library.util.ContextHolder;
 import com.liulishuo.okdownload.OkDownload;
-import com.liulishuo.okdownload.core.connection.DownloadUrlConnection;
 import com.liulishuo.okdownload.core.dispatcher.DownloadDispatcher;
 import com.sheep.gamegroup.di.components.DaggerNetComponent;
 import com.sheep.gamegroup.di.components.NetComponent;
@@ -88,6 +83,8 @@ import org.xutils.x;
 import java.lang.ref.WeakReference;
 
 import cn.jpush.android.api.JPushInterface;
+import io.reactivex.functions.Consumer;
+import io.reactivex.plugins.RxJavaPlugins;
 import ren.yale.android.cachewebviewlib.WebViewCacheInterceptor;
 import ren.yale.android.cachewebviewlib.WebViewCacheInterceptorInst;
 import ren.yale.android.cachewebviewlib.config.CacheExtensionConfig;
@@ -227,6 +224,11 @@ public class SheepApp extends MultiDexApplication {
                 e.printStackTrace();
             }
 
+            /*Rx兜底策略*/
+            RxJavaPlugins.setErrorHandler(throwable -> {
+                Log.e("RxThrowable", throwable.getMessage());
+            });
+
             /*点客广告SDK接入*/
             TMSDKContext.setTMSDKLogEnable(BuildConfig.DEBUG);
             TMSDKContext.init(this, new AbsTMSConfig() {