Move common setService code into PlaybackActivity
This removes the condition where the mini activity finishes when the service is set to null. I'm not aware of any time this actually occurs, anyway...
This commit is contained in:
parent
e6412a9001
commit
c5bf6837c0
@ -143,26 +143,18 @@ public class FullPlaybackActivity extends PlaybackActivity implements View.OnCli
|
||||
@Override
|
||||
protected void setService(IPlaybackService service)
|
||||
{
|
||||
if (service == mService)
|
||||
return;
|
||||
super.setService(service);
|
||||
|
||||
int state = mState;
|
||||
mService = service;
|
||||
|
||||
if (service == null) {
|
||||
mCoverView.clearSongs();
|
||||
} else {
|
||||
try {
|
||||
mCoverView.setPlaybackService(service);
|
||||
state = service.getState();
|
||||
mDuration = service.getDuration();
|
||||
} catch (RemoteException e) {
|
||||
Log.i("VanillaMusic", "Failed to initialize connection to playback service", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mService = service;
|
||||
setState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
package org.kreed.vanilla;
|
||||
|
||||
import org.kreed.vanilla.IPlaybackService;
|
||||
import org.kreed.vanilla.R;
|
||||
|
||||
import android.content.Context;
|
||||
@ -61,20 +60,6 @@ public class MiniPlaybackActivity extends PlaybackActivity implements View.OnCli
|
||||
mNextButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setService(IPlaybackService service)
|
||||
{
|
||||
if (service == null) {
|
||||
finish();
|
||||
} else {
|
||||
mCoverView.setPlaybackService(service);
|
||||
try {
|
||||
setState(service.getState());
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setState(int state)
|
||||
{
|
||||
|
@ -27,6 +27,7 @@ import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
public abstract class PlaybackActivity extends Activity implements ServiceConnection {
|
||||
@ -98,7 +99,17 @@ public abstract class PlaybackActivity extends Activity implements ServiceConnec
|
||||
}
|
||||
|
||||
protected abstract void setState(int state);
|
||||
protected abstract void setService(IPlaybackService service);
|
||||
|
||||
protected void setService(IPlaybackService service)
|
||||
{
|
||||
if (service != null) {
|
||||
mCoverView.setPlaybackService(service);
|
||||
try {
|
||||
setState(service.getState());
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onServiceConnected(ComponentName name, IBinder service)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user