forked from mirrors/Fedilab
Some fixes
This commit is contained in:
parent
0bf5199144
commit
f3e8e8a506
2 changed files with 13 additions and 10 deletions
|
@ -19,6 +19,7 @@ import android.text.Spannable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
@ -92,6 +93,14 @@ public class Status implements Serializable, Cloneable {
|
||||||
@SerializedName("pleroma")
|
@SerializedName("pleroma")
|
||||||
public Pleroma pleroma;
|
public Pleroma pleroma;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object obj) {
|
||||||
|
boolean same = false;
|
||||||
|
if (obj instanceof Status) {
|
||||||
|
same = this.id.equals(((Status) obj).id);
|
||||||
|
}
|
||||||
|
return same;
|
||||||
|
}
|
||||||
|
|
||||||
public Attachment art_attachment;
|
public Attachment art_attachment;
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
private PinnedTimeline pinnedTimeline;
|
private PinnedTimeline pinnedTimeline;
|
||||||
private String ident;
|
private String ident;
|
||||||
private String instance, user_id;
|
private String instance, user_id;
|
||||||
private ArrayList<String> idOfAddedStatuses;
|
|
||||||
private boolean canBeFederated;
|
private boolean canBeFederated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,7 +217,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false);
|
minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false);
|
||||||
statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT);
|
statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT);
|
||||||
}
|
}
|
||||||
idOfAddedStatuses = new ArrayList<>();
|
|
||||||
if (tagTimeline != null) {
|
if (tagTimeline != null) {
|
||||||
ident = "@T@" + tagTimeline.name;
|
ident = "@T@" + tagTimeline.name;
|
||||||
if (tagTimeline.isART) {
|
if (tagTimeline.isART) {
|
||||||
|
@ -310,9 +309,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
statuses.statuses = mediaStatuses;
|
statuses.statuses = mediaStatuses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Status status : statuses.statuses) {
|
|
||||||
idOfAddedStatuses.add(status.id);
|
|
||||||
}
|
|
||||||
flagLoading = statuses.pagination.max_id == null;
|
flagLoading = statuses.pagination.max_id == null;
|
||||||
binding.recyclerView.setVisibility(View.VISIBLE);
|
binding.recyclerView.setVisibility(View.VISIBLE);
|
||||||
if (statusAdapter != null && this.statuses != null) {
|
if (statusAdapter != null && this.statuses != null) {
|
||||||
|
@ -489,11 +485,11 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
* @return int >= 0 | STATUS_PRESENT = -1 | STATUS_AT_THE_BOTTOM = -2
|
* @return int >= 0 | STATUS_PRESENT = -1 | STATUS_AT_THE_BOTTOM = -2
|
||||||
*/
|
*/
|
||||||
private int insertStatus(Status statusReceived) {
|
private int insertStatus(Status statusReceived) {
|
||||||
if (idOfAddedStatuses.contains(statusReceived.id)) {
|
|
||||||
return STATUS_PRESENT;
|
|
||||||
}
|
|
||||||
int position = 0;
|
int position = 0;
|
||||||
if (this.statuses != null) {
|
if (this.statuses != null) {
|
||||||
|
if (this.statuses.contains(statusReceived)) {
|
||||||
|
return STATUS_PRESENT;
|
||||||
|
}
|
||||||
statusAdapter.notifyItemRangeChanged(0, this.statuses.size());
|
statusAdapter.notifyItemRangeChanged(0, this.statuses.size());
|
||||||
//We loop through messages already in the timeline
|
//We loop through messages already in the timeline
|
||||||
for (Status statusAlreadyPresent : this.statuses) {
|
for (Status statusAlreadyPresent : this.statuses) {
|
||||||
|
@ -501,7 +497,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
//Pinned messages are ignored because their date can be older
|
//Pinned messages are ignored because their date can be older
|
||||||
if (statusReceived.id.compareTo(statusAlreadyPresent.id) > 0 && !statusAlreadyPresent.pinned) {
|
if (statusReceived.id.compareTo(statusAlreadyPresent.id) > 0 && !statusAlreadyPresent.pinned) {
|
||||||
//We add the status to a list of id - thus we know it is already in the timeline
|
//We add the status to a list of id - thus we know it is already in the timeline
|
||||||
idOfAddedStatuses.add(statusReceived.id);
|
|
||||||
this.statuses.add(position, statusReceived);
|
this.statuses.add(position, statusReceived);
|
||||||
statusAdapter.notifyItemInserted(position);
|
statusAdapter.notifyItemInserted(position);
|
||||||
break;
|
break;
|
||||||
|
@ -511,7 +506,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
//Statuses added at the bottom, we flag them by position = -2 for not dealing with them and fetch more
|
//Statuses added at the bottom, we flag them by position = -2 for not dealing with them and fetch more
|
||||||
if (position == this.statuses.size()) {
|
if (position == this.statuses.size()) {
|
||||||
//We add the status to a list of id - thus we know it is already in the timeline
|
//We add the status to a list of id - thus we know it is already in the timeline
|
||||||
idOfAddedStatuses.add(statusReceived.id);
|
|
||||||
this.statuses.add(position, statusReceived);
|
this.statuses.add(position, statusReceived);
|
||||||
statusAdapter.notifyItemInserted(position);
|
statusAdapter.notifyItemInserted(position);
|
||||||
return STATUS_AT_THE_BOTTOM;
|
return STATUS_AT_THE_BOTTOM;
|
||||||
|
|
Loading…
Reference in a new issue