Minor changes on MediaBrowser

- Rename add and remove in Subscription putCallback and removeCallback
  for better readability.
- Fix a broken link of javadoc.

Change-Id: If41941d1134d4ee6ef953932ca572f5d445a2aff
This commit is contained in:
Sungsoo Lim
2016-02-16 15:20:16 +09:00
parent a4b27566bd
commit 77dc4bb09e
2 changed files with 14 additions and 14 deletions

View File

@@ -470,7 +470,7 @@ public final class MediaBrowser {
sub = new Subscription(); sub = new Subscription();
mSubscriptions.put(parentId, sub); mSubscriptions.put(parentId, sub);
} }
sub.add(callback, options); sub.putCallback(options, callback);
// If we are connected, tell the service that we are watching. If we aren't connected, // If we are connected, tell the service that we are watching. If we aren't connected,
// the service will be told when we connect. // the service will be told when we connect.
@@ -502,7 +502,7 @@ public final class MediaBrowser {
Subscription sub = mSubscriptions.get(parentId); Subscription sub = mSubscriptions.get(parentId);
// Tell the service if necessary. // Tell the service if necessary.
if (sub != null && sub.remove(options) && mState == CONNECT_STATE_CONNECTED) { if (sub != null && sub.removeCallback(options) && mState == CONNECT_STATE_CONNECTED) {
try { try {
// NOTE: Do not call removeSubscriptionWithOptions when options are null. Otherwise, // NOTE: Do not call removeSubscriptionWithOptions when options are null. Otherwise,
// it will break the action of support library which expects removeSubscription will // it will break the action of support library which expects removeSubscription will
@@ -1093,7 +1093,16 @@ public final class MediaBrowser {
return mCallbacks; return mCallbacks;
} }
public void add(SubscriptionCallback callback, Bundle options) { public SubscriptionCallback getCallback(Bundle options) {
for (int i = 0; i < mOptionsList.size(); ++i) {
if (MediaBrowserUtils.areSameOptions(mOptionsList.get(i), options)) {
return mCallbacks.get(i);
}
}
return null;
}
public void putCallback(Bundle options, SubscriptionCallback callback) {
for (int i = 0; i < mOptionsList.size(); ++i) { for (int i = 0; i < mOptionsList.size(); ++i) {
if (MediaBrowserUtils.areSameOptions(mOptionsList.get(i), options)) { if (MediaBrowserUtils.areSameOptions(mOptionsList.get(i), options)) {
mCallbacks.set(i, callback); mCallbacks.set(i, callback);
@@ -1104,7 +1113,7 @@ public final class MediaBrowser {
mOptionsList.add(options); mOptionsList.add(options);
} }
public boolean remove(Bundle options) { public boolean removeCallback(Bundle options) {
for (int i = 0; i < mOptionsList.size(); ++i) { for (int i = 0; i < mOptionsList.size(); ++i) {
if (MediaBrowserUtils.areSameOptions(mOptionsList.get(i), options)) { if (MediaBrowserUtils.areSameOptions(mOptionsList.get(i), options)) {
mCallbacks.remove(i); mCallbacks.remove(i);
@@ -1114,14 +1123,5 @@ public final class MediaBrowser {
} }
return false; return false;
} }
public SubscriptionCallback getCallback(Bundle options) {
for (int i = 0; i < mOptionsList.size(); ++i) {
if (MediaBrowserUtils.areSameOptions(mOptionsList.get(i), options)) {
return mCallbacks.get(i);
}
}
return null;
}
} }
} }

View File

@@ -121,7 +121,7 @@ public abstract class MediaBrowserService extends Service {
* be thrown. * be thrown.
* *
* @see MediaBrowserService#onLoadChildren * @see MediaBrowserService#onLoadChildren
* @see MediaBrowserService#onGetMediaItem * @see MediaBrowserService#onLoadItem
*/ */
public class Result<T> { public class Result<T> {
private Object mDebug; private Object mDebug;