am 53a5e317: Merge "Wrap measurement optimization in targetSdk check" into klp-dev
* commit '53a5e3175acb6e2bd23c25c1e4cba0789e47488f': Wrap measurement optimization in targetSdk check
This commit is contained in:
@@ -18,6 +18,7 @@ package android.view;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -691,8 +692,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
public static final int NO_ID = -1;
|
||||
|
||||
/**
|
||||
* Signals that compatibility booleans have been initialized according to
|
||||
* target SDK versions.
|
||||
*/
|
||||
private static boolean sCompatibilityDone = false;
|
||||
|
||||
/**
|
||||
* Use the old (broken) way of building MeasureSpecs.
|
||||
*/
|
||||
private static boolean sUseBrokenMakeMeasureSpec = false;
|
||||
|
||||
/**
|
||||
* Ignore any optimizations using the measure cache.
|
||||
*/
|
||||
private static boolean sIgnoreMeasureCache = false;
|
||||
|
||||
/**
|
||||
* This view does not want keystrokes. Use with TAKES_FOCUS_MASK when
|
||||
* calling setFlags.
|
||||
@@ -3426,10 +3441,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
mUserPaddingStart = UNDEFINED_PADDING;
|
||||
mUserPaddingEnd = UNDEFINED_PADDING;
|
||||
|
||||
if (!sUseBrokenMakeMeasureSpec && context != null &&
|
||||
context.getApplicationInfo().targetSdkVersion <= JELLY_BEAN_MR1) {
|
||||
if (!sCompatibilityDone && context != null) {
|
||||
final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion;
|
||||
|
||||
// Older apps may need this compatibility hack for measurement.
|
||||
sUseBrokenMakeMeasureSpec = true;
|
||||
sUseBrokenMakeMeasureSpec = targetSdkVersion <= JELLY_BEAN_MR1;
|
||||
|
||||
// Older apps expect onMeasure() to always be called on a layout pass, regardless
|
||||
// of whether a layout was requested on that View.
|
||||
sIgnoreMeasureCache = targetSdkVersion < KITKAT;
|
||||
|
||||
sCompatibilityDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16431,7 +16453,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
|
||||
int cacheIndex = (mPrivateFlags & PFLAG_FORCE_LAYOUT) == PFLAG_FORCE_LAYOUT ? -1 :
|
||||
mMeasureCache.indexOfKey(key);
|
||||
if (cacheIndex < 0) {
|
||||
if (cacheIndex < 0 || sIgnoreMeasureCache) {
|
||||
// measure ourselves, this should set the measured dimension flag back
|
||||
onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
mPrivateFlags3 &= ~PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT;
|
||||
|
||||
Reference in New Issue
Block a user