Java Code Examples for android.content.pm.activityinfo#activityInfoConfigNativeToJava()
The following examples show how to use
android.content.pm.activityinfo#activityInfoConfigNativeToJava() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssetManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * Retrieves the string value associated with a particular resource * identifier for the current configuration. * * @param resId the resource identifier to load * @param bagEntryId * @return the string value, or {@code null} */ @Nullable final CharSequence getResourceBagText(@StringRes int resId, int bagEntryId) { synchronized (this) { final TypedValue outValue = mValue; final int block = loadResourceBagValue(resId, bagEntryId, outValue, true); if (block < 0) { return null; } // Convert the changing configurations flags populated by native code. outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( outValue.changingConfigurations); if (outValue.type == TypedValue.TYPE_STRING) { return mStringBlocks[block].get(outValue.data); } return outValue.coerceToString(); } }
Example 2
Source File: AssetManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * Populates {@code outValue} with the data associated a particular * resource identifier for the current configuration. * * @param resId the resource identifier to load * @param densityDpi the density bucket for which to load the resource * @param outValue the typed value in which to put the data * @param resolveRefs {@code true} to resolve references, {@code false} * to leave them unresolved * @return {@code true} if the data was loaded into {@code outValue}, * {@code false} otherwise */ final boolean getResourceValue(@AnyRes int resId, int densityDpi, @NonNull TypedValue outValue, boolean resolveRefs) { synchronized (this) { final int block = loadResourceValue(resId, (short) densityDpi, outValue, resolveRefs); if (block < 0) { return false; } // Convert the changing configurations flags populated by native code. outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( outValue.changingConfigurations); if (outValue.type == TypedValue.TYPE_STRING) { outValue.string = mStringBlocks[block].get(outValue.data); } return true; } }
Example 3
Source File: AssetManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * Populates {@code outValue} with the data associated with a particular * resource identifier for the current configuration. Resolves theme * attributes against the specified theme. * * @param theme the native pointer of the theme * @param resId the resource identifier to load * @param outValue the typed value in which to put the data * @param resolveRefs {@code true} to resolve references, {@code false} * to leave them unresolved * @return {@code true} if the data was loaded into {@code outValue}, * {@code false} otherwise */ final boolean getThemeValue(long theme, @AnyRes int resId, @NonNull TypedValue outValue, boolean resolveRefs) { final int block = loadThemeAttributeValue(theme, resId, outValue, resolveRefs); if (block < 0) { return false; } // Convert the changing configurations flags populated by native code. outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( outValue.changingConfigurations); if (outValue.type == TypedValue.TYPE_STRING) { final StringBlock[] blocks = ensureStringBlocks(); outValue.string = blocks[block].get(outValue.data); } return true; }
Example 4
Source File: TypedArray.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Return a mask of the configuration parameters for which the values in * this typed array may change. * * @return Returns a mask of the changing configuration parameters, as * defined by {@link android.content.pm.ActivityInfo}. * @throws RuntimeException if the TypedArray has already been recycled. * @see android.content.pm.ActivityInfo */ public @Config int getChangingConfigurations() { if (mRecycled) { throw new RuntimeException("Cannot make calls to a recycled instance!"); } @Config int changingConfig = 0; final int[] data = mData; final int N = length(); for (int i = 0; i < N; i++) { final int index = i * STYLE_NUM_ENTRIES; final int type = data[index + STYLE_TYPE]; if (type == TypedValue.TYPE_NULL) { continue; } changingConfig |= ActivityInfo.activityInfoConfigNativeToJava( data[index + STYLE_CHANGING_CONFIGURATIONS]); } return changingConfig; }
Example 5
Source File: TypedArray.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private boolean getValueAt(int index, TypedValue outValue) { final int[] data = mData; final int type = data[index + STYLE_TYPE]; if (type == TypedValue.TYPE_NULL) { return false; } outValue.type = type; outValue.data = data[index + STYLE_DATA]; outValue.assetCookie = data[index + STYLE_ASSET_COOKIE]; outValue.resourceId = data[index + STYLE_RESOURCE_ID]; outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( data[index + STYLE_CHANGING_CONFIGURATIONS]); outValue.density = data[index + STYLE_DENSITY]; outValue.string = (type == TypedValue.TYPE_STRING) ? loadStringValueAt(index) : null; return true; }
Example 6
Source File: AssetManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Populates {@code outValue} with the data associated a particular * resource identifier for the current configuration. * * @param resId the resource identifier to load * @param densityDpi the density bucket for which to load the resource * @param outValue the typed value in which to put the data * @param resolveRefs {@code true} to resolve references, {@code false} * to leave them unresolved * @return {@code true} if the data was loaded into {@code outValue}, * {@code false} otherwise */ boolean getResourceValue(@AnyRes int resId, int densityDpi, @NonNull TypedValue outValue, boolean resolveRefs) { Preconditions.checkNotNull(outValue, "outValue"); synchronized (this) { ensureValidLocked(); final int cookie = nativeGetResourceValue( mObject, resId, (short) densityDpi, outValue, resolveRefs); if (cookie <= 0) { return false; } // Convert the changing configurations flags populated by native code. outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( outValue.changingConfigurations); if (outValue.type == TypedValue.TYPE_STRING) { outValue.string = mApkAssets[cookie - 1].getStringFromPool(outValue.data); } return true; } }
Example 7
Source File: AssetManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Retrieves the string value associated with a particular resource * identifier for the current configuration. * * @param resId the resource identifier to load * @param bagEntryId the index into the bag to load * @return the string value, or {@code null} */ @Nullable CharSequence getResourceBagText(@StringRes int resId, int bagEntryId) { synchronized (this) { ensureValidLocked(); final TypedValue outValue = mValue; final int cookie = nativeGetResourceBagValue(mObject, resId, bagEntryId, outValue); if (cookie <= 0) { return null; } // Convert the changing configurations flags populated by native code. outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( outValue.changingConfigurations); if (outValue.type == TypedValue.TYPE_STRING) { return mApkAssets[cookie - 1].getStringFromPool(outValue.data); } return outValue.coerceToString(); } }
Example 8
Source File: AssetManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Populates {@code outValue} with the data associated with a particular * resource identifier for the current configuration. Resolves theme * attributes against the specified theme. * * @param theme the native pointer of the theme * @param resId the resource identifier to load * @param outValue the typed value in which to put the data * @param resolveRefs {@code true} to resolve references, {@code false} * to leave them unresolved * @return {@code true} if the data was loaded into {@code outValue}, * {@code false} otherwise */ boolean getThemeValue(long theme, @AnyRes int resId, @NonNull TypedValue outValue, boolean resolveRefs) { Preconditions.checkNotNull(outValue, "outValue"); synchronized (this) { ensureValidLocked(); final int cookie = nativeThemeGetAttributeValue(mObject, theme, resId, outValue, resolveRefs); if (cookie <= 0) { return false; } // Convert the changing configurations flags populated by native code. outValue.changingConfigurations = ActivityInfo.activityInfoConfigNativeToJava( outValue.changingConfigurations); if (outValue.type == TypedValue.TYPE_STRING) { outValue.string = mApkAssets[cookie - 1].getStringFromPool(outValue.data); } return true; } }
Example 9
Source File: TypedArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Retrieves the string value for the attribute at <var>index</var> that is * not allowed to change with the given configurations. * * @param index Index of attribute to retrieve. * @param allowedChangingConfigs Bit mask of configurations from * {@link Configuration}.NATIVE_CONFIG_* that are allowed to change. * * @return String holding string data. Any styling information is removed. * Returns {@code null} if the attribute is not defined. * @throws RuntimeException if the TypedArray has already been recycled. * @hide */ public String getNonConfigurationString(@StyleableRes int index, @Config int allowedChangingConfigs) { if (mRecycled) { throw new RuntimeException("Cannot make calls to a recycled instance!"); } index *= STYLE_NUM_ENTRIES; final int[] data = mData; final int type = data[index + STYLE_TYPE]; final @Config int changingConfigs = ActivityInfo.activityInfoConfigNativeToJava( data[index + STYLE_CHANGING_CONFIGURATIONS]); if ((changingConfigs & ~allowedChangingConfigs) != 0) { return null; } if (type == TypedValue.TYPE_NULL) { return null; } else if (type == TypedValue.TYPE_STRING) { return loadStringValueAt(index).toString(); } final TypedValue v = mValue; if (getValueAt(index, v)) { final CharSequence cs = v.coerceToString(); return cs != null ? cs.toString() : null; } // We already checked for TYPE_NULL. This should never happen. throw new RuntimeException("getNonConfigurationString of bad type: 0x" + Integer.toHexString(type)); }
Example 10
Source File: ResourcesImpl.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Config int getChangingConfigurations() { synchronized (mKey) { final @NativeConfig int nativeChangingConfig = AssetManager.nativeThemeGetChangingConfigurations(mTheme); return ActivityInfo.activityInfoConfigNativeToJava(nativeChangingConfig); } }