Skip to content

Commit

Permalink
Revert Use stream sorting
Browse files Browse the repository at this point in the history
remove the kotlin-android-extension's android experimental extension block for build to succeed
  • Loading branch information
ShareASmile committed Jun 17, 2024
1 parent 1743c1f commit 2eff73c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 0 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ android {
jvmTarget = JavaVersion.VERSION_11
}

// Required and used only by groupie
androidExtensions {
experimental = true
}

sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
import org.schabi.newpipelegacy.database.LocalItem;
import org.schabi.newpipelegacy.database.playlist.model.PlaylistRemoteEntity;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public interface PlaylistLocalItem extends LocalItem {
String getOrderingName();

static List<PlaylistLocalItem> merge(
final List<PlaylistMetadataEntry> localPlaylists,
final List<PlaylistRemoteEntity> remotePlaylists) {
return Stream.concat(localPlaylists.stream(), remotePlaylists.stream())
.sorted(Comparator.comparing(PlaylistLocalItem::getOrderingName,
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)))
.collect(Collectors.toList());
final List<PlaylistLocalItem> items = new ArrayList<>(
localPlaylists.size() + remotePlaylists.size());
items.addAll(localPlaylists);
items.addAll(remotePlaylists);

Collections.sort(items, Comparator.comparing(PlaylistLocalItem::getOrderingName,
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)));

return items;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
import org.schabi.newpipelegacy.util.external_communication.ShareUtils;
import org.schabi.newpipelegacy.util.external_communication.TextLinkifier;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import icepick.State;
import io.reactivex.rxjava3.disposables.CompositeDisposable;

Expand Down Expand Up @@ -201,7 +205,9 @@ private void addMetadataItem(final LayoutInflater inflater,
}

private void addTagsMetadataItem(final LayoutInflater inflater, final LinearLayout layout) {
if (streamInfo.getTags() != null && !streamInfo.getTags().isEmpty()) {
final List<String> tags = new ArrayList<>(streamInfo.getTags());
Collections.sort(tags);
for (final String tag : tags) {
final ItemMetadataTagsBinding itemBinding =
ItemMetadataTagsBinding.inflate(inflater, layout, false);

Expand All @@ -212,7 +218,7 @@ private void addTagsMetadataItem(final LayoutInflater inflater, final LinearLayo
chip.setOnClickListener(this::onTagClick);
chip.setOnLongClickListener(this::onTagLongClick);
itemBinding.metadataTagsChips.addView(chip);
});
}

layout.addView(itemBinding.getRoot());
}
Expand Down

0 comments on commit 2eff73c

Please sign in to comment.