diff options
author | Sang Tae Park <pastime1971@gmail.com> | 2012-01-29 15:47:22 -0800 |
---|---|---|
committer | Sang Tae Park <pastime1971@gmail.com> | 2012-01-30 22:05:01 -0800 |
commit | ad7b631ced16f0acf279721e43f5d3e7b7c21c93 (patch) | |
tree | 32f70642b1f61e968d02c8793507e237e50ad57d | |
parent | 7e377b4c03b99d59edb919298574ca7a7053ac66 (diff) | |
download | frameworks_base-ad7b631ced16f0acf279721e43f5d3e7b7c21c93.zip frameworks_base-ad7b631ced16f0acf279721e43f5d3e7b7c21c93.tar.gz frameworks_base-ad7b631ced16f0acf279721e43f5d3e7b7c21c93.tar.bz2 |
AbsListView: add option to disable scrolling cache (1/2)
scrolling cache (discard?) can cause performance lag due to GC
allow user to enable/disable/force scrolling cache on the fly
inspired by AndroidON, http://forum.xda-developers.com/showthread.php?t=1411317
Change-Id: I89605b42182edeafbc4c07e2b7650a914f4f7c9a
-rw-r--r-- | core/java/android/widget/AbsListView.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 4a35533..74bcd62 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -29,6 +29,7 @@ import android.os.Debug; import android.os.Handler; import android.os.Parcel; import android.os.Parcelable; +import android.os.SystemProperties; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -330,6 +331,15 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te boolean mStackFromBottom; /** + * Indicates whether to system-wide-override to enable/disable or not. + * 0 = force to enable scrollingCacheEnabled regardless of app setting + * 1 = default is to enable scrollingCacheEnabled unless app specifies + * 2 = default is to disable scrollingCacheEnabled unless app specifies + * 3 = force to disable scrollingCacheEnabled regardless of app setting + */ + int mScrollingCacheProperty = SystemProperties.getInt("persist.sys.scrollingcache",1); + + /** * When set to true, the list automatically discards the children's * bitmap cache after scrolling. */ @@ -618,7 +628,21 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te boolean stackFromBottom = a.getBoolean(R.styleable.AbsListView_stackFromBottom, false); setStackFromBottom(stackFromBottom); - boolean scrollingCacheEnabled = a.getBoolean(R.styleable.AbsListView_scrollingCache, true); + boolean scrollingCacheEnabled = true; + switch(mScrollingCacheProperty) { + case 0: + scrollingCacheEnabled = true; + break; + default: + scrollingCacheEnabled = a.getBoolean(R.styleable.AbsListView_scrollingCache, true); + break; + case 2: + scrollingCacheEnabled = a.getBoolean(R.styleable.AbsListView_scrollingCache, false); + break; + case 3: + scrollingCacheEnabled = false; + break; + } setScrollingCacheEnabled(scrollingCacheEnabled); boolean useTextFilter = a.getBoolean(R.styleable.AbsListView_textFilterEnabled, false); @@ -646,7 +670,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te setFocusableInTouchMode(true); setWillNotDraw(false); setAlwaysDrawnWithCacheEnabled(false); - setScrollingCacheEnabled(true); + boolean scrollingCacheEnabled = (mScrollingCacheProperty < 2); + setScrollingCacheEnabled(scrollingCacheEnabled); final ViewConfiguration configuration = ViewConfiguration.get(mContext); mTouchSlop = configuration.getScaledTouchSlop(); @@ -817,6 +842,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te clearScrollingCache(); } mScrollingCacheEnabled = enabled; + Log.d(ViewDebug.CONSISTENCY_LOG_TAG, "AbsListView " + this + " enabled= " + enabled); } /** |