package com.mgilangjanuar.dev.goscele.modules.auth.view;

import android.app.ProgressDialog;
import android.widget.EditText;

import com.mgilangjanuar.dev.goscele.R;
import com.mgilangjanuar.dev.goscele.base.BaseActivity;
import com.mgilangjanuar.dev.goscele.modules.auth.listener.AuthListener;
import com.mgilangjanuar.dev.goscele.modules.auth.presenter.AuthPresenter;
import com.mgilangjanuar.dev.goscele.modules.main.view.MainActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by mgilangjanuar (mgilangjanuar@gmail.com)
 *
 * @since 2017
 */

public class AuthActivity extends BaseActivity implements AuthListener {

    @BindView(R.id.username)
    EditText username;

    @BindView(R.id.password)
    EditText password;

    private AuthPresenter authPresenter = new AuthPresenter(this);

    @Override
    public int findLayout() {
        return R.layout.activity_auth;
    }

    @OnClick(R.id.login_button)
    public void onClickLogin() {
        hideKeyboard();
        authPresenter.login(username.getText().toString(), password.getText().toString());
    }

    @Override
    public void onUsernameOrPasswordEmpty() {
        showSnackbar(R.string.username_password_required_field);
    }

    @Override
    public ProgressDialog getProgressDialog() {
        return showProgress(R.string.loading);
    }

    @Override
    public void onConnectionFailed() {
        showSnackbar(R.string.connection_problem);
    }

    @Override
    public void onWrongCredential(String error) {
        showSnackbar(error);
    }

    @Override
    public void onSuccess() {
        redirect(MainActivity.class, true);
    }
}

@@ -86,16 +86,42 @@
 Dialog;%0A
+import android.os.Bundle;%0A
 import a
@@ -804,16 +804,156 @@
 esenter 
+authPresenter;%0A%0A    @Override%0A    public void initialize(Bundle savedInstanceState) %7B%0A        super.initialize(savedInstanceState);%0A        
 authPres
@@ -984,16 +984,22 @@
 r(this);
+%0A    %7D
 %0A%0A    @O

fix bug on authentication