Browse Source

bug fixed

hanjing 7 years ago
parent
commit
c133b01650

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

@@ -14,7 +14,7 @@ import static com.sheep.jiuyan.samllsheep.utils.ClassFileHelper.DIR;
  */
 
 public class ConfigUtil {
-    private static ConfigUtil instance = new ConfigUtil();
+    private static ConfigUtil instance;
     private ConfigUtil() {
         if(TestUtil.isTest()) {
             File file = new File(DIR, "smallSheep.config");

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/view/adapter/AdpEveryDayShare.java

@@ -56,9 +56,10 @@ public class AdpEveryDayShare extends AdbCommonRecycler<EveryDayShare> {
 
         } else {
             TextView share_item_title = holder.itemView.findViewById(R.id.share_item_title);
+            TextView share_item_content = holder.itemView.findViewById(R.id.share_item_content);
             ImageView share_item_iv = holder.itemView.findViewById(R.id.share_item_iv);
             ViewUtil.setText(share_item_title, item.getTitle());
-//        ViewUtil.setImage(share_item_iv, item.getPictures());
+            ViewUtil.setText(share_item_content, item.getContent());
             holder.itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtFind.java

@@ -149,7 +149,7 @@ public class FgtFind extends BaseFragment {
                         List<ArticleTag> newList = baseMessage.getDatas(ArticleTag.class);
                         list.clear();
                         list.addAll(newList);
-                        if (loadPager && list.isEmpty() && !ListUtil.isEmpty(newList)) {
+                        if (loadPager && !ListUtil.isEmpty(list)) {
                             loadList();
                         }
                     }

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

@@ -10,7 +10,6 @@ import android.support.multidex.MultiDex;
 import android.support.multidex.MultiDexApplication;
 import android.text.TextUtils;
 import android.util.DisplayMetrics;
-import android.util.Log;
 
 import com.baidu.location.BDAbstractLocationListener;
 import com.baidu.location.BDLocation;
@@ -155,6 +154,7 @@ public class SheepApp extends MultiDexApplication {
 
     @Override
     public void onCreate() {
+        configStrictMode();
         super.onCreate();
         if (AppUtil.isMainProcess(this)) {
             mSheepApp = this;
@@ -162,7 +162,7 @@ public class SheepApp extends MultiDexApplication {
             registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
             initNet();
             initUtils();
-            detectFileUriExposure();
+            configStrictMode();
             ChannelContent.getInstance().initChannelContent(this);
             refWatcher = LeakCanary.install(this);
         }
@@ -180,7 +180,7 @@ public class SheepApp extends MultiDexApplication {
      * 在application的onCreate里:
      * StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
      * StrictMode.setVmPolicy(builder.build());
-     * builder.detectFileUriExposure()
+     * builder.configStrictMode()
      * <p>
      * SDK>24 和<24的解决方案
      * public static void openFile(Context context, File file) {
@@ -201,11 +201,20 @@ public class SheepApp extends MultiDexApplication {
      * 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 configStrictMode() {
+        if (BuildConfig.DEBUG) {
+            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
+                    .detectDiskReads()
+                    .detectDiskWrites()
+                    .detectNetwork()   // or .detectAll() for all detectable problems
+                    .penaltyLog()
+                    .build());
+            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+                    .detectLeakedSqlLiteObjects()
+//                    .detectLeakedClosableObjects()
+                    .penaltyLog()
+                    .penaltyDeath()
+                    .build());
         }
     }
 

+ 4 - 2
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/ClassFileHelper.java

@@ -37,12 +37,14 @@ import java.io.IOException;
  * moveFilesTo
  */
 public class ClassFileHelper {
-    private static String SD_PATH = Environment.getExternalStorageDirectory().getAbsolutePath();
+    private static String SD_PATH;
     public static String FILE_SUFFIX = ".apk";
-    public static String DIR = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Sheep";
+    public static String DIR;
     public static ClassFileHelper INSTANCE = new ClassFileHelper();
 
     private ClassFileHelper() {
+        SD_PATH = Environment.getExternalStorageDirectory().getAbsolutePath();
+        DIR = SD_PATH + File.separator + "Sheep";
     }
 
     public static ClassFileHelper getInstance() {

+ 57 - 79
app/src/main/java/org/afinal/simplecache/ACache.java

@@ -1,12 +1,12 @@
 /**
  * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com).
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,6 +28,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.RandomAccessFile;
 import java.io.Serializable;
+import java.util.Calendar;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -46,12 +47,13 @@ import android.graphics.Canvas;
 import android.graphics.PixelFormat;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
+import android.util.Log;
 
 /**
  * @author Michael Yang(www.yangfuhai.com) update at 2013.08.07
  */
 public class ACache {
-    public static final int TIME_HOUR = 60 * 60;
+    public static final int TIME_HOUR = 60 * 60 * 1000;
     public static final int TIME_DAY = TIME_HOUR * 24;
     private static final int MAX_SIZE = 1000 * 1000 * 50; // 50 mb
     private static final int MAX_COUNT = Integer.MAX_VALUE; // 不限制存放数据的数量
@@ -100,13 +102,12 @@ public class ACache {
     // =======================================
     // ============ String数据 读写 ==============
     // =======================================
+
     /**
      * 保存 String数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的String数据
+     * @param key   保存的key
+     * @param value 保存的String数据
      */
     public void put(String key, String value) {
         File file = mCache.newFile(key);
@@ -132,12 +133,9 @@ public class ACache {
     /**
      * 保存 String数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的String数据
-     * @param saveTime
-     *            保存的时间,单位:秒
+     * @param key      保存的key
+     * @param value    保存的String数据
+     * @param saveTime 保存的时间,单位:秒
      */
     public void put(String key, String value, int saveTime) {
         put(key, Utils.newStringWithDateInfo(saveTime, value));
@@ -153,6 +151,10 @@ public class ACache {
         File file = mCache.get(key);
         if (!file.exists())
             return null;
+        if (System.currentTimeMillis() - file.lastModified() > TIME_HOUR) {
+            file.deleteOnExit();
+            return null;
+        }
         boolean removeFile = false;
         BufferedReader in = null;
         try {
@@ -187,13 +189,12 @@ public class ACache {
     // =======================================
     // ============= JSONObject 数据 读写 ==============
     // =======================================
+
     /**
      * 保存 JSONObject数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的JSON数据
+     * @param key   保存的key
+     * @param value 保存的JSON数据
      */
     public void put(String key, JSONObject value) {
         put(key, value.toString());
@@ -202,12 +203,9 @@ public class ACache {
     /**
      * 保存 JSONObject数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的JSONObject数据
-     * @param saveTime
-     *            保存的时间,单位:秒
+     * @param key      保存的key
+     * @param value    保存的JSONObject数据
+     * @param saveTime 保存的时间,单位:秒
      */
     public void put(String key, JSONObject value, int saveTime) {
         put(key, value.toString(), saveTime);
@@ -233,13 +231,12 @@ public class ACache {
     // =======================================
     // ============ JSONArray 数据 读写 =============
     // =======================================
+
     /**
      * 保存 JSONArray数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的JSONArray数据
+     * @param key   保存的key
+     * @param value 保存的JSONArray数据
      */
     public void put(String key, JSONArray value) {
         put(key, value.toString());
@@ -248,12 +245,9 @@ public class ACache {
     /**
      * 保存 JSONArray数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的JSONArray数据
-     * @param saveTime
-     *            保存的时间,单位:秒
+     * @param key      保存的key
+     * @param value    保存的JSONArray数据
+     * @param saveTime 保存的时间,单位:秒
      */
     public void put(String key, JSONArray value, int saveTime) {
         put(key, value.toString(), saveTime);
@@ -279,13 +273,12 @@ public class ACache {
     // =======================================
     // ============== byte 数据 读写 =============
     // =======================================
+
     /**
      * 保存 byte数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的数据
+     * @param key   保存的key
+     * @param value 保存的数据
      */
     public void put(String key, byte[] value) {
         File file = mCache.newFile(key);
@@ -311,12 +304,9 @@ public class ACache {
     /**
      * 保存 byte数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的数据
-     * @param saveTime
-     *            保存的时间,单位:秒
+     * @param key      保存的key
+     * @param value    保存的数据
+     * @param saveTime 保存的时间,单位:秒
      */
     public void put(String key, byte[] value, int saveTime) {
         put(key, Utils.newByteArrayWithDateInfo(saveTime, value));
@@ -363,13 +353,12 @@ public class ACache {
     // =======================================
     // ============= 序列化 数据 读写 ===============
     // =======================================
+
     /**
      * 保存 Serializable数据 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的value
+     * @param key   保存的key
+     * @param value 保存的value
      */
     public void put(String key, Serializable value) {
         put(key, value, -1);
@@ -378,12 +367,9 @@ public class ACache {
     /**
      * 保存 Serializable数据到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的value
-     * @param saveTime
-     *            保存的时间,单位:秒
+     * @param key      保存的key
+     * @param value    保存的value
+     * @param saveTime 保存的时间,单位:秒
      */
     public void put(String key, Serializable value, int saveTime) {
         ByteArrayOutputStream baos = null;
@@ -449,13 +435,12 @@ public class ACache {
     // =======================================
     // ============== bitmap 数据 读写 =============
     // =======================================
+
     /**
      * 保存 bitmap 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的bitmap数据
+     * @param key   保存的key
+     * @param value 保存的bitmap数据
      */
     public void put(String key, Bitmap value) {
         put(key, Utils.Bitmap2Bytes(value));
@@ -464,12 +449,9 @@ public class ACache {
     /**
      * 保存 bitmap 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的 bitmap 数据
-     * @param saveTime
-     *            保存的时间,单位:秒
+     * @param key      保存的key
+     * @param value    保存的 bitmap 数据
+     * @param saveTime 保存的时间,单位:秒
      */
     public void put(String key, Bitmap value, int saveTime) {
         put(key, Utils.Bitmap2Bytes(value), saveTime);
@@ -491,13 +473,12 @@ public class ACache {
     // =======================================
     // ============= drawable 数据 读写 =============
     // =======================================
+
     /**
      * 保存 drawable 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的drawable数据
+     * @param key   保存的key
+     * @param value 保存的drawable数据
      */
     public void put(String key, Drawable value) {
         put(key, Utils.drawable2Bitmap(value));
@@ -506,12 +487,9 @@ public class ACache {
     /**
      * 保存 drawable 到 缓存中
      *
-     * @param key
-     *            保存的key
-     * @param value
-     *            保存的 drawable 数据
-     * @param saveTime
-     *            保存的时间,单位:秒
+     * @param key      保存的key
+     * @param value    保存的 drawable 数据
+     * @param saveTime 保存的时间,单位:秒
      */
     public void put(String key, Drawable value, int saveTime) {
         put(key, Utils.drawable2Bitmap(value), saveTime);
@@ -561,9 +539,9 @@ public class ACache {
     }
 
     /**
-     * @title 缓存管理器
      * @author 杨福海(michael) www.yangfuhai.com
      * @version 1.0
+     * @title 缓存管理器
      */
     public class ACacheManager {
         private final AtomicLong cacheSize;
@@ -633,7 +611,7 @@ public class ACache {
         private File get(String key) {
             File file = newFile(key);
             Long currentTime = System.currentTimeMillis();
-            file.setLastModified(currentTime);
+//            file.setLastModified(currentTime);
             lastUsageDates.put(file, currentTime);
 
             return file;
@@ -700,9 +678,9 @@ public class ACache {
     }
 
     /**
-     * @title 时间计算工具类
      * @author 杨福海(michael) www.yangfuhai.com
      * @version 1.0
+     * @title 时间计算工具类
      */
     private static class Utils {
 
@@ -777,7 +755,7 @@ public class ACache {
                 String saveDate = new String(copyOfRange(data, 0, 13));
                 String deleteAfter = new String(copyOfRange(data, 14,
                         indexOf(data, mSeparator)));
-                return new String[] { saveDate, deleteAfter };
+                return new String[]{saveDate, deleteAfter};
             }
             return null;
         }

+ 14 - 2
app/src/main/res/layout/item_every_day_share.xml

@@ -16,12 +16,24 @@
         android:layout_height="wrap_content"
         android:layout_toRightOf="@+id/share_item_iv"
         android:ellipsize="end"
-        android:maxLines="3"
-        android:minLines="2"
+
         android:text="abcab"
         android:textColor="@color/black_6_3"
         android:textSize="15sp" />
 
+    <TextView
+        android:id="@+id/share_item_content"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_toRightOf="@+id/share_item_iv"
+        android:layout_below="@id/share_item_title"
+        android:ellipsize="end"
+
+        android:text="abcab"
+        android:textColor="@color/gray"
+        android:textSize="15sp" />
+
+
     <ImageView
         android:id="@+id/share_item_iv"
         android:layout_width="75dp"