Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
app flavours
Browse files Browse the repository at this point in the history
  • Loading branch information
Laith Nurie committed May 2, 2016
1 parent 9fb90ba commit f3c9b6d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
13 changes: 13 additions & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ android {
}
}

productFlavors {
develop {
applicationId 'com.laithlab.rhythm.develop'
resValue "string", "app_name", "Rhythm Develop"
}

production {
applicationId "com.laithlab.rhythm"
resValue "string", "app_name", "Rhythm"

}
}

buildTypes {

release {
Expand Down
34 changes: 19 additions & 15 deletions mobile/src/main/java/com/laithlab/rhythm/fragment/SongFragment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.laithlab.rhythm.fragment;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
Expand Down Expand Up @@ -34,7 +34,7 @@ public class SongFragment extends Fragment implements MediaPlayer.OnErrorListene
private static final String SONG_PARAM = "song";
private static final String SONG_POSITION_PARAM = "songPosition";

private SongFragmentCallback mListener;
private SongFragmentCallback callback;
private SongDTO song;
private RhythmSong rhythmSong;
private int songPosition;
Expand All @@ -47,7 +47,7 @@ public class SongFragment extends Fragment implements MediaPlayer.OnErrorListene
private ImageView playButton;
private int vibrantColor;
private int backgroundColor;
private Handler handler;
private static Handler handler;

private boolean beenDrawn = false;

Expand Down Expand Up @@ -149,28 +149,32 @@ public void onClick(View v) {
public void onPause() {
super.onPause();
stopTimer();
handler.removeCallbacksAndMessages(null);
removePlayerListeners();
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mListener = (SongFragmentCallback) activity;
public void onAttach(Context context) {
super.onAttach(context);
callback = (SongFragmentCallback) context;
}

@Override
public void onDetach() {
super.onDetach();
mListener = null;
callback = null;
handler.removeCallbacksAndMessages(null);
removePlayerListeners();
}

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
if (mediaPlayer == null) {
if (mListener.songChangedFromNotification()) {
if (callback.songChangedFromNotification()) {
mediaPlayer = PlayBackUtil.getMediaPlayer();
mListener.resetChangedSongFromNotification();
callback.resetChangedSongFromNotification();
} else {
if (PlayBackUtil.getCurrentSong() != null && rhythmSong.getSongLocation()
.equals(PlayBackUtil.getCurrentSong().getSongLocation())) {
Expand All @@ -191,8 +195,8 @@ public void setUserVisibleHint(boolean isVisibleToUser) {
trackProgress.setProgress(0);
updateDuration("0:00", milliSecondsToTimer(mediaPlayer.getDuration()));
}
mListener.setToolBarText(rhythmSong.getArtistTitle(), rhythmSong.getAlbumTitle());
mListener.changePlayerStyle(vibrantColor, backgroundColor, songPosition);
callback.setToolBarText(rhythmSong.getArtistTitle(), rhythmSong.getAlbumTitle());
callback.changePlayerStyle(vibrantColor, backgroundColor, songPosition);
PlayBackUtil.setCurrentSong(rhythmSong);
} else {
if (mediaPlayer != null) {
Expand Down Expand Up @@ -291,8 +295,8 @@ public void onCompletion(MediaPlayer mp) {
}

private void playNext() {
if (mListener != null) {
mListener.playNext();
if (callback != null) {
callback.playNext();
} else {
Intent intent = new Intent(getContext().getApplicationContext(), MediaPlayerService.class);
intent.setAction(Constants.ACTION_NEXT);
Expand Down Expand Up @@ -349,11 +353,11 @@ private void updatePlayerUI() {
vibrantColor = vibrantSwatch.getRgb();
backgroundColor = vibrantSwatch.getBodyTextColor();
changePlayerStyle(vibrantSwatch.getRgb());
mListener.changePlayerStyle(vibrantColor, backgroundColor, songPosition);
callback.changePlayerStyle(vibrantColor, backgroundColor, songPosition);
} else {
vibrantColor = getResources().getColor(R.color.color_primary);
backgroundColor = getResources().getColor(R.color.color_primary_dark);
mListener.changePlayerStyle(vibrantColor, backgroundColor, songPosition);
callback.changePlayerStyle(vibrantColor, backgroundColor, songPosition);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">Rhythm</string>
<!--<string name="app_name">Rhythm</string>-->
<string name="duration_format">%1$s &#47; %2$s</string>
<string name="artists">Artists</string>
<string name="loading_message">Updating Music Archive</string>
Expand Down

0 comments on commit f3c9b6d

Please sign in to comment.