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


Java CalendarContract类代码示例

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


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

示例1: addEventToCalendar

import android.provider.CalendarContract; //导入依赖的package包/类
private void addEventToCalendar(ColegiElectoral colegiElectoral) {
    Calendar calendar = Calendar.getInstance(Locale.getDefault());
    calendar.set(2017, Calendar.OCTOBER, 1, 9, 0);

    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setType("vnd.android.cursor.item/event");
    intent.putExtra(CalendarContract.Events.TITLE, StringsManager.getString("notification_title"));
    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calendar.getTimeInMillis());
    intent.putExtra(CalendarContract.Events.ALL_DAY, true);
    String location = colegiElectoral.getLocal() + ": " + colegiElectoral.getAdresa() + ", " + colegiElectoral.getMunicipi();
    intent.putExtra(CalendarContract.Events.EVENT_LOCATION, location);

    startActivity(intent);
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:15,代码来源:VoteFragment.java

示例2: addEventOnCalendar

import android.provider.CalendarContract; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void addEventOnCalendar(PersianDate persianDate) {
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.setData(CalendarContract.Events.CONTENT_URI);

    CivilDate civil = DateConverter.persianToCivil(persianDate);

    intent.putExtra(CalendarContract.Events.DESCRIPTION,
            mPersianCalendarHandler.dayTitleSummary(persianDate));

    Calendar time = Calendar.getInstance();
    time.set(civil.getYear(), civil.getMonth() - 1, civil.getDayOfMonth());

    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
            time.getTimeInMillis());
    intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
            time.getTimeInMillis());
    intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

    startActivity(intent);
}
 
开发者ID:Roojin,项目名称:persian-calendar-view,代码行数:22,代码来源:CalendarFragment.java

示例3: findLocalCalendar

import android.provider.CalendarContract; //导入依赖的package包/类
private long findLocalCalendar() throws android.os.RemoteException,
                                        android.database.sqlite.SQLiteException {
    Cursor cur = mContext.getContentProviderClient().query(
            CalendarContract.Calendars.CONTENT_URI,
            new String[]{ CalendarContract.Calendars._ID },
            String.format("((%s = ?) AND (%s = ?) AND (%s = ?) AND (%s = ?))",
                    CalendarContract.Calendars.ACCOUNT_NAME,
                    CalendarContract.Calendars.ACCOUNT_TYPE,
                    CalendarContract.Calendars.OWNER_ACCOUNT,
                    CalendarContract.Calendars.NAME),
            new String[]{
                    mContext.getAccount().name,
                    mContext.getContext().getString(R.string.account_type),
                    mContext.getAccount().name,
                    mType.id()},
            null);
    long result = -1;
    if (cur != null) {
        if (cur.moveToNext()) {
            result = cur.getLong(0);
        }
        cur.close();
    }
    return result;
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:26,代码来源:FBCalendar.java

示例4: fetchLocalEvents

import android.provider.CalendarContract; //导入依赖的package包/类
private HashMap<String /* FBID */, Long /* local ID */ > fetchLocalEvents(
        String selectorQuery, String[] selectorValues)
        throws android.os.RemoteException,
               android.database.sqlite.SQLiteException
{
    HashMap<String, Long> localIds = new HashMap<>();

    // HACK: Only select future events: Facebook will remove the events from the listing once
    // they pass, but it's desirable that we keep them in the calendar. The only way to achieve
    // so is to ignore them
    Cursor cur = mContext.getContentProviderClient().query(
            CalendarContract.Events.CONTENT_URI,
            new String[]{
                    CalendarContract.Events.UID_2445,
                    CalendarContract.Events._ID },
            selectorQuery, selectorValues,
            null);
    if (cur != null) {
        while (cur.moveToNext()) {
            localIds.put(cur.getString(0), cur.getLong(1));
        }
        cur.close();
    }
    return localIds;
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:26,代码来源:FBCalendar.java

示例5: getLocalReminders

import android.provider.CalendarContract; //导入依赖的package包/类
private HashMap<Integer /* minutes */, Long /* reminder ID */> getLocalReminders(SyncContext context, long localEventId)
    throws android.os.RemoteException,
           android.database.sqlite.SQLiteException
{
    Cursor cur = context.getContentProviderClient().query(
            CalendarContract.Reminders.CONTENT_URI,
            new String[]{
                    CalendarContract.Reminders._ID,
                    CalendarContract.Reminders.MINUTES },
            String.format("(%s = ?)", CalendarContract.Reminders.EVENT_ID),
            new String[]{ String.valueOf(localEventId) },
            null);
    @SuppressLint("UseSparseArrays")
    HashMap<Integer /* minutes */, Long /* reminder ID */> localReminders = new HashMap<>();
    if (cur != null) {
        while (cur.moveToNext()) {
            localReminders.put(cur.getInt(1), cur.getLong(0));
        }
        cur.close();
    }

    return localReminders;
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:24,代码来源:FBEvent.java

示例6: createReminders

import android.provider.CalendarContract; //导入依赖的package包/类
private void createReminders(SyncContext context, long localEventId, Set<Integer> reminders)
    throws android.os.RemoteException,
           android.database.sqlite.SQLiteException
{
    ArrayList<ContentValues> reminderValues = new ArrayList<>();
    for (int reminder : reminders) {
        ContentValues values = new ContentValues();
        values.put(CalendarContract.Reminders.EVENT_ID, localEventId);
        values.put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
        values.put(CalendarContract.Reminders.MINUTES, reminder);
        reminderValues.add(values);
    }

    Uri uri = CalendarContract.Reminders.CONTENT_URI.buildUpon()
            .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
            .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, context.getAccount().name)
            .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, context.getContext().getString(R.string.account_type))
            .build();

    context.getContentProviderClient().bulkInsert(
            uri,
            reminderValues.toArray(new ContentValues[0]));
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:24,代码来源:FBEvent.java

示例7: openCalendar

import android.provider.CalendarContract; //导入依赖的package包/类
@TargetApi(14)
private void openCalendar(JSONArray args) {
  try {
    final Long millis = args.getJSONObject(0).optLong("date");

    cordova.getThreadPool().execute(new Runnable() {
      @Override
      public void run() {
        final Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon().appendPath("time");
        ContentUris.appendId(builder, millis);

        final Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
        Calendar.this.cordova.startActivityForResult(Calendar.this, intent, RESULT_CODE_OPENCAL);

        callback.success();
      }
    });
  } catch (JSONException e) {
    System.err.println("Exception: " + e.getMessage());
    callback.error(e.getMessage());
  }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:23,代码来源:Calendar.java

示例8: deleteCalendar

import android.provider.CalendarContract; //导入依赖的package包/类
@SuppressWarnings("MissingPermission") // already requested in calling method
public void deleteCalendar(String calendarName) {
    try {
        Uri evuri = CalendarContract.Calendars.CONTENT_URI;
        final ContentResolver contentResolver = cordova.getActivity().getContentResolver();
        Cursor result = contentResolver.query(evuri, new String[]{CalendarContract.Calendars._ID, CalendarContract.Calendars.NAME, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME}, null, null, null);
        if (result != null) {
            while (result.moveToNext()) {
                if (result.getString(1).equals(calendarName) || result.getString(2).equals(calendarName)) {
                    long calid = result.getLong(0);
                    Uri deleteUri = ContentUris.withAppendedId(evuri, calid);
                    contentResolver.delete(deleteUri, null, null);
                }
            }
            result.close();
        }

        // also delete previously crashing calendars, see https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin/issues/241
        deleteCrashingCalendars(contentResolver);
    } catch (Throwable t) {
        System.err.println(t.getMessage());
        t.printStackTrace();
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:25,代码来源:AbstractCalendarAccessor.java

示例9: buildEvent

import android.provider.CalendarContract; //导入依赖的package包/类
@Override
protected void buildEvent(Event recurrence, ContentProviderOperation.Builder builder) {
    super.buildEvent(recurrence, builder);

    boolean buildException = recurrence != null;
    Event eventToBuild = buildException ? recurrence : event;

    builder.withValue(COLUMN_UID, event.uid)
            .withValue(COLUMN_SEQUENCE, eventToBuild.sequence)
            .withValue(CalendarContract.Events.DIRTY, 0)
            .withValue(CalendarContract.Events.DELETED, 0);

    if (buildException) {
        builder.withValue(CalendarContract.Events.ORIGINAL_SYNC_ID, fileName);
    } else {
        builder.withValue(CalendarContract.Events._SYNC_ID, fileName)
                .withValue(COLUMN_ETAG, eTag);
    }
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:20,代码来源:LocalEvent.java

示例10: getCalendars

import android.provider.CalendarContract; //导入依赖的package包/类
/**
 * fetching all calendars from local android calendar db
 *
 * @return a set of all calendars
 */
public Set<String> getCalendars() {
    // Fetch a list of all calendars sync'd with the device and their display names
    Cursor cursor = contentResolver.query(CALENDAR_URI, FIELDS, null, null, null);

    try {
        if (cursor.getCount() > 0) {
            while (cursor.moveToNext()) {
                String name = cursor.getString(0);
                String displayName = cursor.getString(1);
                // This is actually a better pattern:
                String color = cursor.getString(cursor.getColumnIndex(CalendarContract.Calendars.CALENDAR_COLOR));
                Boolean selected = !cursor.getString(3).equals("0");
                calendars.add(displayName);
            }
        }
    } catch (AssertionError ex) { /*TODO: log exception and bail*/ }

    return calendars;
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:25,代码来源:CalendarContentUtil.java

示例11: getCalendarIdForName

import android.provider.CalendarContract; //导入依赖的package包/类
public String getCalendarIdForName(String calendarName) {
    String selection = "(" + CalendarContract.Calendars.NAME + " = ?)";
    String[] selectionArgs = new String[] {calendarName};
    Cursor cursor = contentResolver.query(CALENDAR_URI, FIELDS, selection, selectionArgs, null);

    try {
        if (cursor.getCount() > 0) {
            while (cursor.moveToNext()) {
                String id = cursor.getString(0);
                return id;
            }
        }
    } catch (AssertionError ex) { /*TODO: log exception and bail*/ }

    return "";
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:17,代码来源:CalendarContentUtil.java

示例12: ensureCalendarPermissions

import android.provider.CalendarContract; //导入依赖的package包/类
private boolean ensureCalendarPermissions()
{
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED)
    {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR }, 0);
        return false;
    }
    if (mCalendarsClient == null)
    {
        mCalendarsClient = getContentResolver().acquireContentProviderClient(CalendarContract.AUTHORITY);
        mCalendarQueue = new BasicOperationsQueue(mCalendarsClient);
    }
    return true;
}
 
开发者ID:dmfs,项目名称:ContentPal,代码行数:17,代码来源:DemoActivity.java

示例13: create

import android.provider.CalendarContract; //导入依赖的package包/类
public static Uri create(@NonNull Account account, @NonNull ContentProviderClient provider, @NonNull
        CollectionInfo info) throws
        CalendarStorageException {
    ContentValues values = valuesFromCollectionInfo(info, true);

    // ACCOUNT_NAME and ACCOUNT_TYPE are required (see docs)! If it's missing, other apps will crash.
    values.put(CalendarContract.Calendars.ACCOUNT_NAME, account.name);
    values.put(CalendarContract.Calendars.ACCOUNT_TYPE, account.type);
    values.put(CalendarContract.Calendars.OWNER_ACCOUNT, account.name);

    // flag as visible & synchronizable at creation, might be changed by user at any time
    values.put(CalendarContract.Calendars.VISIBLE, 0);
    values.put(CalendarContract.Calendars.SYNC_EVENTS, 1);

    return create(account, provider, values);
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:17,代码来源:LocalCalendar.java

示例14: getDirty

import android.provider.CalendarContract; //导入依赖的package包/类
@Override
public LocalResource[] getDirty() throws CalendarStorageException, FileNotFoundException {
    List<LocalResource> dirty = new LinkedList<>();

    // get dirty events which are required to have an increased SEQUENCE value
    for (LocalEvent event : (LocalEvent[]) queryEvents(
            CalendarContract.Events.DIRTY + "!=0 AND " + CalendarContract.Events.ORIGINAL_ID + " IS NULL",
            null)) {
        if (event.getEvent().sequence ==
                null)      // sequence has not been assigned yet (i.e. this event was just locally created)
        {
            event.getEvent().sequence = 0;
        } else if (event.weAreOrganizer) {
            event.getEvent().sequence++;
        }
        dirty.add(event);
    }

    return dirty.toArray(new LocalResource[dirty.size()]);
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:21,代码来源:LocalCalendar.java

示例15: testSelection

import android.provider.CalendarContract; //导入依赖的package包/类
@Test
public void testSelection() throws Exception
{
    TransactionContext mockTc = failingMock(TransactionContext.class);
    SoftRowReference<CalendarContract.Calendars> dummyReference = dummy(SoftRowReference.class);
    RowSnapshot<CalendarContract.Calendars> mockCalendarRow = failingMock(RowSnapshot.class);

    doReturn(dummyReference).when(mockCalendarRow).reference();
    doReturn(new BackReference<>(dummy(Uri.class), 12)).when(mockTc).resolved(dummyReference);

    assertThat(new CalendarScoped(mockCalendarRow, new EqArg("x", "y")),
            predicateWith(
                    selection(mockTc, "( x = ? ) and ( calendar_id = ? )"),
                    argumentValues(mockTc, "y", "-1"),
                    backReferences(mockTc, AbsentMatcher.<Integer>isAbsent(), isPresent(12))
            ));
}
 
开发者ID:dmfs,项目名称:ContentPal,代码行数:18,代码来源:CalendarScopedPredicateTest.java


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