Android Open Source - pinpoint-android User

From Project

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.

Java Source Code

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();

        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));

    if (null != secondHomescreenId) {
      intValue = secondHomescreenId.intValue();

      this.taskLogs.put(secondHomescreenId, new TaskLog(intValue));
      this.taskManagers.put(secondHomescreenId, new TaskManager(intValue));

    if (null != thirdHomescreenId) {
      intValue = thirdHomescreenId.intValue();

      this.taskLogs.put(thirdHomescreenId, new TaskLog(intValue));
      this.taskManagers.put(thirdHomescreenId, new TaskManager(intValue));

    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()) {

      jsonObject.put("logs", taskLogs);
    } catch (JSONException exception) {
      Pinpoint.log("Could not create JSONObject from User.");

    return jsonObject;

Java Source Code List