mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Hidden categories are not showed in suggested categories (#3853)
This commit is contained in:
parent
8630ba8025
commit
67beb947c5
3 changed files with 20 additions and 3 deletions
|
|
@ -92,8 +92,9 @@ class CategoryClient @Inject constructor(private val categoryInterface: Category
|
||||||
it.query()?.pages() ?: emptyList()
|
it.query()?.pages() ?: emptyList()
|
||||||
}
|
}
|
||||||
.map {
|
.map {
|
||||||
it.map { page -> page.title().replace(CATEGORY_PREFIX, "") }
|
it.filter {
|
||||||
|
page -> page.categoryInfo() == null || !page.categoryInfo().isHidden
|
||||||
|
}.map { page -> page.title().replace(CATEGORY_PREFIX, "") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public interface CategoryInterface {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GET("w/api.php?action=query&format=json&formatversion=2"
|
@GET("w/api.php?action=query&format=json&formatversion=2"
|
||||||
+ "&generator=allcategories")
|
+ "&generator=allcategories&prop=categoryinfo")
|
||||||
Single<MwQueryResponse> searchCategoriesForPrefix(@Query("gacprefix") String prefix,
|
Single<MwQueryResponse> searchCategoriesForPrefix(@Query("gacprefix") String prefix,
|
||||||
@Query("gaclimit") int itemLimit, @Query("gacoffset") int offset);
|
@Query("gaclimit") int itemLimit, @Query("gacoffset") int offset);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ public class MwQueryPage extends BaseModel {
|
||||||
@SuppressWarnings("unused") private int ns;
|
@SuppressWarnings("unused") private int ns;
|
||||||
@SuppressWarnings("unused") private int index;
|
@SuppressWarnings("unused") private int index;
|
||||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String title;
|
@SuppressWarnings("unused,NullableProblems") @NonNull private String title;
|
||||||
|
@SuppressWarnings("unused,NullableProblems") @NonNull private CategoryInfo categoryinfo;
|
||||||
@SuppressWarnings("unused") @Nullable private List<LangLink> langlinks;
|
@SuppressWarnings("unused") @Nullable private List<LangLink> langlinks;
|
||||||
@SuppressWarnings("unused") @Nullable private List<Revision> revisions;
|
@SuppressWarnings("unused") @Nullable private List<Revision> revisions;
|
||||||
@SuppressWarnings("unused") @Nullable private List<Coordinates> coordinates;
|
@SuppressWarnings("unused") @Nullable private List<Coordinates> coordinates;
|
||||||
|
|
@ -42,6 +43,10 @@ public class MwQueryPage extends BaseModel {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull public CategoryInfo categoryInfo() {
|
||||||
|
return categoryinfo;
|
||||||
|
}
|
||||||
|
|
||||||
public int index() {
|
public int index() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
@ -185,6 +190,17 @@ public class MwQueryPage extends BaseModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class CategoryInfo {
|
||||||
|
@SuppressWarnings("unused") private boolean hidden;
|
||||||
|
@SuppressWarnings("unused") private int size;
|
||||||
|
@SuppressWarnings("unused") private int pages;
|
||||||
|
@SuppressWarnings("unused") private int files;
|
||||||
|
@SuppressWarnings("unused") private int subcats;
|
||||||
|
public boolean isHidden() {
|
||||||
|
return hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class Thumbnail {
|
static class Thumbnail {
|
||||||
@SuppressWarnings("unused") private String source;
|
@SuppressWarnings("unused") private String source;
|
||||||
@SuppressWarnings("unused") private int width;
|
@SuppressWarnings("unused") private int width;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue