package com.ikea.kompis.view;

import android.app.Activity;
import android.app.Dialog;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.ikea.kompis.util.UiUtil;

public class CustomInformationPopUp extends DialogFragment
{
  private static final String KEY_DESC = "KEY_DESC";
  private static final String KEY_IMAGE_TYPE = "KEY_IMAGE_TYPE";
  private static final String KEY_LINK = "KEY_LINK";
  private static final String KEY_LINK_TITLE = "KEY_LINK_TITLE";
  private static final String KEY_PRIMARY_BUTTON = "KEY_PRIMARY_BUTTON";
  private static final String KEY_SECONDERY_BUTTON = "KEY_SECONDERY_BUTTON";
  private static final String KEY_TITLE = "KEY_TITLE";
  private int imageHeight;
  private int imageWidth;
  private boolean isTablet;
  private LinearLayout linLayout;
  private TextView mDescription;
  private float mDeviceWidth;
  private ImageView mIcon;
  private CustomPopUpClickListener mIkeaClickListener;
  private String mImageType = "";
  private TextView mLink;
  private TextView mLinkSubTitle;
  private String mLinkSubTitleText = "";
  private String mLinkTitle = "";
  private final View.OnClickListener mOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
        return;
      case 2131624163:
        if (CustomInformationPopUp.this.mIkeaClickListener != null)
          CustomInformationPopUp.this.mIkeaClickListener.onPrimaryBtnClick();
        CustomInformationPopUp.this.dismiss();
        return;
      case 2131624164:
      }
      if (CustomInformationPopUp.this.mIkeaClickListener != null)
        CustomInformationPopUp.this.mIkeaClickListener.onSecondaryBtnClick();
      CustomInformationPopUp.this.dismiss();
    }
  };
  private String mPopUpDesc = "";
  private String mPopUpTitle = "";
  private Button mPrimaryButton;
  private String mPrimaryButtonTitle = "";
  private String mSecondaryButtonTitle = "";
  private Button mSecondryButton;
  private TextView mTitle;
  private int popupWidth;
  private float widthMargin = 40.0F;

  public static CustomInformationPopUp newInstance(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6, String paramString7)
  {
    CustomInformationPopUp localCustomInformationPopUp = new CustomInformationPopUp();
    localCustomInformationPopUp.setStyle(0, 2131558449);
    Bundle localBundle = new Bundle();
    localBundle.putString("KEY_PRIMARY_BUTTON", paramString1);
    localBundle.putString("KEY_SECONDERY_BUTTON", paramString2);
    localBundle.putString("KEY_TITLE", paramString3);
    localBundle.putString("KEY_DESC", paramString6);
    localBundle.putString("KEY_IMAGE_TYPE", paramString4);
    localBundle.putString("KEY_LINK", paramString5);
    localBundle.putString("KEY_LINK_TITLE", paramString7);
    localCustomInformationPopUp.setArguments(localBundle);
    return localCustomInformationPopUp;
  }

  public void dismiss()
  {
    getDialog().dismiss();
  }

  public boolean isShowing()
  {
    if (getDialog() != null)
      return getDialog().isShowing();
    return false;
  }

  public void onAttach(Activity paramActivity)
  {
    super.onAttach(paramActivity);
    Bundle localBundle = getArguments();
    if (localBundle != null)
    {
      if (localBundle.containsKey("KEY_PRIMARY_BUTTON"))
        this.mPrimaryButtonTitle = localBundle.getString("KEY_PRIMARY_BUTTON");
      if (localBundle.containsKey("KEY_SECONDERY_BUTTON"))
        this.mSecondaryButtonTitle = localBundle.getString("KEY_SECONDERY_BUTTON");
      if (localBundle.containsKey("KEY_TITLE"))
        this.mPopUpTitle = localBundle.getString("KEY_TITLE");
      if (localBundle.containsKey("KEY_DESC"))
        this.mPopUpDesc = localBundle.getString("KEY_DESC");
      if (localBundle.containsKey("KEY_LINK"))
        this.mLinkTitle = localBundle.getString("KEY_LINK");
      if (localBundle.containsKey("KEY_LINK_TITLE"))
        this.mLinkSubTitleText = localBundle.getString("KEY_LINK");
      if (localBundle.containsKey("KEY_IMAGE_TYPE"))
        this.mImageType = localBundle.getString("KEY_IMAGE_TYPE");
      if (localBundle.containsKey("KEY_LINK_TITLE"))
        this.mLinkSubTitleText = localBundle.getString("KEY_LINK_TITLE");
    }
  }

  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    View localView = paramLayoutInflater.inflate(2130903093, paramViewGroup, false);
    getDialog().getWindow().requestFeature(1);
    this.mTitle = ((TextView)localView.findViewById(2131624160));
    this.mDescription = ((TextView)localView.findViewById(2131624162));
    this.mPrimaryButton = ((Button)localView.findViewById(2131624163));
    this.mSecondryButton = ((Button)localView.findViewById(2131624164));
    this.mIcon = ((ImageView)localView.findViewById(2131624161));
    this.mLinkSubTitle = ((TextView)localView.findViewById(2131624165));
    this.mLink = ((TextView)localView.findViewById(2131624166));
    this.linLayout = ((LinearLayout)localView.findViewById(2131624159));
    this.isTablet = UiUtil.isTablet(getActivity());
    if (!this.isTablet)
    {
      this.mDeviceWidth = UiUtil.screenWidth(getActivity());
      this.popupWidth = ((int)(Math.round(this.mDeviceWidth) - UiUtil.pxFromDp(getActivity().getBaseContext(), this.widthMargin)));
      FrameLayout.LayoutParams localLayoutParams1 = new FrameLayout.LayoutParams(this.popupWidth, -2);
      this.linLayout.setLayoutParams(localLayoutParams1);
    }
    this.mPrimaryButton.setOnClickListener(this.mOnClickListener);
    this.mSecondryButton.setOnClickListener(this.mOnClickListener);
    this.mPrimaryButton.setText(this.mPrimaryButtonTitle);
    this.mSecondryButton.setText(this.mSecondaryButtonTitle);
    this.mTitle.setText(this.mPopUpTitle);
    this.mDescription.setText(this.mPopUpDesc);
    this.mLinkSubTitle.setText(this.mLinkSubTitleText);
    if (!TextUtils.isEmpty(this.mLinkTitle))
    {
      this.mLink.setText(Html.fromHtml(this.mLinkTitle));
      this.mLink.setMovementMethod(LinkMovementMethod.getInstance());
    }
    TextView localTextView1 = this.mTitle;
    int i;
    int j;
    label371: int k;
    label397: int m;
    label423: int n;
    label449: TextView localTextView4;
    int i2;
    if (this.mPopUpTitle.length() > 0)
    {
      i = 0;
      localTextView1.setVisibility(i);
      TextView localTextView2 = this.mDescription;
      if (this.mPopUpDesc.length() <= 0)
        break label529;
      j = 0;
      localTextView2.setVisibility(j);
      Button localButton1 = this.mPrimaryButton;
      if (this.mPrimaryButtonTitle.length() <= 0)
        break label536;
      k = 0;
      localButton1.setVisibility(k);
      Button localButton2 = this.mSecondryButton;
      if (this.mSecondaryButtonTitle.length() <= 0)
        break label543;
      m = 0;
      localButton2.setVisibility(m);
      TextView localTextView3 = this.mLinkSubTitle;
      if (this.mLinkSubTitleText.length() <= 0)
        break label550;
      n = 0;
      localTextView3.setVisibility(n);
      localTextView4 = this.mLink;
      int i1 = this.mLinkTitle.length();
      i2 = 0;
      if (i1 <= 0)
        break label557;
    }
    while (true)
    {
      localTextView4.setVisibility(i2);
      if (TextUtils.isEmpty(this.mImageType))
        break label776;
      if (!this.mImageType.equals("1"))
        break label564;
      this.mIcon.setBackgroundResource(2130837715);
      return localView;
      i = 8;
      break;
      label529: j = 8;
      break label371;
      label536: k = 8;
      break label397;
      label543: m = 8;
      break label423;
      label550: n = 8;
      break label449;
      label557: i2 = 8;
    }
    label564: if (this.mImageType.equals("2"))
    {
      this.mIcon.setBackgroundResource(2130837734);
      return localView;
    }
    if (this.mImageType.equals("3"))
    {
      this.mIcon.setBackgroundResource(2130837736);
      return localView;
    }
    if (this.mImageType.equals("4"))
    {
      if (!this.isTablet)
      {
        setImageHeightAndWidth(2130837809);
        float f = UiUtil.getAspectRatio(this.imageWidth, this.imageHeight);
        if (this.imageWidth >= this.popupWidth)
        {
          this.imageWidth = this.popupWidth;
          this.imageWidth = ((int)(this.imageWidth - UiUtil.pxFromDp(getActivity().getBaseContext(), this.widthMargin)));
        }
        LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(this.imageWidth, (int)(this.imageWidth / f));
        localLayoutParams.bottomMargin = ((int)UiUtil.pxFromDp(getActivity().getBaseContext(), 20.0F));
        this.mIcon.setLayoutParams(localLayoutParams);
      }
      this.mIcon.setBackgroundResource(2130837809);
      return localView;
    }
    this.mIcon.setBackgroundResource(2130837715);
    return localView;
    label776: this.mIcon.setVisibility(8);
    return localView;
  }

  public void setDescription(String paramString)
  {
    this.mDescription.setText(paramString);
    TextView localTextView = this.mDescription;
    if (paramString.length() > 0);
    for (int i = 0; ; i = 8)
    {
      localTextView.setVisibility(i);
      return;
    }
  }

  public void setIconImage(int paramInt)
  {
    this.mIcon.setImageResource(paramInt);
    this.mIcon.setVisibility(0);
  }

  public void setImageHeightAndWidth(int paramInt)
  {
    Drawable localDrawable = getResources().getDrawable(paramInt);
    this.imageHeight = localDrawable.getIntrinsicHeight();
    this.imageWidth = localDrawable.getIntrinsicWidth();
  }

  public void setLink(String paramString)
  {
    this.mLink.setText(paramString);
    TextView localTextView = this.mLink;
    if (paramString.length() > 0);
    for (int i = 0; ; i = 8)
    {
      localTextView.setVisibility(i);
      return;
    }
  }

  public void setListener(CustomPopUpClickListener paramCustomPopUpClickListener)
  {
    this.mIkeaClickListener = paramCustomPopUpClickListener;
  }

  public void setPrimaryBtn(String paramString)
  {
    this.mPrimaryButton.setText(paramString);
    Button localButton = this.mPrimaryButton;
    if (paramString.length() > 0);
    for (int i = 0; ; i = 8)
    {
      localButton.setVisibility(i);
      return;
    }
  }

  public void setSecondaryBtn(String paramString)
  {
    this.mSecondryButton.setText(paramString);
    Button localButton = this.mSecondryButton;
    if (paramString.length() > 0);
    for (int i = 0; ; i = 8)
    {
      localButton.setVisibility(i);
      return;
    }
  }

  public void setTitle(String paramString)
  {
    this.mTitle.setText(paramString);
    TextView localTextView = this.mTitle;
    if (paramString.length() > 0);
    for (int i = 0; ; i = 8)
    {
      localTextView.setVisibility(i);
      return;
    }
  }

  public void showPopup(FragmentManager paramFragmentManager, String paramString)
  {
    show(paramFragmentManager, paramString);
  }

  public void showPopup(FragmentManager paramFragmentManager, String paramString, CustomPopUpClickListener paramCustomPopUpClickListener)
  {
    this.mIkeaClickListener = paramCustomPopUpClickListener;
    show(paramFragmentManager, paramString);
  }

  public static abstract interface CustomPopUpClickListener
  {
    public abstract boolean onBackKeyPressed();

    public abstract void onCancel();

    public abstract void onPrimaryBtnClick();

    public abstract void onSecondaryBtnClick();
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.view.CustomInformationPopUp
 * JD-Core Version:    0.6.2
 */