mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 08:40:03 +02:00
Order by date
This commit is contained in:
parent
cbd1332213
commit
ad178f3cd0
3 changed files with 23 additions and 20 deletions
|
@ -231,7 +231,7 @@ public interface MastodonTimelinesService {
|
||||||
Call<List<MisskeyNote>> getMisskey(@Body MisskeyNote.MisskeyParams params);
|
Call<List<MisskeyNote>> getMisskey(@Body MisskeyNote.MisskeyParams params);
|
||||||
|
|
||||||
|
|
||||||
@GET("api/v3/post/list")
|
@GET("api/v3/post/list?sort=New")
|
||||||
Call<LemmyPost.LemmyPosts> getLemmyMain(@Query("limit") Integer limit,
|
Call<LemmyPost.LemmyPosts> getLemmyMain(@Query("limit") Integer limit,
|
||||||
@Query("page") String page);
|
@Query("page") String page);
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||||
rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true);
|
rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true);
|
||||||
//Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false
|
//Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false
|
||||||
if (max_id == null && !isViewInitialized && rememberPosition) {
|
if (max_id == null && !isViewInitialized && rememberPosition && 1 == 2) {
|
||||||
max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
|
max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
|
||||||
}
|
}
|
||||||
//Only fragment in main view pager should not have the view initialized
|
//Only fragment in main view pager should not have the view initialized
|
||||||
|
@ -358,7 +358,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||||
rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true);
|
rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true);
|
||||||
//Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false
|
//Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false
|
||||||
if (max_id == null && !isViewInitialized && rememberPosition) {
|
if (max_id == null && !isViewInitialized && rememberPosition && 1 == 2) {
|
||||||
max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
|
max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
|
||||||
}
|
}
|
||||||
if (search != null) {
|
if (search != null) {
|
||||||
|
@ -535,6 +535,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
} else if (max_id == null || Helper.compareTo(fetched_statuses.pagination.max_id, max_id) < 0 || timelineType.getValue().startsWith("TREND_")) {
|
} else if (max_id == null || Helper.compareTo(fetched_statuses.pagination.max_id, max_id) < 0 || timelineType.getValue().startsWith("TREND_")) {
|
||||||
max_id = fetched_statuses.pagination.max_id;
|
max_id = fetched_statuses.pagination.max_id;
|
||||||
}
|
}
|
||||||
|
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.LEMMY) {
|
||||||
|
max_id = fetched_statuses.pagination.max_id;
|
||||||
|
}
|
||||||
if (min_id == null || (fetched_statuses.pagination.min_id != null && Helper.compareTo(fetched_statuses.pagination.min_id, min_id) > 0)) {
|
if (min_id == null || (fetched_statuses.pagination.min_id != null && Helper.compareTo(fetched_statuses.pagination.min_id, min_id) > 0)) {
|
||||||
min_id = fetched_statuses.pagination.min_id;
|
min_id = fetched_statuses.pagination.min_id;
|
||||||
}
|
}
|
||||||
|
@ -577,7 +580,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
route(DIRECTION.REFRESH, true);
|
route(DIRECTION.REFRESH, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (statuses == null || statuses.statuses == null || statuses.statuses.size() == 0) {
|
if (initialStatus == null && (statuses == null || statuses.statuses == null || statuses.statuses.size() == 0)) {
|
||||||
binding.noAction.setVisibility(View.VISIBLE);
|
binding.noAction.setVisibility(View.VISIBLE);
|
||||||
return;
|
return;
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.ART) {
|
} else if (timelineType == Timeline.TimeLineEnum.ART) {
|
||||||
|
@ -623,6 +626,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
if (max_id == null || (statuses.pagination.max_id != null && Helper.compareTo(statuses.pagination.max_id, max_id) < 0) || timelineType.getValue().startsWith("TREND_")) {
|
if (max_id == null || (statuses.pagination.max_id != null && Helper.compareTo(statuses.pagination.max_id, max_id) < 0) || timelineType.getValue().startsWith("TREND_")) {
|
||||||
max_id = statuses.pagination.max_id;
|
max_id = statuses.pagination.max_id;
|
||||||
}
|
}
|
||||||
|
//For Lemmy pagination
|
||||||
|
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.LEMMY) {
|
||||||
|
max_id = statuses.pagination.max_id;
|
||||||
|
}
|
||||||
if (min_id == null || (statuses.pagination.min_id != null && Helper.compareTo(statuses.pagination.min_id, min_id) > 0)) {
|
if (min_id == null || (statuses.pagination.min_id != null && Helper.compareTo(statuses.pagination.min_id, min_id) > 0)) {
|
||||||
min_id = statuses.pagination.min_id;
|
min_id = statuses.pagination.min_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,14 +350,17 @@ public class TimelinesVM extends AndroidViewModel {
|
||||||
Integer limit) {
|
Integer limit) {
|
||||||
MastodonTimelinesService mastodonTimelinesService = initInstanceOnly(instance);
|
MastodonTimelinesService mastodonTimelinesService = initInstanceOnly(instance);
|
||||||
statusesMutableLiveData = new MutableLiveData<>();
|
statusesMutableLiveData = new MutableLiveData<>();
|
||||||
|
if (page == null) {
|
||||||
|
page = "1";
|
||||||
|
}
|
||||||
|
String finalPage = page;
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
||||||
Call<LemmyPost.LemmyPosts> lemmyPostsCall = null;
|
Call<LemmyPost.LemmyPosts> lemmyPostsCall = null;
|
||||||
Call<LemmyPost.LemmyComments> lemmyCommentsCall = null;
|
Call<LemmyPost.LemmyComments> lemmyCommentsCall = null;
|
||||||
if (post_id == null) {
|
if (post_id == null) {
|
||||||
lemmyPostsCall = mastodonTimelinesService.getLemmyMain(limit, page);
|
lemmyPostsCall = mastodonTimelinesService.getLemmyMain(limit, finalPage);
|
||||||
} else {
|
} else {
|
||||||
lemmyCommentsCall = mastodonTimelinesService.getLemmyThread(post_id, limit, page);
|
lemmyCommentsCall = mastodonTimelinesService.getLemmyThread(post_id, limit, finalPage);
|
||||||
}
|
}
|
||||||
Statuses statuses = new Statuses();
|
Statuses statuses = new Statuses();
|
||||||
if (lemmyPostsCall != null) {
|
if (lemmyPostsCall != null) {
|
||||||
|
@ -374,16 +377,9 @@ public class TimelinesVM extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
statuses.statuses = TimelineHelper.filterStatus(getApplication(), statusList, Timeline.TimeLineEnum.PUBLIC);
|
statuses.statuses = TimelineHelper.filterStatus(getApplication(), statusList, Timeline.TimeLineEnum.PUBLIC);
|
||||||
statuses.pagination = new Pagination();
|
statuses.pagination = new Pagination();
|
||||||
if (page == null) {
|
int pageInt = Integer.parseInt(finalPage);
|
||||||
statuses.pagination.min_id = "0";
|
statuses.pagination.min_id = finalPage;
|
||||||
statuses.pagination.max_id = "1";
|
statuses.pagination.max_id = String.valueOf((pageInt + 1));
|
||||||
} else {
|
|
||||||
int pageInt = Integer.parseInt(page);
|
|
||||||
statuses.pagination.min_id = page;
|
|
||||||
statuses.pagination.max_id = String.valueOf((pageInt + 1));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -403,12 +399,12 @@ public class TimelinesVM extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
statuses.statuses = TimelineHelper.filterStatus(getApplication(), statusList, Timeline.TimeLineEnum.PUBLIC);
|
statuses.statuses = TimelineHelper.filterStatus(getApplication(), statusList, Timeline.TimeLineEnum.PUBLIC);
|
||||||
statuses.pagination = new Pagination();
|
statuses.pagination = new Pagination();
|
||||||
if (page == null) {
|
if (finalPage == null) {
|
||||||
statuses.pagination.min_id = "0";
|
statuses.pagination.min_id = "0";
|
||||||
statuses.pagination.max_id = "1";
|
statuses.pagination.max_id = "1";
|
||||||
} else {
|
} else {
|
||||||
int pageInt = Integer.parseInt(page);
|
int pageInt = Integer.parseInt(finalPage);
|
||||||
statuses.pagination.min_id = page;
|
statuses.pagination.min_id = finalPage;
|
||||||
statuses.pagination.max_id = String.valueOf((pageInt + 1));
|
statuses.pagination.max_id = String.valueOf((pageInt + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue