Skip to content

Commit

Permalink
Fix Kiosk-List ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
litetex committed Apr 22, 2022
1 parent a257ec5 commit 441e4b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.schabi.newpipe.extractor.kiosk;

import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;

import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
Expand All @@ -8,13 +10,13 @@
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.localization.Localization;

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import javax.annotation.Nullable;

public class KioskList {

Expand All @@ -26,7 +28,8 @@ KioskExtractor createNewKiosk(StreamingService streamingService,
}

private final StreamingService service;
private final HashMap<String, KioskEntry> kioskList = new HashMap<>();
// Use a linked hash map to keep track of the order
private final HashMap<String, KioskEntry> kioskList = new LinkedHashMap<>();
private String defaultKiosk = null;

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,24 @@ public SuggestionExtractor getSuggestionExtractor() {
public KioskList getKioskList() {
final KioskList list = new KioskList(this);

// add kiosks here e.g.:
list.addKioskEntry(
(streamingService, url, kioskId) -> new MediaCCCConferenceKiosk(
(streamingService, url, kioskId) -> new MediaCCCRecentKiosk(
MediaCCCService.this,
new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url),
new MediaCCCRecentListLinkHandlerFactory().fromUrl(url),
kioskId
),
new MediaCCCConferencesListLinkHandlerFactory(),
"conferences"
new MediaCCCRecentListLinkHandlerFactory(),
"recent"
);

list.addKioskEntry(
(streamingService, url, kioskId) -> new MediaCCCRecentKiosk(
(streamingService, url, kioskId) -> new MediaCCCConferenceKiosk(
MediaCCCService.this,
new MediaCCCRecentListLinkHandlerFactory().fromUrl(url),
new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url),
kioskId
),
new MediaCCCRecentListLinkHandlerFactory(),
"recent"
new MediaCCCConferencesListLinkHandlerFactory(),
"conferences"
);

list.addKioskEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public KioskList getKioskList() {

final InvidiousTrendingLinkHandlerFactory lhf =
new InvidiousTrendingLinkHandlerFactory(InvidiousService.this);
list.addKioskEntry(kioskFactory, lhf, InvidiousTrendingLinkHandlerFactory.KIOSK_POPULAR);
list.addKioskEntry(kioskFactory, lhf, InvidiousTrendingLinkHandlerFactory.KIOSK_TRENDING);
list.addKioskEntry(kioskFactory, lhf, InvidiousTrendingLinkHandlerFactory.KIOSK_POPULAR);
list.setDefaultKiosk(InvidiousTrendingLinkHandlerFactory.KIOSK_TRENDING);

return list;
Expand Down

0 comments on commit 441e4b1

Please sign in to comment.