Created
December 6, 2020 01:25
-
-
Save kapodamy/7964b5b01b1d5011cd4ae4be03dce10a to your computer and use it in GitHub Desktop.
TypedArray.getChangingConfigurations() for kitkat (API 19) or older versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.res.TypedArray; | |
import android.util.TypedValue; | |
public final class TypedArrayCompat { | |
/** | |
* Return a mask of the configuration parameters for which the values in | |
* this typed array may change. | |
* Designed for API <21 | |
* | |
* @return Returns a mask of the changing configuration parameters, as | |
* defined by {@link android.content.pm.ActivityInfo}. | |
* @see android.content.pm.ActivityInfo | |
*/ | |
public static int getChangingConfigurations(TypedArray typedArray) { | |
int changingConfig = 0; | |
final int N = typedArray.length(); | |
for (int i = 0; i < N; i++) { | |
final TypedValue value = typedArray.peekValue(i); | |
if (value == null || value.type == TypedValue.TYPE_NULL) { | |
continue; | |
} | |
changingConfig |= value.changingConfigurations; | |
} | |
return changingConfig; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment