下面列出了android.view.ViewDebug#ExportedProperty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static String mapFlagsToStringUsingAnnotation(
int value,
@Nullable ViewDebug.ExportedProperty annotation) {
if (!canFlagsBeMappedToString(annotation)) {
throw new IllegalStateException("Cannot map using this annotation");
}
StringBuilder stringBuilder = null;
boolean atLeastOneFlag = false;
for (ViewDebug.FlagToString flagToString : annotation.flagMapping()) {
if (flagToString.outputIf() == ((value & flagToString.mask()) == flagToString.equals())) {
if (stringBuilder == null) {
stringBuilder = new StringBuilder();
}
if (atLeastOneFlag) {
stringBuilder.append(" | ");
}
stringBuilder.append(flagToString.name());
atLeastOneFlag = true;
}
}
if (atLeastOneFlag) {
return stringBuilder.toString();
} else {
return NONE_MAPPING;
}
}
private void getStyleFromValue(
View element,
String name,
Object value,
@Nullable ViewDebug.ExportedProperty annotation,
StyleAccumulator styles) {
if (name.equals(ID_NAME)) {
getIdStyle(element, styles);
} else if (value instanceof Integer) {
getStyleFromInteger(name, (Integer) value, annotation, styles);
} else if (value instanceof Float) {
styles.store(name, String.valueOf(value), ((Float) value) == 0.0f);
} else if (value instanceof Boolean) {
styles.store(name, String.valueOf(value), false);
} else if (value instanceof Short) {
styles.store(name, String.valueOf(value), ((Short) value) == 0);
} else if (value instanceof Long) {
styles.store(name, String.valueOf(value), ((Long) value) == 0);
} else if (value instanceof Double) {
styles.store(name, String.valueOf(value), ((Double) value) == 0.0d);
} else if (value instanceof Byte) {
styles.store(name, String.valueOf(value), ((Byte) value) == 0);
} else if (value instanceof Character) {
styles.store(name, String.valueOf(value), ((Character) value) == Character.MIN_VALUE);
} else if (value instanceof CharSequence) {
styles.store(name, String.valueOf(value), ((CharSequence) value).length() == 0);
} else {
getStylesFromObject(element, name, value, annotation, styles);
}
}
public MethodBackedCSSProperty(
Method method,
String cssName,
@Nullable ViewDebug.ExportedProperty annotation) {
super(cssName, annotation);
mMethod = method;
mMethod.setAccessible(true);
}
private static String mapFlagsToStringUsingAnnotation(
int value,
@Nullable ViewDebug.ExportedProperty annotation) {
if (!canFlagsBeMappedToString(annotation)) {
throw new IllegalStateException("Cannot map using this annotation");
}
StringBuilder stringBuilder = null;
boolean atLeastOneFlag = false;
for (ViewDebug.FlagToString flagToString : annotation.flagMapping()) {
if (flagToString.outputIf() == ((value & flagToString.mask()) == flagToString.equals())) {
if (stringBuilder == null) {
stringBuilder = new StringBuilder();
}
if (atLeastOneFlag) {
stringBuilder.append(" | ");
}
stringBuilder.append(flagToString.name());
atLeastOneFlag = true;
}
}
if (atLeastOneFlag) {
return stringBuilder.toString();
} else {
return NONE_MAPPING;
}
}
public MethodBackedCSSProperty(
Method method,
String cssName,
@Nullable ViewDebug.ExportedProperty annotation) {
super(cssName, annotation);
mMethod = method;
mMethod.setAccessible(true);
}
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public String format(Integer integer, @Nullable ViewDebug.ExportedProperty annotation) {
if (annotation != null && annotation.formatToHexString()) {
return "0x" + Integer.toHexString(integer);
}
return super.format(integer, annotation);
}
/**
* Gets the height of the HTML content.
*
* @return the height of the HTML content
*/
@ViewDebug.ExportedProperty(category = "webview")
public int getContentHeight() {
checkThread();
return mProvider.getContentHeight();
}
public ViewCSSProperty(String cssName, @Nullable ViewDebug.ExportedProperty annotation) {
mCSSName = cssName;
mAnnotation = annotation;
}
@ViewDebug.ExportedProperty(category = "drawing")
public int getCacheColorHint() {
return mCacheColorHint;
}
@ViewDebug.ExportedProperty
public boolean isSmoothScrollbarEnabled() {
return mSmoothScrollbarEnabled;
}
@Override
@ViewDebug.ExportedProperty
public boolean isChecked() {
return this.mChecked;
}
@ViewDebug.ExportedProperty
public boolean isScrollingCacheEnabled() {
return mScrollingCacheEnabled;
}
/**
* Gets the URL for the current page. This is not always the same as the URL
* passed to WebViewClient.onPageStarted because although the load for
* that URL has begun, the current page may not have changed.
*
* @return the URL for the current page
*/
@ViewDebug.ExportedProperty(category = "webview")
public String getUrl() {
checkThread();
return mProvider.getUrl();
}
/**
* Indicates whether the children's drawing cache is used during a scroll.
* By default, the drawing cache is enabled but this will consume more memory.
*
* @return true if the scrolling cache is enabled, false otherwise
*
* @see #setScrollingCacheEnabled(boolean)
* @see View#setDrawingCacheEnabled(boolean)
*/
@ViewDebug.ExportedProperty
public boolean isScrollingCacheEnabled() {
return mScrollingCacheEnabled;
}
/**
* <p>Return the upper limit of this progress bar's range.</p>
*
* @return a positive integer
*
* @see #setMax(int)
* @see #getProgress()
* @see #getSecondaryProgress()
*/
@ViewDebug.ExportedProperty(category = "progress")
public synchronized int getMax() {
return mMax;
}
/**
* @return True to recycle the views used to measure this ListView in
* UNSPECIFIED/AT_MOST modes, false otherwise.
* @hide
*/
@ViewDebug.ExportedProperty(category = "list")
protected boolean recycleOnMeasure() {
return true;
}
/**
* <p>Get the progress bar's current level of progress. Return 0 when the
* progress bar is in indeterminate mode.</p>
*
* @return the current progress, between 0 and {@link #getMax()}
*
* @see #setIndeterminate(boolean)
* @see #isIndeterminate()
* @see #setProgress(int)
* @see #setMax(int)
* @see #getMax()
*/
@ViewDebug.ExportedProperty(category = "progress")
public synchronized int getProgress() {
return mIndeterminate ? 0 : mProgress;
}
/**
* @return True to recycle the views used to measure this ListView in
* UNSPECIFIED/AT_MOST modes, false otherwise.
* @hide
*/
@ViewDebug.ExportedProperty(category = "list")
protected boolean recycleOnMeasure() {
return true;
}
/**
* <p>Get the progress bar's current level of secondary progress. Return 0 when the
* progress bar is in indeterminate mode.</p>
*
* @return the current secondary progress, between 0 and {@link #getMax()}
*
* @see #setIndeterminate(boolean)
* @see #isIndeterminate()
* @see #setSecondaryProgress(int)
* @see #setMax(int)
* @see #getMax()
*/
@ViewDebug.ExportedProperty(category = "progress")
public synchronized int getSecondaryProgress() {
return mIndeterminate ? 0 : mSecondaryProgress;
}
/**
* Returns the current state of the fast scroll feature.
*
* @return True if smooth scrollbar is enabled is enabled, false otherwise.
*
* @see #setSmoothScrollbarEnabled(boolean)
*/
@ViewDebug.ExportedProperty
public boolean isSmoothScrollbarEnabled() {
return mSmoothScrollbarEnabled;
}