当前位置: 首页>>代码示例>>Java>>正文


Java Instances类代码示例

本文整理汇总了Java中android.provider.CalendarContract.Instances的典型用法代码示例。如果您正苦于以下问题:Java Instances类的具体用法?Java Instances怎么用?Java Instances使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Instances类属于android.provider.CalendarContract包,在下文中一共展示了Instances类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEventCalendarIdsSelectString

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
/**
 * Make a WHERE clause to filter selected calendars
 * @return generated WHERE clause, or en empty string if there is no calendar selected
 */
private String getEventCalendarIdsSelectString() {
	LinkedHashMap<Long, Boolean> checkedCalendars = PreferencesManager.getCheckedCalendars(context);
	
	StringBuilder builder = new StringBuilder();
	boolean first = true;
	for(long idCalendar : checkedCalendars.keySet()) {
		if(first)
			first = false;
		else
			builder.append(" OR ");
		
		builder.append("(").append(Instances.CALENDAR_ID).append("=").append(idCalendar).append(")");
	}
	return builder.toString();
}
 
开发者ID:RemiNV,项目名称:CalendarMute,代码行数:20,代码来源:CalendarProvider.java

示例2: getContentUri

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
protected Uri getContentUri(int numberOfDaysFromNow) {
	Calendar beginTime = Calendar.getInstance();
	beginTime.add(Calendar.DAY_OF_MONTH, -1);
	beginTime.set(Calendar.HOUR_OF_DAY, 23);
	beginTime.set(Calendar.MINUTE, 59);
	long startMillis = beginTime.getTimeInMillis();

	Calendar endTime = Calendar.getInstance();
	endTime.set(Calendar.HOUR_OF_DAY, 23);
	endTime.set(Calendar.MINUTE, 59);
	endTime.add(Calendar.DAY_OF_MONTH, numberOfDaysFromNow-1);
	long endMillis = endTime.getTimeInMillis();

	// Construct the query with the desired date range.
	Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
	ContentUris.appendId(builder, startMillis);
	ContentUris.appendId(builder, endMillis);
	
	return builder.build();
}
 
开发者ID:JanBobolz,项目名称:agendawatchfaceAndroid,代码行数:21,代码来源:AgendaCalendarService.java

示例3: instancesQuery

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
/**
 * Performs a query to return all visible instances in the given range
 * that match the given selection. This is a blocking function and
 * should not be done on the UI thread. This will cause an expansion of
 * recurring events to fill this time range if they are not already
 * expanded and will slow down for larger time ranges with many
 * recurring events.
 *
 * @param cr The ContentResolver to use for the query
 * @param projection The columns to return
 * @param begin The start of the time range to query in UTC millis since
 *            epoch
 * @param end The end of the time range to query in UTC millis since
 *            epoch
 * @param selection Filter on the query as an SQL WHERE statement
 * @param selectionArgs Args to replace any '?'s in the selection
 * @param orderBy How to order the rows as an SQL ORDER BY statement
 * @return A Cursor of instances matching the selection
 */
private static final Cursor instancesQuery(ContentResolver cr, String[] projection,
        int startDay, int endDay, String selection, String[] selectionArgs, String orderBy) {
    String WHERE_CALENDARS_SELECTED = Calendars.VISIBLE + "=?";
    String[] WHERE_CALENDARS_ARGS = {"1"};
    String DEFAULT_SORT_ORDER = "begin ASC";

    Uri.Builder builder = Instances.CONTENT_BY_DAY_URI.buildUpon();
    ContentUris.appendId(builder, startDay);
    ContentUris.appendId(builder, endDay);
    if (TextUtils.isEmpty(selection)) {
        selection = WHERE_CALENDARS_SELECTED;
        selectionArgs = WHERE_CALENDARS_ARGS;
    } else {
        selection = "(" + selection + ") AND " + WHERE_CALENDARS_SELECTED;
        if (selectionArgs != null && selectionArgs.length > 0) {
            selectionArgs = Arrays.copyOf(selectionArgs, selectionArgs.length + 1);
            selectionArgs[selectionArgs.length - 1] = WHERE_CALENDARS_ARGS[0];
        } else {
            selectionArgs = WHERE_CALENDARS_ARGS;
        }
    }
    return cr.query(builder.build(), projection, selection, selectionArgs,
            orderBy == null ? DEFAULT_SORT_ORDER : orderBy);
}
 
开发者ID:x7hub,项目名称:Calendar_lunar,代码行数:44,代码来源:Event.java

示例4: updateUri

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
/**
 * Updates the uri used by the loader according to the current position of
 * the listview.
 *
 * @return The new Uri to use
 */
private Uri updateUri() {
    SimpleWeekView child = (SimpleWeekView) mListView.getChildAt(0);
    if (child != null) {
        int julianDay = child.getFirstJulianDay();
        mFirstLoadedJulianDay = julianDay;
    }
    // -1 to ensure we get all day events from any time zone
    mTempTime.setJulianDay(mFirstLoadedJulianDay - 1);
    long start = mTempTime.toMillis(true);
    mLastLoadedJulianDay = mFirstLoadedJulianDay + (mNumWeeks + 2 * WEEKS_BUFFER) * 7;
    // +1 to ensure we get all day events from any time zone
    mTempTime.setJulianDay(mLastLoadedJulianDay + 1);
    long end = mTempTime.toMillis(true);

    // Create a new uri with the updated times
    Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
    ContentUris.appendId(builder, start);
    ContentUris.appendId(builder, end);
    return builder.build();
}
 
开发者ID:x7hub,项目名称:Calendar_lunar,代码行数:27,代码来源:MonthByWeekFragment.java

示例5: initContentProviderKeys

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
@Override
 protected EnumMap<KeyIndex, String> initContentProviderKeys() {
   EnumMap<KeyIndex, String> keys = new EnumMap<KeyIndex, String>(
           KeyIndex.class);
   keys.put(KeyIndex.CALENDARS_ID, Calendars._ID);
   keys.put(KeyIndex.CALENDARS_NAME, Calendars.NAME);
keys.put(KeyIndex.CALENDARS_DISPLAY_NAME, Calendars.CALENDAR_DISPLAY_NAME);
   keys.put(KeyIndex.CALENDARS_VISIBLE, Calendars.VISIBLE);
   keys.put(KeyIndex.EVENTS_ID, Events._ID);
   keys.put(KeyIndex.EVENTS_CALENDAR_ID, Events.CALENDAR_ID);
   keys.put(KeyIndex.EVENTS_DESCRIPTION, Events.DESCRIPTION);
   keys.put(KeyIndex.EVENTS_LOCATION, Events.EVENT_LOCATION);
   keys.put(KeyIndex.EVENTS_SUMMARY, Events.TITLE);
   keys.put(KeyIndex.EVENTS_START, Events.DTSTART);
   keys.put(KeyIndex.EVENTS_END, Events.DTEND);
   keys.put(KeyIndex.EVENTS_RRULE, Events.RRULE);
   keys.put(KeyIndex.EVENTS_ALL_DAY, Events.ALL_DAY);
   keys.put(KeyIndex.INSTANCES_ID, Instances._ID);
   keys.put(KeyIndex.INSTANCES_EVENT_ID, Instances.EVENT_ID);
   keys.put(KeyIndex.INSTANCES_BEGIN, Instances.BEGIN);
   keys.put(KeyIndex.INSTANCES_END, Instances.END);
   keys.put(KeyIndex.ATTENDEES_ID, Attendees._ID);
   keys.put(KeyIndex.ATTENDEES_EVENT_ID, Attendees.EVENT_ID);
   keys.put(KeyIndex.ATTENDEES_NAME, Attendees.ATTENDEE_NAME);
   keys.put(KeyIndex.ATTENDEES_EMAIL, Attendees.ATTENDEE_EMAIL);
   keys.put(KeyIndex.ATTENDEES_STATUS, Attendees.ATTENDEE_STATUS);
   return keys;
 }
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:29,代码来源:CalendarProviderAccessor.java

示例6: queryEventInstances

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
@Override
protected Cursor queryEventInstances(long startFrom, long startTo,
                                     String[] projection, String selection, String[] selectionArgs,
                                     String sortOrder) {
  Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
  ContentUris.appendId(builder, startFrom);
  ContentUris.appendId(builder, startTo);
  return this.cordova.getActivity().getContentResolver().query(
          builder.build(), projection, selection, selectionArgs, sortOrder);
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:11,代码来源:CalendarProviderAccessor.java

示例7: initContentProviderKeys

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
@Override
protected EnumMap<KeyIndex, String> initContentProviderKeys() {
  EnumMap<KeyIndex, String> keys = new EnumMap<KeyIndex, String>(
      KeyIndex.class);
  keys.put(KeyIndex.CALENDARS_ID, Calendars._ID);
  keys.put(KeyIndex.CALENDARS_NAME, Calendars.NAME);
  keys.put(KeyIndex.CALENDARS_VISIBLE, Calendars.VISIBLE);
  keys.put(KeyIndex.EVENTS_ID, Events._ID);
  keys.put(KeyIndex.EVENTS_CALENDAR_ID, Events.CALENDAR_ID);
  keys.put(KeyIndex.EVENTS_DESCRIPTION, Events.DESCRIPTION);
  keys.put(KeyIndex.EVENTS_LOCATION, Events.EVENT_LOCATION);
  keys.put(KeyIndex.EVENTS_SUMMARY, Events.TITLE);
  keys.put(KeyIndex.EVENTS_START, Events.DTSTART);
  keys.put(KeyIndex.EVENTS_END, Events.DTEND);
  keys.put(KeyIndex.EVENTS_RRULE, Events.RRULE);
  keys.put(KeyIndex.EVENTS_ALL_DAY, Events.ALL_DAY);
  keys.put(KeyIndex.INSTANCES_ID, Instances._ID);
  keys.put(KeyIndex.INSTANCES_EVENT_ID, Instances.EVENT_ID);
  keys.put(KeyIndex.INSTANCES_BEGIN, Instances.BEGIN);
  keys.put(KeyIndex.INSTANCES_END, Instances.END);
  keys.put(KeyIndex.ATTENDEES_ID, Attendees._ID);
  keys.put(KeyIndex.ATTENDEES_EVENT_ID, Attendees.EVENT_ID);
  keys.put(KeyIndex.ATTENDEES_NAME, Attendees.ATTENDEE_NAME);
  keys.put(KeyIndex.ATTENDEES_EMAIL, Attendees.ATTENDEE_EMAIL);
  keys.put(KeyIndex.ATTENDEES_STATUS, Attendees.ATTENDEE_STATUS);
  return keys;
}
 
开发者ID:Ardumed,项目名称:medicineReminder,代码行数:28,代码来源:CalendarProviderAccessor.java

示例8: queryEventInstances

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
@Override
protected Cursor queryEventInstances(long startFrom, long startTo,
                                     String[] projection, String selection, String[] selectionArgs,
                                     String sortOrder) {
  Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
  ContentUris.appendId(builder, startFrom);
  ContentUris.appendId(builder, startTo);
  return this.cordova.getActivity().getContentResolver().query(
      builder.build(), projection, selection, selectionArgs, sortOrder);
}
 
开发者ID:Ardumed,项目名称:medicineReminder,代码行数:11,代码来源:CalendarProviderAccessor.java

示例9: fetchSystemEvents

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
private boolean fetchSystemEvents(Context mContext) {

        Calendar cal = GregorianCalendar.getInstance();
        Long dtStart = cal.getTime().getTime();
        cal.add(Calendar.DATE, lookahead_days);
        Long dtEnd = cal.getTime().getTime();

        Uri.Builder eventsUriBuilder = CalendarContract.Instances.CONTENT_URI.buildUpon();
        ContentUris.appendId(eventsUriBuilder, dtStart);
        ContentUris.appendId(eventsUriBuilder, dtEnd);
        Uri eventsUri = eventsUriBuilder.build();

        try (Cursor evtCursor = mContext.getContentResolver().query(eventsUri, EVENT_INSTANCE_PROJECTION, null, null, CalendarContract.Instances.BEGIN + " ASC")) {
            if (evtCursor == null || evtCursor.getCount() == 0) {
                return false;
            }
            while (evtCursor.moveToNext()) {
                CalendarEvent calEvent = new CalendarEvent(
                        evtCursor.getLong(1),
                        evtCursor.getLong(2),
                        evtCursor.getLong(3),
                        evtCursor.getString(4),
                        evtCursor.getString(5),
                        evtCursor.getString(6),
                        evtCursor.getString(7)
                );
                calendarEventList.add(calEvent);
            }
            return true;
        }
    }
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:32,代码来源:CalendarEvents.java

示例10: listNextCalenderEvents

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
private void listNextCalenderEvents( )
{
	ContentResolver cr = this.getContentResolver( );
	Cursor cursor = null;

	// cursor = cr.query( ContactsContract.Contacts.CONTENT_URI, new String[ ] { PhoneLookup.DISPLAY_NAME,
	// PhoneLookup.PHOTO_URI }, null, null,
	// null );

	long begin = System.currentTimeMillis( ); // starting time in milliseconds
	long end = begin + ( 1000 * 60 * 60 * 2 ); // ending time in milliseconds
	String[ ] proj =
		new String[ ] {
			Instances._ID,
			Instances.BEGIN,
			Instances.END,
			Instances.EVENT_ID };

	cursor = Instances.query( getContentResolver( ), proj, begin, end );

	if ( cursor == null )
	{
		Log.d( "CONTACTS", "keine Kontakte gefunden" );
	}
	else
	{
		cursor.moveToFirst( );
		while ( cursor.isAfterLast( ) == false )
		{
			Log.d( "CONTACTS", cursor.getString( 0 ) + " " + cursor.getString( 1 ) + " " + cursor.getString( 2 ) +
				" " + cursor.getString( 3 ) );
			printEventDetails( Long.parseLong( cursor.getString( 3 ) ) );
			cursor.moveToNext( );
		}
	}
	cursor.close( );
}
 
开发者ID:DerGary,项目名称:FHWS-MobileApplikationen,代码行数:38,代码来源:MainActivity.java

示例11: getInstancesQueryUri

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
private Uri getInstancesQueryUri() {
	// Event search window : from one month before to one month after, to be sure
	GregorianCalendar dateDebut = new GregorianCalendar();
	dateDebut.add(GregorianCalendar.MONTH, -1);
	GregorianCalendar dateFin = new GregorianCalendar();
	dateFin.add(GregorianCalendar.MONTH, 1);

	// search URI (contains the search window)
	Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
	ContentUris.appendId(builder, dateDebut.getTimeInMillis());
	ContentUris.appendId(builder, dateFin.getTimeInMillis());

	return builder.build();
}
 
开发者ID:rparkins999,项目名称:CalendarTrigger,代码行数:15,代码来源:CalendarProvider.java

示例12: getInstancesQueryUri

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
private Uri getInstancesQueryUri() {
	// Event search window : from one month before to one month after, to be sure
	GregorianCalendar dateDebut = new GregorianCalendar();
	dateDebut.add(GregorianCalendar.MONTH, -1);
	GregorianCalendar dateFin = new GregorianCalendar();
	dateFin.add(GregorianCalendar.MONTH, 1);
	
	// search URI (contains the search window)
	Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
	ContentUris.appendId(builder, dateDebut.getTimeInMillis());
	ContentUris.appendId(builder, dateFin.getTimeInMillis());
	
	return builder.build();
}
 
开发者ID:RemiNV,项目名称:CalendarMute,代码行数:15,代码来源:CalendarProvider.java

示例13: getNextEvent

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
/**
 * Get the next event in the calendars set in the preferences
 * @param currentTime Time to use to search for events
 * @param early Delay to extend event start time before the real start time
 * @return The first event found, or null if there is none
 */
public CalendarEvent getNextEvent(long currentTime, long early, boolean onlyBusy) {
	ContentResolver cr = context.getContentResolver();
	
	// Make the calendar ID selection string
	String calIdsSelect = getEventCalendarIdsSelectString();
	
	if(calIdsSelect.equals(""))
		return null;
	
	// Selection is inclusive on event start time.
	// This way we are consistent wih getCurrentEvent
	String selection = "(" + calIdsSelect + ") AND "
			+ Instances.BEGIN + " >= ? AND " + Instances.ALL_DAY + " = 0";
	
	if(onlyBusy) {
		selection += " AND " + Instances.AVAILABILITY + " = " + Instances.AVAILABILITY_BUSY;
	}
	
	// Substract early from Instances.BEGIN -> same as adding early to currentTime when comparing
	String strCurrentTime = String.valueOf(currentTime + early);
	String[] selectionArgs =  new String[] { strCurrentTime };
	
	Cursor cur = cr.query(getInstancesQueryUri(), INSTANCE_PROJECTION, selection, selectionArgs, Instances.BEGIN); // Sort by start time to get the first event
	
	CalendarEvent res;
	if(cur != null && cur.moveToNext())
		res = new CalendarEvent(cur.getString(INSTANCE_PROJECTION_TITLE_INDEX), cur.getLong(INSTANCE_PROJECTION_BEGIN_INDEX), cur.getLong(INSTANCE_PROJECTION_END_INDEX));
	else {
		res = null;
	}

	if(cur != null) {
		cur.close();
	}
	return res;
}
 
开发者ID:RemiNV,项目名称:CalendarMute,代码行数:43,代码来源:CalendarProvider.java

示例14: filterOnCalendarIDAndCalendarDisplayName

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
/**
 * Commodity method to generate the correct filter string and arguments list according to the owners and visibility defined
 *
 * @param idCalendars          calendar IDs to filter
 * @param calendarDisplayNames calendar display name to filter
 * @return a {@code Pair} containing as first field the selection string and as second field the selection arguments
 */
private static Pair<String, String[]> filterOnCalendarIDAndCalendarDisplayName(Collection<Integer> idCalendars, Collection<String> calendarDisplayNames) {
    String selection = null;
    String selectionArgs[] = null;

    if (idCalendars != null && idCalendars.size() == 0) {
        idCalendars = null;
    }
    if (calendarDisplayNames != null && calendarDisplayNames.size() == 0) {
        calendarDisplayNames = null;
    }

    if (idCalendars != null || calendarDisplayNames != null) {
        // selection will look like
        // calendar_id=? OR calendar_id=? OR calendar_displayName=? OR calendar_displayName=?
        StringBuilder builder = new StringBuilder();
        List<String> arguments = new ArrayList<>();
        if (idCalendars != null) {
            for (Integer idCalendar : idCalendars) {
                builder.append(Instances.CALENDAR_ID).append("=? OR ");
                arguments.add(idCalendar + "");
            }
            builder.setLength(builder.length() - 4);
        }
        if (calendarDisplayNames != null) {
            for (String calendarDisplayName : calendarDisplayNames) {
                builder.append(Instances.CALENDAR_DISPLAY_NAME).append("=? OR ");
                arguments.add(calendarDisplayName);
            }
            builder.setLength(builder.length() - 4);
        }
        selection = builder.toString();
        selectionArgs = arguments.toArray(new String[arguments.size()]);
    }
    return Pair.create(selection, selectionArgs);
}
 
开发者ID:macisamuele,项目名称:CalendarProvider-Lib,代码行数:43,代码来源:EventInfo.java

示例15: getPendingIntent

import android.provider.CalendarContract.Instances; //导入依赖的package包/类
private PendingIntent getPendingIntent(Instance instance) {
    Intent muteIntent = new Intent(getApplicationContext(), MutePhoneBroadcastReceiver.class);
    muteIntent.setAction(Actions.MUTE);
    muteIntent.putExtra(Instances.DTEND, instance.getEndDate());
    muteIntent.putExtra(Instances._ID, instance.getId());

    return PendingIntent.getBroadcast(getApplicationContext(), instance.getId(), muteIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}
 
开发者ID:gigaSproule,项目名称:silent-meeting,代码行数:9,代码来源:AlarmService.java


注:本文中的android.provider.CalendarContract.Instances类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。