/** * Builds a URI that adds the weather date to the end of the forecast content URI path. * This is used to query details about a single weather entry by date. This is what we * use for the detail view query. We assume a normalized date is passed to this method. * * @param date Normalized date in milliseconds * @return Uri to query details about a single weather entry */ public static Uri buildWeatherUriWithDate(long date) { return CONTENT_URI.buildUpon() .appendPath(Long.toString(date)) .build(); }
/** * Builds a URI that adds the weather date to the end of the forecast content URI path. * This is used to query details about a single weather entry by date. This is what we * use for the detail view query. We assume a normalized date is passed to this method. * * @param date Normalized date in milliseconds * @return Uri to query details about a single weather entry */ public static Uri buildWeatherUriWithDate(long date) { return CONTENT_URI.buildUpon() .appendPath(Long.toString(date)) .build(); }
/** * Builds a URI that adds the weather date to the end of the forecast content URI path. * This is used to query details about a single weather entry by date. This is what we * use for the detail view query. We assume a normalized date is passed to this method. * * @param date Normalized date in milliseconds * @return Uri to query details about a single weather entry */ public static Uri buildWeatherUriWithDate(long date) { return CONTENT_URI.buildUpon() .appendPath(Long.toString(date)) .build(); }
/** * Builds a URI that adds the weather date to the end of the forecast content URI path. * This is used to query details about a single weather entry by date. This is what we * use for the detail view query. We assume a normalized date is passed to this method. * * @param date Normalized date in milliseconds * @return Uri to query details about a single weather entry */ public static Uri buildWeatherUriWithDate(long date) { return CONTENT_URI.buildUpon() .appendPath(Long.toString(date)) .build(); }
@Test public void testClearSelection() { activity.onItemSelected(new TestHnItem(1L)); MaterialisticDatabase.getInstance(RuntimeEnvironment.application).setLiveValue(MaterialisticDatabase .getBaseSavedUri() .buildUpon() .appendPath("clear") .build()); assertNull(activity.getSelectedItem()); }
@Override public String syncURL() { // Allow user to specify custom sync server SharedPreferences userPreferences = AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance()); if (userPreferences!= null && userPreferences.getBoolean("useCustomSyncServer", false)) { Uri syncBase = Uri.parse(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE)); return syncBase.buildUpon().appendPath("sync").toString() + "/"; } // Usual case return Consts.SYNC_BASE + "sync/"; }
public String syncURL() { // Allow user to specify custom sync server SharedPreferences userPreferences = AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance()); if (userPreferences!= null && userPreferences.getBoolean("useCustomSyncServer", false)) { Uri syncBase = Uri.parse(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE)); return syncBase.buildUpon().appendPath("sync").toString() + "/"; } // Usual case return Consts.SYNC_BASE + "sync/"; } }
@Override public String getField(MessageInfoHolder source) { LocalMessage message = source.message; int accountNumber = message.getAccount().getAccountNumber(); return CONTENT_URI.buildUpon() .appendPath("delete_message") .appendPath(Integer.toString(accountNumber)) .appendPath(message.getFolder().getServerId()) .appendPath(message.getUid()) .build() .toString(); } }
public static Uri getRawMessageUri(MessageReference messageReference) { return CONTENT_URI.buildUpon() .appendPath(messageReference.toIdentityString()) .build(); }
public static Uri getAttachmentUri(String accountUuid, long id) { return CONTENT_URI.buildUpon() .appendPath(accountUuid) .appendPath(Long.toString(id)) .build(); }
public Uri getContentUri() { return new Uri.Builder() .scheme("file") .path("/android_asset") .appendPath(filename) .build(); }
@Test public void load_withApplicationIconResourceNameUri_asBitmap_withTransform_nonNullBitmap() throws ExecutionException, InterruptedException, NameNotFoundException { for (String packageName : getInstalledPackages()) { int iconResourceId = getResourceId(packageName); Context toUse = context.createPackageContext(packageName, /*flags=*/ 0); Resources resources = toUse.getResources(); Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(packageName) .appendPath(resources.getResourceTypeName(iconResourceId)) .appendPath(resources.getResourceEntryName(iconResourceId)) .build(); Bitmap bitmap = Glide.with(context) .asBitmap() .apply(centerCropTransform()) .load(uri) .submit() .get(); assertThat(bitmap).isNotNull(); } }
@Test public void loadVideoResourceUri_fromName_withFrame_decodesFrame() { Resources resources = context.getResources(); int resourceId = ResourceIds.raw.video; Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(resources.getResourcePackageName(resourceId)) .appendPath(resources.getResourceTypeName(resourceId)) .appendPath(resources.getResourceEntryName(resourceId)) .build(); Bitmap frame = concurrency.get( GlideApp.with(context) .asBitmap() .load(uri) .frame(TimeUnit.SECONDS.toMicros(1)) .submit()); assertThat(frame).isNotNull(); }
@Test public void loadVideoResourceUriString_fromName_withFrame_decodesFrame() { Resources resources = context.getResources(); int resourceId = ResourceIds.raw.video; Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(resources.getResourcePackageName(resourceId)) .appendPath(resources.getResourceTypeName(resourceId)) .appendPath(resources.getResourceEntryName(resourceId)) .build(); Bitmap frame = concurrency.get( GlideApp.with(context) .asBitmap() .load(uri.toString()) .frame(TimeUnit.SECONDS.toMicros(1)) .submit()); assertThat(frame).isNotNull(); } }
@Test public void load_withApplicationIconResourceNameUri_asDrawable_withTransform_nonNullDrawable() throws ExecutionException, InterruptedException, NameNotFoundException { for (String packageName : getInstalledPackages()) { int iconResourceId = getResourceId(packageName); Context toUse = context.createPackageContext(packageName, /*flags=*/ 0); Resources resources = toUse.getResources(); Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(packageName) .appendPath(resources.getResourceTypeName(iconResourceId)) .appendPath(resources.getResourceEntryName(iconResourceId)) .build(); Drawable drawable = Glide.with(context) .load(uri) .apply(centerCropTransform()) .submit() .get(); assertThat(drawable).isNotNull(); } }
@Test public void load_withApplicationIconResourceNameUri_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException, NameNotFoundException { for (String packageName : getInstalledPackages()) { int iconResourceId = getResourceId(packageName); Context toUse = context.createPackageContext(packageName, /*flags=*/ 0); Resources resources = toUse.getResources(); Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(packageName) .appendPath(resources.getResourceTypeName(iconResourceId)) .appendPath(resources.getResourceEntryName(iconResourceId)) .build(); Bitmap bitmap = Glide.with(context) .asBitmap() .load(uri) .submit() .get(); assertThat(bitmap).isNotNull(); } }
@Test public void load_withApplicationIconResourceNameUri_asDrawable_producesNonNullDrawable() throws ExecutionException, InterruptedException, NameNotFoundException { for (String packageName : getInstalledPackages()) { int iconResourceId = getResourceId(packageName); Context toUse = context.createPackageContext(packageName, /*flags=*/ 0); Resources resources = toUse.getResources(); Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(packageName) .appendPath(resources.getResourceTypeName(iconResourceId)) .appendPath(resources.getResourceEntryName(iconResourceId)) .build(); Drawable drawable = Glide.with(context) .load(uri) .submit() .get(); assertThat(drawable).isNotNull(); } }
@Test public void loadVideoResourceUri_asBitmap_fromName_decodesFrame() { Resources resources = context.getResources(); int resourceId = ResourceIds.raw.video; Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(resources.getResourcePackageName(resourceId)) .appendPath(resources.getResourceTypeName(resourceId)) .appendPath(resources.getResourceEntryName(resourceId)) .build(); Bitmap frame = concurrency.get( GlideApp.with(context) .asBitmap() .load(uri) .submit()); assertThat(frame).isNotNull(); }
@Test public void loadVideoResourceUriString_fromName_decodesFrame() { Resources resources = context.getResources(); int resourceId = ResourceIds.raw.video; Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(resources.getResourcePackageName(resourceId)) .appendPath(resources.getResourceTypeName(resourceId)) .appendPath(resources.getResourceEntryName(resourceId)) .build(); Bitmap frame = concurrency.get( GlideApp.with(context) .asBitmap() .load(uri.toString()) .submit()); assertThat(frame).isNotNull(); }
@Test public void loadVideoResourceUri_fromName_decodesFrame() { Resources resources = context.getResources(); int resourceId = ResourceIds.raw.video; Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(resources.getResourcePackageName(resourceId)) .appendPath(resources.getResourceTypeName(resourceId)) .appendPath(resources.getResourceEntryName(resourceId)) .build(); Drawable frame = concurrency.get( GlideApp.with(context) .load(uri) .submit()); assertThat(frame).isNotNull(); }