mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Refreshing subreddit and user details when click the refresh menu item in ViewSubredditDetailActivity and ViewUserDetailActivity.
This commit is contained in:
parent
2f15383718
commit
6d66f9504e
@ -61,6 +61,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||||
|
|
||||||
private static final String FETCH_SUBREDDIT_INFO_STATE = "FSIS";
|
private static final String FETCH_SUBREDDIT_INFO_STATE = "FSIS";
|
||||||
|
private static final String CURRENT_ONLINE_SUBSCRIBERS_STATE = "COSS";
|
||||||
private static final String FRAGMENT_OUT_STATE_KEY = "FOSK";
|
private static final String FRAGMENT_OUT_STATE_KEY = "FOSK";
|
||||||
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
|
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
|
||||||
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||||
@ -87,6 +88,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
private boolean mFetchSubredditInfoSuccess = false;
|
private boolean mFetchSubredditInfoSuccess = false;
|
||||||
|
private int mNCurrentOnlineSubscribers = 0;
|
||||||
private boolean subscriptionReady = false;
|
private boolean subscriptionReady = false;
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
private boolean showToast = false;
|
private boolean showToast = false;
|
||||||
@ -193,6 +195,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
getCurrentAccountAndBindView();
|
getCurrentAccountAndBindView();
|
||||||
} else {
|
} else {
|
||||||
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
|
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
|
||||||
|
mNCurrentOnlineSubscribers = savedInstanceState.getInt(CURRENT_ONLINE_SUBSCRIBERS_STATE);
|
||||||
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||||
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
|
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
|
||||||
mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
|
mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
|
||||||
@ -207,6 +210,10 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY);
|
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY);
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_subreddit_detail_activity, mFragment).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_subreddit_detail_activity, mFragment).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mFetchSubredditInfoSuccess) {
|
||||||
|
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, mNCurrentOnlineSubscribers));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchSubredditData();
|
fetchSubredditData();
|
||||||
@ -340,10 +347,9 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
FetchSubredditData.fetchSubredditData(mRetrofit, subredditName, new FetchSubredditData.FetchSubredditDataListener() {
|
FetchSubredditData.fetchSubredditData(mRetrofit, subredditName, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
new InsertSubredditDataAsyncTask(mRedditDataRoomDatabase, subredditData, () -> {
|
mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers;
|
||||||
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, nCurrentOnlineSubscribers));
|
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, nCurrentOnlineSubscribers));
|
||||||
mFetchSubredditInfoSuccess = true;
|
new InsertSubredditDataAsyncTask(mRedditDataRoomDatabase, subredditData, () -> mFetchSubredditInfoSuccess = true).execute();
|
||||||
}).execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -483,6 +489,8 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
}
|
}
|
||||||
if(mFragment instanceof FragmentCommunicator) {
|
if(mFragment instanceof FragmentCommunicator) {
|
||||||
((FragmentCommunicator) mFragment).refresh();
|
((FragmentCommunicator) mFragment).refresh();
|
||||||
|
mFetchSubredditInfoSuccess = false;
|
||||||
|
fetchSubredditData();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.action_lazy_mode_view_subreddit_detail_activity:
|
case R.id.action_lazy_mode_view_subreddit_detail_activity:
|
||||||
@ -513,6 +521,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
|
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
|
||||||
|
outState.putInt(CURRENT_ONLINE_SUBSCRIBERS_STATE, mNCurrentOnlineSubscribers);
|
||||||
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
||||||
outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken);
|
outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken);
|
||||||
outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
|
outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
|
||||||
|
@ -537,6 +537,8 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
|
|||||||
mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity).setTitle(R.string.action_start_lazy_mode);
|
mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity).setTitle(R.string.action_start_lazy_mode);
|
||||||
}
|
}
|
||||||
sectionsPagerAdapter.refresh();
|
sectionsPagerAdapter.refresh();
|
||||||
|
mFetchUserInfoSuccess = false;
|
||||||
|
fetchUserInfo();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_lazy_mode_view_user_detail_activity:
|
case R.id.action_lazy_mode_view_user_detail_activity:
|
||||||
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
|
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
|
||||||
|
Loading…
Reference in New Issue
Block a user