package com.ikea.kompis.user;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.zxing.BarcodeFormat;
import com.ikea.kompis.util.UiUtil;
import com.ikea.shared.AppConfigData;
import com.ikea.shared.AppConfigManager;
import com.ikea.shared.user.model.ContactMethodList;
import com.ikea.shared.user.model.Customer;
import com.ikea.shared.user.model.CustomerDetail;
import com.ikea.shared.user.model.User;
import com.ikea.shared.user.service.UserService;
import com.ikea.shared.util.ZxingBarcodeManager;

public class IkeaFamilyViewFragment extends Fragment
{
  public static final String FROM_FAMILY = "FROM_FAMILY";
  private int mBarcodeImageHeight;
  private int mBarcodeImageWidth;
  private User mUser;

  private String getFormatedFamily(String paramString)
  {
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    int i = paramString.length() / 4;
    for (int j = 6; j < i + paramString.length(); j += 5)
      localStringBuilder.insert(j, " ");
    return localStringBuilder.toString();
  }

  private String[] getNamePresentationOrder()
  {
    String[] arrayOfString = new String[0];
    if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getNamePresentationString() != null) && (!AppConfigManager.i(getActivity()).getAppConfigData().getNamePresentationString().isEmpty()))
      arrayOfString = AppConfigManager.i(getActivity()).getAppConfigData().getNamePresentationString().split(",");
    return arrayOfString;
  }

  private String getUserName(String[] paramArrayOfString)
  {
    StringBuffer localStringBuffer = new StringBuffer("");
    if ((this.mUser != null) && (this.mUser.getCustomer() != null) && (this.mUser.getCustomer().getCustomerDetail() != null) && (this.mUser.getCustomer().getCustomerDetail().getContactMethodList() != null))
    {
      int i = 0;
      if (i < paramArrayOfString.length)
      {
        if (paramArrayOfString[i].equalsIgnoreCase("TI"))
          if ((this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getNamePrefix() != null) && (!this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getNamePrefix().isEmpty()))
            localStringBuffer.append(this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getNamePrefix() + " ");
        while (true)
        {
          i++;
          break;
          if (paramArrayOfString[i].equalsIgnoreCase("FN"))
          {
            if ((this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getFirstName() != null) && (!this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getFirstName().isEmpty()))
              localStringBuffer.append(this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getFirstName() + " ");
          }
          else if ((paramArrayOfString[i].equalsIgnoreCase("LN")) && (this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getLastName() != null) && (!this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getLastName().isEmpty()))
            localStringBuffer.append(this.mUser.getCustomer().getCustomerDetail().getContactMethodList().getLastName() + " ");
        }
      }
    }
    return localStringBuffer.toString();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.mUser = UserService.i(getActivity()).getUser();
    if (UiUtil.isTablet(getActivity()))
    {
      this.mBarcodeImageWidth = ((int)getResources().getDimension(2131361986));
      this.mBarcodeImageHeight = ((int)getResources().getDimension(2131361985));
      return;
    }
    this.mBarcodeImageWidth = ((int)getResources().getDimension(2131361808));
    this.mBarcodeImageHeight = ((int)getResources().getDimension(2131361809));
  }

  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    View localView = paramLayoutInflater.inflate(2130903095, paramViewGroup, false);
    ImageView localImageView = (ImageView)localView.findViewById(2131624169);
    TextView localTextView1 = (TextView)localView.findViewById(2131624170);
    TextView localTextView2 = (TextView)localView.findViewById(2131624171);
    String[] arrayOfString = getNamePresentationOrder();
    if ((arrayOfString != null) && (arrayOfString.length > 0))
    {
      String str2 = getUserName(arrayOfString);
      if ((str2 != null) && (!str2.isEmpty()))
      {
        localTextView1.setVisibility(0);
        localTextView1.setText(str2);
      }
    }
    String str1;
    Bitmap localBitmap1;
    Matrix localMatrix;
    if (((this.mUser.getIkeaFamilyNumber() != null) && (!this.mUser.getIkeaFamilyNumber().isEmpty())) || ((this.mUser.getLocalIkeaFamilyNumber() != null) && (!this.mUser.getLocalIkeaFamilyNumber().isEmpty())))
    {
      str1 = "";
      if ((this.mUser.getIkeaFamilyNumber() == null) || (this.mUser.getIkeaFamilyNumber().isEmpty()))
        break label273;
      str1 = this.mUser.getIkeaFamilyNumber();
      localBitmap1 = ZxingBarcodeManager.createBarcode(str1, BarcodeFormat.CODE_39, this.mBarcodeImageWidth, this.mBarcodeImageHeight, true);
      if (UiUtil.isTablet(getActivity()))
        break label308;
      localMatrix = new Matrix();
      localMatrix.postRotate(90.0F);
    }
    label273: label308: for (Bitmap localBitmap2 = Bitmap.createBitmap(localBitmap1, 0, 0, localBitmap1.getWidth(), localBitmap1.getHeight(), localMatrix, true); ; localBitmap2 = localBitmap1)
    {
      if (localBitmap2 != null)
        localImageView.setImageBitmap(localBitmap2);
      localTextView2.setText(getFormatedFamily(str1));
      return localView;
      if ((this.mUser.getLocalIkeaFamilyNumber() == null) || (this.mUser.getLocalIkeaFamilyNumber().isEmpty()))
        break;
      str1 = this.mUser.getLocalIkeaFamilyNumber();
      break;
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.user.IkeaFamilyViewFragment
 * JD-Core Version:    0.6.2
 */