diff --git a/app/src/main/java/com/jerey/keepgank/fragment/ListFragment.java b/app/src/main/java/com/jerey/keepgank/fragment/ListFragment.java index 36768b3..1502915 100644 --- a/app/src/main/java/com/jerey/keepgank/fragment/ListFragment.java +++ b/app/src/main/java/com/jerey/keepgank/fragment/ListFragment.java @@ -120,7 +120,6 @@ protected void afterCreate(Bundle savedInstanceState) { mAdapter.notifyDataSetChanged(); } - } catch (IOException e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/jerey/keepgank/fragment/TodayFragment.java b/app/src/main/java/com/jerey/keepgank/fragment/TodayFragment.java index e892b53..0904b70 100644 --- a/app/src/main/java/com/jerey/keepgank/fragment/TodayFragment.java +++ b/app/src/main/java/com/jerey/keepgank/fragment/TodayFragment.java @@ -75,7 +75,6 @@ protected void afterCreate(Bundle savedInstanceState) { initUI(); dynamicAddView(mToolbarLayout, "ContentScrimColor", R.color.app_main_color); mAdapter = new DayFragmentAdapter(getActivity()); - Calendar c = null; java.util.Calendar calendar = java.util.Calendar.getInstance(); calendar.setTime(new Date()); year = calendar.get(java.util.Calendar.YEAR); diff --git a/themelib/src/main/java/com/jerey/themelib/loader/TextViewRepository.java b/themelib/src/main/java/com/jerey/themelib/loader/TextViewRepository.java index 0aea0ef..82e2e47 100644 --- a/themelib/src/main/java/com/jerey/themelib/loader/TextViewRepository.java +++ b/themelib/src/main/java/com/jerey/themelib/loader/TextViewRepository.java @@ -1,38 +1,46 @@ package com.jerey.themelib.loader; import android.graphics.Typeface; +import android.util.Log; import android.widget.TextView; import com.jerey.themelib.utils.TypefaceUtils; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; - /** - * Created by _SOLID - * Date:2016/7/12 - * Time:17:58 + * 字体改变工厂 */ public class TextViewRepository { - private static List mTextViews = new ArrayList<>(); + private static final String TAG = "TextViewRepository"; + /** + * 虽使用了弱引用来解决TextView得不到释放的问题,但是没有效果,内存中的TextView依旧在不断增多. + * 即使不加入列表里面,TextView数量依旧是在使用过程中中变多 + */ + private static ArrayList> mTextViewsWeakList = new ArrayList<>(); public static void add(TextView textView) { - mTextViews.add(textView); + mTextViewsWeakList.add(new WeakReference(textView)); textView.setTypeface(TypefaceUtils.CURRENT_TYPEFACE); + Log.d(TAG, "TextViewRepository mTextViews count: " + mTextViewsWeakList.size()); } public static void clear() { - mTextViews.clear(); + mTextViewsWeakList.clear(); } public static void remove(TextView textView) { - mTextViews.remove(textView); + mTextViewsWeakList.remove(new WeakReference(textView)); } public static void applyFont(Typeface tf) { - for (TextView textView : mTextViews) { - textView.setTypeface(tf); + for (WeakReference textViewWeak : mTextViewsWeakList) { + TextView textView = textViewWeak.get(); + if (textView != null) { + textView.setTypeface(tf); + } } } }