From 835a73a0063fc6c1e5263490a67cae5220a1847e Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Thu, 23 May 2019 16:43:33 +0400 Subject: [PATCH] Fixed bug with LoginActivity (not finished MainActivity when LoginActivity is started) --- .../github/chronosx88/influence/contracts/CoreContracts.kt | 1 + .../github/chronosx88/influence/presenters/MainPresenter.kt | 1 + .../io/github/chronosx88/influence/views/LoginActivity.java | 4 ++++ .../io/github/chronosx88/influence/views/MainActivity.java | 5 +++++ 4 files changed, 11 insertions(+) diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt b/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt index 08a1e2d..17487c0 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt @@ -55,6 +55,7 @@ interface CoreContracts { interface IMainViewContract { fun showSnackbar(message: String) fun showProgressBar(state: Boolean) + fun finishActivity() } // -----ChatActivity----- diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.kt b/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.kt index df19b7b..a01a112 100644 --- a/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.kt +++ b/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.kt @@ -31,6 +31,7 @@ class MainPresenter(private val view: CoreContracts.IMainViewContract) : CoreCon val intent = Intent(AppHelper.getContext(), LoginActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) AppHelper.getContext().startActivity(intent) + view.finishActivity() } } } diff --git a/app/src/main/java/io/github/chronosx88/influence/views/LoginActivity.java b/app/src/main/java/io/github/chronosx88/influence/views/LoginActivity.java index a7d216b..8faf1f3 100644 --- a/app/src/main/java/io/github/chronosx88/influence/views/LoginActivity.java +++ b/app/src/main/java/io/github/chronosx88/influence/views/LoginActivity.java @@ -90,6 +90,9 @@ public class LoginActivity extends AppCompatActivity implements CoreContracts.IL jidEditText.setError(null); passwordEditText.setError(null); + jidInputLayout.setError(null); + passwordInputLayout.setError(null); + String jid = jidEditText.getText().toString(); String password = passwordEditText.getText().toString(); @@ -161,6 +164,7 @@ public class LoginActivity extends AppCompatActivity implements CoreContracts.IL case AuthenticationStatusEvent.CONNECT_AND_LOGIN_SUCCESSFUL: { loadingScreen(false); finish(); + startActivity(new Intent(LoginActivity.this, MainActivity.class)); break; } case AuthenticationStatusEvent.INCORRECT_LOGIN_OR_PASSWORD: { diff --git a/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java b/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java index 377fba0..f715c70 100644 --- a/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java +++ b/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java @@ -143,4 +143,9 @@ public class MainActivity extends AppCompatActivity implements CoreContracts.IMa super.onStop(); presenter.onStop(); } + + @Override + public void finishActivity() { + finish(); + } }