Package com.transifex.txnative
Class TxResources
java.lang.Object
android.content.res.Resources
com.transifex.txnative.TxResources
Resources wrapper that enables TxNative functionality by overriding specific String related
methods.
We override some of the calls that return strings. The rest of the string methods, call
internally the ones we have overridden. The remaining methods are delegated to the
base Resources
object.
All resource method calls made programmatically by the user will reach here. String resources
used during the view inflation process will also be read from here, after having the process
intercepted by TxInterceptor
and having the view transformed by the respective
ViewTransformer
class.
-
Nested Class Summary
Nested classes/interfaces inherited from class android.content.res.Resources
Resources.NotFoundException, Resources.Theme
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTxResources
(Resources baseResources, NativeCore nativeCore) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptiongetAnimation
(int id) Returns theResources
object that is being wrapped.boolean
getBoolean
(int id) int
getColor
(int id) int
getColor
(int id, Resources.Theme theme) getColorStateList
(int id) getColorStateList
(int id, Resources.Theme theme) float
getDimension
(int id) int
getDimensionPixelOffset
(int id) int
getDimensionPixelSize
(int id) getDrawable
(int id) getDrawable
(int id, Resources.Theme theme) getDrawableForDensity
(int id, int density) getDrawableForDensity
(int id, int density, Resources.Theme theme) float
getFloat
(int id) getFont
(int id) float
getFraction
(int id, int base, int pbase) int
getIdentifier
(String name, String defType, String defPackage) int[]
getIntArray
(int id) int
getInteger
(int id) getLayout
(int id) getMovie
(int id) getQuantityText
(int id, int quantity) getResourceEntryName
(int resid) getResourceName
(int resid) getResourcePackageName
(int resid) getResourceTypeName
(int resid) String[]
getStringArray
(int id) getText
(int id) getText
(int id, CharSequence def) getTextArray
(int id) void
getValue
(int id, TypedValue outValue, boolean resolveRefs) void
getValue
(String name, TypedValue outValue, boolean resolveRefs) void
getValueForDensity
(int id, int density, TypedValue outValue, boolean resolveRefs) getXml
(int id) obtainAttributes
(AttributeSet set, int[] attrs) obtainTypedArray
(int id) openRawResource
(int id) openRawResource
(int id, TypedValue value) openRawResourceFd
(int id) void
parseBundleExtra
(String tagName, AttributeSet attrs, Bundle outBundle) void
parseBundleExtras
(XmlResourceParser parser, Bundle outBundle) void
updateConfiguration
(Configuration config, DisplayMetrics metrics) Methods inherited from class android.content.res.Resources
addLoaders, finishPreloading, flushLayoutCache, getAssets, getAttributeSetSourceResId, getQuantityString, getQuantityString, getString, getString, getSystem, newTheme, removeLoaders
-
Constructor Details
-
TxResources
Creates a new instance.- Parameters:
baseResources
- TheResources
object to wrap.nativeCore
- ANativeCore
instance.
-
-
Method Details
-
getText
- Overrides:
getText
in classResources
- Throws:
Resources.NotFoundException
-
getText
-
getQuantityText
@NonNull public CharSequence getQuantityText(@StringRes int id, int quantity) throws Resources.NotFoundException - Overrides:
getQuantityText
in classResources
- Throws:
Resources.NotFoundException
-
getTextArray
- Overrides:
getTextArray
in classResources
- Throws:
Resources.NotFoundException
-
getStringArray
- Overrides:
getStringArray
in classResources
- Throws:
Resources.NotFoundException
-
getBaseResources
Returns theResources
object that is being wrapped.- Returns:
- The
Resources
object that is being wrapped.
-
getFont
- Overrides:
getFont
in classResources
- Throws:
Resources.NotFoundException
-
getIntArray
- Overrides:
getIntArray
in classResources
- Throws:
Resources.NotFoundException
-
obtainTypedArray
- Overrides:
obtainTypedArray
in classResources
- Throws:
Resources.NotFoundException
-
getDimension
- Overrides:
getDimension
in classResources
- Throws:
Resources.NotFoundException
-
getDimensionPixelOffset
- Overrides:
getDimensionPixelOffset
in classResources
- Throws:
Resources.NotFoundException
-
getDimensionPixelSize
- Overrides:
getDimensionPixelSize
in classResources
- Throws:
Resources.NotFoundException
-
getFraction
public float getFraction(int id, int base, int pbase) - Overrides:
getFraction
in classResources
-
getDrawable
- Overrides:
getDrawable
in classResources
- Throws:
Resources.NotFoundException
-
getDrawable
@RequiresApi(21) public Drawable getDrawable(int id, Resources.Theme theme) throws Resources.NotFoundException - Overrides:
getDrawable
in classResources
- Throws:
Resources.NotFoundException
-
getDrawableForDensity
@RequiresApi(15) public Drawable getDrawableForDensity(int id, int density) throws Resources.NotFoundException - Overrides:
getDrawableForDensity
in classResources
- Throws:
Resources.NotFoundException
-
getDrawableForDensity
- Overrides:
getDrawableForDensity
in classResources
-
getMovie
- Overrides:
getMovie
in classResources
- Throws:
Resources.NotFoundException
-
getColor
- Overrides:
getColor
in classResources
- Throws:
Resources.NotFoundException
-
getColor
@RequiresApi(api=23) public int getColor(int id, Resources.Theme theme) throws Resources.NotFoundException - Overrides:
getColor
in classResources
- Throws:
Resources.NotFoundException
-
getColorStateList
- Overrides:
getColorStateList
in classResources
- Throws:
Resources.NotFoundException
-
getColorStateList
@NonNull @RequiresApi(api=23) public ColorStateList getColorStateList(int id, Resources.Theme theme) - Overrides:
getColorStateList
in classResources
-
getBoolean
- Overrides:
getBoolean
in classResources
- Throws:
Resources.NotFoundException
-
getInteger
- Overrides:
getInteger
in classResources
- Throws:
Resources.NotFoundException
-
getFloat
-
getLayout
- Overrides:
getLayout
in classResources
- Throws:
Resources.NotFoundException
-
getAnimation
- Overrides:
getAnimation
in classResources
- Throws:
Resources.NotFoundException
-
getXml
- Overrides:
getXml
in classResources
- Throws:
Resources.NotFoundException
-
openRawResource
- Overrides:
openRawResource
in classResources
- Throws:
Resources.NotFoundException
-
openRawResource
@NonNull public InputStream openRawResource(int id, TypedValue value) throws Resources.NotFoundException - Overrides:
openRawResource
in classResources
- Throws:
Resources.NotFoundException
-
openRawResourceFd
- Overrides:
openRawResourceFd
in classResources
- Throws:
Resources.NotFoundException
-
getValue
public void getValue(int id, TypedValue outValue, boolean resolveRefs) throws Resources.NotFoundException - Overrides:
getValue
in classResources
- Throws:
Resources.NotFoundException
-
getValueForDensity
@RequiresApi(15) public void getValueForDensity(int id, int density, TypedValue outValue, boolean resolveRefs) throws Resources.NotFoundException - Overrides:
getValueForDensity
in classResources
- Throws:
Resources.NotFoundException
-
getValue
public void getValue(String name, TypedValue outValue, boolean resolveRefs) throws Resources.NotFoundException - Overrides:
getValue
in classResources
- Throws:
Resources.NotFoundException
-
obtainAttributes
- Overrides:
obtainAttributes
in classResources
-
updateConfiguration
- Overrides:
updateConfiguration
in classResources
-
getDisplayMetrics
- Overrides:
getDisplayMetrics
in classResources
-
getConfiguration
- Overrides:
getConfiguration
in classResources
-
getIdentifier
- Overrides:
getIdentifier
in classResources
-
getResourceName
- Overrides:
getResourceName
in classResources
- Throws:
Resources.NotFoundException
-
getResourcePackageName
- Overrides:
getResourcePackageName
in classResources
- Throws:
Resources.NotFoundException
-
getResourceTypeName
- Overrides:
getResourceTypeName
in classResources
- Throws:
Resources.NotFoundException
-
getResourceEntryName
- Overrides:
getResourceEntryName
in classResources
- Throws:
Resources.NotFoundException
-
parseBundleExtras
public void parseBundleExtras(XmlResourceParser parser, Bundle outBundle) throws XmlPullParserException, IOException - Overrides:
parseBundleExtras
in classResources
- Throws:
XmlPullParserException
IOException
-
parseBundleExtra
public void parseBundleExtra(String tagName, AttributeSet attrs, Bundle outBundle) throws XmlPullParserException - Overrides:
parseBundleExtra
in classResources
- Throws:
XmlPullParserException
-