Android Open Source - coursera-android-001 To Do Item






From Project

Back to project page coursera-android-001.

License

The source code is released under:

MIT License

If you think the Android project coursera-android-001 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 course.labs.todomanager;
//from  w  w  w. j a v  a  2  s  . c  om
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.content.Intent;

// Do not modify 

public class ToDoItem {

  public static final String ITEM_SEP = System.getProperty("line.separator");

  public enum Priority {
    LOW, MED, HIGH
  };

  public enum Status {
    NOTDONE, DONE
  };

  public final static String TITLE = "title";
  public final static String PRIORITY = "priority";
  public final static String STATUS = "status";
  public final static String DATE = "date";
  public final static String FILENAME = "filename";

  public final static SimpleDateFormat FORMAT = new SimpleDateFormat(
      "yyyy-MM-dd HH:mm:ss", Locale.US);

  private String mTitle = new String();
  private Priority mPriority = Priority.LOW;
  private Status mStatus = Status.NOTDONE;
  private Date mDate = new Date();

  ToDoItem(String title, Priority priority, Status status, Date date) {
    this.mTitle = title;
    this.mPriority = priority;
    this.mStatus = status;
    this.mDate = date;
  }

  // Create a new ToDoItem from data packaged in an Intent

  ToDoItem(Intent intent) {

    mTitle = intent.getStringExtra(ToDoItem.TITLE);
    mPriority = Priority.valueOf(intent.getStringExtra(ToDoItem.PRIORITY));
    mStatus = Status.valueOf(intent.getStringExtra(ToDoItem.STATUS));

    try {
      mDate = ToDoItem.FORMAT.parse(intent.getStringExtra(ToDoItem.DATE));
    } catch (ParseException e) {
      mDate = new Date();
    }
  }

  public String getTitle() {
    return mTitle;
  }

  public void setTitle(String title) {
    mTitle = title;
  }

  public Priority getPriority() {
    return mPriority;
  }

  public void setPriority(Priority priority) {
    mPriority = priority;
  }

  public Status getStatus() {
    return mStatus;
  }

  public void setStatus(Status status) {
    mStatus = status;
  }

  public Date getDate() {
    return mDate;
  }

  public void setDate(Date date) {
    mDate = date;
  }

  // Take a set of String data values and 
  // package them for transport in an Intent

  public static void packageIntent(Intent intent, String title,
      Priority priority, Status status, String date) {

    intent.putExtra(ToDoItem.TITLE, title);
    intent.putExtra(ToDoItem.PRIORITY, priority.toString());
    intent.putExtra(ToDoItem.STATUS, status.toString());
    intent.putExtra(ToDoItem.DATE, date);
  
  }

  public String toString() {
    return mTitle + ITEM_SEP + mPriority + ITEM_SEP + mStatus + ITEM_SEP
        + FORMAT.format(mDate);
  }

  public String toLog() {
    return "Title:" + mTitle + ITEM_SEP + "Priority:" + mPriority
        + ITEM_SEP + "Status:" + mStatus + ITEM_SEP + "Date:"
        + FORMAT.format(mDate);
  }

}




Java Source Code List

course.labs.GraphicsLab.BubbleActivity.java
course.labs.activitylab.ActivityOne.java
course.labs.activitylab.ActivityTwo.java
course.labs.contentproviderlab.MockLocationProvider.java
course.labs.contentproviderlab.PlaceDownloaderTask.java
course.labs.contentproviderlab.PlaceRecord.java
course.labs.contentproviderlab.PlaceViewActivity.java
course.labs.contentproviderlab.PlaceViewAdapter.java
course.labs.contentproviderlab.provider.PlaceBadgeContentProvider.java
course.labs.contentproviderlab.provider.PlaceBadgesContract.java
course.labs.contentproviderlab.provider.PlaceBadgesContract.java
course.labs.dangerousapp.DangerousActivity.java
course.labs.fragmentslab.FeedFragmentData.java
course.labs.fragmentslab.FeedFragment.java
course.labs.fragmentslab.FriendsFragment.java
course.labs.fragmentslab.MainActivity.java
course.labs.intentslab.ActivityLoaderActivity.java
course.labs.intentslab.ExplicitlyLoadedActivity.java
course.labs.intentslab.mybrowser.MyBrowserActivity.java
course.labs.locationlab.MockLocationProvider.java
course.labs.locationlab.PlaceDownloaderTask.java
course.labs.locationlab.PlaceRecord.java
course.labs.locationlab.PlaceViewActivity.java
course.labs.locationlab.PlaceViewAdapter.java
course.labs.notificationslab.DownloaderTask.java
course.labs.notificationslab.FeedFragment.java
course.labs.notificationslab.FriendsFragment.java
course.labs.notificationslab.MainActivity.java
course.labs.notificationslab.SelectionListener.java
course.labs.notificationslab.TestFrontEndActivity.java
course.labs.permissionslab.ActivityLoaderActivity.java
course.labs.permissionslab.BookmarksActivity.java
course.labs.permissionslab.GoToDangerousActivity.java
course.labs.todomanager.AddToDoActivity.java
course.labs.todomanager.ToDoItem.java
course.labs.todomanager.ToDoListAdapter.java
course.labs.todomanager.ToDoManagerActivity.java