package com.ikea.kompis.fte;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.ikea.kompis.IkeaApplication;
import com.ikea.kompis.extendedcontent.ECQRFirstTimeEvent;
import com.ikea.kompis.extendedcontent.ECQRFirstTimeFragment;
import com.ikea.kompis.fte.event.RegistrationFirstTimeEvent;
import com.ikea.kompis.fte.event.ShowNearestStoreEvent;
import com.ikea.kompis.stores.StoreLocatorActivity;
import com.ikea.kompis.user.event.ChooseNearestStore;
import com.ikea.kompis.util.UiUtil;
import com.ikea.shared.AppConfigData;
import com.ikea.shared.AppConfigManager;
import com.ikea.shared.analytics.UsageTracker;
import com.ikea.shared.config.model.Country;
import com.ikea.shared.config.model.KillSwitchConfig;
import com.ikea.shared.store.service.StoreCache;
import com.ikea.shared.stores.model.StoreList;
import com.ikea.shared.util.L;
import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe;
import java.util.Iterator;
import java.util.List;

public class FirstUserExperienceFragment extends Fragment
{
  public static final String FROM_FIRST_USER_EXPERIENCE = "FROM_FIRST_USER_EXPERIENCE";
  public static final String IS_GPS_ON = "IS_GPS_ON";
  private final Bus mBus = IkeaApplication.mBus;
  private EventHandler mEventHandler;
  protected Uri mLaunchedFromCatalogueURI;

  private void showFirstTimeRegistration()
  {
    if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig() != null) && (!AppConfigManager.i(getActivity()).getAppConfigData().getConfig().ismLoginEnabled()))
      ((FirstUserExperienceActivity)getActivity()).moveToWelcome();
    while (true)
    {
      UsageTracker.i().viewInitiate(getActivity(), 3);
      return;
      RegistrationFirstTimeFragment localRegistrationFirstTimeFragment = new RegistrationFirstTimeFragment();
      if (this.mLaunchedFromCatalogueURI != null)
      {
        Bundle localBundle = new Bundle();
        localBundle.putParcelable("LaunchedFromCatalogue", this.mLaunchedFromCatalogueURI);
        localRegistrationFirstTimeFragment.setArguments(localBundle);
      }
      updateContentFragment(localRegistrationFirstTimeFragment, "REGISTER", true);
    }
  }

  public void onAttach(Activity paramActivity)
  {
    super.onAttach(paramActivity);
    Bundle localBundle = getArguments();
    if ((localBundle != null) && (localBundle.containsKey("LaunchedFromCatalogue")))
      this.mLaunchedFromCatalogueURI = ((Uri)localBundle.getParcelable("LaunchedFromCatalogue"));
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.mEventHandler = new EventHandler(null);
    if (paramBundle == null)
    {
      updateContentFragment(new WelcomeFirstTimeFragment(), "WELCOME", false);
      UsageTracker.i().viewInitiate(getActivity(), 1);
    }
  }

  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    return paramLayoutInflater.inflate(2130903086, paramViewGroup, false);
  }

  public void onPause()
  {
    super.onPause();
    try
    {
      this.mBus.unregister(this.mEventHandler);
      return;
    }
    catch (Exception localException)
    {
      L.W("No event handler to unregister");
    }
  }

  public void onResume()
  {
    super.onResume();
    this.mBus.register(this.mEventHandler);
  }

  public void onStart()
  {
    super.onStart();
  }

  public boolean returnBackStackImmediate(FragmentManager paramFragmentManager)
  {
    List localList = paramFragmentManager.getFragments();
    if ((localList != null) && (!localList.isEmpty()))
    {
      int i = 0;
      Iterator localIterator = localList.iterator();
      while (localIterator.hasNext())
      {
        Fragment localFragment1 = (Fragment)localIterator.next();
        if ((localFragment1 != null) && (localFragment1.getChildFragmentManager() != null) && (localFragment1.getChildFragmentManager().getBackStackEntryCount() > 1))
        {
          Fragment localFragment2 = localFragment1.getChildFragmentManager().findFragmentById(2131624123);
          Fragment localFragment3;
          if ((localFragment2 != null) && ((localFragment2 instanceof RegistrationFirstTimeFragment)) && (i > 0))
          {
            localFragment3 = (Fragment)localList.get(i - 1);
            if (!(localFragment3 instanceof ECQRFirstTimeFragment))
              break label155;
          }
          while (((localFragment2 instanceof NearestStoreFragment)) && (((NearestStoreFragment)localFragment2).isCountrtListOpen()))
          {
            ((NearestStoreFragment)localFragment2).closeCountryListOverlay();
            return true;
            label155: if ((localFragment3 instanceof NearestStoreFragment))
            {
              AppConfigManager.i(getActivity()).getAppConfigData().setCountryCode(null);
              AppConfigManager.i(getActivity()).getAppConfigData().setCountryName(null);
              AppConfigManager.i(getActivity()).getAppConfigData().setLanguageCode(null);
              AppConfigManager.i(getActivity()).getAppConfigData().setLanguageName(null);
              AppConfigManager.i(getActivity()).getAppConfigData().setFavStore(null);
              if (StoreCache.i(getActivity()).getCachedStoreList() != null)
                StoreCache.i(getActivity()).getCachedStoreList().setStoreRefList(null);
            }
          }
          if (localFragment1.getChildFragmentManager().popBackStackImmediate())
            return true;
        }
        i++;
      }
    }
    return false;
  }

  protected void showECQRFirstTime()
  {
  }

  protected void showNearestStoreFragment()
  {
    NearestStoreFragment localNearestStoreFragment = new NearestStoreFragment();
    if (this.mLaunchedFromCatalogueURI != null)
    {
      Bundle localBundle = new Bundle();
      localBundle.putParcelable("LaunchedFromCatalogue", this.mLaunchedFromCatalogueURI);
      localNearestStoreFragment.setArguments(localBundle);
    }
    updateContentFragment(localNearestStoreFragment, "STORE", true);
    UsageTracker.i().viewInitiate(getActivity(), 2);
  }

  public void updateContentFragment(Fragment paramFragment, String paramString, boolean paramBoolean)
  {
    FragmentTransaction localFragmentTransaction = getChildFragmentManager().beginTransaction();
    if (paramBoolean)
      localFragmentTransaction.setCustomAnimations(2130968591, 2130968595, 2130968593, 2130968594);
    while (true)
    {
      localFragmentTransaction.replace(2131624123, paramFragment, paramString);
      localFragmentTransaction.addToBackStack(null);
      localFragmentTransaction.commit();
      return;
      localFragmentTransaction.setCustomAnimations(0, 0, 2130968593, 2130968594);
    }
  }

  private class EventHandler
  {
    private EventHandler()
    {
    }

    @Subscribe
    public void showNearestStoreScreen(ShowNearestStoreEvent paramShowNearestStoreEvent)
    {
      FirstUserExperienceFragment.this.showNearestStoreFragment();
    }

    @Subscribe
    public void showQRECFirstTime(ECQRFirstTimeEvent paramECQRFirstTimeEvent)
    {
      FirstUserExperienceFragment.this.showECQRFirstTime();
    }

    @Subscribe
    public void showRegistrationFirstTime(RegistrationFirstTimeEvent paramRegistrationFirstTimeEvent)
    {
      FirstUserExperienceFragment.this.showFirstTimeRegistration();
    }

    @Subscribe
    public void showStoreInMap(ChooseNearestStore paramChooseNearestStore)
    {
      if (AppConfigManager.i(FirstUserExperienceFragment.this.getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo())
      {
        UiUtil.applyLocaleString(FirstUserExperienceFragment.this.getActivity(), false);
        Intent localIntent = new Intent(FirstUserExperienceFragment.this.getActivity(), StoreLocatorActivity.class);
        localIntent.putExtra("FROM_FIRST_USER_EXPERIENCE", true);
        FirstUserExperienceFragment.this.getActivity().startActivityForResult(localIntent, 1);
        FirstUserExperienceFragment.this.getActivity().overridePendingTransition(2130968587, 2130968584);
        return;
      }
      FirstUserExperienceFragment.this.showFirstTimeRegistration();
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.fte.FirstUserExperienceFragment
 * JD-Core Version:    0.6.2
 */