mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-07 00:20:08 +02:00
Fix behavior with min and max ids
This commit is contained in:
parent
2dc19277a7
commit
086be24686
3 changed files with 38 additions and 18 deletions
|
@ -98,6 +98,7 @@ public class Status implements Serializable, Cloneable {
|
||||||
public boolean isExpended = false;
|
public boolean isExpended = false;
|
||||||
public boolean isTruncated = true;
|
public boolean isTruncated = true;
|
||||||
public boolean isFetchMore = false;
|
public boolean isFetchMore = false;
|
||||||
|
public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
||||||
public boolean isMediaDisplayed = false;
|
public boolean isMediaDisplayed = false;
|
||||||
public boolean isMediaObfuscated = true;
|
public boolean isMediaObfuscated = true;
|
||||||
public boolean isChecked = false;
|
public boolean isChecked = false;
|
||||||
|
@ -108,6 +109,11 @@ public class Status implements Serializable, Cloneable {
|
||||||
public transient int cursorPosition = 0;
|
public transient int cursorPosition = 0;
|
||||||
public transient boolean submitted = false;
|
public transient boolean submitted = false;
|
||||||
|
|
||||||
|
public enum PositionFetchMore {
|
||||||
|
TOP,
|
||||||
|
BOTTOM
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object obj) {
|
||||||
boolean same = false;
|
boolean same = false;
|
||||||
|
|
|
@ -113,7 +113,6 @@ import app.fedilab.android.client.entities.app.Account;
|
||||||
import app.fedilab.android.client.entities.app.StatusCache;
|
import app.fedilab.android.client.entities.app.StatusCache;
|
||||||
import app.fedilab.android.client.entities.app.StatusDraft;
|
import app.fedilab.android.client.entities.app.StatusDraft;
|
||||||
import app.fedilab.android.client.entities.app.Timeline;
|
import app.fedilab.android.client.entities.app.Timeline;
|
||||||
import app.fedilab.android.databinding.DrawerFetchMoreBinding;
|
|
||||||
import app.fedilab.android.databinding.DrawerStatusArtBinding;
|
import app.fedilab.android.databinding.DrawerStatusArtBinding;
|
||||||
import app.fedilab.android.databinding.DrawerStatusBinding;
|
import app.fedilab.android.databinding.DrawerStatusBinding;
|
||||||
import app.fedilab.android.databinding.DrawerStatusHiddenBinding;
|
import app.fedilab.android.databinding.DrawerStatusHiddenBinding;
|
||||||
|
@ -1862,7 +1861,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//For reports
|
//For reports
|
||||||
|
|
||||||
if (holder.bindingReport != null) {
|
if (holder.bindingReport != null) {
|
||||||
holder.bindingReport.checkbox.setChecked(status.isChecked);
|
holder.bindingReport.checkbox.setChecked(status.isChecked);
|
||||||
holder.bindingReport.checkbox.setOnClickListener(v -> status.isChecked = !status.isChecked);
|
holder.bindingReport.checkbox.setOnClickListener(v -> status.isChecked = !status.isChecked);
|
||||||
|
@ -1873,7 +1871,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
holder.binding.layoutFetchMore.fetchMoreMin.setOnClickListener(v -> {
|
holder.binding.layoutFetchMore.fetchMoreMin.setOnClickListener(v -> {
|
||||||
status.isFetchMore = false;
|
status.isFetchMore = false;
|
||||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||||
fetchMoreCallBack.onClickMinId(status.id);
|
if (holder.getBindingAdapterPosition() < statusList.size() - 1) {
|
||||||
|
String fromId;
|
||||||
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP) {
|
||||||
|
fromId = statusList.get(holder.getBindingAdapterPosition() + 1).id;
|
||||||
|
} else {
|
||||||
|
fromId = status.id;
|
||||||
|
}
|
||||||
|
fetchMoreCallBack.onClickMinId(fromId);
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
StatusCache statusCache = new StatusCache();
|
StatusCache statusCache = new StatusCache();
|
||||||
|
@ -1888,10 +1893,18 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
holder.binding.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
holder.binding.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
||||||
//We hide the button
|
//We hide the button
|
||||||
status.isFetchMore = false;
|
status.isFetchMore = false;
|
||||||
|
String fromId;
|
||||||
|
if (status.positionFetchMore == Status.PositionFetchMore.TOP) {
|
||||||
|
fromId = statusList.get(holder.getBindingAdapterPosition()).id;
|
||||||
|
} else {
|
||||||
|
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
||||||
|
}
|
||||||
|
fetchMoreCallBack.onClickMaxId(fromId);
|
||||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
@ -1907,7 +1920,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
fetchMoreCallBack.onClickMaxId(status.id);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
holder.binding.layoutFetchMore.fetchMoreContainer.setVisibility(View.GONE);
|
holder.binding.layoutFetchMore.fetchMoreContainer.setVisibility(View.GONE);
|
||||||
|
@ -2070,7 +2082,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
DrawerStatusBinding binding;
|
DrawerStatusBinding binding;
|
||||||
DrawerStatusHiddenBinding bindingHidden;
|
DrawerStatusHiddenBinding bindingHidden;
|
||||||
DrawerStatusReportBinding bindingReport;
|
DrawerStatusReportBinding bindingReport;
|
||||||
DrawerFetchMoreBinding bindingFetchMore;
|
|
||||||
DrawerStatusNotificationBinding bindingNotification;
|
DrawerStatusNotificationBinding bindingNotification;
|
||||||
DrawerStatusArtBinding bindingArt;
|
DrawerStatusArtBinding bindingArt;
|
||||||
|
|
||||||
|
|
|
@ -347,14 +347,17 @@ public class TimelinesVM extends AndroidViewModel {
|
||||||
//When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole
|
//When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole
|
||||||
if (statusList.get(statusList.size() - 1).id.compareToIgnoreCase(timelineStatuses.get(0).id) > 0) {
|
if (statusList.get(statusList.size() - 1).id.compareToIgnoreCase(timelineStatuses.get(0).id) > 0) {
|
||||||
statusList.get(statusList.size() - 1).isFetchMore = true;
|
statusList.get(statusList.size() - 1).isFetchMore = true;
|
||||||
|
statusList.get(statusList.size() - 1).positionFetchMore = Status.PositionFetchMore.TOP;
|
||||||
}
|
}
|
||||||
} else if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.TOP && timelineParams.fetchingMissing) {
|
} else if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.TOP && timelineParams.fetchingMissing) {
|
||||||
if (!timelineStatuses.contains(statusList.get(0))) {
|
if (!timelineStatuses.contains(statusList.get(0))) {
|
||||||
statusList.get(0).isFetchMore = true;
|
statusList.get(0).isFetchMore = true;
|
||||||
|
statusList.get(0).positionFetchMore = Status.PositionFetchMore.BOTTOM;
|
||||||
}
|
}
|
||||||
} else if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.BOTTOM && timelineParams.fetchingMissing) {
|
} else if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.BOTTOM && timelineParams.fetchingMissing) {
|
||||||
if (!timelineStatuses.contains(statusList.get(statusList.size() - 1))) {
|
if (!timelineStatuses.contains(statusList.get(statusList.size() - 1))) {
|
||||||
statusList.get(statusList.size() - 1).isFetchMore = true;
|
statusList.get(statusList.size() - 1).isFetchMore = true;
|
||||||
|
statusList.get(statusList.size() - 1).positionFetchMore = Status.PositionFetchMore.TOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue