public override void OnSwiped(RecyclerView.ViewHolder viewHolder, int direction) { long id = (long)viewHolder.ItemView.Tag; Android.Net.Uri uri = TaskContract.TaskEntry.CONTENT_URI; uri = uri.BuildUpon().AppendPath(id + "").Build(); this.activity.ContentResolver.Delete(uri, null, null); this.activity.LoaderManager.RestartLoader(MainActivity.TASK_LOADER_ID, null, (LoaderManager.ILoaderCallbacks) this.activity); }
Bitmap FetchFavicon(Uri uri) { var iconUri = uri.BuildUpon().Path("favicon.ico").Build(); Log.Info(TAG, "Fetching favicon from: " + iconUri); BufferedStream bis = null; Stream inputStream; try { var conn = new URL(iconUri.ToString()).OpenConnection(); conn.Connect(); inputStream = conn.InputStream; bis = new BufferedStream(inputStream, 8192); return(BitmapFactory.DecodeStream(bis)); } catch (IOException e) { Log.Warn(TAG, "Failed to fetch favicon from " + iconUri, e); return(null); } }
/** Build {@link Uri} for requested {@link #VENDOR_ID}. */ public static Uri BuildVendorUri(String vendorId) { return(CONTENT_URI.BuildUpon().AppendPath(vendorId).Build()); }
/** Build {@link Uri} for requested {@link #SPEAKER_ID}. */ public static Uri BuildSpeakerUri(String speakerId) { return(CONTENT_URI.BuildUpon().AppendPath(speakerId).Build()); }
/** Build {@link Uri} for requested {@link #SESSION_ID}. */ public static Uri BuildSessionUri(String sessionId) { return(CONTENT_URI.BuildUpon().AppendPath(sessionId).Build()); }
/** Build {@link Uri} for requested {@link #ROOM_ID}. */ public static Uri BuildRoomUri(String roomId) { return(CONTENT_URI.BuildUpon().AppendPath(roomId).Build()); }
/** Build {@link Uri} for requested {@link #TRACK_ID}. */ public static Uri BuildTrackUri(String trackId) { return(CONTENT_URI.BuildUpon().AppendPath(trackId).Build()); }
/** Build {@link Uri} for requested {@link #BLOCK_ID}. */ public static Uri BuildBlockUri(String blockId) { return(CONTENT_URI.BuildUpon().AppendPath(blockId).Build()); }
/// <summary> /// Creates a new calendar or updates the name and color of an existing one. /// </summary> /// <param name="calendar">The calendar to create/update</param> /// <exception cref="System.ArgumentException">Calendar does not exist on device or is read-only</exception> /// <exception cref="System.UnauthorizedAccessException">Calendar access denied</exception> /// <exception cref="Calendars.Plugin.Abstractions.PlatformException">Unexpected platform-specific error</exception> public async Task AddOrUpdateCalendarAsync(Calendar calendar) { bool updateExisting = false; long existingId = -1; if (long.TryParse(calendar.ExternalID, out existingId)) { var existingCalendar = await GetCalendarByIdAsync(calendar.ExternalID).ConfigureAwait(false); if (existingCalendar != null) { if (!existingCalendar.CanEditCalendar) { throw new ArgumentException("Destination calendar is not writeable"); } updateExisting = true; } else { throw new ArgumentException("Specified calendar does not exist on device", "calendar"); } } var values = new ContentValues(); values.Put(CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, calendar.Name); values.Put(CalendarContract.Calendars.Name, calendar.Name); // Unlike iOS/WinPhone, Android does not automatically assign a color for us, // so we use our own default of blue. // int colorInt = unchecked ((int)0xFF0000FF); if (!string.IsNullOrEmpty(calendar.Color)) { int.TryParse(calendar.Color.Trim('#'), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out colorInt); } values.Put(CalendarContract.Calendars.InterfaceConsts.CalendarColor, colorInt); if (!updateExisting) { values.Put(CalendarContract.Calendars.InterfaceConsts.CalendarAccessLevel, (int)CalendarAccess.AccessOwner); values.Put(CalendarContract.Calendars.InterfaceConsts.AccountName, AccountName); values.Put(CalendarContract.Calendars.InterfaceConsts.OwnerAccount, OwnerAccount); values.Put(CalendarContract.Calendars.InterfaceConsts.Visible, true); values.Put(CalendarContract.Calendars.InterfaceConsts.SyncEvents, true); values.Put(CalendarContract.Calendars.InterfaceConsts.AccountType, CalendarContract.AccountTypeLocal); } await Task.Run(() => { if (updateExisting) { Update(_calendarsUri, existingId, values); } else { var uri = _calendarsUri.BuildUpon() .AppendQueryParameter(CalendarContract.CallerIsSyncadapter, "true") .AppendQueryParameter(CalendarContract.Calendars.InterfaceConsts.AccountName, AccountName) .AppendQueryParameter(CalendarContract.Calendars.InterfaceConsts.AccountType, CalendarContract.AccountTypeLocal) .Build(); calendar.ExternalID = Insert(uri, values); calendar.CanEditCalendar = true; calendar.CanEditEvents = true; calendar.Color = "#" + colorInt.ToString("x8"); } }).ConfigureAwait(false); }
/// <summary> /// Builds the weather location. /// </summary> /// <returns>The weather location.</returns> /// <description> /// Student: Fill in this buildWeatherLocation function /// </description> public static Android.Net.Uri BuildWeatherLocation(string locationSetting) { return(ContentUri.BuildUpon().AppendPath(locationSetting).Build()); }