I have about 10-15 Activity or Fragment in my application. I have about 5 different types that I use (mostly Roboto options).
In almost every class I have to do this:
roboto_light = Typeface.createFromAsset(getActivity().getAssets(), "fonts/roboto_light.ttf"); roboto_thin = Typeface.createFromAsset(getActivity().getAssets(), "fonts/roboto_thin.ttf"); roboto_regular = Typeface.createFromAsset(getActivity().getAssets(), "fonts/roboto_regular.ttf");
Not all classes use all five. Some use 1, some use 4, some use 3, while others may use a different combination of 3.
Declaring this code in every class seems redundant. Is it possible to declare 5 fonts once, maybe when the application starts, and then I use the helper class to use them statically?
I'm not sure if I should do this - if at all possible - in a class extending the application, or just in a regular class that I can statically call? And where will it be initialized?
source share