Permalink
Browse files

Fix various bugs reported though the Android Market

  • Loading branch information...
1 parent f99f5f5 commit 1e7dd57b6c5708f3ac37fbc2bd09552fbb0a54da Sam Steele committed Feb 27, 2012
@@ -377,7 +377,7 @@ public Boolean doInBackground(Void... params) {
success = true;
} catch (OutOfMemoryError e) {
e.printStackTrace();
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
} catch (WSError e) {
e.printStackTrace();
@@ -558,7 +558,7 @@ public Intent doInBackground(Void... params) {
} catch (WSError e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
- } catch (IOException e1) {
+ } catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
@@ -670,8 +670,7 @@ public Boolean doInBackground(Void... params) {
result = true;
} catch (OutOfMemoryError e) {
e.printStackTrace();
-
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
} catch (WSError e) {
}
@@ -883,6 +883,7 @@ protected Station doInBackground(Void... arg0) {
}
} catch (NullPointerException e) {
} catch (IOException e) {
+ } catch (WSError e) {
}
}
return null;
@@ -102,7 +102,7 @@ public void onCreate(Bundle icicle) {
LastFMApplication.getInstance().playRadioStation(LastFMApplication.getInstance().mCtx, intent.getData().toString(), true);
finish();
return;
- } else if(getIntent().getData().getScheme().equals("http")) { //The search provider sent us an http:// URL, forward it to the metadata screen
+ } else if(getIntent().getData().getScheme() != null && getIntent().getData().getScheme().equals("http")) { //The search provider sent us an http:// URL, forward it to the metadata screen
Intent i = null;
if(intent.getData().getPath().contains("/user/")) {
List<String> segments = getIntent().getData().getPathSegments();
@@ -319,7 +319,7 @@ public void onStart(Intent intent, int startId) {
Session session = intent.getParcelableExtra("session");
if(currentStationURL != null && currentStationURL.equals(stationURL)) {
if(mState == STATE_PAUSED)
- pause();
+ new PauseTask().execute((Void)null);
if(mState != STATE_STOPPED)
return;
}
@@ -1277,6 +1277,7 @@ public void onPostExecute(Boolean result) {
nm.notify(NOTIFY_ID, notification);
}
// Update the remote controls
+ try {
mRemoteControlClientCompat.editMetadata(true)
.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, currentTrack.getCreator())
.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, currentTrack.getTitle())
@@ -1286,6 +1287,9 @@ public void onPostExecute(Boolean result) {
RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK,
mArtwork)
.apply();
+ } catch (Exception e) {
+
+ }
logger.info("Album art updated");
notifyChange(ARTWORK_AVAILABLE);
}
@@ -1360,6 +1364,15 @@ public void onPostExecute(Boolean result) {
}
}
+ private class PauseTask extends AsyncTaskEx<Void, Void, Void> {
+
+ @Override
+ public Void doInBackground(Void... input) {
+ pause();
+ return null;
+ }
+ }
+
private final IRadioPlayer.Stub mBinder = new IRadioPlayer.Stub() {
public boolean supportsFocus() {
return mFocusHelper.isSupported();
@@ -1384,8 +1397,8 @@ public int getState() throws DeadObjectException {
public void pause() throws DeadObjectException {
if(mState == STATE_PAUSED && mp != null)
mp.setVolume(1.0f, 1.0f);
- RadioPlayerService.this.pause();
lostDataConnection = false;
+ new PauseTask().execute((Void)null);
}
public void stop() throws DeadObjectException {
@@ -695,7 +695,7 @@ public Boolean doInBackground(Void... params) {
try {
mScrobblerLock.lock();
- server.removeNowPlaying(mTrack.getCreator(), mTrack.getTitle(), mTrack.getAlbum(), new Integer(mTrack.getDuration() / 1000), ScrobblerService.this.player, mSession.getKey());
+ server.removeNowPlaying(mTrack.getCreator(), mTrack.getTitle(), mTrack.getAlbum(), (long)(mTrack.getDuration() / 1000), ScrobblerService.this.player, mSession.getKey());
success = true;
} catch (Exception e) {
e.printStackTrace();
@@ -742,7 +742,7 @@ public Boolean doInBackground(Void... params) {
try {
mScrobblerLock.lock();
- server.updateNowPlaying(mTrack.getCreator(), mTrack.getTitle(), mTrack.getAlbum(), new Integer(mTrack.getDuration() / 1000), ScrobblerService.this.player, mSession.getKey());
+ server.updateNowPlaying(mTrack.getCreator(), mTrack.getTitle(), mTrack.getAlbum(), (long)(mTrack.getDuration() / 1000), ScrobblerService.this.player, mSession.getKey());
success = true;
} catch (Exception e) {
e.printStackTrace();
@@ -376,8 +376,8 @@
public Serializable[] multiSearch(String query) throws IOException, WSError;
- public void scrobbleTrack(String artist, String track, String album, long timestamp, int duration, String context, String streamid, String sk) throws IOException, WSError;
+ public void scrobbleTrack(String artist, String track, String album, long timestamp, long duration, String context, String streamid, String sk) throws IOException, WSError;
- public void updateNowPlaying(String artist, String track, String album, int duration, String context, String sk) throws IOException, WSError;
- public void removeNowPlaying(String artist, String track, String album, int duration, String context, String sk) throws IOException, WSError;
+ public void updateNowPlaying(String artist, String track, String album, long duration, String context, String sk) throws IOException, WSError;
+ public void removeNowPlaying(String artist, String track, String album, long duration, String context, String sk) throws IOException, WSError;
}
@@ -50,7 +50,7 @@
private String identifier;
private String album;
private String creator;
- private int duration;
+ private long duration;
private String imageUrl;
private String trackAuth;
private Boolean loved;
@@ -62,7 +62,7 @@ public RadioTrack(String locationUrl, String title, String identifier, String al
this.identifier = identifier;
this.album = album;
this.creator = creator;
- this.duration = new Integer(duration).intValue();
+ this.duration = new Long(duration).longValue();
this.imageUrl = imageUrl;
this.trackAuth = trackAuth;
this.loved = loved;
@@ -93,7 +93,7 @@ public String getCreator() {
return creator;
}
- public int getDuration() {
+ public long getDuration() {
return duration;
}
@@ -783,7 +783,7 @@ public void banTrack(String artist, String track, String sk) throws IOException
post(baseUrl, params);
}
- public void scrobbleTrack(String artist, String track, String album, long timestamp, int duration, String context, String streamid, String sk) throws IOException {
+ public void scrobbleTrack(String artist, String track, String album, long timestamp, long duration, String context, String streamid, String sk) throws IOException {
Map<String, String> params = createParams("track.scrobble");
params.put("artist", artist);
params.put("track", track);
@@ -799,7 +799,7 @@ public void scrobbleTrack(String artist, String track, String album, long timest
post(baseUrl, params);
}
- public void updateNowPlaying(String artist, String track, String album, int duration, String context, String sk) throws IOException {
+ public void updateNowPlaying(String artist, String track, String album, long duration, String context, String sk) throws IOException {
Map<String, String> params = createParams("track.updateNowPlaying");
params.put("artist", artist);
params.put("track", track);
@@ -812,7 +812,7 @@ public void updateNowPlaying(String artist, String track, String album, int dura
post(baseUrl, params);
}
- public void removeNowPlaying(String artist, String track, String album, int duration, String context, String sk) throws IOException {
+ public void removeNowPlaying(String artist, String track, String album, long duration, String context, String sk) throws IOException {
Map<String, String> params = createParams("track.removeNowPlaying");
params.put("artist", artist);
params.put("track", track);

0 comments on commit 1e7dd57

Please sign in to comment.