mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Trying to access categorySet
This commit is contained in:
parent
fa060bb41e
commit
3a455418a3
1 changed files with 31 additions and 9 deletions
|
|
@ -29,6 +29,8 @@ public class MwVolleyApi {
|
||||||
private static final Gson GSON = new GsonBuilder().create();
|
private static final Gson GSON = new GsonBuilder().create();
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
|
protected HashSet<String> categorySet;
|
||||||
|
|
||||||
public MwVolleyApi(Context context) {
|
public MwVolleyApi(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
@ -135,19 +137,28 @@ public class MwVolleyApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class QueryResponse {
|
private class QueryResponse {
|
||||||
private Query query;
|
private Query query = new Query();
|
||||||
private Page page;
|
private Page page;
|
||||||
|
|
||||||
|
public QueryResponse() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "query=" + query.toString() + "\n" + page.printSet();
|
return "query=" + query.toString() + "\n" //page.printSet()
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Query {
|
private class Query {
|
||||||
private Page [] pages;
|
private Page [] pages;
|
||||||
|
|
||||||
|
public Query() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder("pages=" + "\n");
|
StringBuilder builder = new StringBuilder("pages=" + "\n");
|
||||||
|
|
@ -156,21 +167,31 @@ public class MwVolleyApi {
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
}
|
}
|
||||||
builder.replace(builder.length() - 1, builder.length(), "");
|
builder.replace(builder.length() - 1, builder.length(), "");
|
||||||
|
|
||||||
|
|
||||||
|
if (categorySet == null || categorySet.isEmpty()) {
|
||||||
|
Log.d("Set", "No category set");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.d("Set", categorySet.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Page {
|
private class Page {
|
||||||
private int pageid;
|
private int pageid;
|
||||||
private int ns;
|
private int ns;
|
||||||
private String title;
|
private String title;
|
||||||
private Category[] categories;
|
private Category[] categories;
|
||||||
private Category category;
|
private Category category;
|
||||||
|
|
||||||
private HashSet<String> categorySet = new HashSet<String>();
|
|
||||||
|
|
||||||
private String printSet() {
|
private String printSet() {
|
||||||
if (categorySet.isEmpty()) {
|
if (categorySet == null || categorySet.isEmpty()) {
|
||||||
return "No collection of categories";
|
return "No collection of categories";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -180,12 +201,13 @@ public class MwVolleyApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
categorySet = new HashSet<String>();
|
||||||
StringBuilder builder = new StringBuilder("PAGEID=" + pageid + " ns=" + ns + " title=" + title + "\n" + " CATEGORIES= ");
|
StringBuilder builder = new StringBuilder("PAGEID=" + pageid + " ns=" + ns + " title=" + title + "\n" + " CATEGORIES= ");
|
||||||
|
|
||||||
if (categories == null || categories.length == 0) {
|
if (categories == null || categories.length == 0) {
|
||||||
builder.append("no categories exist\n");
|
builder.append("no categories exist\n");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
for (Category category : categories) {
|
for (Category category : categories) {
|
||||||
builder.append(category.toString());
|
builder.append(category.toString());
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue