Skip to content

Commit d442d95

Browse files
committed
searchfilters: Make YoutubeSearchQueryHandlerFactory singleton
Singleton to get the same objects of filters during search. The content filter holds a variable search parameter: (filter.getParams()) -> we need the same set of objects
1 parent 95f05c4 commit d442d95

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,21 @@ public final class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFa
2626

2727
private final YoutubeFilters searchFilters = new YoutubeFilters();
2828

29+
private static YoutubeSearchQueryHandlerFactory instance = null;
30+
31+
/**
32+
* Singleton to get the same objects of filters during search.
33+
*
34+
* The content filter holds a variable search parameter: (filter.getParams())
35+
*
36+
* @return
37+
*/
2938
@Nonnull
30-
public static YoutubeSearchQueryHandlerFactory getInstance() {
31-
return new YoutubeSearchQueryHandlerFactory();
39+
public static synchronized YoutubeSearchQueryHandlerFactory getInstance() {
40+
if (instance == null) {
41+
instance = new YoutubeSearchQueryHandlerFactory();
42+
}
43+
return instance;
3244
}
3345

3446
@Override

0 commit comments

Comments
 (0)