Explorar o código

尝试修复bugly上各种空指针和报错;
修复下载管理界面兼容8.0手机的问题;
版本升级为3.3.5

zengjiebin %!s(int64=7) %!d(string=hai) anos
pai
achega
1b43752cc4

+ 183 - 0
app/src/main/java/com/sheep/gamegroup/greendao/download/SdkLoginUserDao.java

@@ -0,0 +1,183 @@
+package com.sheep.gamegroup.greendao.download;
+
+import android.database.Cursor;
+import android.database.sqlite.SQLiteStatement;
+
+import org.greenrobot.greendao.AbstractDao;
+import org.greenrobot.greendao.Property;
+import org.greenrobot.greendao.internal.DaoConfig;
+import org.greenrobot.greendao.database.Database;
+import org.greenrobot.greendao.database.DatabaseStatement;
+
+// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
+/** 
+ * DAO for table "SDK_LOGIN_USER".
+*/
+public class SdkLoginUserDao extends AbstractDao<SdkLoginUser, Long> {
+
+    public static final String TABLENAME = "SDK_LOGIN_USER";
+
+    /**
+     * Properties of entity SdkLoginUser.<br/>
+     * Can be used for QueryBuilder and for referencing column names.
+     */
+    public static class Properties {
+        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
+        public final static Property Token = new Property(1, String.class, "token", false, "token");
+        public final static Property Nickname = new Property(2, String.class, "nickname", false, "nickname");
+        public final static Property Invitation_code = new Property(3, String.class, "invitation_code", false, "invitation_code");
+        public final static Property Avatar = new Property(4, String.class, "avatar", false, "avatar");
+        public final static Property ServiceName = new Property(5, String.class, "serviceName", false, "service_name");
+    }
+
+
+    public SdkLoginUserDao(DaoConfig config) {
+        super(config);
+    }
+    
+    public SdkLoginUserDao(DaoConfig config, DaoSession daoSession) {
+        super(config, daoSession);
+    }
+
+    /** Creates the underlying database table. */
+    public static void createTable(Database db, boolean ifNotExists) {
+        String constraint = ifNotExists? "IF NOT EXISTS ": "";
+        db.execSQL("CREATE TABLE " + constraint + "\"SDK_LOGIN_USER\" (" + //
+                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
+                "\"token\" TEXT," + // 1: token
+                "\"nickname\" TEXT," + // 2: nickname
+                "\"invitation_code\" TEXT," + // 3: invitation_code
+                "\"avatar\" TEXT," + // 4: avatar
+                "\"service_name\" TEXT);"); // 5: serviceName
+    }
+
+    /** Drops the underlying database table. */
+    public static void dropTable(Database db, boolean ifExists) {
+        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SDK_LOGIN_USER\"";
+        db.execSQL(sql);
+    }
+
+    @Override
+    protected final void bindValues(DatabaseStatement stmt, SdkLoginUser entity) {
+        stmt.clearBindings();
+ 
+        Long id = entity.getId();
+        if (id != null) {
+            stmt.bindLong(1, id);
+        }
+ 
+        String token = entity.getToken();
+        if (token != null) {
+            stmt.bindString(2, token);
+        }
+ 
+        String nickname = entity.getNickname();
+        if (nickname != null) {
+            stmt.bindString(3, nickname);
+        }
+ 
+        String invitation_code = entity.getInvitation_code();
+        if (invitation_code != null) {
+            stmt.bindString(4, invitation_code);
+        }
+ 
+        String avatar = entity.getAvatar();
+        if (avatar != null) {
+            stmt.bindString(5, avatar);
+        }
+ 
+        String serviceName = entity.getServiceName();
+        if (serviceName != null) {
+            stmt.bindString(6, serviceName);
+        }
+    }
+
+    @Override
+    protected final void bindValues(SQLiteStatement stmt, SdkLoginUser entity) {
+        stmt.clearBindings();
+ 
+        Long id = entity.getId();
+        if (id != null) {
+            stmt.bindLong(1, id);
+        }
+ 
+        String token = entity.getToken();
+        if (token != null) {
+            stmt.bindString(2, token);
+        }
+ 
+        String nickname = entity.getNickname();
+        if (nickname != null) {
+            stmt.bindString(3, nickname);
+        }
+ 
+        String invitation_code = entity.getInvitation_code();
+        if (invitation_code != null) {
+            stmt.bindString(4, invitation_code);
+        }
+ 
+        String avatar = entity.getAvatar();
+        if (avatar != null) {
+            stmt.bindString(5, avatar);
+        }
+ 
+        String serviceName = entity.getServiceName();
+        if (serviceName != null) {
+            stmt.bindString(6, serviceName);
+        }
+    }
+
+    @Override
+    public Long readKey(Cursor cursor, int offset) {
+        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
+    }    
+
+    @Override
+    public SdkLoginUser readEntity(Cursor cursor, int offset) {
+        SdkLoginUser entity = new SdkLoginUser( //
+            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
+            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // token
+            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // nickname
+            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // invitation_code
+            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // avatar
+            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // serviceName
+        );
+        return entity;
+    }
+     
+    @Override
+    public void readEntity(Cursor cursor, SdkLoginUser entity, int offset) {
+        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
+        entity.setToken(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
+        entity.setNickname(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
+        entity.setInvitation_code(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
+        entity.setAvatar(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
+        entity.setServiceName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
+     }
+    
+    @Override
+    protected final Long updateKeyAfterInsert(SdkLoginUser entity, long rowId) {
+        entity.setId(rowId);
+        return rowId;
+    }
+    
+    @Override
+    public Long getKey(SdkLoginUser entity) {
+        if(entity != null) {
+            return entity.getId();
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public boolean hasKey(SdkLoginUser entity) {
+        return entity.getId() != null;
+    }
+
+    @Override
+    protected final boolean isEntityUpdateable() {
+        return true;
+    }
+    
+}

+ 6 - 1
app/src/main/java/com/sheep/gamegroup/helper/ImageListHelper.java

@@ -11,6 +11,7 @@ import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
 import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import java.util.ArrayList; /**
  * Created by realicing on 2018/7/5.
@@ -28,7 +29,11 @@ public class ImageListHelper {
             public void convert(ViewHolder viewHolder, String url, final int position) {
                 View view = viewHolder.getView(R.id.img_detail);
                 if (view instanceof ImageView) {
-                    Glide.with(recyclerView.getContext()).load(url).into((ImageView) view);
+                    try {
+                        Glide.with(SheepApp.getInstance()).load(url).into((ImageView) view);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
                     view.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {

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

@@ -963,7 +963,7 @@ public class ViewUtil {
         String btnRightText = dialogConfig.getBtnRightText();
         final View.OnClickListener btnRightOnClickListener = dialogConfig.getBtnRightOnClickListener();
         final View.OnClickListener btnCloseOnClickListener = dialogConfig.getBtnCloseOnClickListener();
-        View dialog_parent = View.inflate(mContext, dialogConfig.getParentLayoutId(), null);
+        View dialog_parent = View.inflate(SheepApp.getInstance(), dialogConfig.getParentLayoutId(), null);
         final AlertDialog dialog = new AlertDialog.Builder(mContext, mContext instanceof Activity ? R.style.MyDialogActivityTheme : R.style.AppTheme_Dialog_Alert).setView(dialog_parent).create();
         TextView dialog_title = dialog_parent.findViewById(R.id.dialog_title);
         switch (dialogConfig.getTheme()) {//设置按钮风格

+ 2 - 0
app/src/main/java/com/sheep/gamegroup/view/adapter/DownloadMgrAdapter.java

@@ -5,6 +5,7 @@ import android.widget.ImageView;
 import android.widget.ProgressBar;
 
 import com.bumptech.glide.Glide;
+import com.bumptech.glide.request.RequestOptions;
 import com.kfzs.appstore.utils.adapter.MDLAdpater;
 import com.kfzs.appstore.utils.adapter.MDLViewHolderHelper;
 import com.kfzs.duanduan.utils.ApkUtils;
@@ -75,6 +76,7 @@ public class DownloadMgrAdapter extends MDLAdpater<DownLoadInfo> {
 
         Glide.with(mContext)
                 .load(model.getMIconUrl())
+                .apply(new RequestOptions().disallowHardwareConfig())
                 .into((ImageView) helper.getView(R.id.download_mgr_iv_icon));
 
 

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtAudit.java

@@ -97,6 +97,9 @@ public class FgtAudit extends BaseFragment {
     }
 
     private void initView() {
+        if(title == null){
+            butterKnifeBindView();
+        }
         title.setVisibility(View.GONE);
         empty_view.setPadding(0, 50, 0, 0);
         swipe_container.setFooterView(activity, withdrawalListview, R.layout.listview_footer);

+ 6 - 2
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtSmallSheep.java

@@ -1406,8 +1406,12 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
         banner.setImageLoader(new ImageLoader() {
             @Override
             public void displayImage(Context context, Object o, ImageView imageView) {
-                if (o instanceof SlideshowEty)
-                    Glide.with(context).load(((SlideshowEty) o).getUrl()).apply(new RequestOptions().dontAnimate()).into(imageView);
+                try {
+                    if (o instanceof SlideshowEty && activity != null && !activity.isDestroyed())
+                        Glide.with(context).load(((SlideshowEty) o).getUrl()).apply(new RequestOptions().dontAnimate()).into(imageView);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
         })
                 .setDelayTime(4000)

+ 44 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -3,7 +3,9 @@ package com.sheep.jiuyan.samllsheep;
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Build;
 import android.os.Bundle;
+import android.os.StrictMode;
 import android.support.multidex.MultiDex;
 import android.support.multidex.MultiDexApplication;
 import android.text.TextUtils;
@@ -167,10 +169,52 @@ public class SheepApp extends MultiDexApplication {
             registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
             initNet();
             initUtils();
+            detectFileUriExposure();
             ChannelContent.getInstance().initChannelContent(this);
         }
     }
 
+    /**
+     * https://bugly.qq.com/v2/crash-reporting/crashes/0dd998212c/21541?pid=1
+     * #21541 android.os.FileUriExposedException
+     * file:///storage/emulated/0/Sheep/com.woniu.wdqk.coolpad.kf689667873.apk exposed beyond app through Intent.getData()
+     * com.sheep.jiuyan.samllsheep.utils.h.b(PackageUtil.java:103)
+     *
+     * 解决方案
+     * 因为buildsdk是>=24,所以调用Uri.fromFile时保错,解决方法:
+     *
+     * 在application的onCreate里:
+     * StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
+     * StrictMode.setVmPolicy(builder.build());
+     * builder.detectFileUriExposure()
+     *
+     * SDK>24 和<24的解决方案
+     * public static void openFile(Context context, File file) {
+     *         Intent intent = new Intent();
+     *         intent.setAction(android.content.Intent.ACTION_VIEW);
+     *         Uri uri;
+     *         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+     *             intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+     *             Uri contentUri = FileProvider.getUriForFile(context,
+     *                     context.getApplicationContext().getPackageName() + ".provider",
+     *                     file);
+     *             intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
+     *         } else {
+     *             uri = Uri.fromFile(file);
+     *             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+     *             intent.setDataAndType(uri, "application/vnd.android.package-archive");
+     *         }
+     *         context.startActivity(intent);
+     *     }
+     */
+    private void detectFileUriExposure() {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
+            StrictMode.setVmPolicy(builder.build());
+            builder.detectFileUriExposure();
+        }
+    }
+
     private void initUtils() {
         RefreshUtil.newInstance().initRefresh();
         DisplayMetrics metric = getResources().getDisplayMetrics();

+ 5 - 1
app/src/main/java/com/sheep/jiuyan/samllsheep/base/BaseFragment.java

@@ -88,9 +88,13 @@ public abstract class BaseFragment extends Fragment {
         } else {
             mIsFirstInit = false;
         }
+        butterKnifeBindView();
+        return mView;
+    }
+    //绑定view
+    public void butterKnifeBindView() {
         if(userButterKnife())
             unbinder = ButterKnife.bind(this, mView);
-        return mView;
     }
 
     public abstract int getLayoutId();

+ 3 - 1
app/src/main/res/layout/include_item_sdk_user.xml

@@ -68,7 +68,9 @@
     <View
         android:id="@+id/item_sdk_user_line"
         android:layout_width="match_parent"
-        android:layout_height="1px"
+        android:layout_height="1dp"
+        android:layout_marginStart="15dp"
+        android:layout_marginEnd="15dp"
         android:visibility="invisible"
         android:background="#F5F5F5"/>
 </RelativeLayout>

BIN=BIN
app/src/main/res/mipmap-xxhdpi/x.png


+ 2 - 2
gradle.properties

@@ -17,8 +17,8 @@
 # org.gradle.parallel=true
 #android.injected.build.model.only.versioned = 3
 
-VERSION_NAME=3.3.2
-VERSION_CODE=3003002
+VERSION_NAME=3.3.5
+VERSION_CODE=3003005
 ANDROID_COMPILE_SDK_VERSION=28
 ANDROID_BUILD_TOOLS_VERSION=28.0.3
 ANDROID_MIN_SDK_VERSION=18