fix memory leaks (they happened due to hiding keyboard) and lint null pointer warnings in the same code (#1471)

This commit is contained in:
neslihanturan 2018-04-30 14:42:19 +03:00 committed by GitHub
parent 6d2c41b91e
commit 35f05be8df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 32 deletions

View file

@ -128,7 +128,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
forgotPasswordText.setOnClickListener(view -> forgotPassword());
if(BuildConfig.FLAVOR == "beta"){
if(BuildConfig.FLAVOR.equals("beta")){
loginCredentials.setText(getString(R.string.login_credential));
} else {
loginCredentials.setVisibility(View.GONE);
@ -145,8 +145,12 @@ public class LoginActivity extends AccountAuthenticatorActivity {
}
public void hideKeyboard(View view) {
InputMethodManager inputMethodManager =(InputMethodManager)this.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
if (view != null) {
InputMethodManager inputMethodManager = (InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
}