Android Open Source - Android_ApplicationTemplate Font Manager

From Project

Back to project page Android_ApplicationTemplate.


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.widget.TextView;

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));
    case CONTENT:
      typeface = Typeface.createFromAsset(context.getAssets(), context.getString(R.string.font_content));
    } //check font type to set 
    if (typeface != null && text != null)
    } catch (Exception e) {
      LogManager.getIns().e("BQ", "Error Loading Font" + e.toString());
  } //method: set text font

Java Source Code List