Removed trailing whitespaces, replaced space intendation with tabs.
This commit is contained in:
parent
10e5f86ecf
commit
2314e895d1
14 changed files with 1428 additions and 1437 deletions
|
@ -240,12 +240,11 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
return new MediaRouter.Callback() {
|
||||
@Override
|
||||
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())) {
|
||||
mRouteAdapter.remove(mRouteAdapter.getItem(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
mRouteAdapter.add(route);
|
||||
}
|
||||
|
||||
|
@ -367,7 +366,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
@Override
|
||||
public boolean onBackPressed() {
|
||||
if (mListView.getAdapter() == mPlaylistAdapter) {
|
||||
if (mPlaying) {
|
||||
if (mPlaying)
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.exit_renderer)
|
||||
.setPositiveButton(android.R.string.yes,
|
||||
|
@ -382,7 +381,6 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
}
|
||||
else
|
||||
deviceListMode();
|
||||
return true;
|
||||
|
@ -525,8 +523,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
*/
|
||||
private String generateTimeString(int time) {
|
||||
assert(time >= 0);
|
||||
int seconds = (int) time % 60;
|
||||
int minutes = (int) time / 60;
|
||||
int seconds = time % 60;
|
||||
int minutes = time / 60;
|
||||
if (minutes > 99)
|
||||
return "99:99";
|
||||
else
|
||||
|
|
|
@ -212,20 +212,18 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
|
|||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
if (getListAdapter() == mServerAdapter)
|
||||
browsingMode(mServerAdapter.getItem(position));
|
||||
else if (getListAdapter() == mFileAdapter) {
|
||||
else if (getListAdapter() == mFileAdapter)
|
||||
if (mFileAdapter.getItem(position) instanceof Container)
|
||||
getFiles(((Container) mFileAdapter.getItem(position)).getId());
|
||||
else {
|
||||
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)
|
||||
playlist.add((Item) mFileAdapter.getItem(i));
|
||||
}
|
||||
MainActivity activity = (MainActivity) getActivity();
|
||||
activity.play(playlist, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays available servers in the ListView.
|
||||
|
@ -248,6 +246,7 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
|
|||
TextView emptyView = (TextView) getListView().getEmptyView();
|
||||
emptyView.setText(R.string.folder_list_empty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a new directory and displays it.
|
||||
*/
|
||||
|
@ -345,8 +344,7 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
|
|||
mServerAdapter.deviceAdded(d);
|
||||
mUpnpService.getControlPoint().search();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else
|
||||
for (int i = 0; i < mServerAdapter.getCount(); i++) {
|
||||
Device<?, ?, ?> d = mServerAdapter.getItem(i);
|
||||
UDN udn = new UDN(d.getIdentity().getUdn().toString());
|
||||
|
@ -361,7 +359,6 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -440,4 +440,5 @@ public class MediaRouterPlayService extends Service {
|
|||
public RouteInfo getCurrentRoute() {
|
||||
return mCurrentRoute;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,4 +46,5 @@ public class MediaRouterPlayServiceBinder extends Binder {
|
|||
public MediaRouterPlayService getService() {
|
||||
return mService;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,13 +70,16 @@ final class Provider extends MediaRouteProvider {
|
|||
// Device has been added.
|
||||
// param: Device device
|
||||
public static final int MSG_RENDERER_ADDED = 1;
|
||||
|
||||
// Device has been removed.
|
||||
// param: int id
|
||||
public static final int MSG_RENDERER_REMOVED = 2;
|
||||
|
||||
// Playback status information, retrieved after RemotePlayService.MSG_GET_STATUS.
|
||||
// param: bundle media_item_status
|
||||
// param: int hash
|
||||
public static final int MSG_STATUS_INFO = 3;
|
||||
|
||||
// Indicates an error in communication between RemotePlayService and renderer.
|
||||
// param: String error
|
||||
public static final int MSG_ERROR = 4;
|
||||
|
@ -245,6 +248,7 @@ final class Provider extends MediaRouteProvider {
|
|||
* requests and control requests.
|
||||
*/
|
||||
private final class RouteController extends MediaRouteProvider.RouteController {
|
||||
|
||||
private final String mRouteId;
|
||||
|
||||
public RouteController(String routeId) {
|
||||
|
@ -339,6 +343,7 @@ final class Provider extends MediaRouteProvider {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -381,14 +386,12 @@ final class Provider extends MediaRouteProvider {
|
|||
mRequests.get(data.getInt("hash"));
|
||||
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,
|
||||
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,
|
||||
pair.first.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID));
|
||||
}
|
||||
pair.second.onResult(status);
|
||||
break;
|
||||
case MSG_ERROR:
|
||||
|
|
|
@ -33,11 +33,11 @@ import android.support.v7.media.MediaRouteProviderService;
|
|||
public class ProviderService extends MediaRouteProviderService {
|
||||
|
||||
private Provider mProvider;
|
||||
|
||||
@Override
|
||||
public MediaRouteProvider onCreateMediaRouteProvider() {
|
||||
if (mProvider == null) {
|
||||
if (mProvider == null)
|
||||
mProvider = new Provider(this);
|
||||
}
|
||||
return mProvider;
|
||||
}
|
||||
|
||||
|
@ -47,4 +47,5 @@ public class ProviderService extends MediaRouteProviderService {
|
|||
mProvider.close();
|
||||
mProvider = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ import android.os.Messenger;
|
|||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
/**
|
||||
* Allows UPNP playback from different apps by providing a proxy interface.
|
||||
* 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) {
|
||||
mUpnpService = (AndroidUpnpService) service;
|
||||
mUpnpService.getRegistry().addListener(RemotePlayService.this);
|
||||
for (Device<?, ?, ?> d : mUpnpService.getControlPoint().getRegistry().getDevices()) {
|
||||
for (Device<?, ?, ?> d : mUpnpService.getControlPoint().getRegistry().getDevices())
|
||||
if (d instanceof LocalDevice)
|
||||
localDeviceAdded(mUpnpService.getRegistry(), (LocalDevice) d);
|
||||
else
|
||||
remoteDeviceAdded(mUpnpService.getRegistry(), (RemoteDevice) d);
|
||||
}
|
||||
mUpnpService.getControlPoint().search();
|
||||
}
|
||||
|
||||
|
@ -102,7 +100,6 @@ public class RemotePlayService extends Service implements RegistryListener {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* All active binders. The Hashmap value is unused.
|
||||
*/
|
||||
|
@ -180,22 +177,18 @@ public class RemotePlayService extends Service implements RegistryListener {
|
|||
deviceAdded(d);
|
||||
mUpnpService.getControlPoint().search();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Entry<String, Device<?, ?, ?>> d : mDevices.entrySet()) {
|
||||
} else
|
||||
for (Entry<String, Device<?, ?, ?>> d : mDevices.entrySet())
|
||||
if (mUpnpService.getControlPoint().getRegistry()
|
||||
.getDevice(new UDN(d.getKey()), false) == null) {
|
||||
deviceRemoved(d.getValue());
|
||||
for (RemotePlayServiceBinder b : mBinders.keySet()) {
|
||||
for (RemotePlayServiceBinder b : mBinders.keySet())
|
||||
if (b.mCurrentRenderer.equals(d.getValue())) {
|
||||
b.mSubscriptionCallback.end();
|
||||
b.mCurrentRenderer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -327,4 +320,5 @@ public class RemotePlayService extends Service implements RegistryListener {
|
|||
public void remoteDeviceUpdated(Registry registry, RemoteDevice device) {
|
||||
deviceUpdated(device);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,10 +92,9 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
|
|||
@Override
|
||||
public void selectRenderer(String id) throws RemoteException {
|
||||
mCurrentRenderer = mRps.mDevices.get(id);
|
||||
for (RemotePlayServiceBinder b : mRps.mBinders.keySet()) {
|
||||
for (RemotePlayServiceBinder b : mRps.mBinders.keySet())
|
||||
if (b != this && mCurrentRenderer.equals(b.mCurrentRenderer))
|
||||
b.unselectRenderer("");
|
||||
}
|
||||
|
||||
mSubscriptionCallback = new SubscriptionCallback(
|
||||
mCurrentRenderer.findService(
|
||||
|
@ -360,16 +359,14 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
|
|||
Message msg = Message.obtain(null, Provider.MSG_STATUS_INFO, 0, 0);
|
||||
Builder status = null;
|
||||
|
||||
if (positionInfo.getTrackURI().equals(itemId)) {
|
||||
if (positionInfo.getTrackURI().equals(itemId))
|
||||
status = new MediaItemStatus.Builder(mPlaybackState)
|
||||
.setContentPosition(positionInfo.getTrackElapsedSeconds() * 1000)
|
||||
.setContentDuration(positionInfo.getTrackDurationSeconds() * 1000)
|
||||
.setTimestamp(positionInfo.getAbsCount());
|
||||
}
|
||||
else {
|
||||
else
|
||||
status = new MediaItemStatus.Builder(
|
||||
MediaItemStatus.PLAYBACK_STATE_INVALIDATED);
|
||||
}
|
||||
|
||||
msg.getData().putBundle("media_item_status", status.build().asBundle());
|
||||
msg.getData().putInt("hash", requestHash);
|
||||
|
@ -377,4 +374,5 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
|
@ -47,7 +47,6 @@ import android.widget.TextView;
|
|||
|
||||
import com.github.nutomic.controldlna.R;
|
||||
|
||||
|
||||
/**
|
||||
* Displays the devices that are inserted through the RegistryListener (either
|
||||
* of type RENDERER or SERVER).
|
||||
|
@ -91,14 +90,13 @@ public class DeviceArrayAdapter extends ArrayAdapter<Device<?, ?, ?>>
|
|||
|
||||
if (getItem(position).hasIcons()) {
|
||||
URI uri = getItem(position).getIcons()[0].getUri();
|
||||
if (getItem(position) instanceof RemoteDevice) {
|
||||
if (getItem(position) instanceof RemoteDevice)
|
||||
try {
|
||||
RemoteDevice device = (RemoteDevice) getItem(position);
|
||||
uri = device.normalizeURI(uri).toURI();
|
||||
} catch (URISyntaxException e) {
|
||||
Log.w(TAG, "Failed to get device icon URI", e);
|
||||
}
|
||||
}
|
||||
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.
|
||||
*/
|
||||
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))
|
||||
return;
|
||||
}
|
||||
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
|
||||
|
@ -179,4 +176,5 @@ public class DeviceArrayAdapter extends ArrayAdapter<Device<?, ?, ?>>
|
|||
@Override
|
||||
public void afterShutdown() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue