Created
October 14, 2019 05:02
-
-
Save saurabhthorat/dcf935502aa97abc2c318db0857b5930 to your computer and use it in GitHub Desktop.
This file contains 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.Context | |
import android.graphics.drawable.Drawable | |
import androidx.annotation.ColorRes | |
import androidx.annotation.DrawableRes | |
import androidx.annotation.IntegerRes | |
import androidx.annotation.StringRes | |
import androidx.core.content.ContextCompat | |
class ResourceProvider(val context: Context) { | |
inline fun getText(@StringRes resId: Int): CharSequence = context.getText(resId) | |
inline fun getString(@StringRes resId: Int): String = context.getString(resId) | |
inline fun getInteger(@IntegerRes resId: Int) = context.resources.getInteger(resId) | |
inline fun getDrawable(@DrawableRes resId: Int): Drawable? = ContextCompat.getDrawable(context, resId) | |
inline fun getColor(@ColorRes resId: Int) = ContextCompat.getColor(context, resId) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment