package com.ikea.kompis.user;

import android.app.ActionBar;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import com.ikea.kompis.IkeaApplication;
import com.ikea.kompis.extendedcontent.ECStuffActivity;
import com.ikea.kompis.user.event.LoginResultEvent;
import com.ikea.kompis.user.event.SignUpEvent;
import com.ikea.kompis.util.UiUtil;
import com.ikea.shared.analytics.UsageTracker;
import com.ikea.shared.util.Constant;
import com.ikea.shared.util.L;
import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe;

public class LoginActivity extends ECStuffActivity
{
  public static final String COME_FROM_FIRST_EXPERIENCE = "COME_FROM_FIRST_EXPERIENCE";
  public static final String LOGIN_FRAGMENT = "LOGIN_FRAGMENT";
  public static final String LOGIN_FROM_IKEA_FAMILY = "LOGIN_FROM_IKEA_FAMILY";
  public static final String LOGIN_FROM_TRAY = "LOGIN_FROM_TRAY";
  public static final String LOGIN_SUCESSFUL = "LOGIN_SUCESSFUL";
  public static final String SIGNUP_FRAGMENT = "SIGNUP_FRAGMENT";
  private boolean isFormFirstExp = false;
  private Bus mBus = IkeaApplication.mBus;
  private EventHandler mEventHandler;
  private boolean mLaunchedFromIKEAFamily = false;
  private boolean mLaunchedFromTray = false;
  private View mLoginLayout;

  private void handleBackPressed()
  {
    UiUtil.closeSoftKeyBoard(this.mLoginLayout);
    UsageTracker.i().setBackPressed();
    if (getSupportFragmentManager().getBackStackEntryCount() > 1)
    {
      getSupportFragmentManager().popBackStack();
      return;
    }
    if (this.mLaunchedFromCatalogueURI != null)
    {
      Intent localIntent = new Intent();
      localIntent.putExtra("LOGIN_RESULT", false);
      setResult(-1, localIntent);
    }
    finish();
    if (!UiUtil.isTablet(getApplicationContext()))
    {
      overridePendingTransition(2130968583, 2130968582);
      return;
    }
    Constant.i().setOfflineToastNeedToShow(false);
  }

  private void updateContentFragment(Fragment paramFragment, String paramString, boolean paramBoolean)
  {
    FragmentTransaction localFragmentTransaction = getSupportFragmentManager().beginTransaction();
    if (paramBoolean)
      localFragmentTransaction.setCustomAnimations(2130968591, 2130968592, 2130968593, 2130968594);
    localFragmentTransaction.replace(this.mLoginLayout.getId(), paramFragment, paramString);
    localFragmentTransaction.addToBackStack(null);
    localFragmentTransaction.commit();
  }

  public void onBackPressed()
  {
    handleBackPressed();
  }

  protected void onCreate(Bundle paramBundle)
  {
    if (UiUtil.isTablet(this))
      requestWindowFeature(1);
    super.onCreate(paramBundle);
    this.mEventHandler = new EventHandler(null);
    getWindow().setSoftInputMode(3);
    setContentView(2130903045);
    Intent localIntent = getIntent();
    String str = null;
    if (localIntent != null)
    {
      Bundle localBundle = getIntent().getExtras();
      str = null;
      if (localBundle != null)
      {
        this.isFormFirstExp = getIntent().getExtras().getBoolean("COME_FROM_FIRST_EXPERIENCE", false);
        this.mLaunchedFromCatalogueURI = ((Uri)getIntent().getExtras().getParcelable("LaunchedFromCatalogue"));
        str = getIntent().getExtras().getString("LaunchedFromCatalogueuser", null);
        this.mLaunchedFromIKEAFamily = getIntent().getExtras().getBoolean("LOGIN_FROM_IKEA_FAMILY", false);
        this.mLaunchedFromTray = getIntent().getExtras().getBoolean("LOGIN_FROM_TRAY", false);
      }
    }
    if (!UiUtil.isTablet(this))
    {
      ImageView localImageView = (ImageView)getActionBar().getCustomView().findViewById(2131624017);
      if (localImageView != null)
        localImageView.setOnClickListener(new View.OnClickListener()
        {
          public void onClick(View paramAnonymousView)
          {
            LoginActivity.this.handleBackPressed();
          }
        });
    }
    this.mLoginLayout = findViewById(2131623990);
    if (paramBundle == null)
      updateContentFragment(LoginFragment.newInstance(this.isFormFirstExp, this.mLaunchedFromTray, this.mLaunchedFromIKEAFamily, this.mLaunchedFromCatalogueURI, str), "LOGIN_FRAGMENT", false);
    if (!UiUtil.isTablet(this))
      setRequestedOrientation(1);
  }

  protected void onPause()
  {
    super.onPause();
    try
    {
      this.mBus.unregister(this.mEventHandler);
      return;
    }
    catch (Exception localException)
    {
      L.W("No event handler to unregister");
    }
  }

  protected void onResume()
  {
    super.onResume();
    this.mBus.register(this.mEventHandler);
  }

  private class EventHandler
  {
    private EventHandler()
    {
    }

    @Subscribe
    public void handleLoginResult(LoginResultEvent paramLoginResultEvent)
    {
      Intent localIntent = new Intent();
      localIntent.putExtra("LOGIN_FROM_IKEA_FAMILY", LoginActivity.this.mLaunchedFromIKEAFamily);
      LoginActivity.this.setResult(-1, localIntent);
      LoginActivity.this.finish();
      LoginActivity.this.overridePendingTransition(0, 2130968598);
    }

    @Subscribe
    public void showSignUpFragment(SignUpEvent paramSignUpEvent)
    {
      UsageTracker.i().viewSignup(LoginActivity.this, paramSignUpEvent.fromTray, paramSignUpEvent.fromfamily, paramSignUpEvent.fromFTE);
      SignUpFragment localSignUpFragment = SignUpFragment.newInstance(paramSignUpEvent.fromTray, paramSignUpEvent.fromfamily, paramSignUpEvent.fromFTE);
      LoginActivity.this.updateContentFragment(localSignUpFragment, "SIGNUP_FRAGMENT", true);
    }
  }
}

/* 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.LoginActivity
 * JD-Core Version:    0.6.2
 */