Minor refactoring.
This commit is contained in:
parent
faef0888c2
commit
3a3e14c850
1 changed files with 15 additions and 17 deletions
|
@ -227,8 +227,6 @@ public class RendererFragment extends Fragment implements
|
||||||
if (mCurrentRenderer != null) {
|
if (mCurrentRenderer != null) {
|
||||||
mListView.setAdapter(mPlaylistAdapter);
|
mListView.setAdapter(mPlaylistAdapter);
|
||||||
mCurrentTrack = track;
|
mCurrentTrack = track;
|
||||||
final Service<?, ?> service = mCurrentRenderer.findService(
|
|
||||||
new ServiceType("schemas-upnp-org", "AVTransport"));
|
|
||||||
DIDLParser parser = new DIDLParser();
|
DIDLParser parser = new DIDLParser();
|
||||||
DIDLContent didl = new DIDLContent();
|
DIDLContent didl = new DIDLContent();
|
||||||
didl.addItem(mPlaylist.get(track));
|
didl.addItem(mPlaylist.get(track));
|
||||||
|
@ -240,7 +238,8 @@ public class RendererFragment extends Fragment implements
|
||||||
Log.w(TAG, "Metadata serialization failed", e);
|
Log.w(TAG, "Metadata serialization failed", e);
|
||||||
metadata = "NO METADATA";
|
metadata = "NO METADATA";
|
||||||
}
|
}
|
||||||
mUpnpService.getControlPoint().execute(new SetAVTransportURI(service,
|
mUpnpService.getControlPoint().execute(new SetAVTransportURI(
|
||||||
|
getService("AVTransport"),
|
||||||
mPlaylist.get(track).getFirstResource().getValue(), metadata) {
|
mPlaylist.get(track).getFirstResource().getValue(), metadata) {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
|
@ -270,9 +269,8 @@ public class RendererFragment extends Fragment implements
|
||||||
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
|
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
|
||||||
if (mListView.getAdapter() == mRendererAdapter) {
|
if (mListView.getAdapter() == mRendererAdapter) {
|
||||||
mCurrentRenderer = mRendererAdapter.getItem(position);
|
mCurrentRenderer = mRendererAdapter.getItem(position);
|
||||||
Service<?, ?> service = mCurrentRenderer.findService(
|
mSubscriptionCallback = new SubscriptionCallback(
|
||||||
new ServiceType("schemas-upnp-org", "AVTransport"));
|
getService("AVTransport"), 600) {
|
||||||
mSubscriptionCallback = new SubscriptionCallback(service, 600) {
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
|
@ -417,8 +415,7 @@ public class RendererFragment extends Fragment implements
|
||||||
* Sends 'pause' signal to current renderer.
|
* Sends 'pause' signal to current renderer.
|
||||||
*/
|
*/
|
||||||
private void pause() {
|
private void pause() {
|
||||||
final Service<?, ?> service = mCurrentRenderer.findService(
|
final Service<?, ?> service = getService("AVTransport");
|
||||||
new ServiceType("schemas-upnp-org", "AVTransport"));
|
|
||||||
mUpnpService.getControlPoint().execute(new Stop(service) {
|
mUpnpService.getControlPoint().execute(new Stop(service) {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
@ -443,9 +440,7 @@ public class RendererFragment extends Fragment implements
|
||||||
* Sends 'play' signal to current renderer.
|
* Sends 'play' signal to current renderer.
|
||||||
*/
|
*/
|
||||||
private void play() {
|
private void play() {
|
||||||
final Service<?, ?> service = mCurrentRenderer.findService(
|
mUpnpService.getControlPoint().execute(new Play(getService("AVTransport")) {
|
||||||
new ServiceType("schemas-upnp-org", "AVTransport"));
|
|
||||||
mUpnpService.getControlPoint().execute(new Play(service) {
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
|
@ -463,10 +458,9 @@ public class RendererFragment extends Fragment implements
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||||
boolean fromUser) {
|
boolean fromUser) {
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
final Service<?, ?> service = mCurrentRenderer.findService(
|
mUpnpService.getControlPoint().execute(new Seek(
|
||||||
new ServiceType("schemas-upnp-org", "AVTransport"));
|
getService("AVTransport"), SeekMode.REL_TIME,
|
||||||
mUpnpService.getControlPoint().execute(new Seek(service,
|
Integer.toString(progress)) {
|
||||||
SeekMode.REL_TIME, Integer.toString(progress)) {
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
|
@ -495,8 +489,7 @@ public class RendererFragment extends Fragment implements
|
||||||
public void changeVolume(final boolean increase) {
|
public void changeVolume(final boolean increase) {
|
||||||
if (mCurrentRenderer == null)
|
if (mCurrentRenderer == null)
|
||||||
return;
|
return;
|
||||||
final Service<?, ?> service = mCurrentRenderer.findService(
|
final Service<?, ?> service = getService("RenderingControl");
|
||||||
new ServiceType("schemas-upnp-org", "RenderingControl"));
|
|
||||||
mUpnpService.getControlPoint().execute(new GetVolume(service) {
|
mUpnpService.getControlPoint().execute(new GetVolume(service) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -521,5 +514,10 @@ public class RendererFragment extends Fragment implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Service<?, ?> getService(String name) {
|
||||||
|
return mCurrentRenderer.findService(
|
||||||
|
new ServiceType("schemas-upnp-org", name));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue