Android Open Source - android-calendar-drafts Load Event By Id Cmd






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.cmd;
/*from  w  w  w .j a v  a 2 s . c  om*/
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CalendarContract.Events;

import com.touchableheroes.drafts.calendar.cursor.GetValueFacade;
import com.touchableheroes.drafts.calendar.dao.Event;

/**
 * @author A. Siebert, ask@touchableheroes.com
 */
public class LoadEventByIdCmd extends ContextCmd {

  public LoadEventByIdCmd(Context ctx) {
    super(ctx);
  }

  
  public Event exec( final Uri id) {
    final ContentResolver cr = getContentResolver();
    final String[] projection = { Events.TITLE, Events._ID, Events.DTSTART, Events.DTEND, Events.DESCRIPTION };
    
    final Cursor cursor = cr.query(id, projection, null,
        null, null);
    
    final GetValueFacade get = new GetValueFacade(cursor, null);
    
    Event rval = null;
    if (cursor.moveToNext()) {
      get.id(Events._ID);
      
      get.string( "title", Events.TITLE );
      get.longVal( "start", Events.DTSTART );
      get.longVal( "end", Events.DTEND );

      get.string( "description", Events.DESCRIPTION );
      
      rval = get.push();
    }
    
    cursor.close();
    
    return rval;
  }
}




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