Nextrek
@ 11
Nextrek / Android / Minstrek / MinstrekLib / src / nextrek / minstrek / core / PageModel.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
package nextrek.minstrek.core; import java.util.ArrayList; import java.util.Locale; import org.json.JSONException; import org.json.JSONObject; public class PageModel { String text; String topImage; ArrayList<ButtonModel> buttons = new ArrayList<ButtonModel>(); public PageModel(JSONObject jsonData) { this.text = jsonData.optString("text"); this.topImage = jsonData.optString("topImage"); if (this.topImage != null) { this.topImage = this.topImage.toLowerCase(Locale.ENGLISH); this.topImage = this.topImage.replaceAll("à", "a"); this.topImage = this.topImage.replaceAll("è", "e"); this.topImage = this.topImage.replaceAll("é", "e"); this.topImage = this.topImage.replaceAll("ì", "i"); this.topImage = this.topImage.replaceAll("ò", "o"); this.topImage = this.topImage.replaceAll("ù", "u"); } int buttonCount = jsonData.optInt("buttons"); for (int i = 0; i < buttonCount; i++) { try { buttons.add(new ButtonModel(jsonData.getJSONObject("button" + i))); } catch (JSONException e) { e.printStackTrace(); } } } public String getText() { return this.text; } public String getTopImage() { return this.topImage; } public ArrayList<ButtonModel> getButtons() { return this.buttons; } } |