Android Open Source - ingress-key-counter Category






From Project

Back to project page ingress-key-counter.

License

The source code is released under:

MIT License

If you think the Android project ingress-key-counter 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 de.lehrbaum.keycounter;
//from  www  .j a v a 2 s .co m
import android.content.Context;
import android.database.Cursor;
import android.util.Log;

public class Category {
  private static final String TAG = Category.class
    .getCanonicalName();
  
  private final int id;
  private String name;
  
  public Category(Context context, String name) {
    DatabaseHandler dh = new DatabaseHandler(context);
    id = dh.addCategory(name);
    if (id < 0) {
      Log.d(Category.TAG, "Could not add Category: " + name);
      return;//something went wrong
    }
    this.name = name;
  }
  
  public Category(Cursor c) {
    id = c.getInt(0);
    name = c.getString(1);
  }
  
  /**
   * @return the unique id of the category
   */
  public int getId() {
    return id;
  }
  
  /**
   * @return the name of the category.
   */
  public String getName() {
    return name;
  }
  
  @Override
  public String toString() {
    return name;
  }
  
  public void delete(Context c) {
    DatabaseHandler dh = new DatabaseHandler(c);
    dh.deleteCategory(id);
  }
  
  @Override
  public boolean equals(Object o) {
    if (o instanceof Category) {
      return ((Category) o).id == id;
    }
    return false;
  }
}




Java Source Code List

de.lehrbaum.keycounter.AbstractEncapsuledList.java
de.lehrbaum.keycounter.CategoriesFragment.java
de.lehrbaum.keycounter.Category.java
de.lehrbaum.keycounter.CounterListAdapter.java
de.lehrbaum.keycounter.DatabaseHandler.java
de.lehrbaum.keycounter.MainActivity.java
de.lehrbaum.keycounter.MainFragment.java
de.lehrbaum.keycounter.PortalList.java
de.lehrbaum.keycounter.PortalView.java
de.lehrbaum.keycounter.Portal.java