Manage Peertube videos

This commit is contained in:
Thomas 2022-06-28 16:45:58 +02:00
parent a48f997ae3
commit 1b8211a341
3 changed files with 13 additions and 18 deletions

View file

@ -141,10 +141,8 @@ public class MisskeyNote implements Serializable {
public boolean remote = false;
@SerializedName("reply")
public boolean reply = false;
@SerializedName("max_id")
public String max_id;
@SerializedName("since_id")
public String since_id;
@SerializedName("untilId")
public String untilId;
@SerializedName("limit")
public int limit;
}

View file

@ -649,16 +649,15 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
}//MISSKEY TIMELINES
else if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.MISSKEY) {
if (direction == null) {
timelinesVM.getMisskey(remoteInstance, null, null, MastodonHelper.statusesPerCall(requireActivity()))
timelinesVM.getMisskey(remoteInstance, null, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
} else if (direction == DIRECTION.BOTTOM) {
timelinesVM.getMisskey(remoteInstance, max_id, null, MastodonHelper.statusesPerCall(requireActivity()))
timelinesVM.getMisskey(remoteInstance, max_id, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false));
} else if (direction == DIRECTION.TOP) {
timelinesVM.getMisskey(remoteInstance, null, fetchingMissing ? min_id_fetch_more : min_id, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.TOP, fetchingMissing));
flagLoading = false;
} else if (direction == DIRECTION.REFRESH) {
timelinesVM.getMisskey(remoteInstance, null, null, MastodonHelper.statusesPerCall(requireActivity()))
timelinesVM.getMisskey(remoteInstance, null, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statusesRefresh -> {
if (statusAdapter != null) {
dealWithPagination(statusesRefresh, DIRECTION.REFRESH, true);
@ -674,7 +673,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
timelinesVM.getPeertube(remoteInstance, null, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
} else if (direction == DIRECTION.BOTTOM) {
timelinesVM.getPeertube(remoteInstance, max_id, MastodonHelper.statusesPerCall(requireActivity()))
timelinesVM.getPeertube(remoteInstance, String.valueOf(statuses.size()), MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false));
} else if (direction == DIRECTION.TOP) {
flagLoading = false;

View file

@ -150,21 +150,18 @@ public class TimelinesVM extends AndroidViewModel {
/**
* Public timeline for Misskey
*
* @param maxId Return results older than this id
* @param sinceId Return results newer than this id
* @param untilId Return results older than this id
* @param limit Maximum number of results to return. Defaults to 20.
* @return {@link LiveData} containing a {@link Statuses}
*/
public LiveData<Statuses> getMisskey(@NonNull String instance,
String maxId,
String sinceId,
String untilId,
Integer limit) {
MastodonTimelinesService mastodonTimelinesService = initInstanceOnly(instance);
statusesMutableLiveData = new MutableLiveData<>();
new Thread(() -> {
MisskeyNote.MisskeyParams misskeyParams = new MisskeyNote.MisskeyParams();
misskeyParams.max_id = maxId;
misskeyParams.since_id = sinceId;
misskeyParams.untilId = untilId;
misskeyParams.limit = limit;
Call<List<MisskeyNote>> publicTlCall = mastodonTimelinesService.getMisskey(misskeyParams);
Statuses statuses = new Statuses();
@ -231,8 +228,9 @@ public class TimelinesVM extends AndroidViewModel {
statuses.statuses = SpannableHelper.convertStatus(getApplication().getApplicationContext(), filteredStatuses);
statuses.pagination = new Pagination();
if (statusList.size() > 0) {
statuses.pagination.min_id = statusList.get(0).id;
statuses.pagination.max_id = statusList.get(statusList.size() - 1).id;
//These values are not used.
statuses.pagination.min_id = null;
statuses.pagination.max_id = null;
}
}
} catch (Exception e) {