Created
December 18, 2015 13:19
-
-
Save adrian-bl/ace63e529135ea06baca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ch/blinkenlights/android/vanilla/CoverView.java b/src/ch/blinkenlights/android/vanilla/CoverView.java | |
index 1938cbc..caa73a4 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/CoverView.java | |
+++ b/src/ch/blinkenlights/android/vanilla/CoverView.java | |
@@ -38,6 +38,8 @@ import android.view.View; | |
import android.view.ViewConfiguration; | |
import android.widget.Scroller; | |
+import android.util.Log; | |
+ | |
/** | |
* Displays a flingable/draggable View of cover art/song info images | |
* generated by CoverBitmap. | |
@@ -360,7 +362,7 @@ public final class CoverView extends View implements Handler.Callback { | |
private void generateBitmap(int i) | |
{ | |
Song song = mSongs[i]; | |
- | |
+Log.v("VanillaMusic", "Generating bitmap"); | |
int style = mCoverStyle; | |
Context context = getContext(); | |
Bitmap cover = song == null ? null : song.getCover(context); | |
@@ -384,7 +386,7 @@ public final class CoverView extends View implements Handler.Callback { | |
{ | |
if (song == mSongs[i]) | |
return; | |
- | |
+Log.v("VanillaMusic", ">>> SET SONG COVER "+song); | |
mSongs[i] = song; | |
mBitmaps[i] = null; | |
if (song != null) { | |
@@ -404,6 +406,7 @@ public final class CoverView extends View implements Handler.Callback { | |
return; | |
} | |
+Log.v("VanillaMusic", ">>> "+mHandler.hasMessages(MSG_GENERATE_BITMAP)); | |
mHandler.removeMessages(MSG_GENERATE_BITMAP); | |
Song[] songs = mSongs; | |
@@ -427,11 +430,13 @@ public final class CoverView extends View implements Handler.Callback { | |
} | |
if (newBitmaps[i] == null) { | |
- mHandler.sendMessage(mHandler.obtainMessage(MSG_GENERATE_BITMAP, i, 0)); | |
+ mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_GENERATE_BITMAP, i, 0), 250); | |
} | |
} | |
- resetScroll(); | |
+ // Ensure that view is in sane state | |
+ if (!mScrolling) | |
+ resetScroll(); | |
} | |
/** | |
diff --git a/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java b/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java | |
index 5c3ea7e..0595f64 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java | |
+++ b/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java | |
@@ -723,7 +723,7 @@ public class FullPlaybackActivity extends PlaybackActivity | |
public void onClick(View view) | |
{ | |
if (view == mOverlayText && (mState & PlaybackService.FLAG_EMPTY_QUEUE) != 0) { | |
- setState(PlaybackService.get(this).setFinishAction(SongTimeline.FINISH_RANDOM)); | |
+ PlaybackService.get(this).setFinishAction(SongTimeline.FINISH_RANDOM); | |
} else if (view == mCoverView) { | |
performAction(mCoverPressAction); | |
} else if (view.getId() == R.id.info_table) { | |
diff --git a/src/ch/blinkenlights/android/vanilla/MirrorLinkMediaBrowserService.java b/src/ch/blinkenlights/android/vanilla/MirrorLinkMediaBrowserService.java | |
index 77968bd..08377d5 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/MirrorLinkMediaBrowserService.java | |
+++ b/src/ch/blinkenlights/android/vanilla/MirrorLinkMediaBrowserService.java | |
@@ -770,12 +770,12 @@ public class MirrorLinkMediaBrowserService extends MediaBrowserService implement | |
// updatePlaybackState(null); | |
} | |
- public void setState(long uptime, int state) { | |
+ public void setState(int state) { | |
mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_STATE, null)); | |
// updatePlaybackState(null); | |
} | |
- public void setSong(long uptime, Song song) { | |
+ public void setSong(Song song) { | |
mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_STATE, null)); | |
// updatePlaybackState(null); | |
if(song == null) { | |
@@ -810,7 +810,7 @@ public class MirrorLinkMediaBrowserService extends MediaBrowserService implement | |
public void onMediaChanged() { | |
if(PlaybackService.hasInstance()) { | |
- setSong(0,PlaybackService.get(this).getSong(0)); | |
+ setSong(PlaybackService.get(this).getSong(0)); | |
} | |
} | |
diff --git a/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java b/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java | |
index 0d7da39..9370009 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java | |
+++ b/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java | |
@@ -46,6 +46,8 @@ import android.view.WindowManager; | |
import android.widget.ImageButton; | |
import android.widget.Toast; | |
+import android.util.Log; | |
+ | |
/** | |
* Base activity for activities that contain playback controls. Handles | |
* communication with the PlaybackService and response to state and song | |
@@ -79,8 +81,6 @@ public abstract class PlaybackActivity extends Activity | |
protected ImageButton mEndButton; | |
protected int mState; | |
- private long mLastStateEvent; | |
- private long mLastSongEvent; | |
@Override | |
public void onCreate(Bundle state) | |
@@ -175,7 +175,8 @@ public abstract class PlaybackActivity extends Activity | |
@Override | |
public void shiftCurrentSong(int delta) | |
{ | |
- setSong(PlaybackService.get(this).shiftCurrentSong(delta)); | |
+ Log.v("VanillaMusic", "Shifting it "+delta); | |
+ PlaybackService.get(this).shiftCurrentSong(delta); | |
} | |
public void playPause() | |
@@ -184,12 +185,11 @@ public abstract class PlaybackActivity extends Activity | |
int state = service.playPause(); | |
if ((state & PlaybackService.FLAG_ERROR) != 0) | |
showToast(service.getErrorMessage(), Toast.LENGTH_LONG); | |
- setState(state); | |
} | |
private void rewindCurrentSong() | |
{ | |
- setSong(PlaybackService.get(this).rewindCurrentSong()); | |
+ PlaybackService.get(this).rewindCurrentSong(); | |
} | |
@@ -236,8 +236,7 @@ public abstract class PlaybackActivity extends Activity | |
protected void setState(final int state) | |
{ | |
- mLastStateEvent = System.nanoTime(); | |
- | |
+Log.v("VanillaMusic", this + " :: setState: "+state); | |
if (mState != state) { | |
final int toggled = mState ^ state; | |
mState = state; | |
@@ -251,14 +250,6 @@ public abstract class PlaybackActivity extends Activity | |
} | |
} | |
- /** | |
- * Called by PlaybackService to update the state. | |
- */ | |
- public void setState(long uptime, int state) | |
- { | |
- if (uptime >= mLastStateEvent) | |
- setState(state); | |
- } | |
/** | |
* Sets up components when the PlaybackService is initialized and available to | |
@@ -284,7 +275,6 @@ public abstract class PlaybackActivity extends Activity | |
protected void setSong(final Song song) | |
{ | |
- mLastSongEvent = System.nanoTime(); | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() | |
@@ -305,14 +295,6 @@ public abstract class PlaybackActivity extends Activity | |
return fs_start; | |
} | |
- /** | |
- * Called by PlaybackService to update the current song. | |
- */ | |
- public void setSong(long uptime, Song song) | |
- { | |
- if (uptime >= mLastSongEvent) | |
- setSong(song); | |
- } | |
/** | |
* Called by PlaybackService to update an active song (next, previous, or | |
@@ -515,7 +497,7 @@ public abstract class PlaybackActivity extends Activity | |
*/ | |
public void cycleShuffle() | |
{ | |
- setState(PlaybackService.get(this).cycleShuffle()); | |
+ PlaybackService.get(this).cycleShuffle(); | |
} | |
/** | |
@@ -523,7 +505,7 @@ public abstract class PlaybackActivity extends Activity | |
*/ | |
public void cycleFinishAction() | |
{ | |
- setState(PlaybackService.get(this).cycleFinishAction()); | |
+ PlaybackService.get(this).cycleFinishAction(); | |
} | |
/** | |
@@ -585,10 +567,11 @@ public abstract class PlaybackActivity extends Activity | |
{ | |
int group = item.getGroupId(); | |
int id = item.getItemId(); | |
+ | |
if (group == GROUP_SHUFFLE) | |
- setState(PlaybackService.get(this).setShuffleMode(id)); | |
+ PlaybackService.get(this).setShuffleMode(id); | |
else if (group == GROUP_FINISH) | |
- setState(PlaybackService.get(this).setFinishAction(id)); | |
+ PlaybackService.get(this).setFinishAction(id); | |
return true; | |
} | |
} | |
diff --git a/src/ch/blinkenlights/android/vanilla/PlaybackService.java b/src/ch/blinkenlights/android/vanilla/PlaybackService.java | |
index 9179eb4..a5964bb 100644 | |
--- a/src/ch/blinkenlights/android/vanilla/PlaybackService.java | |
+++ b/src/ch/blinkenlights/android/vanilla/PlaybackService.java | |
@@ -950,7 +950,7 @@ public final class PlaybackService extends Service | |
if (state != oldState) { | |
mHandler.sendMessage(mHandler.obtainMessage(MSG_PROCESS_STATE, oldState, state)); | |
- mHandler.sendMessage(mHandler.obtainMessage(MSG_BROADCAST_CHANGE, state, 0, new TimestampedObject(null))); | |
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_BROADCAST_CHANGE, state, 0, null)); | |
} | |
return state; | |
@@ -1026,28 +1026,28 @@ public final class PlaybackService extends Service | |
} | |
} | |
- private void broadcastChange(int state, Song song, long uptime) | |
+ private void broadcastChange(int state, Song song) | |
{ | |
if (state != -1) { | |
ArrayList<PlaybackActivity> list = sActivities; | |
for (int i = list.size(); --i != -1; ) | |
- list.get(i).setState(uptime, state); | |
+ list.get(i).setState(state); | |
MirrorLinkMediaBrowserService service = sMirrorLinkMediaBrowserService; | |
if(service != null) { | |
- service.setState(uptime, state); | |
+ service.setState(state); | |
} | |
} | |
if (song != null) { | |
ArrayList<PlaybackActivity> list = sActivities; | |
for (int i = list.size(); --i != -1; ) | |
- list.get(i).setSong(uptime, song); | |
+ list.get(i).setSong(song); | |
} | |
MirrorLinkMediaBrowserService service = sMirrorLinkMediaBrowserService; | |
if(service != null) { | |
- service.setSong(uptime, song); | |
+ service.setSong(song); | |
} | |
updateWidgets(); | |
@@ -1301,7 +1301,7 @@ public final class PlaybackService extends Service | |
mMediaPlayerInitialized = false; | |
mHandler.sendMessage(mHandler.obtainMessage(MSG_PROCESS_SONG, song)); | |
- mHandler.sendMessage(mHandler.obtainMessage(MSG_BROADCAST_CHANGE, -1, 0, new TimestampedObject(song))); | |
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_BROADCAST_CHANGE, -1, 0, song)); | |
return song; | |
} | |
@@ -1522,8 +1522,7 @@ public final class PlaybackService extends Service | |
processNewState(message.arg1, message.arg2); | |
break; | |
case MSG_BROADCAST_CHANGE: | |
- TimestampedObject tso = (TimestampedObject)message.obj; | |
- broadcastChange(message.arg1, (Song)tso.object, tso.uptime); | |
+ broadcastChange(message.arg1, (Song)message.obj); | |
break; | |
case MSG_ENTER_SLEEP_STATE: | |
enterSleepState(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment