Simplify comparators (#181)

This commit is contained in:
Kavin 2022-02-03 11:29:59 +00:00 committed by GitHub
parent 3748afdd72
commit 8ba39000b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import java.io.IOException;
public class LbryHelper { public class LbryHelper {
public static String getLBRYId(String videoId) throws IOException, InterruptedException { public static String getLBRYId(String videoId) throws IOException {
return new JSONObject( return new JSONObject(
RequestUtils.sendGet("https://api.lbry.com/yt/resolve?video_ids=" + URLUtils.silentEncode(videoId)) RequestUtils.sendGet("https://api.lbry.com/yt/resolve?video_ids=" + URLUtils.silentEncode(videoId))
).getJSONObject("data").getJSONObject("videos").optString(videoId, null); ).getJSONObject("data").getJSONObject("videos").optString(videoId, null);

View File

@ -727,7 +727,7 @@ public class ResponseHelper {
}); });
feedItems.sort((a, b) -> (int) (b.uploaded - a.uploaded)); feedItems.sort(Comparator.comparing(o -> ((FeedItem) o).uploaded).reversed());
s.close(); s.close();
@ -764,7 +764,7 @@ public class ResponseHelper {
.setParameter("user", user.getId()).addEntity("Video", Video.class) .setParameter("user", user.getId()).addEntity("Video", Video.class)
.addEntity("Channel", me.kavin.piped.utils.obj.db.Channel.class).getResultList(); .addEntity("Channel", me.kavin.piped.utils.obj.db.Channel.class).getResultList();
queryResults.sort((a, b) -> (int) (((Video) b[0]).getUploaded() - ((Video) a[0]).getUploaded())); queryResults.sort(Comparator.comparing(o -> ((Video) (((Object[]) o)[0])).getUploaded()).reversed());
final List<SyndEntry> entries = new ObjectArrayList<>(); final List<SyndEntry> entries = new ObjectArrayList<>();