package ai.pai.lensman.login;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;

import com.android.views.progressbar.ProgressWheel;

import ai.pai.lensman.R;
import ai.pai.lensman.upload.UploadActivity;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LoginActivity extends FragmentActivity implements LoginContract.View{

    @BindView(R.id.wheel_wait_http)    ProgressWheel progressWheel;

    private LoginContract.Presenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        presenter = new LoginPresenter(this,this);
    }


    @OnClick(R.id.btn_login)
    public void login(){
        presenter.start();
    }

    @Override
    public void showLoginHint(String hint) {
        if(TextUtils.isEmpty(hint)){
            return;
        }
        Toast.makeText(this,hint,Toast.LENGTH_SHORT).show();
    }

    @Override
    public void showProgressView() {
        progressWheel.setVisibility(View.VISIBLE);
        progressWheel.startSpinning();
    }

    @Override
    public void hideProgressView() {
        progressWheel.stopSpinning();
        progressWheel.setVisibility(View.GONE);
    }

    @Override
    public void jumpMain() {
        startActivity(new Intent(this, UploadActivity.class));
        finish();
    }

}
