SignUpActivity.java 5.86 KB
package com.bitstrips.imoji.ui.activities;

import android.app.AlertDialog.Builder;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import com.bitstrips.imoji.InjectorApplication;
import com.bitstrips.imoji.analytics.LegacyAnalyticsService;
import com.bitstrips.imoji.analytics.PageViewReporter;
import com.bitstrips.imoji.api.BSAuthResponse;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.experiments.Experiments;
import com.bitstrips.imoji.models.BSUser;
import com.bitstrips.imoji.ui.OnboardingFormBaseActivity;
import com.bitstrips.imoji.ui.fragments.BirthdaySignUpFragment;
import com.bitstrips.imoji.ui.fragments.BirthdaySignUpFragment.OnBirthdaySelectedListener;
import com.bitstrips.imoji.ui.fragments.SignUpFormFragment;
import com.bitstrips.imoji.ui.fragments.SignUpFormFragment.FragmentWithValidationContainer;
import com.bitstrips.imoji.util.PreferenceUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import javax.inject.Inject;
import retrofit.Callback;
import retrofit.RetrofitError;

public class SignUpActivity
  extends OnboardingFormBaseActivity
  implements BirthdaySignUpFragment.OnBirthdaySelectedListener, SignUpFormFragment.FragmentWithValidationContainer
{
  public static final String EXTRA_LINK_BSAUTH = "linkBSAuth";
  public static final int MIN_PASSWORD_LENGTH = 6;
  @Inject
  LegacyAnalyticsService n;
  @Inject
  BitmojiApi o;
  @Inject
  PreferenceUtils p;
  @Inject
  Experiments q;
  @Inject
  PageViewReporter r;
  private Boolean s;
  private String t;
  
  private void a()
  {
    ((InputMethodManager)getSystemService("input_method")).hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
  }
  
  public void doSignUp(final BSUser paramBSUser)
  {
    paramBSUser.setBirthday(this.t);
    disableButtons();
    Callback local1 = new Callback()
    {
      public final void failure(RetrofitError paramAnonymousRetrofitError)
      {
        SignUpActivity.a(SignUpActivity.this, paramAnonymousRetrofitError);
      }
    };
    Callback local2 = new Callback()
    {
      public final void failure(RetrofitError paramAnonymousRetrofitError)
      {
        SignUpActivity.a(SignUpActivity.this, paramAnonymousRetrofitError);
      }
    };
    if (this.s.booleanValue()) {
      this.o.linkBSAuth(paramBSUser, local2);
    }
    for (;;)
    {
      a();
      return;
      this.o.createUser(paramBSUser, local1);
    }
  }
  
  public void onBackPressed()
  {
    if (getFragmentManager().getBackStackEntryCount() > 0)
    {
      a();
      getFragmentManager().popBackStack();
      setTitle(2131230861);
      return;
    }
    super.onBackPressed();
  }
  
  public void onBirthdaySelected(Calendar paramCalendar)
  {
    this.t = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(paramCalendar.getTime());
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.setTime(new Date());
    int j = localCalendar.get(1) - paramCalendar.get(1);
    int i;
    if (paramCalendar.get(2) <= localCalendar.get(2))
    {
      i = j;
      if (paramCalendar.get(2) == localCalendar.get(2))
      {
        i = j;
        if (paramCalendar.get(5) <= localCalendar.get(5)) {}
      }
    }
    else
    {
      i = j - 1;
    }
    if (i < 13)
    {
      this.r.enteredInvalidBirthday();
      if (isActivityValid()) {
        new AlertDialog.Builder(this).setMessage(getString(2131230760)).setNeutralButton(17039370, new DialogInterface.OnClickListener()
        {
          public final void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
          {
            paramAnonymousDialogInterface.dismiss();
            SignUpActivity.this.finish();
          }
        }).show();
      }
      return;
    }
    this.r.enteredValidBirthday();
    getFragmentManager().beginTransaction().replace(2131689942, new SignUpFormFragment()).addToBackStack(null).commit();
    ((InputMethodManager)getSystemService("input_method")).toggleSoftInput(2, 1);
  }
  
  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    ((InjectorApplication)getApplication()).inject(this);
    setContentView(2130903204);
    this.s = Boolean.valueOf(getIntent().getBooleanExtra("linkBSAuth", false));
    setSupportActionBar((Toolbar)findViewById(2131689623));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    FragmentTransaction localFragmentTransaction = getFragmentManager().beginTransaction();
    if (this.s.booleanValue()) {}
    for (paramBundle = new SignUpFormFragment();; paramBundle = new BirthdaySignUpFragment())
    {
      localFragmentTransaction.add(2131689942, paramBundle);
      localFragmentTransaction.commit();
      this.r.birthdayPageView();
      return;
    }
  }
  
  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    if (paramMenuItem.getItemId() == 16908332)
    {
      onBackPressed();
      return true;
    }
    return super.onOptionsItemSelected(paramMenuItem);
  }
  
  protected void onPause()
  {
    super.onPause();
  }
  
  public void onResume()
  {
    super.onResume();
  }
  
  public void setMainButton(Button paramButton)
  {
    super.setMainButton(paramButton);
  }
  
  public void setTitleBasedOnExtras()
  {
    if (this.s.booleanValue())
    {
      setTitle(2131230982);
      return;
    }
    setTitle(2131231031);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/ui/activities/SignUpActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */