Loading media/java/android/media/browse/MediaBrowser.java +15 −7 Original line number Original line Diff line number Diff line Loading @@ -633,7 +633,6 @@ public final class MediaBrowser { return; return; } } List<MediaItem> data = list == null ? null : list.getList(); if (DBG) { if (DBG) { Log.d(TAG, "onLoadChildren for " + mServiceComponent + " id=" + parentId); Log.d(TAG, "onLoadChildren for " + mServiceComponent + " id=" + parentId); } } Loading @@ -644,11 +643,20 @@ public final class MediaBrowser { // Tell the app. // Tell the app. SubscriptionCallback subscriptionCallback = subscription.getCallback(options); SubscriptionCallback subscriptionCallback = subscription.getCallback(options); if (subscriptionCallback != null) { if (subscriptionCallback != null) { List<MediaItem> data = list == null ? null : list.getList(); if (options == null) { if (options == null) { if (data == null) { subscriptionCallback.onError(parentId); } else { subscriptionCallback.onChildrenLoaded(parentId, data); subscriptionCallback.onChildrenLoaded(parentId, data); } } else { if (data == null) { subscriptionCallback.onError(parentId, options); } else { } else { subscriptionCallback.onChildrenLoaded(parentId, data, options); subscriptionCallback.onChildrenLoaded(parentId, data, options); } } } return; return; } } } } Loading Loading @@ -848,21 +856,21 @@ public final class MediaBrowser { * Called when the list of children is loaded or updated. * Called when the list of children is loaded or updated. * * * @param parentId The media id of the parent media item. * @param parentId The media id of the parent media item. * @param children The children which were loaded, or null if the id is invalid. * @param children The children which were loaded. */ */ public void onChildrenLoaded(@NonNull String parentId, List<MediaItem> children) { public void onChildrenLoaded(@NonNull String parentId, @NonNull List<MediaItem> children) { } } /** /** * Called when the list of children is loaded or updated. * Called when the list of children is loaded or updated. * * * @param parentId The media id of the parent media item. * @param parentId The media id of the parent media item. * @param children The children which were loaded, or null if the id is invalid. * @param children The children which were loaded. * @param options A bundle of service-specific arguments sent to the media * @param options A bundle of service-specific arguments sent to the media * browse service. The contents of this bundle may affect the * browse service. The contents of this bundle may affect the * information returned when browsing. * information returned when browsing. */ */ public void onChildrenLoaded(@NonNull String parentId, List<MediaItem> children, public void onChildrenLoaded(@NonNull String parentId, @NonNull List<MediaItem> children, @NonNull Bundle options) { @NonNull Bundle options) { } } Loading media/java/android/service/media/MediaBrowserService.java +22 −6 Original line number Original line Diff line number Diff line Loading @@ -45,6 +45,7 @@ import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; Loading Loading @@ -120,8 +121,8 @@ public abstract class MediaBrowserService extends Service { * they are done. If more than one of those methods is called, an exception will * they are done. If more than one of those methods is called, an exception will * be thrown. * be thrown. * * * @see MediaBrowserService#onLoadChildren * @see #onLoadChildren * @see MediaBrowserService#onLoadItem * @see #onLoadItem */ */ public class Result<T> { public class Result<T> { private Object mDebug; private Object mDebug; Loading Loading @@ -367,10 +368,16 @@ public abstract class MediaBrowserService extends Service { * {@link Result#detach result.detach} may be called before returning from * {@link Result#detach result.detach} may be called before returning from * this function, and then {@link Result#sendResult result.sendResult} * this function, and then {@link Result#sendResult result.sendResult} * called when the loading is complete. * called when the loading is complete. * </p><p> * In case the media item does not have any children, call {@link Result#sendResult} * with an empty list which is not {@code null}. If {@code null} is sent that means * the given {@code parentId} is invalid and {@link MediaBrowser.SubscriptionCallback#onError} * will be called. * </p> * * * @param parentId The id of the parent media item whose children are to be * @param parentId The id of the parent media item whose children are to be * queried. * queried. * @param result The Result to send the list of children to, or null if the * @param result The Result to send the list of children to. Send null if the * id is invalid. * id is invalid. */ */ public abstract void onLoadChildren(@NonNull String parentId, public abstract void onLoadChildren(@NonNull String parentId, Loading @@ -385,10 +392,16 @@ public abstract class MediaBrowserService extends Service { * {@link Result#detach result.detach} may be called before returning from * {@link Result#detach result.detach} may be called before returning from * this function, and then {@link Result#sendResult result.sendResult} * this function, and then {@link Result#sendResult result.sendResult} * called when the loading is complete. * called when the loading is complete. * </p><p> * In case the media item does not have any children, call {@link Result#sendResult} * with an empty list which is not {@code null}. If {@code null} is sent that means * the given {@code parentId} is invalid and {@link MediaBrowser.SubscriptionCallback#onError} * will be called. * </p> * * * @param parentId The id of the parent media item whose children are to be * @param parentId The id of the parent media item whose children are to be * queried. * queried. * @param result The Result to send the list of children to, or null if the * @param result The Result to send the list of children to. Send null if the * id is invalid. * id is invalid. * @param options A bundle of service-specific arguments sent from the media * @param options A bundle of service-specific arguments sent from the media * browse. The information returned through the result should be * browse. The information returned through the result should be Loading Loading @@ -416,7 +429,7 @@ public abstract class MediaBrowserService extends Service { * * * @param itemId The id for the specific * @param itemId The id for the specific * {@link android.media.browse.MediaBrowser.MediaItem}. * {@link android.media.browse.MediaBrowser.MediaItem}. * @param result The Result to send the item to, or null if the id is * @param result The Result to send the item to. Send null if the id is * invalid. * invalid. */ */ public void onLoadItem(String itemId, Result<MediaBrowser.MediaItem> result) { public void onLoadItem(String itemId, Result<MediaBrowser.MediaItem> result) { Loading Loading @@ -630,6 +643,9 @@ public abstract class MediaBrowserService extends Service { private List<MediaBrowser.MediaItem> applyOptions(List<MediaBrowser.MediaItem> list, private List<MediaBrowser.MediaItem> applyOptions(List<MediaBrowser.MediaItem> list, final Bundle options) { final Bundle options) { if (list == null) { return null; } int page = options.getInt(MediaBrowser.EXTRA_PAGE, -1); int page = options.getInt(MediaBrowser.EXTRA_PAGE, -1); int pageSize = options.getInt(MediaBrowser.EXTRA_PAGE_SIZE, -1); int pageSize = options.getInt(MediaBrowser.EXTRA_PAGE_SIZE, -1); if (page == -1 && pageSize == -1) { if (page == -1 && pageSize == -1) { Loading @@ -638,7 +654,7 @@ public abstract class MediaBrowserService extends Service { int fromIndex = pageSize * (page - 1); int fromIndex = pageSize * (page - 1); int toIndex = fromIndex + pageSize; int toIndex = fromIndex + pageSize; if (page < 1 || pageSize < 1 || fromIndex >= list.size()) { if (page < 1 || pageSize < 1 || fromIndex >= list.size()) { return null; return Collections.EMPTY_LIST; } } if (toIndex > list.size()) { if (toIndex > list.size()) { toIndex = list.size(); toIndex = list.size(); Loading Loading
media/java/android/media/browse/MediaBrowser.java +15 −7 Original line number Original line Diff line number Diff line Loading @@ -633,7 +633,6 @@ public final class MediaBrowser { return; return; } } List<MediaItem> data = list == null ? null : list.getList(); if (DBG) { if (DBG) { Log.d(TAG, "onLoadChildren for " + mServiceComponent + " id=" + parentId); Log.d(TAG, "onLoadChildren for " + mServiceComponent + " id=" + parentId); } } Loading @@ -644,11 +643,20 @@ public final class MediaBrowser { // Tell the app. // Tell the app. SubscriptionCallback subscriptionCallback = subscription.getCallback(options); SubscriptionCallback subscriptionCallback = subscription.getCallback(options); if (subscriptionCallback != null) { if (subscriptionCallback != null) { List<MediaItem> data = list == null ? null : list.getList(); if (options == null) { if (options == null) { if (data == null) { subscriptionCallback.onError(parentId); } else { subscriptionCallback.onChildrenLoaded(parentId, data); subscriptionCallback.onChildrenLoaded(parentId, data); } } else { if (data == null) { subscriptionCallback.onError(parentId, options); } else { } else { subscriptionCallback.onChildrenLoaded(parentId, data, options); subscriptionCallback.onChildrenLoaded(parentId, data, options); } } } return; return; } } } } Loading Loading @@ -848,21 +856,21 @@ public final class MediaBrowser { * Called when the list of children is loaded or updated. * Called when the list of children is loaded or updated. * * * @param parentId The media id of the parent media item. * @param parentId The media id of the parent media item. * @param children The children which were loaded, or null if the id is invalid. * @param children The children which were loaded. */ */ public void onChildrenLoaded(@NonNull String parentId, List<MediaItem> children) { public void onChildrenLoaded(@NonNull String parentId, @NonNull List<MediaItem> children) { } } /** /** * Called when the list of children is loaded or updated. * Called when the list of children is loaded or updated. * * * @param parentId The media id of the parent media item. * @param parentId The media id of the parent media item. * @param children The children which were loaded, or null if the id is invalid. * @param children The children which were loaded. * @param options A bundle of service-specific arguments sent to the media * @param options A bundle of service-specific arguments sent to the media * browse service. The contents of this bundle may affect the * browse service. The contents of this bundle may affect the * information returned when browsing. * information returned when browsing. */ */ public void onChildrenLoaded(@NonNull String parentId, List<MediaItem> children, public void onChildrenLoaded(@NonNull String parentId, @NonNull List<MediaItem> children, @NonNull Bundle options) { @NonNull Bundle options) { } } Loading
media/java/android/service/media/MediaBrowserService.java +22 −6 Original line number Original line Diff line number Diff line Loading @@ -45,6 +45,7 @@ import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; Loading Loading @@ -120,8 +121,8 @@ public abstract class MediaBrowserService extends Service { * they are done. If more than one of those methods is called, an exception will * they are done. If more than one of those methods is called, an exception will * be thrown. * be thrown. * * * @see MediaBrowserService#onLoadChildren * @see #onLoadChildren * @see MediaBrowserService#onLoadItem * @see #onLoadItem */ */ public class Result<T> { public class Result<T> { private Object mDebug; private Object mDebug; Loading Loading @@ -367,10 +368,16 @@ public abstract class MediaBrowserService extends Service { * {@link Result#detach result.detach} may be called before returning from * {@link Result#detach result.detach} may be called before returning from * this function, and then {@link Result#sendResult result.sendResult} * this function, and then {@link Result#sendResult result.sendResult} * called when the loading is complete. * called when the loading is complete. * </p><p> * In case the media item does not have any children, call {@link Result#sendResult} * with an empty list which is not {@code null}. If {@code null} is sent that means * the given {@code parentId} is invalid and {@link MediaBrowser.SubscriptionCallback#onError} * will be called. * </p> * * * @param parentId The id of the parent media item whose children are to be * @param parentId The id of the parent media item whose children are to be * queried. * queried. * @param result The Result to send the list of children to, or null if the * @param result The Result to send the list of children to. Send null if the * id is invalid. * id is invalid. */ */ public abstract void onLoadChildren(@NonNull String parentId, public abstract void onLoadChildren(@NonNull String parentId, Loading @@ -385,10 +392,16 @@ public abstract class MediaBrowserService extends Service { * {@link Result#detach result.detach} may be called before returning from * {@link Result#detach result.detach} may be called before returning from * this function, and then {@link Result#sendResult result.sendResult} * this function, and then {@link Result#sendResult result.sendResult} * called when the loading is complete. * called when the loading is complete. * </p><p> * In case the media item does not have any children, call {@link Result#sendResult} * with an empty list which is not {@code null}. If {@code null} is sent that means * the given {@code parentId} is invalid and {@link MediaBrowser.SubscriptionCallback#onError} * will be called. * </p> * * * @param parentId The id of the parent media item whose children are to be * @param parentId The id of the parent media item whose children are to be * queried. * queried. * @param result The Result to send the list of children to, or null if the * @param result The Result to send the list of children to. Send null if the * id is invalid. * id is invalid. * @param options A bundle of service-specific arguments sent from the media * @param options A bundle of service-specific arguments sent from the media * browse. The information returned through the result should be * browse. The information returned through the result should be Loading Loading @@ -416,7 +429,7 @@ public abstract class MediaBrowserService extends Service { * * * @param itemId The id for the specific * @param itemId The id for the specific * {@link android.media.browse.MediaBrowser.MediaItem}. * {@link android.media.browse.MediaBrowser.MediaItem}. * @param result The Result to send the item to, or null if the id is * @param result The Result to send the item to. Send null if the id is * invalid. * invalid. */ */ public void onLoadItem(String itemId, Result<MediaBrowser.MediaItem> result) { public void onLoadItem(String itemId, Result<MediaBrowser.MediaItem> result) { Loading Loading @@ -630,6 +643,9 @@ public abstract class MediaBrowserService extends Service { private List<MediaBrowser.MediaItem> applyOptions(List<MediaBrowser.MediaItem> list, private List<MediaBrowser.MediaItem> applyOptions(List<MediaBrowser.MediaItem> list, final Bundle options) { final Bundle options) { if (list == null) { return null; } int page = options.getInt(MediaBrowser.EXTRA_PAGE, -1); int page = options.getInt(MediaBrowser.EXTRA_PAGE, -1); int pageSize = options.getInt(MediaBrowser.EXTRA_PAGE_SIZE, -1); int pageSize = options.getInt(MediaBrowser.EXTRA_PAGE_SIZE, -1); if (page == -1 && pageSize == -1) { if (page == -1 && pageSize == -1) { Loading @@ -638,7 +654,7 @@ public abstract class MediaBrowserService extends Service { int fromIndex = pageSize * (page - 1); int fromIndex = pageSize * (page - 1); int toIndex = fromIndex + pageSize; int toIndex = fromIndex + pageSize; if (page < 1 || pageSize < 1 || fromIndex >= list.size()) { if (page < 1 || pageSize < 1 || fromIndex >= list.size()) { return null; return Collections.EMPTY_LIST; } } if (toIndex > list.size()) { if (toIndex > list.size()) { toIndex = list.size(); toIndex = list.size(); Loading