More bugs fixed
- fixed a lot of crashes - AbsBaseActivity will send the activity tag as tag to crashlytics
This commit is contained in:
parent
6b514c0c0a
commit
94763814c5
9 changed files with 53 additions and 13 deletions
|
|
@ -37,6 +37,7 @@ public class ArtistAlbumLoader {
|
|||
}
|
||||
|
||||
public static Cursor makeArtistAlbumCursor(final Context context, final int artistId) {
|
||||
if(artistId == -1) return null;
|
||||
return context.getContentResolver().query(
|
||||
MediaStore.Audio.Artists.Albums.getContentUri("external", artistId), new String[]{
|
||||
/* 0 */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ package com.kabouzeid.materialmusic.misc;
|
|||
* Created by karim on 22.12.14.
|
||||
*/
|
||||
public final class AppKeys {
|
||||
public static final String CL_CURRENT_ACTIVITY = "Current activity";
|
||||
|
||||
public static final String SP_THEME = "com.kabouzeid.materialmusic.THEME";
|
||||
public static final String SP_NAVIGATION_DRAWER_ITEM_POSITION = "com.kabouzeid.materialmusic.NAVIGATION_DRAWER_ITEM_POSITION";
|
||||
public static final String SP_USER_LEARNED_DRAWER = "com.kabouzeid.materialmusic.NAVIGATION_DRAWER_LEARNED";
|
||||
|
|
|
|||
|
|
@ -201,11 +201,13 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
|
||||
public void stopPlaying() {
|
||||
isPlayerPrepared = false;
|
||||
if (player != null) {
|
||||
player.stop();
|
||||
playingNotificationHelper.updatePlayState(isPlaying());
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
player.release();
|
||||
player = null;
|
||||
}
|
||||
playingNotificationHelper.updatePlayState(isPlaying());
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STOP);
|
||||
}
|
||||
|
||||
|
|
@ -446,9 +448,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
case AudioManager.AUDIOFOCUS_GAIN:
|
||||
// resume playback
|
||||
registerEverything();
|
||||
if (!isPlayerPrepared()) {
|
||||
setUpMediaPlayerIfNeeded();
|
||||
}
|
||||
player.setVolume(1.0f, 1.0f);
|
||||
if (wasPlayingBeforeFocusLoss) {
|
||||
resumePlaying();
|
||||
|
|
|
|||
|
|
@ -362,6 +362,11 @@ public class AlbumDetailActivity extends AbsFabActivity implements OnMusicRemote
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void lollipopTransitionImageWrongSizeFix() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
|
||||
|
|
|
|||
|
|
@ -342,6 +342,11 @@ public class ArtistDetailActivity extends AbsFabActivity implements OnMusicRemot
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void lollipopTransitionImageWrongSizeFix() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.kabouzeid.materialmusic.helper.PlayingQueueDialogHelper;
|
|||
import com.kabouzeid.materialmusic.interfaces.KabSearchAbleFragment;
|
||||
import com.kabouzeid.materialmusic.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.materialmusic.interfaces.OnMusicRemoteEventListener;
|
||||
import com.kabouzeid.materialmusic.model.MusicRemoteEvent;
|
||||
import com.kabouzeid.materialmusic.model.Song;
|
||||
import com.kabouzeid.materialmusic.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.materialmusic.ui.fragments.NavigationDrawerFragment;
|
||||
|
|
@ -80,13 +81,15 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
private void updateNavigationDrawerHeader() {
|
||||
if (navigationDrawerFragment != null) {
|
||||
Song song = getApp().getMusicPlayerRemote().getCurrentSong();
|
||||
if (navigationDrawerFragment != null && song.id != -1) {
|
||||
if (song.id != -1) {
|
||||
ImageLoader.getInstance().displayImage(MusicUtil.getAlbumArtUri(song.albumId).toString(), navigationDrawerFragment.getAlbumArtImageView(), new ImageLoaderUtil.defaultAlbumArtOnFailed());
|
||||
navigationDrawerFragment.getSongTitle().setText(song.title);
|
||||
navigationDrawerFragment.getSongArtist().setText(song.artistName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpToolBar() {
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
|
|
@ -139,6 +142,11 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationDrawerItemSelected(int position) {
|
||||
if (position == NavigationDrawerFragment.NAVIGATION_DRAWER_HEADER) {
|
||||
|
|
@ -317,6 +325,14 @@ public class MainActivity extends AbsFabActivity
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMusicRemoteEvent(MusicRemoteEvent event) {
|
||||
super.onMusicRemoteEvent(event);
|
||||
if (event.getAction() == MusicRemoteEvent.STATE_RESTORED || event.getAction() == MusicRemoteEvent.TRACK_CHANGED) {
|
||||
updateNavigationDrawerHeader();
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlaceholderFragment extends Fragment {
|
||||
|
||||
public PlaceholderFragment() {
|
||||
|
|
|
|||
|
|
@ -346,6 +346,11 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateControllerState() {
|
||||
super.updateControllerState();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.support.v4.util.Pair;
|
|||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.kabouzeid.materialmusic.App;
|
||||
import com.kabouzeid.materialmusic.R;
|
||||
import com.kabouzeid.materialmusic.adapter.songadapter.SongAdapter;
|
||||
|
|
@ -28,6 +29,7 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Crashlytics.setString(AppKeys.CL_CURRENT_ACTIVITY, getTag());
|
||||
setTheme(getApp().getAppTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
|
@ -125,4 +127,6 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
|
|||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getTag();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,12 +152,14 @@ public class Util {
|
|||
}
|
||||
|
||||
public static String getFilePathFromContentProviderUri(Context context, Uri uri) {
|
||||
String path = "";
|
||||
String[] projection = {MediaStore.MediaColumns.DATA};
|
||||
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
|
||||
if (cursor == null) return null;
|
||||
int column_index = cursor.getColumnIndexOrThrow(projection[0]);
|
||||
cursor.moveToFirst();
|
||||
String path = cursor.getString(column_index);
|
||||
if (cursor.moveToFirst()) {
|
||||
path = cursor.getString(column_index);
|
||||
}
|
||||
cursor.close();
|
||||
return path;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue