remove weird blue flicker when logging in

This commit is contained in:
Andrew Dolgov 2017-06-05 19:31:47 +03:00
parent 4f35eb65a5
commit 8d3776ccc0
2 changed files with 15 additions and 38 deletions

View File

@ -359,7 +359,7 @@ public class OnlineActivity extends CommonActivity {
public void login(boolean refresh, OnLoginFinishedListener listener) { public void login(boolean refresh, OnLoginFinishedListener listener) {
if (m_prefs.getString("ttrss_url", "").trim().length() == 0) { if (m_prefs.getString("ttrss_url", "").trim().length() == 0) {
setLoadingStatus(R.string.login_need_configure, false); setLoadingStatus(R.string.login_need_configure);
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.dialog_need_configure_prompt) builder.setMessage(R.string.dialog_need_configure_prompt)
@ -382,7 +382,7 @@ public class OnlineActivity extends CommonActivity {
alert.show(); alert.show();
} else { } else {
setLoadingStatus(R.string.login_in_progress, true); setLoadingStatus(R.string.login_in_progress);
LoginRequest ar = new LoginRequest(getApplicationContext(), refresh, listener); LoginRequest ar = new LoginRequest(getApplicationContext(), refresh, listener);
@ -396,12 +396,12 @@ public class OnlineActivity extends CommonActivity {
ar.execute(map); ar.execute(map);
setLoadingStatus(R.string.login_in_progress, true); setLoadingStatus(R.string.login_in_progress);
} }
} }
protected void loginSuccess(boolean refresh) { protected void loginSuccess(boolean refresh) {
setLoadingStatus(R.string.blank, false); setLoadingStatus(R.string.blank);
initMenu(); initMenu();
@ -1098,48 +1098,26 @@ public class OnlineActivity extends CommonActivity {
req.execute(map); req.execute(map);
} }
private void setLoadingStatus(int status, boolean showProgress) { private void setLoadingStatus(int status) {
TextView tv = (TextView) findViewById(R.id.loading_message); setLoadingStatus(getString(status));
if (tv != null) {
tv.setText(status);
}
View loadingContainer = findViewById(R.id.loading_container);
if (loadingContainer != null) {
loadingContainer.setVisibility(status == R.string.blank ? View.GONE : View.VISIBLE);
}
} }
private void setLoadingStatus(String status, boolean showProgress) { private void setLoadingStatus(String status) {
TextView tv = (TextView) findViewById(R.id.loading_message); TextView tv = (TextView) findViewById(R.id.loading_message);
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View loadingContainer = findViewById(R.id.loading_container);
if (loadingContainer != null) {
loadingContainer.setVisibility(status.equals("") ? View.GONE : View.VISIBLE);
}
} }
protected void logout() { protected void logout() {
setSessionId(null); setSessionId(null);
View loadingContainer = findViewById(R.id.loading_container); setLoadingStatus(R.string.login_ready);
if (loadingContainer != null) {
loadingContainer.setVisibility(View.VISIBLE);
}
setLoadingStatus(R.string.login_ready, false);
initMenu(); initMenu();
} }
protected void loginFailure() { protected void loginFailure() {
setSessionId(null); setSessionId(null);
initMenu(); initMenu();
@ -1582,12 +1560,12 @@ public class OnlineActivity extends CommonActivity {
} else if (m_lastError != ApiCommon.ApiError.API_UNKNOWN_METHOD) { } else if (m_lastError != ApiCommon.ApiError.API_UNKNOWN_METHOD) {
// Unknown method means old tt-rss, in that case we assume API 0 and continue // Unknown method means old tt-rss, in that case we assume API 0 and continue
setLoadingStatus(getErrorMessage(), false); setLoadingStatus(getErrorMessage());
if (m_lastErrorMessage != null) { if (m_lastErrorMessage != null) {
setLoadingStatus(getString(getErrorMessage()) + "\n\n" + m_lastErrorMessage, false); setLoadingStatus(getString(getErrorMessage()) + "\n\n" + m_lastErrorMessage);
} else { } else {
setLoadingStatus(getErrorMessage(), false); setLoadingStatus(getErrorMessage());
} }
if (m_listener != null) { if (m_listener != null) {
@ -1617,7 +1595,7 @@ public class OnlineActivity extends CommonActivity {
req.execute(map); req.execute(map);
setLoadingStatus(R.string.loading_message, true); setLoadingStatus(R.string.loading_message);
} }
return; return;
@ -1631,9 +1609,9 @@ public class OnlineActivity extends CommonActivity {
setSessionId(null); setSessionId(null);
if (m_lastErrorMessage != null) { if (m_lastErrorMessage != null) {
setLoadingStatus(getString(getErrorMessage()) + "\n\n" + m_lastErrorMessage, false); setLoadingStatus(getString(getErrorMessage()) + "\n\n" + m_lastErrorMessage);
} else { } else {
setLoadingStatus(getErrorMessage(), false); setLoadingStatus(getErrorMessage());
} }
loginFailure(); loginFailure();

View File

@ -1,5 +1,4 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loading_container"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" > android:layout_height="fill_parent" >