Fix behavior with min and max ids
This commit is contained in:
parent
2dc19277a7
commit
086be24686
|
@ -98,6 +98,7 @@ public class Status implements Serializable, Cloneable {
|
|||
public boolean isExpended = false;
|
||||
public boolean isTruncated = true;
|
||||
public boolean isFetchMore = false;
|
||||
public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
||||
public boolean isMediaDisplayed = false;
|
||||
public boolean isMediaObfuscated = true;
|
||||
public boolean isChecked = false;
|
||||
|
@ -108,6 +109,11 @@ public class Status implements Serializable, Cloneable {
|
|||
public transient int cursorPosition = 0;
|
||||
public transient boolean submitted = false;
|
||||
|
||||
public enum PositionFetchMore {
|
||||
TOP,
|
||||
BOTTOM
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
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.StatusDraft;
|
||||
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.DrawerStatusBinding;
|
||||
import app.fedilab.android.databinding.DrawerStatusHiddenBinding;
|
||||
|
@ -1862,7 +1861,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
}
|
||||
});
|
||||
//For reports
|
||||
|
||||
if (holder.bindingReport != null) {
|
||||
holder.bindingReport.checkbox.setChecked(status.isChecked);
|
||||
holder.bindingReport.checkbox.setOnClickListener(v -> status.isChecked = !status.isChecked);
|
||||
|
@ -1873,25 +1871,40 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
holder.binding.layoutFetchMore.fetchMoreMin.setOnClickListener(v -> {
|
||||
status.isFetchMore = false;
|
||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||
fetchMoreCallBack.onClickMinId(status.id);
|
||||
if (!remote) {
|
||||
new Thread(() -> {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = status;
|
||||
statusCache.status_id = status.id;
|
||||
try {
|
||||
new StatusCache(context).updateIfExists(statusCache);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
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) {
|
||||
new Thread(() -> {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = status;
|
||||
statusCache.status_id = status.id;
|
||||
try {
|
||||
new StatusCache(context).updateIfExists(statusCache);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.binding.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
||||
//We hide the button
|
||||
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());
|
||||
if (!remote) {
|
||||
new Thread(() -> {
|
||||
|
@ -1907,7 +1920,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
}
|
||||
}).start();
|
||||
}
|
||||
fetchMoreCallBack.onClickMaxId(status.id);
|
||||
});
|
||||
} else {
|
||||
holder.binding.layoutFetchMore.fetchMoreContainer.setVisibility(View.GONE);
|
||||
|
@ -2070,7 +2082,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
DrawerStatusBinding binding;
|
||||
DrawerStatusHiddenBinding bindingHidden;
|
||||
DrawerStatusReportBinding bindingReport;
|
||||
DrawerFetchMoreBinding bindingFetchMore;
|
||||
DrawerStatusNotificationBinding bindingNotification;
|
||||
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
|
||||
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).positionFetchMore = Status.PositionFetchMore.TOP;
|
||||
}
|
||||
} else if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.TOP && timelineParams.fetchingMissing) {
|
||||
if (!timelineStatuses.contains(statusList.get(0))) {
|
||||
statusList.get(0).isFetchMore = true;
|
||||
statusList.get(0).positionFetchMore = Status.PositionFetchMore.BOTTOM;
|
||||
}
|
||||
} else if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.BOTTOM && timelineParams.fetchingMissing) {
|
||||
if (!timelineStatuses.contains(statusList.get(statusList.size() - 1))) {
|
||||
statusList.get(statusList.size() - 1).isFetchMore = true;
|
||||
statusList.get(statusList.size() - 1).positionFetchMore = Status.PositionFetchMore.TOP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue