Added Android code
[wl-app.git] / Android / app / src / main / java / com / moiseum / wolnelektury / view / login / LoginActivity.java
1 package com.moiseum.wolnelektury.view.login;
2
3 import android.app.ProgressDialog;
4 import android.content.Context;
5 import android.net.Uri;
6 import android.os.Bundle;
7 import android.widget.Toast;
8
9 import com.moiseum.wolnelektury.R;
10 import com.moiseum.wolnelektury.base.AbstractActivity;
11 import com.moiseum.wolnelektury.base.AbstractIntent;
12 import com.moiseum.wolnelektury.base.mvp.PresenterActivity;
13
14 import butterknife.OnClick;
15
16 /**
17  * Created by Piotr Ostrowski on 11.09.2018.
18  */
19 public class LoginActivity extends PresenterActivity<LoginPresenter> implements LoginView {
20
21         public static class LoginIntent extends AbstractIntent {
22
23                 public LoginIntent(Context context) {
24                         super(context, LoginActivity.class);
25                 }
26         }
27
28         private ProgressDialog progressDialog;
29
30         @Override
31         public int getLayoutResourceId() {
32                 return R.layout.activity_login;
33         }
34
35         @Override
36         public void prepareView(Bundle savedInstanceState) {
37
38         }
39
40         @Override
41         protected LoginPresenter createPresenter() {
42                 return new LoginPresenter(this);
43         }
44
45         @Override
46         public void setProgressDialogVisibility(boolean visible) {
47                 if (visible && progressDialog == null) {
48                         String dialogMessage = getString(R.string.main_view_progress);
49                         progressDialog = ProgressDialog.show(this, null, dialogMessage, true, false);
50                 } else if (!visible && progressDialog != null) {
51                         progressDialog.hide();
52                         progressDialog = null;
53                 }
54         }
55
56         @Override
57         public void showToastMessage(int messageResId) {
58                 Toast.makeText(this, messageResId, Toast.LENGTH_LONG).show();
59         }
60
61         @Override
62         public void showCustomTabsAuthentication(Uri authorizationUrl) {
63                 showBrowserView(authorizationUrl);
64                 finish();
65         }
66
67         @OnClick(R.id.ibBack)
68         public void onBackClicked() {
69                 finish();
70         }
71
72         @OnClick(R.id.btnLogin)
73         public void onLoginClicked() {
74                 getPresenter().onLoginClicked();
75         }
76 }