package com.ikea.kompis.util;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.NumberPicker;
import android.widget.NumberPicker.OnValueChangeListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.ikea.shared.products.model.GPRUISelectionCriteriaValue;

public class CustomPicker
{
  private static final int MAX_QUANTITY = 99;
  private boolean mAddMode;
  private final AlertDialog mAlertDialog;
  private final Button mApplyButton;
  private final View mCrossIcon;
  private SelectionListener mListener;
  private final PickerModeEnum mMode;
  private final TextView mNumberPickerMetric;
  private final TextView mNumberPickerMetric2;
  private final View.OnClickListener mOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
      case 2131624310:
      case 2131624319:
      case 2131624314:
      }
      do
      {
        do
        {
          return;
          CustomPicker.this.dismissDialog();
          if ((CustomPicker.this.mListener != null) && (CustomPicker.this.mMode == CustomPicker.PickerModeEnum.NORMAL))
          {
            CustomPicker.this.mListener.onCancel();
            return;
          }
        }
        while ((CustomPicker.this.mSizeListener == null) || (CustomPicker.this.mMode != CustomPicker.PickerModeEnum.PRODUCT_SIZE));
        CustomPicker.this.mSizeListener.onCancel();
        return;
        if ((CustomPicker.this.mListener != null) && (CustomPicker.this.mMode == CustomPicker.PickerModeEnum.NORMAL))
          CustomPicker.this.mListener.onSelection(CustomPicker.this.mPicker1.getValue());
        while (true)
        {
          CustomPicker.this.dismissDialog();
          return;
          if ((CustomPicker.this.mSizeListener != null) && (CustomPicker.this.mMode == CustomPicker.PickerModeEnum.PRODUCT_SIZE))
            CustomPicker.this.mSizeListener.onProductSizeSelected(CustomPicker.this.mPicker1.getValue(), CustomPicker.this.mPicker2.getValue());
        }
        CustomPicker.this.dismissDialog();
        if ((CustomPicker.this.mListener != null) && (CustomPicker.this.mMode == CustomPicker.PickerModeEnum.NORMAL))
        {
          CustomPicker.this.mListener.onCancel();
          return;
        }
      }
      while ((CustomPicker.this.mSizeListener == null) || (CustomPicker.this.mMode != CustomPicker.PickerModeEnum.PRODUCT_SIZE));
      CustomPicker.this.mSizeListener.onCancel();
    }
  };
  private final NumberPicker.OnValueChangeListener mOnValueChangeListener = new NumberPicker.OnValueChangeListener()
  {
    public void onValueChange(NumberPicker paramAnonymousNumberPicker, int paramAnonymousInt1, int paramAnonymousInt2)
    {
      if (CustomPicker.this.mApplyButton != null)
      {
        if ((CustomPicker.this.mOptionGpr != null) && (CustomPicker.this.mOptionGpr[paramAnonymousInt2] != null) && (!CustomPicker.this.mOptionGpr[paramAnonymousInt2].isSupported()))
          CustomPicker.this.mApplyButton.setEnabled(false);
      }
      else
        return;
      CustomPicker.this.mApplyButton.setEnabled(true);
    }
  };
  private GPRUISelectionCriteriaValue[] mOptionGpr;
  private final NumberPicker mPicker1;
  private final NumberPicker mPicker2;
  private ProductSizeSelectionListener mSizeListener;
  private final TextView mSubTitle;
  private final TextView mTitle;

  @SuppressLint({"InflateParams"})
  public CustomPicker(Context paramContext, PickerModeEnum paramPickerModeEnum, boolean paramBoolean)
  {
    this.mMode = paramPickerModeEnum;
    View localView = LayoutInflater.from(paramContext).inflate(2130903125, null, false);
    this.mPicker1 = ((NumberPicker)localView.findViewById(2131624315));
    this.mNumberPickerMetric = ((TextView)localView.findViewById(2131624316));
    this.mPicker2 = ((NumberPicker)localView.findViewById(2131624317));
    this.mNumberPickerMetric2 = ((TextView)localView.findViewById(2131624318));
    this.mPicker1.setOnValueChangedListener(this.mOnValueChangeListener);
    this.mPicker2.setOnValueChangedListener(this.mOnValueChangeListener);
    LinearLayout localLinearLayout = (LinearLayout)localView.findViewById(2131624312);
    RelativeLayout localRelativeLayout = (RelativeLayout)localView.findViewById(2131624308);
    if (paramBoolean)
    {
      this.mTitle = ((TextView)localView.findViewById(2131624313));
      this.mCrossIcon = localView.findViewById(2131624314);
      localLinearLayout.setVisibility(0);
      localRelativeLayout.setVisibility(8);
    }
    while (true)
    {
      this.mSubTitle = ((TextView)localView.findViewById(2131624311));
      this.mCrossIcon.setOnClickListener(this.mOnClickListener);
      this.mApplyButton = ((Button)localView.findViewById(2131624319));
      this.mApplyButton.setOnClickListener(this.mOnClickListener);
      this.mPicker1.setMaxValue(99);
      this.mPicker1.setMinValue(0);
      this.mPicker2.setMaxValue(99);
      this.mPicker2.setMinValue(0);
      this.mPicker1.setWrapSelectorWheel(false);
      this.mPicker2.setWrapSelectorWheel(false);
      if (this.mMode == PickerModeEnum.PRODUCT_SIZE)
        this.mTitle.setText(paramContext.getString(2131165643));
      AlertDialog.Builder localBuilder = new AlertDialog.Builder(paramContext);
      localBuilder.setView(localView);
      localBuilder.setCancelable(true);
      this.mAlertDialog = localBuilder.create();
      this.mAlertDialog.setCancelable(true);
      this.mAlertDialog.setCanceledOnTouchOutside(true);
      this.mAlertDialog.setOnCancelListener(new DialogInterface.OnCancelListener()
      {
        public void onCancel(DialogInterface paramAnonymousDialogInterface)
        {
          if ((CustomPicker.this.mListener != null) && (CustomPicker.this.mMode == CustomPicker.PickerModeEnum.NORMAL))
            CustomPicker.this.mListener.onCancel();
          while ((CustomPicker.this.mSizeListener == null) || (CustomPicker.this.mMode != CustomPicker.PickerModeEnum.PRODUCT_SIZE))
            return;
          CustomPicker.this.mSizeListener.onCancel();
        }
      });
      return;
      this.mTitle = ((TextView)localView.findViewById(2131624309));
      this.mCrossIcon = localView.findViewById(2131624310);
      localLinearLayout.setVisibility(8);
      localRelativeLayout.setVisibility(0);
    }
  }

  public void dismissDialog()
  {
    if ((this.mAlertDialog != null) && (this.mAlertDialog.isShowing()))
      this.mAlertDialog.dismiss();
  }

  public int getCurrentSelectedSubUnit()
  {
    PickerModeEnum localPickerModeEnum1 = this.mMode;
    PickerModeEnum localPickerModeEnum2 = PickerModeEnum.PRODUCT_SIZE;
    int i = 0;
    if (localPickerModeEnum1 == localPickerModeEnum2)
      i = this.mPicker2.getValue();
    return i;
  }

  public int getCurrentSelectedUnit()
  {
    PickerModeEnum localPickerModeEnum1 = this.mMode;
    PickerModeEnum localPickerModeEnum2 = PickerModeEnum.PRODUCT_SIZE;
    int i = 0;
    if (localPickerModeEnum1 == localPickerModeEnum2)
      i = this.mPicker1.getValue();
    return i;
  }

  public int getCurrentSelectedValue()
  {
    PickerModeEnum localPickerModeEnum1 = this.mMode;
    PickerModeEnum localPickerModeEnum2 = PickerModeEnum.NORMAL;
    int i = 0;
    if (localPickerModeEnum1 == localPickerModeEnum2)
      i = this.mPicker1.getValue();
    return i;
  }

  public PickerModeEnum getMode()
  {
    return this.mMode;
  }

  public boolean isAddMode()
  {
    return this.mAddMode;
  }

  public boolean isPickerVisible()
  {
    return this.mAlertDialog.isShowing();
  }

  public void setAddMode(boolean paramBoolean)
  {
    this.mAddMode = paramBoolean;
  }

  public void setCancelable(boolean paramBoolean)
  {
    this.mAlertDialog.setCancelable(paramBoolean);
    this.mAlertDialog.setCanceledOnTouchOutside(paramBoolean);
  }

  public void setDisplayValue(String[] paramArrayOfString)
  {
    if (this.mMode == PickerModeEnum.NORMAL)
    {
      this.mPicker1.setMaxValue(-1 + paramArrayOfString.length);
      this.mPicker1.setMinValue(0);
      this.mPicker1.setDisplayedValues(paramArrayOfString);
      this.mPicker1.setWrapSelectorWheel(false);
    }
  }

  public void setEnableCrossIcon(boolean paramBoolean)
  {
    this.mCrossIcon.setEnabled(paramBoolean);
  }

  public void setGPRDisplayValue(String[] paramArrayOfString, GPRUISelectionCriteriaValue[] paramArrayOfGPRUISelectionCriteriaValue)
  {
    if (this.mMode == PickerModeEnum.NORMAL)
    {
      this.mPicker1.setMaxValue(-1 + paramArrayOfString.length);
      this.mPicker1.setMinValue(0);
      this.mPicker1.setDisplayedValues(paramArrayOfString);
      this.mOptionGpr = paramArrayOfGPRUISelectionCriteriaValue;
      this.mPicker1.setWrapSelectorWheel(false);
    }
  }

  public void setSubTitle(String paramString)
  {
    this.mSubTitle.setText(paramString);
    TextView localTextView = this.mSubTitle;
    if (paramString.length() > 0);
    for (int i = 0; ; i = 8)
    {
      localTextView.setVisibility(i);
      return;
    }
  }

  public void setSubUnitRange(int paramInt1, int paramInt2)
  {
    if (this.mMode == PickerModeEnum.PRODUCT_SIZE)
    {
      this.mPicker2.setMaxValue(paramInt2);
      this.mPicker2.setMinValue(paramInt1);
    }
  }

  public void setTitle(String paramString)
  {
    this.mTitle.setText(paramString);
  }

  public void setUnitRange(int paramInt1, int paramInt2)
  {
    if (this.mMode == PickerModeEnum.PRODUCT_SIZE)
    {
      this.mPicker1.setMaxValue(paramInt2);
      this.mPicker1.setMinValue(paramInt1);
    }
  }

  public void showPicker(int paramInt, SelectionListener paramSelectionListener)
  {
    this.mListener = paramSelectionListener;
    if ((this.mListener != null) && (this.mMode == PickerModeEnum.NORMAL))
    {
      this.mPicker1.setValue(paramInt);
      this.mPicker1.setWrapSelectorWheel(false);
      this.mAlertDialog.show();
    }
  }

  public void showSizePicker(int paramInt1, int paramInt2, String paramString1, String paramString2, ProductSizeSelectionListener paramProductSizeSelectionListener)
  {
    this.mSizeListener = paramProductSizeSelectionListener;
    if ((this.mSizeListener != null) && (this.mMode == PickerModeEnum.PRODUCT_SIZE))
    {
      this.mPicker1.setValue(paramInt1);
      this.mPicker2.setValue(paramInt2);
      this.mNumberPickerMetric.setText(paramString1);
      this.mNumberPickerMetric2.setText(paramString2);
      this.mNumberPickerMetric2.setVisibility(0);
      this.mAlertDialog.show();
    }
  }

  public void toggleCrossIcon(boolean paramBoolean)
  {
    View localView = this.mCrossIcon;
    if (paramBoolean);
    for (int i = 0; ; i = 8)
    {
      localView.setVisibility(i);
      return;
    }
  }

  public static enum PickerModeEnum
  {
    static
    {
      PickerModeEnum[] arrayOfPickerModeEnum = new PickerModeEnum[2];
      arrayOfPickerModeEnum[0] = NORMAL;
      arrayOfPickerModeEnum[1] = PRODUCT_SIZE;
    }
  }

  public static abstract interface ProductSizeSelectionListener
  {
    public abstract void onCancel();

    public abstract void onProductSizeSelected(int paramInt1, int paramInt2);
  }

  public static abstract interface SelectionListener
  {
    public abstract void onCancel();

    public abstract void onSelection(int paramInt);
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.util.CustomPicker
 * JD-Core Version:    0.6.2
 */