ChannelLogoUtils
@WorkerThread open class ChannelLogoUtils
kotlin.Any | |
↳ | androidx.tvprovider.media.tv.ChannelLogoUtils |
A utility class for conveniently storing and loading channel logos.
Summary
Public constructors | |
---|---|
<init>() |
Public methods | |
---|---|
open static Bitmap! |
loadChannelLogo(@NonNull context: Context, channelId: Long) A convenient helper method to get the channel logo associated to the given channel ID from the system content provider. |
open static Boolean |
storeChannelLogo(@NonNull context: Context, channelId: Long, @NonNull logoUri: Uri) Stores channel logo in the system content provider from the given URI. |
open static Boolean |
storeChannelLogo(@NonNull context: Context, channelId: Long, @NonNull logo: Bitmap) Stores the given channel logo |
Public constructors
<init>
ChannelLogoUtils()
Deprecated: This type should not be instantiated as it contains only static methods.
Public methods
loadChannelLogo
@WorkerThread open static fun loadChannelLogo(
@NonNull context: Context,
channelId: Long
): Bitmap!
A convenient helper method to get the channel logo associated to the given channel ID from the system content provider.
Parameters | |
---|---|
context |
Context: the context used to access the system content provider |
channelId |
Long: the ID of the channel whose logo is supposed to be loaded |
Return | |
---|---|
Bitmap! |
the requested channel logo in Bitmap , or null if not available. |
storeChannelLogo
open static fun storeChannelLogo(
@NonNull context: Context,
channelId: Long,
@NonNull logoUri: Uri
): Boolean
Stores channel logo in the system content provider from the given URI. The method will try to fetch the image file and decode it into Bitmap
. Once the image is successfully fetched, it will be stored in the system content provider and associated with the given channel ID.
The URI provided to this method can be a URL referring to a image file residing in some remote site/server, or a URI in one of the following formats:
- content (
android.content.ContentResolver#SCHEME_CONTENT
) - android.resource (
#SCHEME_ANDROID_RESOURCE
) - file (
android.content.ContentResolver#SCHEME_FILE
)
This method should be run in a worker thread since it may require network connection, which will raise an exception if it's running in the main thread.
Parameters | |
---|---|
context |
Context: the context used to access the system content provider |
channelId |
Long: the ID of the target channel with which the fetched logo should be associated |
logoUri |
Uri: the Uri of the logo file to be fetched and stored in the system provider |
Return | |
---|---|
Boolean |
true if successfully fetched the image file referred by the give logo URI and stored it in the system content provider, or false if failed. |
See Also
storeChannelLogo
@WorkerThread open static fun storeChannelLogo(
@NonNull context: Context,
channelId: Long,
@NonNull logo: Bitmap
): Boolean
Stores the given channel logo Bitmap
in the system content provider and associate it with the given channel ID.
Parameters | |
---|---|
context |
Context: the context used to access the system content provider |
channelId |
Long: the ID of the target channel with which the given logo should be associated |
logo |
Bitmap: the logo image to be stored |
Return | |
---|---|
Boolean |
true if successfully stored the logo in the system content provider, otherwise false . |
See Also