package org.fossasia.susi.ai.activities;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import org.fossasia.susi.ai.R;
import org.fossasia.susi.ai.helper.Constant;
import org.fossasia.susi.ai.helper.CredentialHelper;
import org.fossasia.susi.ai.helper.PrefManager;
import org.fossasia.susi.ai.rest.ClientBuilder;
import org.fossasia.susi.ai.rest.model.LoginResponse;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class LoginActivity extends AppCompatActivity {

    @BindView(R.id.email)
    TextInputLayout email;
    @BindView(R.id.password)
    TextInputLayout password;
    @BindView(R.id.log_in)
    Button logIn;
    TextView signup;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        signup=(TextView)findViewById(R.id.sign_up);
        signup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LoginActivity.this, SignUpActivity.class);
                startActivity(intent);
            }
        });
    }

    @OnClick(R.id.log_in)
    void logIn() {
        if (CredentialHelper.checkIfEmpty(email, this) | CredentialHelper.checkIfEmpty(password, this)) {
            return;
        }
        if (!CredentialHelper.isEmailValid(email.getEditText().getText().toString())) {
            email.setError("Invalid email");
            return;
        }
        email.setError(null);
        
        logIn.setEnabled(false);
        final ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("Logging in...");
        progressDialog.show();
        final Call<LoginResponse> authResponseCall = new ClientBuilder().getSusiApi()
                .login(email.getEditText().getText().toString().trim(),
                        password.getEditText().getText().toString());
        progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                authResponseCall.cancel();
                logIn.setEnabled(true);
            }
        });
        authResponseCall.enqueue(new Callback<LoginResponse>() {
            @Override
            public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
                if (response.isSuccessful() && response.body() != null) {
                    Toast.makeText(LoginActivity.this, response.body().getMessage(), Toast.LENGTH_SHORT).show();
                    //Save token and expiry date.
                    PrefManager.putString(Constant.ACCESS_TOKEN, response.body().getAccessToken());
                    long validity = System.currentTimeMillis() + response.body().getValidSeconds() * 1000;
                    PrefManager.putLong(Constant.TOKEN_VALIDITY, validity);
                    Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    finish();
                } else
                    Toast.makeText(LoginActivity.this, response.message(), Toast.LENGTH_SHORT).show();
                logIn.setEnabled(true);
                progressDialog.dismiss();


            }

            @Override
            public void onFailure(Call<LoginResponse> call, Throwable t) {
                t.printStackTrace();
                Toast.makeText(LoginActivity.this, "Please check your internet.", Toast.LENGTH_SHORT).show();
                logIn.setEnabled(true);
                progressDialog.dismiss();
            }
        });
    }

}

@@ -1084,25 +1084,9 @@
     
-TextView signup;
 %0A
+
     
@@ -1285,192 +1285,62 @@
     
-    signup=(TextView)findViewById(R.id.sign_up);
+%7D
 %0A    
+%0A
     
-signup.setOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A        
+@OnClick(R.id.sign_up)%0A    void signUp() %7B%0A
     
@@ -1409,32 +1409,24 @@
 ity.class);%0A
-        
         star
@@ -1448,34 +1448,8 @@
 t);%0A
-            %7D%0A        %7D);%0A
     

Add butterknife to signup