public class FontHelper {
private static final String TAG = FontHelper.class. getSimpleName();
public static void applyFont(final Context context, final View root, final String fontPath)
{
try {
if (root instanceof ViewGroup)
{
ViewGroup viewGroup = (ViewGroup) root;
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++)
applyFont(context, viewGroup.getChildAt(i), fontPath);
}
else if (root instanceof TextView)
((TextView) root).setTypeface(Typeface.cre ateFromAsset(context. getAssets(), fontPath));
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void applyFontWithLang(final Context context, final View root) {
String _fontPath = "abc.ttf";
try {
String mLanguage = "" + SessionSave.getSession("Lang", context);
String nLang = "" + SessionSave.getSession("LANG_N", context);
if (mLanguage.equalsIgnoreCase(" en")) { // English _fontPath = "english.ttf";
} else {
if (nLang.equalsIgnoreCase( "langChange")) / _fontPath = "def.ttf";
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (root instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) root;
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++)
applyFontWithLang(context, viewGroup.getChildAt(i));
} else if (root instanceof TextView)
((TextView) root).setTypeface(Typeface.cre ateFromAsset(context. getAssets(), _fontPath));
} catch (Exception e) {
e.printStackTrace();
}
}
}
private static final String TAG = FontHelper.class.
public static void applyFont(final Context context, final View root, final String fontPath)
{
try {
if (root instanceof ViewGroup)
{
ViewGroup viewGroup = (ViewGroup) root;
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++)
applyFont(context, viewGroup.getChildAt(i), fontPath);
}
else if (root instanceof TextView)
((TextView) root).setTypeface(Typeface.cre
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void applyFontWithLang(final Context context, final View root) {
String _fontPath = "abc.ttf";
try {
String mLanguage = "" + SessionSave.getSession("Lang", context);
String nLang = "" + SessionSave.getSession("LANG_N", context);
if (mLanguage.equalsIgnoreCase("
} else {
if (nLang.equalsIgnoreCase(
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (root instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) root;
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++)
applyFontWithLang(context, viewGroup.getChildAt(i));
} else if (root instanceof TextView)
((TextView) root).setTypeface(Typeface.cre
} catch (Exception e) {
e.printStackTrace();
}
}
}
Comments
Post a Comment