Removed trailing whitespaces, replaced space intendation with tabs.

This commit is contained in:
Felix Ableitner 2014-02-08 21:16:30 +01:00
parent 10e5f86ecf
commit 2314e895d1
14 changed files with 1428 additions and 1437 deletions

View file

@ -240,12 +240,11 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
return new MediaRouter.Callback() { return new MediaRouter.Callback() {
@Override @Override
public void onRouteAdded(MediaRouter router, RouteInfo route) { public void onRouteAdded(MediaRouter router, RouteInfo route) {
for (int i = 0; i < mRouteAdapter.getCount(); i++) { for (int i = 0; i < mRouteAdapter.getCount(); i++)
if (mRouteAdapter.getItem(i).getId().equals(route.getId())) { if (mRouteAdapter.getItem(i).getId().equals(route.getId())) {
mRouteAdapter.remove(mRouteAdapter.getItem(i)); mRouteAdapter.remove(mRouteAdapter.getItem(i));
break; break;
} }
}
mRouteAdapter.add(route); mRouteAdapter.add(route);
} }
@ -367,7 +366,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
@Override @Override
public boolean onBackPressed() { public boolean onBackPressed() {
if (mListView.getAdapter() == mPlaylistAdapter) { if (mListView.getAdapter() == mPlaylistAdapter) {
if (mPlaying) { if (mPlaying)
new AlertDialog.Builder(getActivity()) new AlertDialog.Builder(getActivity())
.setMessage(R.string.exit_renderer) .setMessage(R.string.exit_renderer)
.setPositiveButton(android.R.string.yes, .setPositiveButton(android.R.string.yes,
@ -382,7 +381,6 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
}) })
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.no, null)
.show(); .show();
}
else else
deviceListMode(); deviceListMode();
return true; return true;
@ -525,8 +523,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
*/ */
private String generateTimeString(int time) { private String generateTimeString(int time) {
assert(time >= 0); assert(time >= 0);
int seconds = (int) time % 60; int seconds = time % 60;
int minutes = (int) time / 60; int minutes = time / 60;
if (minutes > 99) if (minutes > 99)
return "99:99"; return "99:99";
else else

View file

@ -212,20 +212,18 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
public void onListItemClick(ListView l, View v, int position, long id) { public void onListItemClick(ListView l, View v, int position, long id) {
if (getListAdapter() == mServerAdapter) if (getListAdapter() == mServerAdapter)
browsingMode(mServerAdapter.getItem(position)); browsingMode(mServerAdapter.getItem(position));
else if (getListAdapter() == mFileAdapter) { else if (getListAdapter() == mFileAdapter)
if (mFileAdapter.getItem(position) instanceof Container) if (mFileAdapter.getItem(position) instanceof Container)
getFiles(((Container) mFileAdapter.getItem(position)).getId()); getFiles(((Container) mFileAdapter.getItem(position)).getId());
else { else {
List<Item> playlist = new ArrayList<Item>(); List<Item> playlist = new ArrayList<Item>();
for (int i = 0; i < mFileAdapter.getCount(); i++) { for (int i = 0; i < mFileAdapter.getCount(); i++)
if (mFileAdapter.getItem(i) instanceof Item) if (mFileAdapter.getItem(i) instanceof Item)
playlist.add((Item) mFileAdapter.getItem(i)); playlist.add((Item) mFileAdapter.getItem(i));
}
MainActivity activity = (MainActivity) getActivity(); MainActivity activity = (MainActivity) getActivity();
activity.play(playlist, position); activity.play(playlist, position);
} }
} }
}
/** /**
* Displays available servers in the ListView. * Displays available servers in the ListView.
@ -248,6 +246,7 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
TextView emptyView = (TextView) getListView().getEmptyView(); TextView emptyView = (TextView) getListView().getEmptyView();
emptyView.setText(R.string.folder_list_empty); emptyView.setText(R.string.folder_list_empty);
} }
/** /**
* Opens a new directory and displays it. * Opens a new directory and displays it.
*/ */
@ -345,8 +344,7 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
mServerAdapter.deviceAdded(d); mServerAdapter.deviceAdded(d);
mUpnpService.getControlPoint().search(); mUpnpService.getControlPoint().search();
} }
} } else
else {
for (int i = 0; i < mServerAdapter.getCount(); i++) { for (int i = 0; i < mServerAdapter.getCount(); i++) {
Device<?, ?, ?> d = mServerAdapter.getItem(i); Device<?, ?, ?> d = mServerAdapter.getItem(i);
UDN udn = new UDN(d.getIdentity().getUdn().toString()); UDN udn = new UDN(d.getIdentity().getUdn().toString());
@ -361,7 +359,6 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
} }
} }
} }
}
}; };
} }

View file

@ -440,4 +440,5 @@ public class MediaRouterPlayService extends Service {
public RouteInfo getCurrentRoute() { public RouteInfo getCurrentRoute() {
return mCurrentRoute; return mCurrentRoute;
} }
} }

View file

@ -46,4 +46,5 @@ public class MediaRouterPlayServiceBinder extends Binder {
public MediaRouterPlayService getService() { public MediaRouterPlayService getService() {
return mService; return mService;
} }
} }

View file

@ -70,13 +70,16 @@ final class Provider extends MediaRouteProvider {
// Device has been added. // Device has been added.
// param: Device device // param: Device device
public static final int MSG_RENDERER_ADDED = 1; public static final int MSG_RENDERER_ADDED = 1;
// Device has been removed. // Device has been removed.
// param: int id // param: int id
public static final int MSG_RENDERER_REMOVED = 2; public static final int MSG_RENDERER_REMOVED = 2;
// Playback status information, retrieved after RemotePlayService.MSG_GET_STATUS. // Playback status information, retrieved after RemotePlayService.MSG_GET_STATUS.
// param: bundle media_item_status // param: bundle media_item_status
// param: int hash // param: int hash
public static final int MSG_STATUS_INFO = 3; public static final int MSG_STATUS_INFO = 3;
// Indicates an error in communication between RemotePlayService and renderer. // Indicates an error in communication between RemotePlayService and renderer.
// param: String error // param: String error
public static final int MSG_ERROR = 4; public static final int MSG_ERROR = 4;
@ -245,6 +248,7 @@ final class Provider extends MediaRouteProvider {
* requests and control requests. * requests and control requests.
*/ */
private final class RouteController extends MediaRouteProvider.RouteController { private final class RouteController extends MediaRouteProvider.RouteController {
private final String mRouteId; private final String mRouteId;
public RouteController(String routeId) { public RouteController(String routeId) {
@ -339,6 +343,7 @@ final class Provider extends MediaRouteProvider {
} }
return false; return false;
} }
} }
/** /**
@ -381,14 +386,12 @@ final class Provider extends MediaRouteProvider {
mRequests.get(data.getInt("hash")); mRequests.get(data.getInt("hash"));
Bundle status = data.getBundle("media_item_status"); Bundle status = data.getBundle("media_item_status");
if (pair.first.hasExtra(MediaControlIntent.EXTRA_SESSION_ID)) { if (pair.first.hasExtra(MediaControlIntent.EXTRA_SESSION_ID))
status.putString(MediaControlIntent.EXTRA_SESSION_ID, status.putString(MediaControlIntent.EXTRA_SESSION_ID,
pair.first.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID)); pair.first.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID));
} if (pair.first.hasExtra(MediaControlIntent.EXTRA_ITEM_ID))
if (pair.first.hasExtra(MediaControlIntent.EXTRA_ITEM_ID)) {
status.putString(MediaControlIntent.EXTRA_ITEM_ID, status.putString(MediaControlIntent.EXTRA_ITEM_ID,
pair.first.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID)); pair.first.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID));
}
pair.second.onResult(status); pair.second.onResult(status);
break; break;
case MSG_ERROR: case MSG_ERROR:

View file

@ -33,11 +33,11 @@ import android.support.v7.media.MediaRouteProviderService;
public class ProviderService extends MediaRouteProviderService { public class ProviderService extends MediaRouteProviderService {
private Provider mProvider; private Provider mProvider;
@Override @Override
public MediaRouteProvider onCreateMediaRouteProvider() { public MediaRouteProvider onCreateMediaRouteProvider() {
if (mProvider == null) { if (mProvider == null)
mProvider = new Provider(this); mProvider = new Provider(this);
}
return mProvider; return mProvider;
} }
@ -47,4 +47,5 @@ public class ProviderService extends MediaRouteProviderService {
mProvider.close(); mProvider.close();
mProvider = null; mProvider = null;
} }
} }

View file

@ -61,7 +61,6 @@ import android.os.Messenger;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
/** /**
* Allows UPNP playback from different apps by providing a proxy interface. * Allows UPNP playback from different apps by providing a proxy interface.
* You can communicate to this service via RemotePlayServiceBinder. * You can communicate to this service via RemotePlayServiceBinder.
@ -88,12 +87,11 @@ public class RemotePlayService extends Service implements RegistryListener {
public void onServiceConnected(ComponentName className, IBinder service) { public void onServiceConnected(ComponentName className, IBinder service) {
mUpnpService = (AndroidUpnpService) service; mUpnpService = (AndroidUpnpService) service;
mUpnpService.getRegistry().addListener(RemotePlayService.this); mUpnpService.getRegistry().addListener(RemotePlayService.this);
for (Device<?, ?, ?> d : mUpnpService.getControlPoint().getRegistry().getDevices()) { for (Device<?, ?, ?> d : mUpnpService.getControlPoint().getRegistry().getDevices())
if (d instanceof LocalDevice) if (d instanceof LocalDevice)
localDeviceAdded(mUpnpService.getRegistry(), (LocalDevice) d); localDeviceAdded(mUpnpService.getRegistry(), (LocalDevice) d);
else else
remoteDeviceAdded(mUpnpService.getRegistry(), (RemoteDevice) d); remoteDeviceAdded(mUpnpService.getRegistry(), (RemoteDevice) d);
}
mUpnpService.getControlPoint().search(); mUpnpService.getControlPoint().search();
} }
@ -102,7 +100,6 @@ public class RemotePlayService extends Service implements RegistryListener {
} }
}; };
/** /**
* All active binders. The Hashmap value is unused. * All active binders. The Hashmap value is unused.
*/ */
@ -180,22 +177,18 @@ public class RemotePlayService extends Service implements RegistryListener {
deviceAdded(d); deviceAdded(d);
mUpnpService.getControlPoint().search(); mUpnpService.getControlPoint().search();
} }
} } else
else { for (Entry<String, Device<?, ?, ?>> d : mDevices.entrySet())
for (Entry<String, Device<?, ?, ?>> d : mDevices.entrySet()) {
if (mUpnpService.getControlPoint().getRegistry() if (mUpnpService.getControlPoint().getRegistry()
.getDevice(new UDN(d.getKey()), false) == null) { .getDevice(new UDN(d.getKey()), false) == null) {
deviceRemoved(d.getValue()); deviceRemoved(d.getValue());
for (RemotePlayServiceBinder b : mBinders.keySet()) { for (RemotePlayServiceBinder b : mBinders.keySet())
if (b.mCurrentRenderer.equals(d.getValue())) { if (b.mCurrentRenderer.equals(d.getValue())) {
b.mSubscriptionCallback.end(); b.mSubscriptionCallback.end();
b.mCurrentRenderer = null; b.mCurrentRenderer = null;
} }
} }
} }
}
}
}
}; };
/** /**
@ -327,4 +320,5 @@ public class RemotePlayService extends Service implements RegistryListener {
public void remoteDeviceUpdated(Registry registry, RemoteDevice device) { public void remoteDeviceUpdated(Registry registry, RemoteDevice device) {
deviceUpdated(device); deviceUpdated(device);
} }
} }

View file

@ -92,10 +92,9 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
@Override @Override
public void selectRenderer(String id) throws RemoteException { public void selectRenderer(String id) throws RemoteException {
mCurrentRenderer = mRps.mDevices.get(id); mCurrentRenderer = mRps.mDevices.get(id);
for (RemotePlayServiceBinder b : mRps.mBinders.keySet()) { for (RemotePlayServiceBinder b : mRps.mBinders.keySet())
if (b != this && mCurrentRenderer.equals(b.mCurrentRenderer)) if (b != this && mCurrentRenderer.equals(b.mCurrentRenderer))
b.unselectRenderer(""); b.unselectRenderer("");
}
mSubscriptionCallback = new SubscriptionCallback( mSubscriptionCallback = new SubscriptionCallback(
mCurrentRenderer.findService( mCurrentRenderer.findService(
@ -360,16 +359,14 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
Message msg = Message.obtain(null, Provider.MSG_STATUS_INFO, 0, 0); Message msg = Message.obtain(null, Provider.MSG_STATUS_INFO, 0, 0);
Builder status = null; Builder status = null;
if (positionInfo.getTrackURI().equals(itemId)) { if (positionInfo.getTrackURI().equals(itemId))
status = new MediaItemStatus.Builder(mPlaybackState) status = new MediaItemStatus.Builder(mPlaybackState)
.setContentPosition(positionInfo.getTrackElapsedSeconds() * 1000) .setContentPosition(positionInfo.getTrackElapsedSeconds() * 1000)
.setContentDuration(positionInfo.getTrackDurationSeconds() * 1000) .setContentDuration(positionInfo.getTrackDurationSeconds() * 1000)
.setTimestamp(positionInfo.getAbsCount()); .setTimestamp(positionInfo.getAbsCount());
} else
else {
status = new MediaItemStatus.Builder( status = new MediaItemStatus.Builder(
MediaItemStatus.PLAYBACK_STATE_INVALIDATED); MediaItemStatus.PLAYBACK_STATE_INVALIDATED);
}
msg.getData().putBundle("media_item_status", status.build().asBundle()); msg.getData().putBundle("media_item_status", status.build().asBundle());
msg.getData().putInt("hash", requestHash); msg.getData().putInt("hash", requestHash);
@ -377,4 +374,5 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
} }
}); });
} }
}; };

View file

@ -47,7 +47,6 @@ import android.widget.TextView;
import com.github.nutomic.controldlna.R; import com.github.nutomic.controldlna.R;
/** /**
* Displays the devices that are inserted through the RegistryListener (either * Displays the devices that are inserted through the RegistryListener (either
* of type RENDERER or SERVER). * of type RENDERER or SERVER).
@ -91,14 +90,13 @@ public class DeviceArrayAdapter extends ArrayAdapter<Device<?, ?, ?>>
if (getItem(position).hasIcons()) { if (getItem(position).hasIcons()) {
URI uri = getItem(position).getIcons()[0].getUri(); URI uri = getItem(position).getIcons()[0].getUri();
if (getItem(position) instanceof RemoteDevice) { if (getItem(position) instanceof RemoteDevice)
try { try {
RemoteDevice device = (RemoteDevice) getItem(position); RemoteDevice device = (RemoteDevice) getItem(position);
uri = device.normalizeURI(uri).toURI(); uri = device.normalizeURI(uri).toURI();
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
Log.w(TAG, "Failed to get device icon URI", e); Log.w(TAG, "Failed to get device icon URI", e);
} }
}
image.setImageUri(uri); image.setImageUri(uri);
} }
@ -109,10 +107,9 @@ public class DeviceArrayAdapter extends ArrayAdapter<Device<?, ?, ?>>
* Adds a new device to the list if its type equals mDeviceType. * Adds a new device to the list if its type equals mDeviceType.
*/ */
public void deviceAdded(final Device<?, ?, ?> device) { public void deviceAdded(final Device<?, ?, ?> device) {
for (int i = 0; i < getCount(); i++) { for (int i = 0; i < getCount(); i++)
if (getItem(i).equals(device)) if (getItem(i).equals(device))
return; return;
}
mActivity.runOnUiThread(new Runnable() { mActivity.runOnUiThread(new Runnable() {
@ -179,4 +176,5 @@ public class DeviceArrayAdapter extends ArrayAdapter<Device<?, ?, ?>>
@Override @Override
public void afterShutdown() { public void afterShutdown() {
} }
} }