Skip to content

Commit

Permalink
Merge "AbsListView: add option to disable scrolling cache (1/2)" into…
Browse files Browse the repository at this point in the history
… gingerbread
  • Loading branch information
rmcc authored and Gerrit Code Review committed Feb 1, 2012
2 parents 5b46273 + ad7b631 commit 46c5c8e
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions core/java/android/widget/AbsListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -329,6 +330,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.
Expand Down Expand Up @@ -618,7 +628,21 @@ public AbsListView(Context context, AttributeSet attrs, int defStyle) {
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);
Expand Down Expand Up @@ -646,7 +670,8 @@ private void initAbsListView() {
setFocusableInTouchMode(true);
setWillNotDraw(false);
setAlwaysDrawnWithCacheEnabled(false);
setScrollingCacheEnabled(true);
boolean scrollingCacheEnabled = (mScrollingCacheProperty < 2);
setScrollingCacheEnabled(scrollingCacheEnabled);

final ViewConfiguration configuration = ViewConfiguration.get(mContext);
mTouchSlop = configuration.getScaledTouchSlop();
Expand Down Expand Up @@ -817,6 +842,7 @@ public void setScrollingCacheEnabled(boolean enabled) {
clearScrollingCache();
}
mScrollingCacheEnabled = enabled;
Log.d(ViewDebug.CONSISTENCY_LOG_TAG, "AbsListView " + this + " enabled= " + enabled);
}

/**
Expand Down

0 comments on commit 46c5c8e

Please sign in to comment.