org.robolectric.shadows.ShadowContentUris Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadows-framework Show documentation
Show all versions of shadows-framework Show documentation
An alternative Android testing framework.
package org.robolectric.shadows;
import android.content.ContentUris;
import android.net.Uri;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@Implements(ContentUris.class)
public class ShadowContentUris {
@Implementation
protected static Uri withAppendedId(Uri contentUri, long id) {
return Uri.withAppendedPath(contentUri, String.valueOf(id));
}
@Implementation
protected static long parseId(Uri contentUri) {
if (!contentUri.isHierarchical()) {
throw new UnsupportedOperationException();
}
String path = contentUri.getLastPathSegment();
if (path == null) return -1;
return Long.parseLong(path);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy