Package-level declarations

Albums management.

Albums

The functionality of albums is described by the Albums interface.

val photoManager: PhotoManager
val albums: Albums = photoManager.albums

Working with albums is divided into actions with the album and its content.

Album Actions

Fetch Albums

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
albums.fetchAlbums(
userId = 0L,
types = setOf(
AlbumType.SIMPLE,
AlbumType.FLASHBACK,
AlbumType.PLACES,
)
)
}

lifecycleScope.launch(Dispatchers.IO) {
albums.createAlbumsFlow(
userId = 0L,
albumTypes = setOf(AlbumType.SIMPLE, AlbumType.SHARED_BY_ME)
).collect { albums -> // albums: List<AlbumItem>
// Handle it...
}
}

Create Album

The Create Album operation creates an album for the specified user. When calling, you can specify the album type, its name, and a list of media to be added when creating the album. Any unuploaded media will be uploaded later.

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
val result: CreateAlbumResult = albums.createAlbum(
userId = 0L,
type = AlbumType.SIMPLE,
name = "Album name",
mediaIds = setOf(1L, 2L, 3L),
mediaUris = setOf("URI1", "URI2", "URI3")
)
}

Edit Album

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
val album: AlbumItem = albums.editAlbum(
albumId = 0L,
type = AlbumType.SIMPLE,
name = "New album name",
isViewed = true, // Mark album as viewed
hideItems = true // Hide album items from timeline.
)
}

Delete Album

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
albums.deleteAlbum(
albumId = 0L,
)
}

Album Shared Link

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
val sharedLink: SharedLinkItem? = albums.getSharedLink(
albumId = 0L
)

val album: AlbumItem = albums.openSharedLink(
sharedLink = "shared link"
)
}

Album Content Actions

Fetch Album Content

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
albums.fetchAlbumContent(
albumId = 0L
)
}

Add Media To Album

When you open the album, you can specify the album type, its name, and a list of media to be added when creating the album. Any unuploaded media will be uploaded later.

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
val result: AddMediaToAlbumResult = albums.addMediaToAlbum(
albumId = 0L,
mediaIds = setOf(1L, 2L, 3L),
mediaUris = setOf("URI1", "URI2", "URI3")
)
}

Delete Media From Album

val albums: Albums

lifecycleScope.launch(Dispatchers.IO) {
val result: DeleteMediaFromAlbumResult = albums.deleteMediaFromAlbum(
albumId = 0L,
mediaIds = setOf(1L, 2L, 3L)
)
}

Types

Link copied to clipboard
data class AddMediaToAlbumResult(val addedMediaCount: Int, val failedMediaCount: Int, val failedReasons: List<Throwable>)
Link copied to clipboard
data class AlbumCover(val fileObjectName: String, val coordinates: List<Int>?, val previews: List<AlbumCover.Preview>) : Parcelable
Link copied to clipboard
data class AlbumDatabaseSummary(val photoCount: Int, val videoCount: Int)
Link copied to clipboard
data class AlbumItem(val id: Long, val types: Set<AlbumType>, val description: String, val covers: List<AlbumCover>, val createdAt: Long, val updatedAt: Long, val firstPhotoCreatedAt: Long, val lastPhotoCreatedAt: Long, val itemsCount: Int, val isViewed: Boolean, val isVisible: Boolean, val hideItems: Boolean, val setSharedLink: String?) : Parcelable
Link copied to clipboard
interface Albums

Provides functionality for working with albums.

Link copied to clipboard
Link copied to clipboard
data class CreateAlbumResult(val album: AlbumItem, val addMediaResult: AddMediaToAlbumResult?)
Link copied to clipboard
data class DeleteMediaFromAlbumResult(val deletedMediaCount: Int, val failedMediaCount: Int, val failedReasons: List<Throwable>)