Fix lifecycle for ViewUser/ViewCommunity activities

This commit is contained in:
Balazs Toldi 2023-08-18 09:22:35 +02:00
parent 171338f492
commit 81e2fdcf91
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 39 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
@ -391,6 +392,23 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
}
@Override
protected void onStart() {
super.onStart();
Log.e("ViewSubredditDetail", "onStart");
if (communityData != null) {
setupVisibleElements();
} else {
fetchSubredditData();
}
}
@Override
protected void onStop() {
super.onStop();
mFetchSubredditInfoSuccess = false;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (sectionsPagerAdapter != null) {

View File

@ -246,6 +246,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private String mAccountName;
private String mAccountQualifiedName;
private String username;
private String qualifiedName;
private String description;
private boolean subscriptionReady = false;
@ -320,7 +321,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
mMessageId = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
qualifiedName = savedInstanceState.getString(NEW_ACCOUNT_QUALIFIED_NAME_STATE);
qualifiedName = savedInstanceState.getString("qualified_name");
}
checkNewAccountAndInitializeViewPager();
@ -332,6 +333,22 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
}
@Override
protected void onStart() {
super.onStart();
if (mUserData != null) {
setupVisibleElements();
} else {
fetchUserInfo();
}
}
@Override
protected void onStop() {
super.onStop();
mFetchUserInfoSuccess = false;
}
private void setupVisibleElements() {
Resources resources = getResources();
String title = username;
@ -1134,7 +1151,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
mUserData = userData;
username = userData.getName();
username = userData.getDisplayName();
setupVisibleElements();
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
@ -1361,7 +1378,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageId);
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
outState.getString(NEW_ACCOUNT_QUALIFIED_NAME_STATE, mAccountQualifiedName);
outState.putString(NEW_ACCOUNT_QUALIFIED_NAME_STATE, mAccountQualifiedName);
outState.putString("qualified_name", qualifiedName);
}
@Override