Android Open Source - pinpoint-android User






From Project

Back to project page pinpoint-android.

License

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

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




Java Source Code List

co.islovely.pinpoint.ColumnsActivity.java
co.islovely.pinpoint.Configuration.java
co.islovely.pinpoint.DeviceMetrics.java
co.islovely.pinpoint.GridActivity.java
co.islovely.pinpoint.HomescreenAdapter.java
co.islovely.pinpoint.HomescreenSelectActivity.java
co.islovely.pinpoint.Homescreen.java
co.islovely.pinpoint.IntermissionActivity.java
co.islovely.pinpoint.LauncherItem.java
co.islovely.pinpoint.LauncherReader.java
co.islovely.pinpoint.LayoutConfigurationActivity.java
co.islovely.pinpoint.MainActivity.java
co.islovely.pinpoint.MyApplication.java
co.islovely.pinpoint.PinpointActivity.java
co.islovely.pinpoint.Pinpoint.java
co.islovely.pinpoint.QuadrantsActivity.java
co.islovely.pinpoint.RowsActivity.java
co.islovely.pinpoint.StatisticsActivity.java
co.islovely.pinpoint.TaskLogEntry.java
co.islovely.pinpoint.TaskLog.java
co.islovely.pinpoint.TaskManager.java
co.islovely.pinpoint.Task.java
co.islovely.pinpoint.User.java
util.Base64.java