Android Open Source - Android_ApplicationTemplate Font Manager






From Project

Back to project page Android_ApplicationTemplate.

License

The source code is released under:

MIT License

If you think the Android project Android_ApplicationTemplate listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.iaraby.template.util;
//w w w . ja  v  a 2  s  . c om
import android.content.Context;
import android.graphics.Typeface;
import android.widget.TextView;

import com.company.appname.R;
import com.iaraby.utility.LogManager;

public class FontManager {
    
  //public static final int APP_TITLE = 0;
  public static final int TITLE = 1;
  public static final int CONTENT = 2;
  
  private static FontManager instance;
  private Context context;
  
  public static FontManager getInstance(Context context) {
    if (instance == null)
      instance = new FontManager(context);
    
    return instance;
  } //manage class instances
  
  public FontManager(Context context) {
    this.context = context;
  } //constructor
  
  public void setTextFont(TextView text, int key) {
    try {
    Typeface typeface = null;
    switch (key) {
    
    case TITLE:
      typeface = Typeface.createFromAsset(context.getAssets(), context.getString(R.string.font_title));
      break;
    case CONTENT:
      typeface = Typeface.createFromAsset(context.getAssets(), context.getString(R.string.font_content));
      break;
    default:
      break;
    } //check font type to set 
    
    if (typeface != null && text != null)
      text.setTypeface(typeface);
    } catch (Exception e) {
      LogManager.getIns().e("BQ", "Error Loading Font" + e.toString());
    }
  } //method: set text font
}




Java Source Code List

android.UnusedStub.java
com.iaraby.template.control.DetailsPagerAdapter.java
com.iaraby.template.control.DetailsTask.java
com.iaraby.template.control.FavGarbagCollector.java
com.iaraby.template.data.Beans.java
com.iaraby.template.data.Constants.java
com.iaraby.template.data.FavoriteManager.java
com.iaraby.template.data.MyDataAdapter.java
com.iaraby.template.data.Preferences.java
com.iaraby.template.util.DialogManager.java
com.iaraby.template.util.FontManager.java
com.iaraby.template.view.MainActivity.java
com.iaraby.template.view.Master_Activity.java
com.iaraby.template.view.fragment.DetailsFrag.java
com.iaraby.template.view.fragment.ListFrag.java
com.iaraby.template.view.fragment.MainFragment.java