More bug fixes
This commit is contained in:
parent
94763814c5
commit
aefd490278
5 changed files with 34 additions and 37 deletions
|
|
@ -283,8 +283,8 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
registerEverything();
|
||||
isPlayerPrepared = false;
|
||||
player.reset();
|
||||
Uri trackUri = getCurrentPositionTrackUri();
|
||||
try {
|
||||
Uri trackUri = getCurrentPositionTrackUri();
|
||||
player.setDataSource(getApplicationContext(), trackUri);
|
||||
currentSongId = getPlayingQueue().get(getPosition()).id;
|
||||
updateNotification();
|
||||
|
|
@ -298,8 +298,6 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
playingNotificationHelper.updatePlayState(false);
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, getResources().getString(R.string.audio_focus_denied), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.TRACK_CHANGED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
|
|||
if (getApp().getMusicPlayerRemote().getPosition() >= 0) {
|
||||
song = getApp().getMusicPlayerRemote().getPlayingQueue().get(getApp().getMusicPlayerRemote().getPosition());
|
||||
} else {
|
||||
song = new Song();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.kabouzeid.materialmusic.ui.activities.base;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
|
@ -78,6 +79,10 @@ public abstract class AbsFabActivity extends AbsBaseActivity implements OnMusicR
|
|||
protected FloatingActionButton getFab() {
|
||||
if (fab == null) {
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
if(fab == null){
|
||||
fab = new FloatingActionButton(this);
|
||||
Log.e(getTag(), "No FAB found created default FAB.");
|
||||
}
|
||||
}
|
||||
return fab;
|
||||
}
|
||||
|
|
@ -92,13 +97,13 @@ public abstract class AbsFabActivity extends AbsBaseActivity implements OnMusicR
|
|||
@Override
|
||||
public void enableViews() {
|
||||
super.enableViews();
|
||||
fab.setEnabled(true);
|
||||
getFab().setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableViews() {
|
||||
super.disableViews();
|
||||
fab.setEnabled(false);
|
||||
getFab().setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -144,19 +149,19 @@ public abstract class AbsFabActivity extends AbsBaseActivity implements OnMusicR
|
|||
public void onMusicRemoteEvent(MusicRemoteEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MusicRemoteEvent.PLAY:
|
||||
fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_pause_white_48dp));
|
||||
getFab().setImageDrawable(getResources().getDrawable(R.drawable.ic_pause_white_48dp));
|
||||
break;
|
||||
case MusicRemoteEvent.PAUSE:
|
||||
fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_play_arrow_white_48dp));
|
||||
getFab().setImageDrawable(getResources().getDrawable(R.drawable.ic_play_arrow_white_48dp));
|
||||
break;
|
||||
case MusicRemoteEvent.RESUME:
|
||||
fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_pause_white_48dp));
|
||||
getFab().setImageDrawable(getResources().getDrawable(R.drawable.ic_pause_white_48dp));
|
||||
break;
|
||||
case MusicRemoteEvent.STOP:
|
||||
fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_play_arrow_white_48dp));
|
||||
getFab().setImageDrawable(getResources().getDrawable(R.drawable.ic_play_arrow_white_48dp));
|
||||
break;
|
||||
case MusicRemoteEvent.QUEUE_COMPLETED:
|
||||
fab.setImageResource(R.drawable.ic_play_arrow_white_48dp);
|
||||
getFab().setImageResource(R.drawable.ic_play_arrow_white_48dp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ public abstract class AbsTagEditorActivity extends ActionBarActivity {
|
|||
try {
|
||||
return AudioFileIO.read(new File(path));
|
||||
} catch (CannotReadException | ReadOnlyFileException | InvalidAudioFrameException | TagException | IOException e) {
|
||||
Log.e(TAG, "error while trying to create the AudioFile from File", e);
|
||||
Log.e(TAG, "Error while trying to create the AudioFile from java.io.File", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -438,50 +438,44 @@ public abstract class AbsTagEditorActivity extends ActionBarActivity {
|
|||
protected String getAlbumTitle() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.ALBUM);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException ignored) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getArtistName() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.ARTIST);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException ignored) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getAlbumArtistName() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.ALBUM_ARTIST);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException ignored) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getGenreName() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.GENRE);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException ignored) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getSongYear() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.YEAR);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException ignored) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getTrackNumber() {
|
||||
try {
|
||||
return getAudioFile(songPaths.get(0)).getTagOrCreateAndSetDefault().getFirst(FieldKey.TRACK);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException ignored) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected Bitmap getAlbumArt() {
|
||||
try {
|
||||
|
|
@ -490,8 +484,7 @@ public abstract class AbsTagEditorActivity extends ActionBarActivity {
|
|||
byte[] artworkBinaryData = artworkTag.getBinaryData();
|
||||
return BitmapFactory.decodeByteArray(artworkBinaryData, 0, artworkBinaryData.length);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
} catch (NullPointerException ignored) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ public class ImageLoaderUtil {
|
|||
public static class defaultAlbumArtOnFailed implements ImageLoadingListener {
|
||||
@Override
|
||||
public void onLoadingStarted(String imageUri, View view) {
|
||||
((ImageView) view).setImageResource(R.drawable.default_album_art);
|
||||
if (view != null) ((ImageView) view).setImageResource(R.drawable.default_album_art);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
((ImageView) view).setImageResource(R.drawable.default_album_art);
|
||||
if (view != null) ((ImageView) view).setImageResource(R.drawable.default_album_art);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -63,7 +63,7 @@ public class ImageLoaderUtil {
|
|||
|
||||
@Override
|
||||
public void onLoadingCancelled(String imageUri, View view) {
|
||||
((ImageView) view).setImageResource(R.drawable.default_album_art);
|
||||
if (view != null) ((ImageView) view).setImageResource(R.drawable.default_album_art);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,12 +71,12 @@ public class ImageLoaderUtil {
|
|||
|
||||
@Override
|
||||
public void onLoadingStarted(String imageUri, View view) {
|
||||
((ImageView) view).setImageResource(R.drawable.default_artist_image);
|
||||
if (view != null) ((ImageView) view).setImageResource(R.drawable.default_artist_image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
((ImageView) view).setImageResource(R.drawable.default_artist_image);
|
||||
if (view != null) ((ImageView) view).setImageResource(R.drawable.default_artist_image);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -86,7 +86,7 @@ public class ImageLoaderUtil {
|
|||
|
||||
@Override
|
||||
public void onLoadingCancelled(String imageUri, View view) {
|
||||
((ImageView) view).setImageResource(R.drawable.default_artist_image);
|
||||
if (view != null) ((ImageView) view).setImageResource(R.drawable.default_artist_image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue