Created
December 27, 2017 15:17
-
-
Save abhinav272/0218da1831e60da263d1dd27d1e6ed74 to your computer and use it in GitHub Desktop.
Util for accessing Android Resources in Presenter or Model (non-Android files)
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.content.res.Resources; | |
import android.graphics.drawable.Drawable; | |
import com.task.App; | |
import static android.os.Build.VERSION.SDK_INT; | |
import static android.os.Build.VERSION_CODES.LOLLIPOP; | |
public class ResourcesUtil { | |
private static Context context = App.getContext(); | |
private static Resources.Theme theme = App.getContext().getTheme(); | |
public static Drawable getDrawableById(int resId) { | |
return SDK_INT >= LOLLIPOP ? context.getResources().getDrawable(resId, theme) : | |
context.getResources().getDrawable(resId); | |
} | |
public static String getString(int resId) { | |
return SDK_INT >= LOLLIPOP ? context.getResources().getString(resId) : | |
context.getResources().getString(resId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment