Last active
August 29, 2015 14:22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.funnythingz.iroiro.domain; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import java.util.ArrayList; | |
public class ColorsFactory { | |
protected JSONObject mJsonObject; | |
public ColorsFactory(JSONObject jsonObject) { | |
mJsonObject = jsonObject; | |
} | |
public ArrayList<Color> createColors() throws JSONException { | |
JSONArray colorsJsonArray = mJsonObject.getJSONArray("color_list"); | |
ArrayList<Color> colorsArrayList = new ArrayList<Color>(); | |
int len = colorsJsonArray.length(); | |
for(int i = 0; i < len; i++) { | |
JSONObject color = colorsJsonArray.getJSONObject(i); | |
int colorId = color.getInt("id"); | |
String colorName = color.getString("name"); | |
String colorCode = color.getString("code"); | |
String colorTextCode = color.getString("text_code"); | |
colorsArrayList.add(new Color(colorName, colorCode, colorTextCode)); | |
} | |
return colorsArrayList; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.funnythingz.iroiro.domain; | |
import org.json.JSONObject; | |
public class Color { | |
public String name; | |
public String code; | |
public String textCode; | |
public Color(String name, String code, String textCode) { | |
this.name = name; | |
this.code = code; | |
this.textCode = textCode; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment