Android Open Source - android-calendar-drafts Event Id






From Project

Back to project page android-calendar-drafts.

License

The source code is released under:

Apache License

If you think the Android project android-calendar-drafts 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.touchableheroes.drafts.calendar.dao;
/*from  w w  w .j ava 2s  .co  m*/
import android.annotation.TargetApi;
import android.content.ContentUris;
import android.net.Uri;
import android.provider.CalendarContract.Events;
import android.util.Log;

/**
 * Basic class to work with calendar-event-ids.
 * 
 * @author A.Siebert, ask@touchableheroes.com
 */
public class EventId {

  private Long id;
  private final Uri uri;

  public EventId(final Uri uri) {
    this.uri = uri;
    
    try {
      final String idStr = uri.getLastPathSegment();
      this.id = Long.parseLong(idStr);
    } catch (final Throwable x) {
      Log.e( "calendar-drafts", "couldn't parse uri. Not found id. uri = " + uri );
      this.id = null;
    }
  }
  
  
  private EventId(final long id) {
    this.uri = createUri(id);
    this.id = id;
  }


  public boolean isValid() {
    return this.id != null;
  }
  
  public Long getId() {
    return id;
  }
  
  public Uri getUri() {
    return uri;
  }


  @TargetApi(14)
  private static Uri createUri_14(long id) {
    return ContentUris.withAppendedId(Events.CONTENT_URI, id);
  }



  public static Uri createUri(long id) {
    return createUri_14(id);
  }

  /**
   * Factory-method to create an EventId.
   * 
   * @param id positive number. internal db id.
   * @return instance or null.
   */
  public static EventId create(long id) {
    if( id < 1 )
      return null;
    
    return new EventId(id);
  }
  
}




Java Source Code List

com.touchableheroes.drafts.calendar.Start.java
com.touchableheroes.drafts.calendar.cmd.ContextCmd.java
com.touchableheroes.drafts.calendar.cmd.DeleteEventByHeaderCmd.java
com.touchableheroes.drafts.calendar.cmd.DeleteEventCmd.java
com.touchableheroes.drafts.calendar.cmd.ExistsEventCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertDaylyRepeatableEventCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertEventCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertReminderCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertRepeatableEventCmd.java
com.touchableheroes.drafts.calendar.cmd.LoadEventByIdCmd.java
com.touchableheroes.drafts.calendar.cmd.LoadEventsCmd.java
com.touchableheroes.drafts.calendar.cmd.ModifyEventCmd.java
com.touchableheroes.drafts.calendar.cmd.UpdateEventByHeaderCmd.java
com.touchableheroes.drafts.calendar.cursor.GetValueFacade.java
com.touchableheroes.drafts.calendar.dao.EventId.java
com.touchableheroes.drafts.calendar.dao.Event.java
com.touchableheroes.drafts.calendar.dao.EventsDAO.java
com.touchableheroes.drafts.calendar.util.WherePart.java
com.touchableheroes.drafts.calendar.util.WhereQueryPartBuilder.java