微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.provider.CalendarContract.Reminders的实例源码

项目:diary    文件QueryHandler.java   
@Override
public void onInsertComplete(int token,Object object,Uri uri)
{
    if (uri != null)
    {
        if (BuildConfig.DEBUG)
            Log.d(TAG,"Insert complete " + uri.getLastPathSegment());

        switch (token)
        {
        case EVENT:
            long eventID = Long.parseLong(uri.getLastPathSegment());
            ContentValues values = new ContentValues();
            values.put(Reminders.MINUTES,10);
            values.put(Reminders.EVENT_ID,eventID);
            values.put(Reminders.METHOD,Reminders.METHOD_ALERT);
            startInsert(REMINDER,null,Reminders.CONTENT_URI,values);
            break;
        }
    }
}
项目:Calendar_lunar    文件EditEventHelperTest.java   
private void addExpectedMinutes(ArrayList<ContentProviderOperation> expectedOps) {
    ContentProviderOperation.Builder b;
    mValues = new ContentValues();

    mValues.clear();
    mValues.put(Reminders.MINUTES,5);
    mValues.put(Reminders.METHOD,Reminders.METHOD_DEFAULT);
    mValues.put(Reminders.EVENT_ID,TEST_EVENT_ID);
    b = ContentProviderOperation.newInsert(Reminders.CONTENT_URI).withValues(mValues);
    expectedOps.add(b.build());

    mValues.clear();
    mValues.put(Reminders.MINUTES,10);
    mValues.put(Reminders.METHOD,15);
    mValues.put(Reminders.METHOD,TEST_EVENT_ID);
    b = ContentProviderOperation.newInsert(Reminders.CONTENT_URI).withValues(mValues);
    expectedOps.add(b.build());
}
项目:Calendar_lunar    文件EditEventHelperTest.java   
private void addExpectedMinutesWithBackRef(ArrayList<ContentProviderOperation> expectedOps) {
    ContentProviderOperation.Builder b;
    mValues = new ContentValues();

    mValues.clear();
    mValues.put(Reminders.MINUTES,Reminders.METHOD_DEFAULT);
    b = ContentProviderOperation.newInsert(Reminders.CONTENT_URI).withValues(mValues);
    b.withValueBackReference(Reminders.EVENT_ID,TEST_EVENT_INDEX_ID);
    expectedOps.add(b.build());

    mValues.clear();
    mValues.put(Reminders.MINUTES,TEST_EVENT_INDEX_ID);
    expectedOps.add(b.build());
}
项目:cordova-plugin-calendarsync    文件EventAccessor.java   
/** Fetch all the reminders of the specified event,and put them in a JSONArray.
*/
private JSONArray getReminders(long eventId) {
    Cursor c = Reminders.query(
        context.getContentResolver(),eventId,REMINDER_COLUMNS
    );

    JSONArray result = Tools.rows2JSONArray(c,REMINDER_COLUMNS);
    c.close();
    return result;
}
项目:CucumberSync    文件LocalCalendar.java   
void populateReminders(Event e) throws remoteexception {
    // reminders
    Uri remindersUri = Reminders.CONTENT_URI.buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,"true")
            .build();
    @Cleanup Cursor c = providerClient.query(remindersUri,new String[]{
            /* 0 */ Reminders.MINUTES,Reminders.METHOD
    },Reminders.EVENT_ID + "=?",new String[]{String.valueOf(e.getLocalID())},null);
    while (c != null && c.movetoNext()) {
        //Duration duration = new Duration.Builder().prior(true).minutes(c.getInt(0)).build();
        Duration duration = new Duration.Builder().minutes(c.getInt(0)).build();
        Trigger trigger = new Trigger(duration,Related.START);
        VAlarm alarm = VAlarm.display(trigger,e.getSummary());
        e.addAlarm(alarm);
    }
}
项目:CucumberSync    文件LocalCalendar.java   
@Override
protected void addDaTarows(Resource resource,long localID,int backrefIdx) {
    Event event = (Event)resource;
    for (Attendee attendee : event.getAttendees())
        pendingOperations.add(buildAttendee(newDataInsertBuilder(Attendees.CONTENT_URI,Attendees.EVENT_ID,localID,backrefIdx),attendee).build());
    for (VAlarm alarm : event.getAlarms())
        pendingOperations.add(buildreminder(newDataInsertBuilder(Reminders.CONTENT_URI,Reminders.EVENT_ID,alarm).build());
}
项目:CucumberSync    文件LocalCalendar.java   
@Override
protected void removeDaTarows(Resource resource) {
    Event event = (Event)resource;
    pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Attendees.CONTENT_URI))
            .withSelection(Attendees.EVENT_ID + "=?",new String[] { String.valueOf(event.getLocalID()) }).build());
    pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Reminders.CONTENT_URI))
            .withSelection(Reminders.EVENT_ID + "=?",new String[]{String.valueOf(event.getLocalID())}).build());
}
项目:CucumberSync    文件LocalCalendar.java   
protected Builder buildreminder(Builder builder,VAlarm alarm) {
    int minutes = 0;

    if (alarm.getTrigger() != null && alarm.getTrigger().getDuration() != null)
        //minutes = duration.getDays() * 24*60 + duration.getHours()*60 + duration.getMinutes();
        minutes = (int)(alarm.getTrigger().getDuration().toMillis()/60000);

    Log.d(TAG,"Adding alarm " + minutes + " min before");

    return builder
            .withValue(Reminders.METHOD,Reminders.METHOD_ALERT)
            .withValue(Reminders.MINUTES,minutes);
}
项目:Calendar_lunar    文件EditEventHelper.java   
/**
 * Saves the reminders,if they changed. Returns true if operations to
 * update the database were added.
 *
 * @param ops the array of ContentProviderOperations
 * @param eventId the id of the event whose reminders are being updated
 * @param reminders the array of reminders set by the user
 * @param originalReminders the original array of reminders
 * @param forceSave if true,then save the reminders even if they didn't change
 * @return true if operations to update the database were added
 */
public static boolean saveReminders(ArrayList<ContentProviderOperation> ops,long eventId,ArrayList<ReminderEntry> reminders,ArrayList<ReminderEntry> originalReminders,boolean forceSave) {
    // If the reminders have not changed,then don't update the database
    if (reminders.equals(originalReminders) && !forceSave) {
        return false;
    }

    // Delete all the existing reminders for this event
    String where = Reminders.EVENT_ID + "=?";
    String[] args = new String[] {Long.toString(eventId)};
    ContentProviderOperation.Builder b = ContentProviderOperation
            .newDelete(Reminders.CONTENT_URI);
    b.withSelection(where,args);
    ops.add(b.build());

    ContentValues values = new ContentValues();
    int len = reminders.size();

    // Insert the new reminders,if any
    for (int i = 0; i < len; i++) {
        ReminderEntry re = reminders.get(i);

        values.clear();
        values.put(Reminders.MINUTES,re.getMinutes());
        values.put(Reminders.METHOD,re.getmethod());
        values.put(Reminders.EVENT_ID,eventId);
        b = ContentProviderOperation.newInsert(Reminders.CONTENT_URI).withValues(values);
        ops.add(b.build());
    }
    return true;
}
项目:Calendar_lunar    文件EditEventHelper.java   
/**
 * Saves the reminders,if they changed. Returns true if operations to
 * update the database were added. Uses a reference id since an id isn't
 * created until the row is added.
 *
 * @param ops the array of ContentProviderOperations
 * @param eventId the id of the event whose reminders are being updated
 * @param reminderMinutes the array of reminders set by the user
 * @param originalMinutes the original array of reminders
 * @param forceSave if true,then save the reminders even if they didn't change
 * @return true if operations to update the database were added
 */
public static boolean saveRemindersWithBackRef(ArrayList<ContentProviderOperation> ops,int eventIdindex,then don't update the database
    if (reminders.equals(originalReminders) && !forceSave) {
        return false;
    }

    // Delete all the existing reminders for this event
    ContentProviderOperation.Builder b = ContentProviderOperation
            .newDelete(Reminders.CONTENT_URI);
    b.withSelection(Reminders.EVENT_ID + "=?",new String[1]);
    b.withSelectionBackReference(0,eventIdindex);
    ops.add(b.build());

    ContentValues values = new ContentValues();
    int len = reminders.size();

    // Insert the new reminders,re.getmethod());
        b = ContentProviderOperation.newInsert(Reminders.CONTENT_URI).withValues(values);
        b.withValueBackReference(Reminders.EVENT_ID,eventIdindex);
        ops.add(b.build());
    }
    return true;
}
项目:Calendar_lunar    文件CalendarEventModel.java   
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof ReminderEntry)) {
        return false;
    }

    ReminderEntry re = (ReminderEntry) obj;

    if (re.mMinutes != mMinutes) {
        return false;
    }

    // Treat ALERT and DEFAULT as equivalent.  This is useful during the "has anything
    // "changed" test,so that if DEFAULT is present,but we don't change anything,// the internal conversion of DEFAULT to ALERT doesn't force a database update.
    return re.mMethod == mMethod ||
        (re.mMethod == Reminders.METHOD_DEFAULT && mMethod == Reminders.METHOD_ALERT) ||
        (re.mMethod == Reminders.METHOD_ALERT && mMethod == Reminders.METHOD_DEFAULT);
}
项目:Calendar_lunar    文件EditEventHelperTest.java   
private void addOwnerAttendeetoOps(ArrayList<ContentProviderOperation> expectedOps,int id) {
    addOwnerAttendee();
    ContentProviderOperation.Builder b;
    b = ContentProviderOperation.newInsert(Attendees.CONTENT_URI).withValues(mExpectedValues);
    b.withValueBackReference(Reminders.EVENT_ID,id);
    expectedOps.add(b.build());
}
项目:assistance-platform-client-sdk-android    文件CalendarSensor.java   
protected void syncReminders(DbCalendarSensor event) {

        if (event == null) {
            return;
        }

        boolean hasAlarm = event.getHasAlarm();

        if (hasAlarm) {

            long eventId = event.getEventId();
            LongSparseArray<DbCalendarReminderSensor> mapExistingReminders = getExistingReminders(eventId);

            // optional reminderSelection
            String[] selectionArgs = {String.valueOf(eventId)};

            Cursor cur = null;

            try {

                long deviceid = PreferenceProvider.getInstance(context).getCurrentdeviceid();

                cur = contentResolver.query(URI_REMINDER,PROJECTION_REMINDERS,reminderSelection,selectionArgs,null);

                if (cur == null || cur.getCount() <= 0) {
                    return;
                }

                List<DbCalendarReminderSensor> entriesToInsert = new ArrayList<>(cur.getCount());
                String created = DateUtils.datetoISO8601String(new Date(),Locale.getDefault());

                // Iterate over event
                while (cur.movetoNext() && isRunning()) {

                    DbCalendarReminderSensor reminder = new DbCalendarReminderSensor();

                    reminder.setReminderId(getLongByColumnName(cur,Reminders._ID));
                    reminder.setEventId(eventId);
                    reminder.setMethod(getIntByColumnName(cur,Reminders.METHOD));
                    reminder.setMinutes(getIntByColumnName(cur,Reminders.MINUTES));
                    reminder.setIsNew(Boolean.TRUE);
                    reminder.setIsDeleted(Boolean.FALSE);
                    reminder.setIsUpdated(Boolean.TRUE);
                    reminder.setdeviceid(deviceid);
                    reminder.setCreated(created);

                    if (checkForReminderChange(mapExistingReminders,reminder)) {
                        entriesToInsert.add(reminder);
                    }
                }

                if (!entriesToInsert.isEmpty()) {
                    calendarReminderSensorDao.insert(entriesToInsert);
                }

            } finally {
                if (cur != null) {
                    cur.close();
                }
            }

        }
    }
项目:mobilesensor    文件Plugin.java   
/**
 * Initialize the multithread handler manager for ContentObservers and
 * initialize the context observers for the sensors
 */
@SuppressLint("NewApi")
public void startContentObservers(){
    //Register the sensor handler thread with the handler managers

    //Multitasking
    thread_multitasking.start();
    thread_sensor_multi = new Handler(thread_multitasking.getLooper());
    multitask_observer = new MultitaskingObserver(thread_sensor_multi,this);
    MultitaskingObserver.lastMultiESM = screenOnTime;
    MultitaskingObserver.lastemailESM = screenOnTime;

    //Phone 
    thread_phone.start();
    thread_sensor_phone = new Handler(thread_phone.getLooper());
    phone_observer = new VoiceCallObserver(thread_sensor_phone,this);
    VoiceCallObserver.lastVoiceESM = screenOnTime;

    //Text Messaging
    thread_messages.start();
    thread_sensor_messages = new Handler(thread_messages.getLooper());
    messages_observer = new MessageObserver(thread_sensor_messages,this);
    MessageObserver.lastMessageESM = screenOnTime;

    //Installations
    thread_install.start();
    thread_sensor_install = new Handler(thread_install.getLooper());
    install_observer = new InstallationsObserver(thread_sensor_install,this);

    //ESM
    thread_esm.start();
    thread_sensor_esm = new Handler(thread_esm.getLooper());
    esm_observer = new ESMObserver(thread_sensor_esm,this);

    //Calendar
    thread_calendar.start();
    thread_observer_calendar = new Handler(thread_calendar.getLooper());
    calendar_observer = new CalendarObserver(thread_observer_calendar,this);

    //Screen
    thread_screen.start();
    thread_sensor_screen = new Handler(thread_screen.getLooper());
    //create a context filter for screen
    IntentFilter screenFilter = new IntentFilter();
    screenFilter.addAction(Screen.ACTION_AWARE_SCREEN_ON);
    screenFilter.addAction(Screen.ACTION_AWARE_SCREEN_OFF);
    screenListener = new ScreenObserver(this);

    //Create a context filter for Activity
    thread_activity.start();
    thread_sensor_activity = new Handler(thread_activity.getLooper());
    IntentFilter activityFilter = new IntentFilter();
    activityFilter.addAction(ActivityObserver.ACTION_AWARE_GOOGLE_ACTIVITY_RECOGNITION);
    activityListener = new ActivityObserver(this);
    ActivityObserver.lastActivityESM = screenOnTime;

    //Ambient noise
    thread_ambient_noise.start();
    thread_sensor_ambient_noise = new Handler(thread_ambient_noise.getLooper());
    ambient_noise_observer = new AmbientNoiSEObserver(thread_sensor_ambient_noise,this);
    AmbientNoiSEObserver.lastAmbientESM = screenOnTime;

    //Ask Android to register our context receiver
    registerReceiver(screenListener,screenFilter,thread_sensor_screen);
    registerReceiver(activityListener,activityFilter,thread_sensor_activity);
    //Start listening to changes on the Applications_Foreground,MoT,and NoiseLevel databases
    getContentResolver().registerContentObserver(Applications_Foreground.CONTENT_URI,true,multitask_observer);
    getContentResolver().registerContentObserver(Installations_Data.CONTENT_URI,install_observer);
    getContentResolver().registerContentObserver(AmbientNoise_Data.CONTENT_URI,ambient_noise_observer);
    getContentResolver().registerContentObserver(Calls_Data.CONTENT_URI,phone_observer);
    getContentResolver().registerContentObserver(Messages_Data.CONTENT_URI,messages_observer);
    getContentResolver().registerContentObserver(ESM_Data.CONTENT_URI,esm_observer);
    getContentResolver().registerContentObserver(Reminders.CONTENT_URI,calendar_observer);
}
项目:mobilesensor    文件Plugin.java   
@Override
public void run() {
    clearallEvents();
    cal = new GregorianCalendar();
    Calendar newCal = new GregorianCalendar();
    //Reset at 12:30am
    int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
    int minOfDay = cal.get(Calendar.MINUTE);
    if(hourOfDay == 0 && minOfDay < 30){
        newCal.set(Calendar.HOUR_OF_DAY,0);
        newCal.set(Calendar.MINUTE,30);
        newCal.set(Calendar.SECOND,0); 
    } else{
        newCal.add(Calendar.DAY_OF_WEEK,1); //recalculates calendar if at the end
        newCal.set(Calendar.HOUR_OF_DAY,0);
    }
    String[] mSelectionArgs = new String[3];
    String mSelection = "DELETED = ? AND hasAlarm = ? AND allDay = ?";
    long start = cal.getTimeInMillis(); //current time
    long stop = newCal.getTimeInMillis(); //end of day
    mSelectionArgs[0] = "0"; 
    mSelectionArgs[1] = "1"; 
    mSelectionArgs[2] = "0"; 
    Cursor calendar = getContentResolver().query(Events.CONTENT_URI,mSelection,mSelectionArgs,Events.DTSTART+" ASC");
    //Go through and grab all events with reminders with our time constraint
    if(calendar != null && calendar.movetoFirst()){
        do{
            String repeating = calendar.getString(calendar.getColumnIndex("rrule"));
            long begin = calendar.getLong(calendar.getColumnIndex(Events.DTSTART));
            long end = calendar.getLong(calendar.getColumnIndex(Events.DTEND));
            if((repeating == null && begin >= start && end <= stop) || (repeating != null)){
                String id = calendar.getString(calendar.getColumnIndex(Events._ID));
                String name = calendar.getString(calendar.getColumnIndex(Events.TITLE));
                //Filter out deleted instances and grab repeating events
                String[] INSTANCE_PROJECTION = new String[] {
                    Instances.EVENT_ID,// 0
                    Instances.BEGIN,// 1
                    Instances.END,// 2
                    Instances.TITLE          // 3
                };
                String selection = Instances.EVENT_ID + " = ?";
                String[] selectionArgs = new String[] {id};
                Cursor instances = null;
                //Uri for events withing start and stop
                Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
                ContentUris.appendId(builder,start);
                ContentUris.appendId(builder,stop);
                instances = getContentResolver().query(builder.build(),INSTANCE_PROJECTION,selection,null);
                if(instances == null || instances.getCount() > 0 && instances.movetoNext()){
                    //Make sure the instance's begin is after current time (since we didn't check it before)
                    if(instances.getLong(instances.getColumnIndex((Instances.BEGIN))) >= start){
                        begin = instances.getLong(instances.getColumnIndex(Instances.BEGIN));
                        end = instances.getLong(instances.getColumnIndex(Instances.END));
                        String[] toReturn = {""};
                        toReturn[0] = ""+id;
                        int maxReminder = 0;
                        Cursor reminders = getContentResolver().query(Reminders.CONTENT_URI,"event_id = ?",toReturn,null);
                        if(reminders != null && reminders.movetoLast()){
                            do{
                                int rem = reminders.getInt(reminders.getColumnIndex(Reminders.MINUTES)) ;
                                if(rem > maxReminder)
                                    maxReminder = rem; 
                            }while(reminders.movetoPrevIoUs());
                        }
                        if(maxReminder >= 1 && maxReminder <= 60){
                            CalendarEvent e = new CalendarEvent(id,name,begin,end,maxReminder);
                            eventList.add(e);
                        }
                    }
                } if(instances != null && ! instances.isClosed() ) instances.close(); 
            }
        }while(calendar.movetoNext());
    } if(calendar != null && ! calendar.isClosed() ) calendar.close();
    //Run this again when you reach 12:30am either today or the next day
    long current = System.currentTimeMillis();
    if(eventList.size() > 0)
        startCalendaralarm(0);
    thread_calSetup.postDelayed(this,(stop-current));
}
项目:CucumberSync    文件LocalCalendar.java   
@SuppressLint("InlinedApi")
public static void create(Account account,ContentResolver resolver,ServerInfo.ResourceInfo info) throws remoteexception {
    ContentProviderClient client = resolver.acquireContentProviderClient(CalendarContract.AUTHORITY);

    //FIXME - change default colour
    int color = 0xFFC3EA6E;     // fallback: "DAVdroid green"
    if (info.getColor() != null) {
        Pattern p = Pattern.compile("#(\\p{XDigit}{6})(\\p{XDigit}{2})?");
        Matcher m = p.matcher(info.getColor());
        if (m.find()) {
            int color_rgb = Integer.parseInt(m.group(1),16);
            int color_alpha = m.group(2) != null ? (Integer.parseInt(m.group(2),16) & 0xFF) : 0xFF;
            color = (color_alpha << 24) | color_rgb;
        }
    }

    ContentValues values = new ContentValues();
    values.put(Calendars.ACCOUNT_NAME,account.name);
    values.put(Calendars.ACCOUNT_TYPE,account.type);
    values.put(Calendars.NAME,info.getCollection());
    values.put(Calendars.CALENDAR_disPLAY_NAME,info.getTitle());
    values.put(Calendars.CALENDAR_COLOR,color);
    values.put(Calendars.OWNER_ACCOUNT,account.name);
    values.put(Calendars.SYNC_EVENTS,1);
    values.put(Calendars.VISIBLE,1);
    values.put(Calendars.ALLOWED_REMINDERS,Reminders.METHOD_ALERT);

    if (info.isReadOnly())
        values.put(Calendars.CALENDAR_ACCESS_LEVEL,Calendars.CAL_ACCESS_READ);
    else {
        values.put(Calendars.CALENDAR_ACCESS_LEVEL,Calendars.CAL_ACCESS_OWNER);
        values.put(Calendars.CAN_ORGANIZER_RESPOND,1);
        values.put(Calendars.CAN_MODIFY_TIME_ZONE,1);
    }

    if (android.os.Build.VERSION.SDK_INT >= 15) {
        values.put(Calendars.ALLOWED_AVAILABILITY,Events.AVAILABILITY_BUSY + "," + Events.AVAILABILITY_FREE + "," + Events.AVAILABILITY_TENTATIVE);
        values.put(Calendars.ALLOWED_ATTENDEE_TYPES,Attendees.TYPE_NONE + "," + Attendees.TYPE_OPTIONAL + "," + Attendees.TYPE_required + "," + Attendees.TYPE_RESOURCE);
    }

    if (info.getTimezone() != null)
        values.put(Calendars.CALENDAR_TIME_ZONE,info.getTimezone());

    Log.i(TAG,"Inserting calendar: " + values.toString() + " -> " + calendarsURI(account).toString());
    client.insert(calendarsURI(account),values);
}
项目:Calendar_lunar    文件EditEventHelperTest.java   
@Smoke
@SmallTest
public void testSaveReminders() {
    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    ArrayList<ContentProviderOperation> expectedOps = new ArrayList<ContentProviderOperation>();
    long eventId = TEST_EVENT_ID;
    ArrayList<ReminderEntry> reminders = new ArrayList<ReminderEntry>();
    ArrayList<ReminderEntry> originalReminders = new ArrayList<ReminderEntry>();
    boolean forceSave = true;
    boolean result;
    mActivity = buildTestContext();
    mHelper = new EditEventHelper(mActivity,null);
    assertNotNull(mHelper);

    // First test forcing a delete with no reminders.
    String where = Reminders.EVENT_ID + "=?";
    String[] args = new String[] {Long.toString(eventId)};
    ContentProviderOperation.Builder b =
            ContentProviderOperation.newDelete(Reminders.CONTENT_URI);
    b.withSelection(where,args);
    expectedOps.add(b.build());

    result = mHelper.saveReminders(ops,reminders,originalReminders,forceSave);
    assertTrue(result);
    assertEquals(expectedOps,ops);

    // Now test calling save with identical reminders and no forcing
    reminders.add(ReminderEntry.valueOf(5));
    reminders.add(ReminderEntry.valueOf(10));
    reminders.add(ReminderEntry.valueOf(15));

    originalReminders.add(ReminderEntry.valueOf(5));
    originalReminders.add(ReminderEntry.valueOf(10));
    originalReminders.add(ReminderEntry.valueOf(15));

    forceSave = false;

    ops.clear();

    // Should fail to create any ops since nothing changed
    result = mHelper.saveReminders(ops,forceSave);
    assertFalse(result);
    assertEquals(ops.size(),0);

    //Now test adding a single reminder
    originalReminders.remove(2);

    addExpectedMinutes(expectedOps);

    result = mHelper.saveReminders(ops,ops);
}
项目:Calendar_lunar    文件EditEventHelperTest.java   
@Smoke
@SmallTest
public void testSaveRemindersWithBackRef() {
    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    ArrayList<ContentProviderOperation> expectedOps = new ArrayList<ContentProviderOperation>();
    long eventId = TEST_EVENT_ID;
    ArrayList<ReminderEntry> reminders = new ArrayList<ReminderEntry>();
    ArrayList<ReminderEntry> originalReminders = new ArrayList<ReminderEntry>();
    boolean forceSave = true;
    boolean result;
    mActivity = buildTestContext();
    mHelper = new EditEventHelper(mActivity,null);
    assertNotNull(mHelper);

    // First test forcing a delete with no reminders.
    ContentProviderOperation.Builder b =
            ContentProviderOperation.newDelete(Reminders.CONTENT_URI);
    b.withSelection(Reminders.EVENT_ID + "=?",TEST_EVENT_INDEX_ID);
    expectedOps.add(b.build());

    result =
            mHelper.saveRemindersWithBackRef(ops,TEST_EVENT_INDEX_ID,forceSave);
    assertTrue(result);
    assertEquals(ops,expectedOps);

    // Now test calling save with identical reminders and no forcing
    reminders.add(ReminderEntry.valueOf(5));
    reminders.add(ReminderEntry.valueOf(10));
    reminders.add(ReminderEntry.valueOf(15));

    originalReminders.add(ReminderEntry.valueOf(5));
    originalReminders.add(ReminderEntry.valueOf(10));
    originalReminders.add(ReminderEntry.valueOf(15));

    forceSave = false;

    ops.clear();

    result = mHelper.saveRemindersWithBackRef(ops,ops.size(),0);

    //Now test adding a single reminder
    originalReminders.remove(2);

    addExpectedMinutesWithBackRef(expectedOps);

    result = mHelper.saveRemindersWithBackRef(ops,expectedOps);
}
项目:Calendar_lunar    文件CalendarEventModel.java   
/**
 * Returns a ReminderEntry,with the specified number of minutes and a default alert method.
 *
 * @param minutes Number of minutes before the start of the event that the alert will fire.
 */
public static ReminderEntry valueOf(int minutes) {
    return valueOf(minutes,Reminders.METHOD_DEFAULT);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。