From eb134344716a82751b24fcb8da498a5df32994d9 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 17:10:27 +0300 Subject: [PATCH] Format and refactor ContentsJsonParser --- .../wikivoyage/data/ContentsJsonParser.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java index 8852c3a5a3..a6686934cd 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/ContentsJsonParser.java @@ -1,6 +1,6 @@ package net.osmand.plus.wikivoyage.data; -import android.content.Context; +import android.support.annotation.Nullable; import org.json.JSONArray; import org.json.JSONException; @@ -10,15 +10,15 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; - class ContentsJsonParser { - static ContentsContainer parseJsonContents(String contentsJson, Context context) { - LinkedHashMap map = new LinkedHashMap(); - ArrayList listDataHeader = new ArrayList(); - LinkedHashMap> listDataChild = new LinkedHashMap>(); + @Nullable + static ContentsContainer parseJsonContents(String contentsJson) { + LinkedHashMap map = new LinkedHashMap<>(); + ArrayList listDataHeader = new ArrayList<>(); + LinkedHashMap> listDataChild = new LinkedHashMap<>(); - JSONObject reader = null; + JSONObject reader; try { reader = new JSONObject(contentsJson); } catch (JSONException e) { @@ -38,11 +38,11 @@ class ContentsJsonParser { if (level == 2) { listDataHeader.add(reader.names().getString(i)); - secondLevel = new ArrayList(); + secondLevel = new ArrayList<>(); } if (level == 3) { if (secondLevel == null) { - secondLevel = new ArrayList(); + secondLevel = new ArrayList<>(); } secondLevel.add(reader.names().getString(i)); listDataChild.put(listDataHeader.get(listDataHeader.size() - 1), secondLevel); @@ -60,12 +60,12 @@ class ContentsJsonParser { public ArrayList listDataHeader; public LinkedHashMap> listDataChild; - public ContentsContainer(LinkedHashMap map, ArrayList listDataHeader, - LinkedHashMap> listChildData) { + ContentsContainer(LinkedHashMap map, + ArrayList listDataHeader, + LinkedHashMap> listChildData) { this.map = map; this.listDataHeader = listDataHeader; this.listDataChild = listChildData; } - } }