Back to project page pinpoint-android.
The source code is released under:
MIT License
If you think the Android project pinpoint-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package co.islovely.pinpoint; // w w w. j av a 2 s . c o m import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class User { public static final String TYPE_USER = "user", TYPE_ATTACKER = "attacker"; private List<Integer> homescreenIds; private Map<Integer, TaskLog> taskLogs; private Map<Integer, TaskManager> taskManagers; private String type; public User(String type) { this.taskLogs = new HashMap<Integer, TaskLog>(); this.taskManagers = new HashMap<Integer, TaskManager>(); this.homescreenIds = new ArrayList<Integer>(); Configuration configuration = Configuration.getInstance(); Integer firstHomescreenId = configuration.getFirstHomescreenId(), secondHomescreenId = configuration.getSecondHomescreenId(), thirdHomescreenId = configuration.getThirdHomescreenId(); int intValue; if (null != firstHomescreenId) { intValue = firstHomescreenId.intValue(); this.taskLogs.put(firstHomescreenId, new TaskLog(intValue)); this.taskManagers.put(firstHomescreenId, new TaskManager(intValue)); this.homescreenIds.add(firstHomescreenId); } if (null != secondHomescreenId) { intValue = secondHomescreenId.intValue(); this.taskLogs.put(secondHomescreenId, new TaskLog(intValue)); this.taskManagers.put(secondHomescreenId, new TaskManager(intValue)); this.homescreenIds.add(secondHomescreenId); } if (null != thirdHomescreenId) { intValue = thirdHomescreenId.intValue(); this.taskLogs.put(thirdHomescreenId, new TaskLog(intValue)); this.taskManagers.put(thirdHomescreenId, new TaskManager(intValue)); this.homescreenIds.add(thirdHomescreenId); } this.type = type; } public List<Integer> getHomescreenIds() { return this.homescreenIds; } public TaskLog getTaskLog() { return this.taskLogs.get(this.homescreenIds.get(0)); } public TaskManager getTaskManager() { return this.taskManagers.get(this.homescreenIds.get(0)); } public JSONObject toJSONObject() { JSONObject jsonObject = new JSONObject(); JSONArray taskLogs = new JSONArray(); try { jsonObject.put("type", this.type); for (Integer key : this.taskLogs.keySet()) { taskLogs.put(this.taskLogs.get(key).toJSONObject()); } jsonObject.put("logs", taskLogs); } catch (JSONException exception) { Pinpoint.log("Could not create JSONObject from User."); } return jsonObject; } }