Android Open Source - CriminalIntent Crime






From Project

Back to project page CriminalIntent.

License

The source code is released under:

MIT License

If you think the Android project CriminalIntent 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 com.ambergleam.criminalintent.model;
/*  w  w  w .  j a v a2  s .  co m*/
import java.util.Date;
import java.util.UUID;

import org.json.JSONException;
import org.json.JSONObject;

public class Crime {

  private static final String JSON_ID = "id";
  private static final String JSON_TITLE = "title";
  private static final String JSON_SOLVED = "solved";
  private static final String JSON_DATE = "date";
  private static final String JSON_SUSPECT = "suspect";
  
  private UUID mId;
  private String mTitle;
  private Date mDate;
  private boolean mSolved;
  private String mSuspect;

  public Crime() {
    // Generate unique identifier
    mId = UUID.randomUUID();
    mDate = new Date();
  }
  
  public Crime(JSONObject json) throws JSONException {
    mId = UUID.fromString(json.getString(JSON_ID));
    if (json.has(JSON_TITLE)) {
      mTitle = json.getString(JSON_TITLE);
    }
    mSolved = json.getBoolean(JSON_SOLVED);
    mDate = new Date(json.getLong(JSON_DATE));
    
    if (json.has(JSON_SUSPECT))
      mSuspect = json.getString(JSON_SUSPECT);
  }
  
  public JSONObject toJSON() throws JSONException {
    JSONObject json = new JSONObject();
    json.put(JSON_ID, mId.toString());
    json.put(JSON_TITLE, mTitle);
    json.put(JSON_SOLVED, mSolved);
    json.put(JSON_DATE, mDate.getTime());
    json.put(JSON_SUSPECT, mSuspect);
    return json;
  }

  public UUID getId() {
    return mId;
  }

  public String getTitle() {
    return mTitle;
  }

  public void setTitle(String mTitle) {
    this.mTitle = mTitle;
  }

  public Date getDate() {
    return mDate;
  }

  public void setDate(Date mDate) {
    this.mDate = mDate;
  }

  public boolean isSolved() {
    return mSolved;
  }

  public void setSolved(boolean mSolved) {
    this.mSolved = mSolved;
  }
  
  @Override
  public String toString() {
    return mTitle;
  }

  public String getSuspect() {
    return mSuspect;
  }

  public void setSuspect(String mSuspect) {
    this.mSuspect = mSuspect;
  }

}




Java Source Code List

com.ambergleam.criminalintent.controller.CrimeFragment.java
com.ambergleam.criminalintent.controller.CrimeListActivity.java
com.ambergleam.criminalintent.controller.CrimeListFragment.java
com.ambergleam.criminalintent.controller.CrimePagerActivity.java
com.ambergleam.criminalintent.controller.DatePickerFragment.java
com.ambergleam.criminalintent.helper.CriminalIntentJSONSerializer.java
com.ambergleam.criminalintent.helper.SingleFragmentActivity.java
com.ambergleam.criminalintent.model.CrimeLab.java
com.ambergleam.criminalintent.model.Crime.java