package com.ikea.kompis.fragments;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.ikea.kompis.TrayAdapter;
import com.ikea.kompis.WelcomeActivity;
import com.ikea.kompis.browse.event.BrowseProductEvent;
import com.ikea.kompis.browse.event.GoToSearchEvent;
import com.ikea.kompis.campaign.event.WelcomeResumedEvent;
import com.ikea.kompis.event.ShowInformationEvent;
import com.ikea.kompis.event.ShowWelcomeEvent;
import com.ikea.kompis.scan.event.ScanEvent;
import com.ikea.kompis.setting.event.CountryChangeEvent;
import com.ikea.kompis.setting.event.ShowSettingsEvent;
import com.ikea.kompis.stores.event.GoToStoreLocatorEvent;
import com.ikea.kompis.user.LoginCanceledEvent;
import com.ikea.kompis.user.event.LoginDoneEvent;
import com.ikea.kompis.user.event.LogoutDoneEvent;
import com.ikea.kompis.user.event.PerformLoginEvent;
import com.ikea.shared.AppConfigData;
import com.ikea.shared.AppConfigManager;
import com.ikea.shared.config.model.Country;
import com.ikea.shared.config.model.KillSwitchConfig;
import com.ikea.shared.user.event.FavStoreChangeEvent;
import com.ikea.shared.user.model.User;
import com.ikea.shared.user.service.UserService;
import com.ikea.shared.util.L;
import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe;
import java.util.ArrayList;

public class TrayFragment extends BaseFragment
  implements AdapterView.OnItemClickListener
{
  private static final String PREVIOUS_SELECTED_INDEX = "PREVIOUS_SELECTED_INDEX";
  private static final String SELECTED_INDEX = "SELECTED_INDEX";
  private static final ArrayList<Integer> mTrayDrawable = new ArrayList()
  {
    private static final long serialVersionUID = -3124658423742340324L;
  };
  private static final ArrayList<Integer> mTrayTitle = new ArrayList()
  {
    private static final long serialVersionUID = 927839136552985944L;
  };
  private ListView mListView = null;
  private int mPrevSelectedIndex = 1;
  private int mSelectedIndex = 1;
  private TrayAdapter mTrayAdapter = null;

  private boolean isIRWSupport()
  {
    boolean bool1 = true;
    if ((AppConfigManager.i(getActivity()) != null) && (AppConfigManager.i(getActivity()).getAppConfigData() != null))
    {
      bool1 = AppConfigManager.i(getActivity()).getAppConfigData().isIRWSupported();
      L.I("isIRWSupported : " + bool1);
      boolean bool2 = AppConfigManager.i(getActivity()).getAppConfigData().isFamilyCardDisabled();
      L.I("isFamilyCardDisabled : " + bool2);
      if ((!bool1) || (bool2))
        bool1 = false;
    }
    return bool1;
  }

  private void setTrayAdaper()
  {
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    int i = 1;
    int j = 1;
    boolean bool1 = isIRWSupport();
    if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig() != null) && (!AppConfigManager.i(getActivity()).getAppConfigData().getConfig().isBarCodeEnabled()))
      i = 0;
    if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig() != null) && (!AppConfigManager.i(getActivity()).getAppConfigData().getConfig().ismLoginEnabled()))
      j = 0;
    boolean bool2 = AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo();
    int k = 0;
    if (k < mTrayDrawable.size())
    {
      if ((i == 0) && (((Integer)mTrayDrawable.get(k)).intValue() == 2130837769));
      while (true)
      {
        k++;
        break;
        if (((bool1) || (((Integer)mTrayDrawable.get(k)).intValue() != 2130837711)) && ((j != 0) || (((Integer)mTrayDrawable.get(k)).intValue() != 2130837721)) && ((bool2) || (((Integer)mTrayDrawable.get(k)).intValue() != 2130837752)))
        {
          localArrayList1.add(mTrayDrawable.get(k));
          localArrayList2.add(mTrayTitle.get(k));
        }
      }
    }
    ListView localListView = this.mListView;
    TrayAdapter localTrayAdapter = new TrayAdapter(this.mParent, localArrayList2, localArrayList1);
    this.mTrayAdapter = localTrayAdapter;
    localListView.setAdapter(localTrayAdapter);
  }

  @Subscribe
  public void handleCountryChange(CountryChangeEvent paramCountryChangeEvent)
  {
    L.I("CountryChangeEvent is found !");
    setTrayAdaper();
    this.mTrayAdapter.notifyDataSetChanged();
  }

  @Subscribe
  public void handleFavStoreChanged(FavStoreChangeEvent paramFavStoreChangeEvent)
  {
    this.mTrayAdapter.notifyDataSetChanged();
  }

  @Subscribe
  public void handleLoginCancel(LoginCanceledEvent paramLoginCanceledEvent)
  {
    this.mListView.setItemChecked(this.mPrevSelectedIndex, true);
    this.mTrayAdapter.notifyDataSetChanged();
  }

  @Subscribe
  public void handleLogout(LoginDoneEvent paramLoginDoneEvent)
  {
    L.I("handleLogout called");
    this.mTrayAdapter.notifyDataSetChanged();
  }

  @Subscribe
  public void handleLogout(LogoutDoneEvent paramLogoutDoneEvent)
  {
    this.mTrayAdapter.notifyDataSetChanged();
  }

  @Subscribe
  public void handleWelcomeResume(WelcomeResumedEvent paramWelcomeResumedEvent)
  {
    L.I("handleWelcomeResume called");
    this.mSelectedIndex = 1;
    this.mListView.setItemChecked(this.mSelectedIndex, true);
    this.mTrayAdapter.notifyDataSetChanged();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    if (paramBundle != null)
    {
      if (paramBundle.containsKey("SELECTED_INDEX"))
        this.mSelectedIndex = paramBundle.getInt("SELECTED_INDEX");
      if (paramBundle.containsKey("PREVIOUS_SELECTED_INDEX"))
        this.mPrevSelectedIndex = paramBundle.getInt("PREVIOUS_SELECTED_INDEX");
    }
  }

  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    this.mListView = ((ListView)paramLayoutInflater.inflate(2130903163, paramViewGroup, false));
    setTrayAdaper();
    this.mListView.setClickable(true);
    this.mListView.setItemChecked(1, true);
    this.mListView.setOnItemClickListener(this);
    return this.mListView;
  }

  public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
  {
    User localUser = UserService.i(this.mParent).getUser();
    switch (((Integer)paramAdapterView.getAdapter().getItem(paramInt)).intValue())
    {
    default:
      return;
    case 2131165444:
      this.mSelectedIndex = paramInt;
      if ((localUser != null) && (localUser.isLoggedIn()))
      {
        ((WelcomeActivity)getActivity()).close();
        this.mBus.post(new ShowSettingsEvent(true));
        return;
      }
      this.mBus.post(new PerformLoginEvent(true, false));
      return;
    case 2131165705:
      this.mSelectedIndex = paramInt;
      this.mPrevSelectedIndex = paramInt;
      ((WelcomeActivity)getActivity()).close();
      this.mBus.post(new ShowWelcomeEvent(true, false, false));
      return;
    case 2131165626:
      this.mSelectedIndex = paramInt;
      this.mPrevSelectedIndex = paramInt;
      ((WelcomeActivity)getActivity()).closeTray();
      this.mBus.post(new GoToSearchEvent(true));
      return;
    case 2131165568:
      this.mSelectedIndex = paramInt;
      this.mPrevSelectedIndex = paramInt;
      ((WelcomeActivity)getActivity()).close();
      this.mBus.post(new BrowseProductEvent(true));
      return;
    case 2131165600:
      this.mBus.post(new ScanEvent(true));
      return;
    case 2131165399:
      this.mSelectedIndex = paramInt;
      this.mPrevSelectedIndex = paramInt;
      ((WelcomeActivity)getActivity()).close();
      this.mBus.post(new OpenBaseFamily(true));
      return;
    case 2131165287:
      ((WelcomeActivity)getActivity()).close();
      this.mSelectedIndex = paramInt;
      this.mPrevSelectedIndex = paramInt;
      this.mBus.post(new GoToStoreLocatorEvent(true, false, false, false));
      return;
    case 2131165650:
      this.mSelectedIndex = paramInt;
      this.mPrevSelectedIndex = paramInt;
      ((WelcomeActivity)getActivity()).close();
      this.mBus.post(new ShowSettingsEvent(true));
      return;
    case 2131165410:
    }
    this.mSelectedIndex = paramInt;
    this.mPrevSelectedIndex = paramInt;
    ((WelcomeActivity)getActivity()).close();
    this.mBus.post(new ShowInformationEvent(true));
  }

  public void onPause()
  {
    super.onPause();
    try
    {
      this.mBus.unregister(this);
      return;
    }
    catch (Exception localException)
    {
      L.W("No event handler to unregister");
    }
  }

  public void onResume()
  {
    super.onResume();
    this.mBus.register(this);
    if (this.mTrayAdapter != null)
    {
      this.mTrayAdapter.notifyDataSetChanged();
      this.mListView.setItemChecked(this.mSelectedIndex, true);
    }
  }

  public void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    paramBundle.putInt("SELECTED_INDEX", this.mSelectedIndex);
    paramBundle.putInt("PREVIOUS_SELECTED_INDEX", this.mPrevSelectedIndex);
  }

  public void refreshAdapter()
  {
    setTrayAdaper();
    this.mTrayAdapter.notifyDataSetChanged();
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.fragments.TrayFragment
 * JD-Core Version:    0.6.2
 */