cleaned some code

This commit is contained in:
Chumva 2018-04-13 18:28:25 +03:00
parent 6169fe89d0
commit cf77d0b445
2 changed files with 17 additions and 17 deletions

View file

@ -60,16 +60,16 @@ public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFrag
final LinkedHashMap<String, List<String>> listDataChild = new LinkedHashMap<String, List<String>>();
map = new LinkedHashMap<>();
for (int i = 0; i < contentsContainer.getChilds().size(); i++) {
WikivoyageJsonParser.ContentsContainer Header = contentsContainer.getChilds().get(i);
for (int i = 0; i < contentsContainer.getChildItems().size(); i++) {
WikivoyageJsonParser.ContentsContainer Header = contentsContainer.getChildItems().get(i);
listDataHeader.add(Header.getName());
map.put(Header.getName(), Header.getLink());
if (Header.getChilds() != null && !Header.getChilds().isEmpty()) {
if (Header.getChildItems() != null && !Header.getChildItems().isEmpty()) {
ArrayList<String> subHeaders = new ArrayList<>();
for (int j = 0; j < Header.getChilds().size(); j++) {
WikivoyageJsonParser.ContentsContainer subHeader = Header.getChilds().get(j);
for (int j = 0; j < Header.getChildItems().size(); j++) {
WikivoyageJsonParser.ContentsContainer subHeader = Header.getChildItems().get(j);
subHeaders.add(subHeader.getName());
map.put(subHeader.getName(), subHeader.getLink());
}

View file

@ -36,7 +36,7 @@ public class WikivoyageJsonParser {
JSONObject jsonHeader = jArray.getJSONObject(jArray.names().getString(i));
link = jsonHeader.getString(LINK);
ContentsContainer contentsHeaderContainer = new ContentsContainer(jArray.names().getString(i), link);
topContentsContainer.childs.add(contentsHeaderContainer);
topContentsContainer.childItems.add(contentsHeaderContainer);
contentsHeaderContainer.setParent(topContentsContainer);
JSONArray jsonSubheaders = jsonHeader.getJSONArray(SUBHEADERS);
@ -51,7 +51,7 @@ public class WikivoyageJsonParser {
link = jsonSubheaderLink.getString(LINK);
ContentsContainer contentsSubHeaderContainer = new ContentsContainer(jsonSubheader.names().getString(0), link);
contentsHeaderContainer.childs.add(contentsSubHeaderContainer);
contentsHeaderContainer.childItems.add(contentsSubHeaderContainer);
contentsSubHeaderContainer.setParent(topContentsContainer);
}
} catch (JSONException e) {
@ -63,18 +63,23 @@ public class WikivoyageJsonParser {
public static class ContentsContainer {
ArrayList<ContentsContainer> childs = new ArrayList<>();
ArrayList<ContentsContainer> childItems = new ArrayList<>();
ContentsContainer parent;
String name;
String link;
public ArrayList<ContentsContainer> getChilds() {
return childs;
public ContentsContainer(String name, String link) {
this.name = name;
this.link = link;
}
public void setChilds(ArrayList<ContentsContainer> childs) {
this.childs = childs;
public ArrayList<ContentsContainer> getChildItems() {
return childItems;
}
public void setChildItems(ArrayList<ContentsContainer> childItems) {
this.childItems = childItems;
}
@ -101,10 +106,5 @@ public class WikivoyageJsonParser {
public void setParent(ContentsContainer parent) {
this.parent = parent;
}
public ContentsContainer(String name, String link) {
this.name = name;
this.link = link;
}
}
}