Fix duplicated messages in threads
This commit is contained in:
parent
dbc118064c
commit
86dc5d2f13
|
@ -55,6 +55,7 @@ public class FragmentMastodonContext extends Fragment {
|
||||||
private StatusesVM statusesVM;
|
private StatusesVM statusesVM;
|
||||||
private List<Status> statuses;
|
private List<Status> statuses;
|
||||||
private StatusAdapter statusAdapter;
|
private StatusAdapter statusAdapter;
|
||||||
|
private boolean refresh;
|
||||||
//Handle actions that can be done in other fragments
|
//Handle actions that can be done in other fragments
|
||||||
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -154,6 +155,7 @@ public class FragmentMastodonContext extends Fragment {
|
||||||
focusedStatus = null;
|
focusedStatus = null;
|
||||||
pullToRefresh = false;
|
pullToRefresh = false;
|
||||||
focusedStatusURI = null;
|
focusedStatusURI = null;
|
||||||
|
refresh = true;
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
||||||
remote_instance = getArguments().getString(Helper.ARG_REMOTE_INSTANCE, null);
|
remote_instance = getArguments().getString(Helper.ARG_REMOTE_INSTANCE, null);
|
||||||
|
@ -182,7 +184,7 @@ public class FragmentMastodonContext extends Fragment {
|
||||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
binding.recyclerView.setAdapter(statusAdapter);
|
binding.recyclerView.setAdapter(statusAdapter);
|
||||||
binding.swipeContainer.setOnRefreshListener(() -> {
|
binding.swipeContainer.setOnRefreshListener(() -> {
|
||||||
if (this.statuses.size() > 0) {
|
if (this.statuses.size() > 0 && !refresh) {
|
||||||
binding.swipeContainer.setRefreshing(true);
|
binding.swipeContainer.setRefreshing(true);
|
||||||
pullToRefresh = true;
|
pullToRefresh = true;
|
||||||
statusesVM.getContext(user_instance, user_token, focusedStatus.id)
|
statusesVM.getContext(user_instance, user_token, focusedStatus.id)
|
||||||
|
@ -229,7 +231,7 @@ public class FragmentMastodonContext extends Fragment {
|
||||||
* @param context {@link Context}
|
* @param context {@link Context}
|
||||||
*/
|
*/
|
||||||
private void initializeContextView(final Context context) {
|
private void initializeContextView(final Context context) {
|
||||||
|
refresh = false;
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
Helper.sendToastMessage(requireActivity(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error));
|
Helper.sendToastMessage(requireActivity(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue