All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.robolectric.shadows.ShadowContentUris Maven / Gradle / Ivy

There is a newer version: 4.14
Show newest version
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