package com.ikea.kompis;

import android.content.Context;
import android.content.res.TypedArray;
import android.inputmethodservice.ExtractEditText;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater.Factory2;
import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.Chronometer;
import android.widget.EditText;
import android.widget.MultiAutoCompleteTextView;
import android.widget.RadioButton;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.ikea.kompis.util.UiUtil;
import com.ikea.kompis.view.CustomEditText;
import com.ikea.kompis.view.TitleView;
import com.ikea.shared.AppConfigData;
import com.ikea.shared.AppConfigManager;
import java.util.HashMap;
import java.util.Map;

public class FontHelper
  implements LayoutInflater.Factory2
{
  public static final String ATTRIB_TTF = "ttf";
  public static final String FONT_BOLD = "_bold";
  public static final String FONT_BOLD_ITALIC = "_bold_italic";
  public static final String FONT_ITALIC = "_italic";
  public static final String FONT_NORMAL = "";
  private static FontHelper sInstance = new FontHelper();
  private static Map<String, TextViewCreator> sTextViewAndSons = new HashMap();

  static
  {
    sTextViewAndSons.put("TextView", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new TextView(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("Button", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new Button(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("CheckedTextView", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new CheckedTextView(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("Chronometer", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new Chronometer(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("EditText", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new EditText(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("com.ikea.kompis.view.CustomEditText", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new CustomEditText(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("AutoCompleteTextView", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new AutoCompleteTextView(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("CheckBox", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new CheckBox(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("MultiAutoCompleteTextView", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new MultiAutoCompleteTextView(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("RadioButton", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new RadioButton(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("Switch", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new Switch(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("ToggleButton", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new ToggleButton(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("android.inputmethodservice.ExtractEditText", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new ExtractEditText(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
    sTextViewAndSons.put("com.ikea.kompis.view.TitleView", new TextViewCreator()
    {
      public TextView create(Context paramAnonymousContext, AttributeSet paramAnonymousAttributeSet)
      {
        return new TitleView(paramAnonymousContext, paramAnonymousAttributeSet);
      }
    });
  }

  private String getFontStyle(String paramString)
  {
    String str = "";
    if (paramString.contains("_bold_italic"))
      str = "_bold_italic";
    do
    {
      return str;
      if (paramString.contains("_italic"))
        return "_italic";
    }
    while (!paramString.contains("_bold"));
    return "_bold";
  }

  public static FontHelper i()
  {
    return sInstance;
  }

  public View onCreateView(View paramView, String paramString, Context paramContext, AttributeSet paramAttributeSet)
  {
    return onCreateView(paramString, paramContext, paramAttributeSet);
  }

  public View onCreateView(String paramString, Context paramContext, AttributeSet paramAttributeSet)
  {
    TextViewCreator localTextViewCreator = (TextViewCreator)sTextViewAndSons.get(paramString);
    if (localTextViewCreator != null)
    {
      TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.FontHelper);
      String str1 = localTypedArray.getString(0);
      localTypedArray.recycle();
      if (!TextUtils.isEmpty(str1))
      {
        if ((AppConfigManager.i(paramContext) != null) && (AppConfigManager.i(paramContext).getAppConfigData() != null) && (AppConfigManager.i(paramContext).getAppConfigData().getFontName() != null))
        {
          String str2 = AppConfigManager.i(paramContext).getAppConfigData().getFontName().toLowerCase();
          if (UiUtil.isFontFileExits(str2))
            str1 = str2 + getFontStyle(str1);
        }
        TextView localTextView = localTextViewCreator.create(paramContext, paramAttributeSet);
        localTextView.setTypeface(TypeFaceProvider.getTypeFace(paramContext, str1));
        return localTextView;
      }
    }
    return null;
  }

  private static abstract interface TextViewCreator
  {
    public abstract TextView create(Context paramContext, AttributeSet paramAttributeSet);
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.FontHelper
 * JD-Core Version:    0.6.2
 */