gt:                 show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
context: /*
   * Der Bund ePaper Downloader - App to download ePaper issues of the Der Bund newspaper
   * Copyright (C) 2013 Adrian Gygax
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program. If not, see {http://www.gnu.org/licenses/}.
   */
  
  package com.github.notizklotz.derbunddownloader.ui;
  
  import android.animation.Animator;
  import android.animation.AnimatorListenerAdapter;
  import android.content.Intent;
  import android.os.AsyncTask;
  import android.os.Build;
  import android.os.Bundle;
  import android.support.design.widget.TextInputEditText;
  import android.support.design.widget.TextInputLayout;
  import android.support.v7.app.AppCompatActivity;
  import android.text.Html;
  import android.text.Spanned;
  import android.text.TextUtils;
  import android.text.method.LinkMovementMethod;
  import android.view.KeyEvent;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.inputmethod.EditorInfo;
  import android.widget.Button;
  import android.widget.TextView;
  
  import com.github.notizklotz.derbunddownloader.DerBundDownloaderApplication;
  import com.github.notizklotz.derbunddownloader.R;
  import com.github.notizklotz.derbunddownloader.download.client.EpaperApiClient;
  import com.github.notizklotz.derbunddownloader.settings.Settings;
  
  import org.apache.commons.lang3.StringUtils;
  
  import javax.inject.Inject;
  
  /**
   * A login screen that offers login via email/password.
   */
  public class LoginActivity extends AppCompatActivity {
  
      @Inject
      Settings settings;
  
      @Inject
      EpaperApiClient epaperApiClient;
  
      /**
       * Keep track of the login task to ensure we can cancel it if requested.
       */
      private UserLoginTask mAuthTask = null;
  
      private TextInputEditText mPasswordView;
      private TextInputEditText mEmailView;
  
      private TextInputLayout emailViewInputLayout;
      private TextInputLayout passwordViewInputLayout;
  
      private View mProgressView;
      private View mLoginFormView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          ((DerBundDownloaderApplication)getApplication()).getUiComponent().inject(this);
  
          setContentView(R.layout.activity_login);
          // Set up the login form.
          mEmailView = (TextInputEditText) findViewById(R.id.email);
  
          mPasswordView = (TextInputEditText) findViewById(R.id.password);
          mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
              @Override
              public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
                  if (id == R.id.login || id == EditorInfo.IME_NULL) {
                      attemptLogin();
                      return true;
                  }
                  return false;
              }
          });
  
          emailViewInputLayout = (TextInputLayout) findViewById(R.id.emailInputLayout);
          passwordViewInputLayout = (TextInputLayout) findViewById(R.id.passwordInputLayout);
  
          Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
          mEmailSignInButton.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View view) {
                  attemptLogin();
              }
          });
  
          mLoginFormView = findViewById(R.id.login_form);
          mProgressView = findViewById(R.id.login_progress);
  
          TextView registrationLinkTextView = (TextView) findViewById(R.id.registrationLink);
          registrationLinkTextView.setText(createSpanned("<a href=\"" + getString(R.string.registration_url) + "\">" + getString(R.string.register) + "</a>"));
          registrationLinkTextView.setMovementMethod(LinkMovementMethod.getInstance());
  
          TextView pwResetLinkTextView = (TextView) findViewById(R.id.pwResetLink);
          pwResetLinkTextView.setText(createSpanned("<a href=\"" + getString(R.string.pw_request_url) + "\">" + getString(R.string.request_pw) + "</a>"));
          pwResetLinkTextView.setMovementMethod(LinkMovementMethod.getInstance());
  
          String username = settings.getUsername();
          if (StringUtils.isNotBlank(username)) {
              mEmailView.setText(username);
          }
          mPasswordView.setText(settings.getPassword());
      }
  
      private Spanned createSpanned(String registrationLink) {
          Spanned text;
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
              text = Html.fromHtml(registrationLink, Html.FROM_HTML_MODE_COMPACT);
          } else {
              //noinspection deprecation
              text = Html.fromHtml(registrationLink);
          }
          return text;
      }
  
      /**
       * Attempts to sign in or register the account specified by the login form.
       * If there are form errors (invalid email, missing fields, etc.), the
       * errors are presented and no actual login attempt is made.
       */
      private void attemptLogin() {
          if (mAuthTask != null) {
              return;
          }
  
          // Reset errors.
          mEmailView.setError(null);
          mPasswordView.setError(null);
  
          // Store values at the time of the login attempt.
          String email = mEmailView.getText().toString();
          String password = mPasswordView.getText().toString();
  
          boolean cancel = false;
          View focusView = null;
  
          // Check for a valid email address.
          if (TextUtils.isEmpty(password)) {
              passwordViewInputLayout.setError(getString(R.string.error_field_required));
              focusView = mPasswordView;
              cancel = true;
          }
  
          // Check for a valid email address.
          if (TextUtils.isEmpty(email)) {
              emailViewInputLayout.setError(getString(R.string.error_field_required));
              focusView = mEmailView;
              cancel = true;
          }
  
          if (cancel) {
              // There was an error; don't attempt login and focus the first
              // form field with an error.
              focusView.requestFocus();
          } else {
              // Show a progress spinner, and kick off a background task to
              // perform the user login attempt.
              showProgress(true);
              mAuthTask = new UserLoginTask(email, password);
              mAuthTask.execute((Void) null);
          }
      }
  
      /**
       * Shows the progress UI and hides the login form.
       */
      private void showProgress(final boolean show) {
          int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
  
          mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
          mLoginFormView.animate().setDuration(shortAnimTime).alpha(
                  show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                  mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
              }
          });
  
          mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
          mProgressView.animate().setDuration(shortAnimTime).alpha(
  