1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2025-02-21 19:04:46 +01:00

Hide actionbar during login (#79)

This commit is contained in:
Rafał Borcz 2018-04-08 15:54:46 +02:00 committed by Mikołaj Pich
parent c72e7748e2
commit cb6afb137f
3 changed files with 20 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout; import android.support.design.widget.TextInputLayout;
import android.support.v7.app.ActionBar;
import android.view.View; import android.view.View;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -209,6 +210,18 @@ public class LoginActivity extends BaseActivity implements LoginContract.View {
}); });
} }
@Override
public void showActionBar(boolean show) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
if (show) {
actionBar.show();
} else {
actionBar.hide();
}
}
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();

View File

@ -33,6 +33,8 @@ public interface LoginContract {
void hideSoftInput(); void hideSoftInput();
void showActionBar(boolean show);
} }
@PerActivity @PerActivity

View File

@ -55,6 +55,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.View>
@Override @Override
public void onStartAsync() { public void onStartAsync() {
if (isViewAttached()) { if (isViewAttached()) {
getView().showActionBar(false);
getView().showLoginProgress(true); getView().showLoginProgress(true);
} }
} }
@ -84,24 +85,25 @@ public class LoginPresenter extends BasePresenter<LoginContract.View>
public void onEndAsync(boolean success, Exception exception) { public void onEndAsync(boolean success, Exception exception) {
if (success) { if (success) {
getView().openMainActivity(); getView().openMainActivity();
return;
} else if (exception instanceof BadCredentialsException) { } else if (exception instanceof BadCredentialsException) {
getView().setErrorPassIncorrect(); getView().setErrorPassIncorrect();
getView().showSoftInput(); getView().showSoftInput();
getView().showLoginProgress(false);
} else if (exception instanceof AccountPermissionException) { } else if (exception instanceof AccountPermissionException) {
getView().setErrorSymbolRequired(); getView().setErrorSymbolRequired();
getView().showSoftInput(); getView().showSoftInput();
getView().showLoginProgress(false);
} else { } else {
getView().onError(getRepository().getErrorLoginMessage(exception)); getView().onError(getRepository().getErrorLoginMessage(exception));
getView().showLoginProgress(false);
} }
getView().showActionBar(true);
getView().showLoginProgress(false);
} }
@Override @Override
public void onCanceledAsync() { public void onCanceledAsync() {
if (isViewAttached()) { if (isViewAttached()) {
getView().showActionBar(true);
getView().showLoginProgress(false); getView().showLoginProgress(false);
} }
} }