Android Open Source - trivial-lists Item






From Project

Back to project page trivial-lists.

License

The source code is released under:

MIT License

If you think the Android project trivial-lists 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 org.hbabcock.triviallists;
/* www .j  a  va  2s  .  c  o  m*/
import java.util.UUID;

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

public class Item {
  private static final String JSON_CATEGORY_ID = "category_id";
  private static final String JSON_COUNT = "count";
  private static final String JSON_ID = "id";
  private static final String JSON_NAME = "name";

  private UUID mCategoryId;
  private int mCount;
  private UUID mId;
  private String mName;

  public Item(String name, Category c){
    mCategoryId = c.getId();
    mCount = 0;
    mId = UUID.randomUUID();
    mName = name;
  }

  public Item(JSONObject json) throws JSONException {
    mCategoryId = UUID.fromString(json.getString(JSON_CATEGORY_ID));
    mCount = json.getInt(JSON_COUNT);
    mId = UUID.fromString(json.getString(JSON_ID));
    mName = json.getString(JSON_NAME);
  }

  public UUID getCategoryId(){
    return mCategoryId;
  }
  
  public int getCount(){
    return mCount;
  }

  public UUID getId(){
    return mId;
  }

  public String getName(){
    return mName;
  }

  public void setCount(int count){
    mCount = count;
  }

  public void setName(String name){
    mName = name;
  }
  
  public JSONObject toJSON() throws JSONException {
    JSONObject json = new JSONObject();
    json.put(JSON_CATEGORY_ID, mCategoryId.toString());
    json.put(JSON_COUNT, mCount);
    json.put(JSON_ID, mId.toString());
    json.put(JSON_NAME, mName);
    return json;
  }

}




Java Source Code List

org.hbabcock.triviallists.CategoryActivity.java
org.hbabcock.triviallists.CategoryDeleteDialog.java
org.hbabcock.triviallists.CategoryFragment.java
org.hbabcock.triviallists.CategoryItemManager.java
org.hbabcock.triviallists.Category.java
org.hbabcock.triviallists.GenericEditorDialogFragment.java
org.hbabcock.triviallists.ItemFragmentEdit.java
org.hbabcock.triviallists.ItemFragmentShop.java
org.hbabcock.triviallists.ItemFragment.java
org.hbabcock.triviallists.ItemPagerActivity.java
org.hbabcock.triviallists.Item.java
org.hbabcock.triviallists.SingleFragmentActivity.java
org.hbabcock.triviallists.TrivialListJSONSerializer.java