|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2019 Afero, Inc. All rights reserved. |
| 3 | + */ |
| 4 | + |
| 5 | +package io.afero.aferolab.resetPassword; |
| 6 | + |
| 7 | +import android.content.Context; |
| 8 | +import android.support.annotation.AttrRes; |
| 9 | +import android.support.annotation.NonNull; |
| 10 | +import android.support.annotation.Nullable; |
| 11 | +import android.util.AttributeSet; |
| 12 | +import android.view.View; |
| 13 | + |
| 14 | +import butterknife.BindView; |
| 15 | +import butterknife.ButterKnife; |
| 16 | +import butterknife.OnClick; |
| 17 | +import io.afero.aferolab.R; |
| 18 | +import io.afero.aferolab.widget.AferoEditText; |
| 19 | +import io.afero.aferolab.widget.ProgressSpinnerView; |
| 20 | +import io.afero.aferolab.widget.ScreenView; |
| 21 | +import io.afero.sdk.client.afero.AferoClient; |
| 22 | + |
| 23 | +public class RequestCodeView extends ScreenView { |
| 24 | + |
| 25 | + @BindView(R.id.edit_text_email) |
| 26 | + AferoEditText emailEditText; |
| 27 | + |
| 28 | + @BindView(R.id.progress_request_code) |
| 29 | + ProgressSpinnerView progressView; |
| 30 | + |
| 31 | + private RequestCodeController mController; |
| 32 | + |
| 33 | + |
| 34 | + public RequestCodeView(@NonNull Context context) { |
| 35 | + super(context); |
| 36 | + } |
| 37 | + |
| 38 | + public RequestCodeView(@NonNull Context context, @Nullable AttributeSet attrs) { |
| 39 | + super(context, attrs); |
| 40 | + } |
| 41 | + |
| 42 | + public RequestCodeView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { |
| 43 | + super(context, attrs, defStyleAttr); |
| 44 | + } |
| 45 | + |
| 46 | + public static RequestCodeView create(@NonNull View contextView) { |
| 47 | + return inflateView(R.layout.view_request_code, contextView); |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public void onFinishInflate() { |
| 52 | + super.onFinishInflate(); |
| 53 | + ButterKnife.bind(this); |
| 54 | + } |
| 55 | + |
| 56 | + public RequestCodeView start(AferoClient aferoClient) { |
| 57 | + pushOnBackStack(); |
| 58 | + |
| 59 | + mController = new RequestCodeController(this, aferoClient); |
| 60 | + mController.start(); |
| 61 | + |
| 62 | + emailEditText.showKeyboard(); |
| 63 | + |
| 64 | + return this; |
| 65 | + } |
| 66 | + |
| 67 | + @Override |
| 68 | + public void stop() { |
| 69 | + mController.stop(); |
| 70 | + |
| 71 | + super.stop(); |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public boolean onBackPressed() { |
| 76 | + return false; |
| 77 | + } |
| 78 | + |
| 79 | + @OnClick(R.id.button_request_code) |
| 80 | + void onClickRequestCode() { |
| 81 | + emailEditText.hideKeyboard(); |
| 82 | + mController.onClickRequestCode(emailEditText.getText().toString()); |
| 83 | + } |
| 84 | + |
| 85 | + @OnClick(R.id.button_already_have_code) |
| 86 | + void onClickAlreadyHaveCode() { |
| 87 | + emailEditText.hideKeyboard(); |
| 88 | + mController.onClickAlreadyHaveCode(); |
| 89 | + } |
| 90 | + |
| 91 | + void showProgress() { |
| 92 | + progressView.show(); |
| 93 | + } |
| 94 | + |
| 95 | + void hideProgress() { |
| 96 | + progressView.hide(); |
| 97 | + } |
| 98 | +} |
0 commit comments