The Android Arsenal – Resources


ResOf is an Android resource wrapper library.

To install

project / build.gradle

allprojects { repositories { ... maven { url 'https://jitpack.io' } }
}

app / build.gradle

dependencies { implementation 'com.github.dev-weiqi:ResOf:$latestVersion'
}

use

Just use it! You do not have to carry out any initialization!

xml

<resources> <string name="app_name">ResOf</string>
</resources>
  1. function
val appName = stringOf(R.string.app_name)Log.v(TAG,"AppName: $appName !")--------------------V/TAG: AppName: ResOf !
  1. extension
val appName = R.string.app_name.asString()Log.v(TAG,"AppName: $appName !")--------------------V/TAG: AppName: ResOf !

Supported resources

Resource typeAAPT classfunctionKotlin extensionReturn type
animationR.animanimOfasAnimanimation
Boolean valueR.boolboolOfasBoolBoolean value
colourR.colorcolorIntOfasColorIntInt
ColorStateListR.colorcolorStateListOfasColorStateListColorStateList
DimensionsR.dimendimenOfasDimenHover
DimenR.dimendimenOffsetOfasFimenOffsetInt
DimenR.dimendimenSizeOfasDimenSizeInt
DrawableR.drawabledrawableOfasDrawableDrawable
fontR.fontfontOfasFontfont
fractionR. fractiona fraction ofasFractionHover
IntArrayR.arrayintArrayOfasIntArrayIntArray
IntegerR.integerintegerOfasIntegerInt
InterpolatorR.interpolatorinterpolatorOfasInterpolatorInterpolator
layoutR.layoutLayout ofasLayoutXmlResourceParser
Plural formsR. pluralspluralsOfasPluralsString
RawR.rawrawOfasRawInput current
StringR.stringstringOfasStringString
StringArrayR.arraystringArrayOfasStringArrayArray
TypedArrayR.arraytypedArrayOfasTypedArrayTypedArray
XmlR.xmlxmlOfasXmlXmlResourceParser

Contribution

Contributions are always welcome. If you have any ideas or suggestions, you can create a Github problem. I will get back to you as soon as possible.

License

Copyright 2020 Wei-Qi Wang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox