Commit 2dfb54dd authored by Thomas's avatar Thomas
Browse files

- Fix #1345 - Add Mastodon trending remote as pinnable timeline

parent cac96974
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -197,6 +197,8 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart
                        .build();
                if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) {
                    url = "https://" + instanceName + "/api/v1/timelines/public?local=true";
                } else if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.mastodon_trending_instance) {
                    url = "https://" + instanceName + "/api/v1/trends/statuses";
                } else if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.peertube_instance) {
                    url = "https://" + instanceName + "/api/v1/videos/";
                } else if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) {
@@ -249,6 +251,8 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart
                                    RemoteInstance.InstanceType instanceType = null;
                                    if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) {
                                        instanceType = RemoteInstance.InstanceType.MASTODON;
                                    } else if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.mastodon_trending_instance) {
                                        instanceType = RemoteInstance.InstanceType.MASTODON_TRENDING;
                                    } else if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.peertube_instance) {
                                        instanceType = RemoteInstance.InstanceType.PEERTUBE;
                                    } else if (popupSearchInstanceBinding.setAttachmentGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) {
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ public class RemoteInstance implements Serializable {
    public enum InstanceType {
        @SerializedName("MASTODON")
        MASTODON("MASTODON"),
        @SerializedName("MASTODON_TRENDING")
        MASTODON_TRENDING("MASTODON_TRENDING"),
        @SerializedName("PIXELFED")
        PIXELFED("PIXELFED"),
        @SerializedName("PEERTUBE")
+6 −0
Original line number Diff line number Diff line
@@ -407,6 +407,9 @@ public class PinnedTimelineHelper {
                                case MASTODON:
                                    tabCustomViewBinding.icon.setImageResource(R.drawable.mastodon_icon_item);
                                    break;
                                case MASTODON_TRENDING:
                                    tabCustomViewBinding.icon.setImageResource(R.drawable.ic_baseline_trending_up_24);
                                    break;
                                case LEMMY:
                                    tabCustomViewBinding.icon.setImageResource(R.drawable.lemmy);
                                    break;
@@ -506,6 +509,9 @@ public class PinnedTimelineHelper {
                            case MASTODON:
                                item.setIcon(R.drawable.mastodon_icon_item);
                                break;
                            case MASTODON_TRENDING:
                                item.setIcon(R.drawable.ic_baseline_trending_up_24);
                                break;
                            case PEERTUBE:
                                item.setIcon(R.drawable.peertube_icon);
                                break;
+3 −0
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ public class ReorderTabAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
                    case MASTODON:
                        holder.binding.icon.setImageResource(R.drawable.mastodon_icon_item);
                        break;
                    case MASTODON_TRENDING:
                        holder.binding.icon.setImageResource(R.drawable.ic_baseline_trending_up_24);
                        break;
                    case PIXELFED:
                        holder.binding.icon.setImageResource(R.drawable.pixelfed);
                        break;
+11 −1
Original line number Diff line number Diff line
@@ -1158,6 +1158,16 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
                } else {
                    binding.swipeContainer.setRefreshing(false);
                }
            } else if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.MASTODON_TRENDING) {
                if (direction == null) {
                    timelinesVM.getStatusTrends(null, remoteInstance, null, MastodonHelper.statusesPerCall(requireActivity()))
                            .observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
                } else if (direction == DIRECTION.BOTTOM) {
                    timelinesVM.getStatusTrends(null, remoteInstance, max_id, MastodonHelper.statusesPerCall(requireActivity()))
                            .observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false, true, fetchStatus));
                } else {
                    flagLoading = false;
                }
            } else { //Other remote timelines
                routeCommon(direction, fetchingMissing, fetchStatus);
            }
Loading