diff --git a/.idea/RetroMusicPlayer.iml b/.idea/RetroMusicPlayer.iml
deleted file mode 100644
index c5796822..00000000
--- a/.idea/RetroMusicPlayer.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
new file mode 100644
index 00000000..2a9c5e01
--- /dev/null
+++ b/.idea/assetWizardSettings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle____local_aars____Users_hemanths_Desktop_KeepSafe_RetroMusicPlayer_app_libs_jsoup_1_11_2_jar_unspecified_jar.xml b/.idea/libraries/Gradle____local_aars____Users_hemanths_Desktop_KeepSafe_RetroMusicPlayer_app_libs_jsoup_1_11_2_jar_unspecified_jar.xml
deleted file mode 100644
index c6d6bce5..00000000
--- a/.idea/libraries/Gradle____local_aars____Users_hemanths_Desktop_KeepSafe_RetroMusicPlayer_app_libs_jsoup_1_11_2_jar_unspecified_jar.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_mpatric_mp3agic_0_8_3_jar.xml b/.idea/libraries/Gradle__com_mpatric_mp3agic_0_8_3_jar.xml
deleted file mode 100644
index 9b5bf4b0..00000000
--- a/.idea/libraries/Gradle__com_mpatric_mp3agic_0_8_3_jar.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__jp_wasabeef_glide_transformations_2_0_2.xml b/.idea/libraries/Gradle__jp_wasabeef_glide_transformations_2_0_2.xml
deleted file mode 100644
index 24015588..00000000
--- a/.idea/libraries/Gradle__jp_wasabeef_glide_transformations_2_0_2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 26dc4f51..ddffd329 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,25 +5,32 @@
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index bef72af7..9138ca8d 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 83067447..35eb1ddf 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,5 @@
-
\ No newline at end of file
diff --git a/RetroMusicPlayer.iml b/RetroMusicPlayer.iml
index c5796822..92f9a14a 100644
--- a/RetroMusicPlayer.iml
+++ b/RetroMusicPlayer.iml
@@ -13,7 +13,7 @@
-
+
\ No newline at end of file
diff --git a/app/app.iml b/app/app.iml
index cf066c09..be879509 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -130,6 +130,8 @@
+
+
@@ -141,11 +143,16 @@
+
+
+
+
+
@@ -159,7 +166,7 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 930f5a87..bc3183e4 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,8 +11,8 @@ android {
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
- versionCode 206
- versionName 'R - 1.7.10'
+ versionCode 207
+ versionName '1.7.10'
multiDexEnabled true
diff --git a/app/src/main/java/code/name/monkey/retromusic/Injection.java b/app/src/main/java/code/name/monkey/retromusic/Injection.java
index 481613ff..4fe94a74 100644
--- a/app/src/main/java/code/name/monkey/retromusic/Injection.java
+++ b/app/src/main/java/code/name/monkey/retromusic/Injection.java
@@ -9,15 +9,15 @@ import code.name.monkey.retromusic.util.schedulers.SchedulerProvider;
public class Injection {
- public static Repository provideRepository() {
- return RepositoryImpl.getInstance();
- }
+ public static Repository provideRepository() {
+ return RepositoryImpl.getInstance();
+ }
- public static BaseSchedulerProvider provideSchedulerProvider() {
- return SchedulerProvider.getInstance();
- }
+ public static BaseSchedulerProvider provideSchedulerProvider() {
+ return SchedulerProvider.getInstance();
+ }
- public static KuGouApiService provideKuGouApiService() {
- return new KogouClient().getApiService();
- }
+ public static KuGouApiService provideKuGouApiService() {
+ return new KogouClient().getApiService();
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/swipebtn/DimentionUtils.java b/app/src/main/java/code/name/monkey/retromusic/swipebtn/DimentionUtils.java
deleted file mode 100755
index 587055a5..00000000
--- a/app/src/main/java/code/name/monkey/retromusic/swipebtn/DimentionUtils.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package code.name.monkey.retromusic.swipebtn;
-
-import android.content.Context;
-
-final class DimentionUtils {
-
- private DimentionUtils() {
- }
-
- static float convertPixelsToSp(float px, Context context) {
- return px / context.getResources().getDisplayMetrics().scaledDensity;
- }
-}
diff --git a/app/src/main/java/code/name/monkey/retromusic/swipebtn/OnActiveListener.java b/app/src/main/java/code/name/monkey/retromusic/swipebtn/OnActiveListener.java
deleted file mode 100755
index 429584ce..00000000
--- a/app/src/main/java/code/name/monkey/retromusic/swipebtn/OnActiveListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package code.name.monkey.retromusic.swipebtn;
-
-public interface OnActiveListener {
- void onActive();
-}
diff --git a/app/src/main/java/code/name/monkey/retromusic/swipebtn/OnStateChangeListener.java b/app/src/main/java/code/name/monkey/retromusic/swipebtn/OnStateChangeListener.java
deleted file mode 100755
index c4adf4a2..00000000
--- a/app/src/main/java/code/name/monkey/retromusic/swipebtn/OnStateChangeListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package code.name.monkey.retromusic.swipebtn;
-
-public interface OnStateChangeListener {
- void onStateChange(boolean active);
-}
diff --git a/app/src/main/java/code/name/monkey/retromusic/swipebtn/SwipeButton.java b/app/src/main/java/code/name/monkey/retromusic/swipebtn/SwipeButton.java
deleted file mode 100755
index eaecc952..00000000
--- a/app/src/main/java/code/name/monkey/retromusic/swipebtn/SwipeButton.java
+++ /dev/null
@@ -1,486 +0,0 @@
-package code.name.monkey.retromusic.swipebtn;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.support.v4.content.ContextCompat;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.AccelerateDecelerateInterpolator;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import code.name.monkey.retromusic.R;
-
-public class SwipeButton extends RelativeLayout {
-
-
- private static final int ENABLED = 0;
- private static final int DISABLED = 1;
- private ImageView swipeButtonInner;
- private float initialX;
- private boolean active;
- private TextView centerText;
- private ViewGroup background;
- private Drawable disabledDrawable;
- private Drawable enabledDrawable;
- private OnStateChangeListener onStateChangeListener;
- private OnActiveListener onActiveListener;
- private int collapsedWidth;
- private int collapsedHeight;
-
- private LinearLayout layer;
- private boolean trailEnabled = false;
- private boolean hasActivationState;
-
- public SwipeButton(Context context) {
- super(context);
-
- init(context, null, -1, -1);
- }
-
- public SwipeButton(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- init(context, attrs, -1, -1);
- }
-
- public SwipeButton(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
-
- init(context, attrs, defStyleAttr, -1);
- }
-
- @TargetApi(21)
- public SwipeButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
-
- init(context, attrs, defStyleAttr, defStyleRes);
- }
-
- public void setCenterTextColor(int color) {
- if (centerText == null) {
- return;
- }
- centerText.setTextColor(color);
- }
-
- public boolean isActive() {
- return active;
- }
-
- public void setText(String text) {
- centerText.setText(text);
- }
-
- public void setBackground(Drawable drawable) {
- background.setBackground(drawable);
- }
-
- public ViewGroup getSwipeBackground() {
- return background;
- }
-
- public void setSlidingButtonBackground(Drawable drawable) {
- background.setBackground(drawable);
- }
-
- public void setDisabledDrawable(Drawable drawable) {
- disabledDrawable = drawable;
-
- if (!active) {
- swipeButtonInner.setImageDrawable(drawable);
- }
- }
-
- public void setButtonBackground(Drawable buttonBackground) {
- if (buttonBackground != null) {
- swipeButtonInner.setBackground(buttonBackground);
- }
- }
-
- public void setEnabledDrawable(Drawable drawable) {
- enabledDrawable = drawable;
-
- if (active) {
- swipeButtonInner.setImageDrawable(drawable);
- }
- }
-
- public void setOnStateChangeListener(OnStateChangeListener onStateChangeListener) {
- this.onStateChangeListener = onStateChangeListener;
- }
-
- public void setOnActiveListener(OnActiveListener onActiveListener) {
- this.onActiveListener = onActiveListener;
- }
-
- public void setInnerTextPadding(int left, int top, int right, int bottom) {
- centerText.setPadding(left, top, right, bottom);
- }
-
- public void setSwipeButtonPadding(int left, int top, int right, int bottom) {
- swipeButtonInner.setPadding(left, top, right, bottom);
- }
-
- public void setHasActivationState(boolean hasActivationState) {
- this.hasActivationState = hasActivationState;
- }
-
- private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- hasActivationState = true;
-
- background = new RelativeLayout(context);
-
- LayoutParams layoutParamsView = new LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
-
- layoutParamsView.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
-
- addView(background, layoutParamsView);
-
- final TextView centerText = new TextView(context);
- this.centerText = centerText;
- centerText.setGravity(Gravity.CENTER);
-
- LayoutParams layoutParams = new LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
-
- layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
-
- background.addView(centerText, layoutParams);
-
- final ImageView swipeButton = new ImageView(context);
- this.swipeButtonInner = swipeButton;
-
- if (attrs != null && defStyleAttr == -1 && defStyleRes == -1) {
- TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeButton,
- defStyleAttr, defStyleRes);
-
- collapsedWidth = (int) typedArray.getDimension(R.styleable.SwipeButton_button_image_width,
- ViewGroup.LayoutParams.WRAP_CONTENT);
- collapsedHeight = (int) typedArray.getDimension(R.styleable.SwipeButton_button_image_height,
- ViewGroup.LayoutParams.WRAP_CONTENT);
- trailEnabled = typedArray.getBoolean(R.styleable.SwipeButton_button_trail_enabled,
- false);
- Drawable trailingDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_trail_drawable);
-
- Drawable backgroundDrawable = typedArray.getDrawable(R.styleable.SwipeButton_inner_text_background);
-
- if (backgroundDrawable != null) {
- background.setBackground(backgroundDrawable);
- } else {
- background.setBackground(ContextCompat.getDrawable(context, R.drawable.shape_rounded_edit));
- }
-
- if (trailEnabled) {
- layer = new LinearLayout(context);
-
- if (trailingDrawable != null) {
- layer.setBackground(trailingDrawable);
- } else {
- layer.setBackground(typedArray.getDrawable(R.styleable.SwipeButton_button_background));
- }
-
- layer.setGravity(Gravity.START);
- layer.setVisibility(View.GONE);
- background.addView(layer, layoutParamsView);
- }
-
- centerText.setText(typedArray.getText(R.styleable.SwipeButton_inner_text));
- centerText.setTextColor(typedArray.getColor(R.styleable.SwipeButton_inner_text_color,
- Color.WHITE));
-
- float textSize = DimentionUtils.convertPixelsToSp(
- typedArray.getDimension(R.styleable.SwipeButton_inner_text_size, 0), context);
-
- if (textSize != 0) {
- centerText.setTextSize(textSize);
- } else {
- centerText.setTextSize(12);
- }
-
- disabledDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_image_disabled);
- enabledDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_image_enabled);
- float innerTextLeftPadding = typedArray.getDimension(
- R.styleable.SwipeButton_inner_text_left_padding, 0);
- float innerTextTopPadding = typedArray.getDimension(
- R.styleable.SwipeButton_inner_text_top_padding, 0);
- float innerTextRightPadding = typedArray.getDimension(
- R.styleable.SwipeButton_inner_text_right_padding, 0);
- float innerTextBottomPadding = typedArray.getDimension(
- R.styleable.SwipeButton_inner_text_bottom_padding, 0);
-
- int initialState = typedArray.getInt(R.styleable.SwipeButton_initial_state, DISABLED);
-
- if (initialState == ENABLED) {
- LayoutParams layoutParamsButton = new LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
-
- layoutParamsButton.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
- layoutParamsButton.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
-
- swipeButton.setImageDrawable(enabledDrawable);
-
- addView(swipeButton, layoutParamsButton);
-
- active = true;
- } else {
- LayoutParams layoutParamsButton = new LayoutParams(collapsedWidth, collapsedHeight);
-
- layoutParamsButton.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
- layoutParamsButton.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
-
- swipeButton.setImageDrawable(disabledDrawable);
-
- addView(swipeButton, layoutParamsButton);
-
- active = false;
- }
-
- centerText.setPadding((int) innerTextLeftPadding,
- (int) innerTextTopPadding,
- (int) innerTextRightPadding,
- (int) innerTextBottomPadding);
-
- Drawable buttonBackground = typedArray.getDrawable(R.styleable.SwipeButton_button_background);
-
- if (buttonBackground != null) {
- swipeButton.setBackground(buttonBackground);
- } else {
- swipeButton.setBackground(ContextCompat.getDrawable(context, R.drawable.shape_rounded_edit));
- }
-
- float buttonLeftPadding = typedArray.getDimension(
- R.styleable.SwipeButton_button_left_padding, 0);
- float buttonTopPadding = typedArray.getDimension(
- R.styleable.SwipeButton_button_top_padding, 0);
- float buttonRightPadding = typedArray.getDimension(
- R.styleable.SwipeButton_button_right_padding, 0);
- float buttonBottomPadding = typedArray.getDimension(
- R.styleable.SwipeButton_button_bottom_padding, 0);
-
- swipeButton.setPadding((int) buttonLeftPadding,
- (int) buttonTopPadding,
- (int) buttonRightPadding,
- (int) buttonBottomPadding);
-
- hasActivationState = typedArray.getBoolean(R.styleable.SwipeButton_has_activate_state, true);
-
- typedArray.recycle();
- }
-
- setOnTouchListener(getButtonTouchListener());
- }
-
- private OnTouchListener getButtonTouchListener() {
- return new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- return !TouchUtils.isTouchOutsideInitialPosition(event, swipeButtonInner);
- case MotionEvent.ACTION_MOVE:
- if (initialX == 0) {
- initialX = swipeButtonInner.getX();
- }
-
- if (event.getX() > swipeButtonInner.getWidth() / 2 &&
- event.getX() + swipeButtonInner.getWidth() / 2 < getWidth()) {
- swipeButtonInner.setX(event.getX() - swipeButtonInner.getWidth() / 2);
- centerText.setAlpha(1 - 1.3f * (swipeButtonInner.getX() + swipeButtonInner.getWidth()) / getWidth());
- setTrailingEffect();
- }
-
- if (event.getX() + swipeButtonInner.getWidth() / 2 > getWidth() &&
- swipeButtonInner.getX() + swipeButtonInner.getWidth() / 2 < getWidth()) {
- swipeButtonInner.setX(getWidth() - swipeButtonInner.getWidth());
- }
-
- if (event.getX() < swipeButtonInner.getWidth() / 2) {
- swipeButtonInner.setX(0);
- }
-
- return true;
- case MotionEvent.ACTION_UP:
- if (active) {
- collapseButton();
- } else {
- if (swipeButtonInner.getX() + swipeButtonInner.getWidth() > getWidth() * 0.9) {
- if (hasActivationState) {
- expandButton();
- } else if (onActiveListener != null) {
- onActiveListener.onActive();
- moveButtonBack();
- }
- } else {
- moveButtonBack();
- }
- }
-
- return true;
- }
-
- return false;
- }
- };
- }
-
- private void expandButton() {
- final ValueAnimator positionAnimator =
- ValueAnimator.ofFloat(swipeButtonInner.getX(), 0);
- positionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- float x = (Float) positionAnimator.getAnimatedValue();
- swipeButtonInner.setX(x);
- }
- });
-
-
- final ValueAnimator widthAnimator = ValueAnimator.ofInt(
- swipeButtonInner.getWidth(),
- getWidth());
-
- widthAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- ViewGroup.LayoutParams params = swipeButtonInner.getLayoutParams();
- params.width = (Integer) widthAnimator.getAnimatedValue();
- swipeButtonInner.setLayoutParams(params);
- }
- });
-
-
- AnimatorSet animatorSet = new AnimatorSet();
- animatorSet.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
-
- active = true;
- swipeButtonInner.setImageDrawable(enabledDrawable);
-
- if (onStateChangeListener != null) {
- onStateChangeListener.onStateChange(active);
- }
-
- if (onActiveListener != null) {
- onActiveListener.onActive();
- }
- }
- });
-
- animatorSet.playTogether(positionAnimator, widthAnimator);
- animatorSet.start();
- }
-
- private void moveButtonBack() {
- final ValueAnimator positionAnimator =
- ValueAnimator.ofFloat(swipeButtonInner.getX(), 0);
- positionAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
- positionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- float x = (Float) positionAnimator.getAnimatedValue();
- swipeButtonInner.setX(x);
- setTrailingEffect();
- }
- });
-
- positionAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- if (layer != null) {
- layer.setVisibility(View.GONE);
- }
- }
- });
-
- ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(
- centerText, "alpha", 1);
-
- positionAnimator.setDuration(200);
-
- AnimatorSet animatorSet = new AnimatorSet();
- animatorSet.playTogether(objectAnimator, positionAnimator);
- animatorSet.start();
- }
-
- private void collapseButton() {
- int finalWidth;
-
- if (collapsedWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
- finalWidth = swipeButtonInner.getHeight();
- } else {
- finalWidth = collapsedWidth;
- }
-
- final ValueAnimator widthAnimator = ValueAnimator.ofInt(swipeButtonInner.getWidth(), finalWidth);
-
- widthAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- ViewGroup.LayoutParams params = swipeButtonInner.getLayoutParams();
- params.width = (Integer) widthAnimator.getAnimatedValue();
- swipeButtonInner.setLayoutParams(params);
- setTrailingEffect();
- }
- });
-
- widthAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- active = false;
- swipeButtonInner.setImageDrawable(disabledDrawable);
- if (onStateChangeListener != null) {
- onStateChangeListener.onStateChange(active);
- }
- if (layer != null) {
- layer.setVisibility(View.GONE);
- }
- }
- });
-
- ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(
- centerText, "alpha", 1);
-
- AnimatorSet animatorSet = new AnimatorSet();
-
- animatorSet.playTogether(objectAnimator, widthAnimator);
- animatorSet.start();
- }
-
- private void setTrailingEffect() {
- if (trailEnabled) {
- layer.setVisibility(View.VISIBLE);
- layer.setLayoutParams(new LayoutParams(
- (int) (swipeButtonInner.getX() + swipeButtonInner.getWidth() / 3), centerText.getHeight()));
- }
- }
-
- public void toggleState() {
- if (isActive()) {
- collapseButton();
- } else {
- expandButton();
- }
- }
-}
diff --git a/app/src/main/java/code/name/monkey/retromusic/swipebtn/TouchUtils.java b/app/src/main/java/code/name/monkey/retromusic/swipebtn/TouchUtils.java
deleted file mode 100755
index b9762592..00000000
--- a/app/src/main/java/code/name/monkey/retromusic/swipebtn/TouchUtils.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package code.name.monkey.retromusic.swipebtn;
-
-import android.view.MotionEvent;
-import android.view.View;
-
-final class TouchUtils {
- private TouchUtils() {
- }
-
- static boolean isTouchOutsideInitialPosition(MotionEvent event, View view) {
- return event.getX() > view.getX() + view.getWidth();
- }
-}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java
index 7fe40e3e..936317f3 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/activities/base/AbsThemeActivity.java
@@ -77,9 +77,6 @@ public abstract class AbsThemeActivity extends ATHToolbarActivity implements Run
: ContextCompat.getDrawable(this, R.drawable.square_window);
background = TintHelper.createTintedDrawable(background, ThemeStore.primaryColor(this));
getWindow().setBackgroundDrawable(background);
- //View decor = getWindow().getDecorView();
- //GradientDrawable gradientDrawable = (GradientDrawable) decor.getBackground();
- //gradientDrawable.setColor(ThemeStore.primaryColor(this));
}
protected void setDrawUnderStatusBar(boolean drawUnderStatusbar) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewCustomGridSizeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewCustomGridSizeFragment.java
index 16f999ef..a4ee752a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewCustomGridSizeFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/base/AbsLibraryPagerRecyclerViewCustomGridSizeFragment.java
@@ -120,7 +120,7 @@ public abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment extends
- AbsLibraryPagerFragment implements OnOffsetChangedListener {
+ AbsLibraryPagerFragment implements OnOffsetChangedListener {
- public static final String TAG = AbsLibraryPagerRecyclerViewFragment.class.getSimpleName();
- @BindView(R.id.container)
- ViewGroup container;
- @BindView(R.id.recycler_view)
- RecyclerView recyclerView;
- @BindView(android.R.id.empty)
- TextView empty;
+ public static final String TAG = AbsLibraryPagerRecyclerViewFragment.class.getSimpleName();
+ @BindView(R.id.container)
+ ViewGroup container;
+ @BindView(R.id.recycler_view)
+ RecyclerView recyclerView;
+ @BindView(android.R.id.empty)
+ TextView empty;
- private Unbinder unbinder;
- private A adapter;
- private LM layoutManager;
+ private Unbinder unbinder;
+ private A adapter;
+ private LM layoutManager;
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(getLayoutRes(), container, false);
- unbinder = ButterKnife.bind(this, view);
- return view;
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(getLayoutRes(), container, false);
+ unbinder = ButterKnife.bind(this, view);
+ return view;
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ getLibraryFragment().addOnAppBarOffsetChangedListener(this);
+ initLayoutManager();
+ initAdapter();
+ setUpRecyclerView();
+ }
+
+ private void setUpRecyclerView() {
+ if (recyclerView instanceof FastScrollRecyclerView) {
+ //noinspection ConstantConditions
+ ViewUtil.setUpFastScrollRecyclerViewColor(getActivity(),
+ ((FastScrollRecyclerView) recyclerView), ThemeStore.accentColor(getActivity()));
}
+ recyclerView.setLayoutManager(layoutManager);
+ recyclerView.setAdapter(adapter);
+ }
- @Override
- public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- getLibraryFragment().addOnAppBarOffsetChangedListener(this);
- initLayoutManager();
- initAdapter();
- setUpRecyclerView();
- }
+ @Override
+ public void onQueueChanged() {
+ super.onQueueChanged();
+ checkForPadding();
+ }
- private void setUpRecyclerView() {
- if (recyclerView instanceof FastScrollRecyclerView) {
- //noinspection ConstantConditions
- ViewUtil.setUpFastScrollRecyclerViewColor(getActivity(),
- ((FastScrollRecyclerView) recyclerView), ThemeStore.accentColor(getActivity()));
- }
- recyclerView.setLayoutManager(layoutManager);
- recyclerView.setAdapter(adapter);
- }
+ @Override
+ public void onServiceConnected() {
+ super.onServiceConnected();
+ checkForPadding();
+ }
- @Override
- public void onQueueChanged() {
- super.onQueueChanged();
- checkForPadding();
- }
+ private void checkForPadding() {
+ int height = (MusicPlayerRemote.getPlayingQueue().isEmpty() ? getResources()
+ .getDimensionPixelSize(R.dimen.mini_player_height) : 0);
+ recyclerView.setPadding(0, 0, 0, height);
+ }
- @Override
- public void onServiceConnected() {
- super.onServiceConnected();
- checkForPadding();
- }
+ protected void invalidateLayoutManager() {
+ initLayoutManager();
+ recyclerView.setLayoutManager(layoutManager);
+ }
- private void checkForPadding() {
- int height = (MusicPlayerRemote.getPlayingQueue().isEmpty() ? getResources().getDimensionPixelSize(R.dimen.mini_player_height) : 0);
- recyclerView.setPadding(0, 0, 0, height);
- }
+ protected void invalidateAdapter() {
+ initAdapter();
+ checkIsEmpty();
+ recyclerView.setAdapter(adapter);
+ }
- protected void invalidateLayoutManager() {
- initLayoutManager();
- recyclerView.setLayoutManager(layoutManager);
- }
-
- protected void invalidateAdapter() {
- initAdapter();
+ private void initAdapter() {
+ adapter = createAdapter();
+ adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
+ @Override
+ public void onChanged() {
+ super.onChanged();
checkIsEmpty();
- recyclerView.setAdapter(adapter);
- }
+ checkForPadding();
+ }
+ });
+ }
- private void initAdapter() {
- adapter = createAdapter();
- adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
- @Override
- public void onChanged() {
- super.onChanged();
- checkIsEmpty();
- checkForPadding();
- }
- });
- }
+ private void initLayoutManager() {
+ layoutManager = createLayoutManager();
+ }
- private void initLayoutManager() {
- layoutManager = createLayoutManager();
- }
+ protected A getAdapter() {
+ return adapter;
+ }
- protected A getAdapter() {
- return adapter;
- }
+ protected LM getLayoutManager() {
+ return layoutManager;
+ }
- protected LM getLayoutManager() {
- return layoutManager;
- }
+ protected RecyclerView getRecyclerView() {
+ return recyclerView;
+ }
- protected RecyclerView getRecyclerView() {
- return recyclerView;
- }
+ public ViewGroup getContainer() {
+ return container;
+ }
- public ViewGroup getContainer() {
- return container;
- }
+ @Override
+ public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
+ container.setPadding(container.getPaddingLeft(), container.getPaddingTop(),
+ container.getPaddingRight(), getLibraryFragment().getTotalAppBarScrollingRange() + i);
+ }
- @Override
- public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
- container.setPadding(container.getPaddingLeft(), container.getPaddingTop(),
- container.getPaddingRight(), getLibraryFragment().getTotalAppBarScrollingRange() + i);
- }
+ private void checkIsEmpty() {
+ empty.setText(getEmptyMessage());
+ empty.setVisibility(adapter == null || adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
+ }
- private void checkIsEmpty() {
- empty.setText(getEmptyMessage());
- empty.setVisibility(adapter == null || adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
- }
+ @StringRes
+ protected int getEmptyMessage() {
+ return R.string.empty;
+ }
- @StringRes
- protected int getEmptyMessage() {
- return R.string.empty;
- }
+ @LayoutRes
+ protected int getLayoutRes() {
+ return R.layout.fragment_main_activity_recycler_view;
+ }
- @LayoutRes
- protected int getLayoutRes() {
- return R.layout.fragment_main_activity_recycler_view;
- }
+ protected abstract LM createLayoutManager();
- protected abstract LM createLayoutManager();
+ @NonNull
+ protected abstract A createAdapter();
- @NonNull
- protected abstract A createAdapter();
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- getLibraryFragment().removeOnAppBarOffsetChangedListener(this);
- unbinder.unbind();
- }
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ getLibraryFragment().removeOnAppBarOffsetChangedListener(this);
+ unbinder.unbind();
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java
index ccdf51f4..46f6fbc8 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/AlbumsFragment.java
@@ -4,9 +4,6 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
-
-import java.util.ArrayList;
-
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.Album;
import code.name.monkey.retromusic.mvp.contract.AlbumContract;
@@ -14,155 +11,156 @@ import code.name.monkey.retromusic.mvp.presenter.AlbumPresenter;
import code.name.monkey.retromusic.ui.adapter.album.AlbumAdapter;
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.util.PreferenceUtil;
+import java.util.ArrayList;
public class AlbumsFragment extends
- AbsLibraryPagerRecyclerViewCustomGridSizeFragment implements
- AlbumContract.AlbumView {
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment implements
+ AlbumContract.AlbumView {
- public static final String TAG = AlbumsFragment.class.getSimpleName();
+ public static final String TAG = AlbumsFragment.class.getSimpleName();
- private AlbumPresenter presenter;
+ private AlbumPresenter presenter;
- public static AlbumsFragment newInstance() {
- Bundle args = new Bundle();
- AlbumsFragment fragment = new AlbumsFragment();
- fragment.setArguments(args);
- return fragment;
+ public static AlbumsFragment newInstance() {
+ Bundle args = new Bundle();
+ AlbumsFragment fragment = new AlbumsFragment();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ protected GridLayoutManager createLayoutManager() {
+ return new GridLayoutManager(getActivity(), getGridSize());
+ }
+
+ @NonNull
+ @Override
+ protected AlbumAdapter createAdapter() {
+ int itemLayoutRes = getItemLayoutRes();
+ notifyLayoutResChanged(itemLayoutRes);
+ if (itemLayoutRes != R.layout.item_list) {
+ itemLayoutRes = PreferenceUtil.getInstance(getContext()).getAlbumGridStyle(getContext());
}
+ ArrayList dataSet =
+ getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
+ return new AlbumAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
+ loadUsePalette(), getLibraryFragment());
+ }
- @Override
- protected GridLayoutManager createLayoutManager() {
- return new GridLayoutManager(getActivity(), getGridSize());
- }
+ @Override
+ protected int getEmptyMessage() {
+ return R.string.no_albums;
+ }
- @NonNull
- @Override
- protected AlbumAdapter createAdapter() {
- int itemLayoutRes = getItemLayoutRes();
- notifyLayoutResChanged(itemLayoutRes);
- if (itemLayoutRes != R.layout.item_list) {
- itemLayoutRes = PreferenceUtil.getInstance(getContext()).getAlbumGridStyle(getContext());
- }
- ArrayList dataSet =
- getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
- return new AlbumAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
- loadUsePalette(), getLibraryFragment());
- }
+ @Override
+ public boolean loadUsePalette() {
+ return PreferenceUtil.getInstance(getActivity()).albumColoredFooters();
+ }
- @Override
- protected int getEmptyMessage() {
- return R.string.no_albums;
- }
+ @Override
+ protected void setUsePalette(boolean usePalette) {
+ getAdapter().usePalette(usePalette);
+ }
- @Override
- public boolean loadUsePalette() {
- return PreferenceUtil.getInstance(getActivity()).albumColoredFooters();
- }
+ @Override
+ protected void setGridSize(int gridSize) {
+ getLayoutManager().setSpanCount(gridSize);
+ getAdapter().notifyDataSetChanged();
+ }
- @Override
- protected void setUsePalette(boolean usePalette) {
- getAdapter().usePalette(usePalette);
- }
+ @Override
+ protected void setSortOrder(String sortOrder) {
+ presenter.loadAlbums();
+ }
- @Override
- protected void setGridSize(int gridSize) {
- getLayoutManager().setSpanCount(gridSize);
- getAdapter().notifyDataSetChanged();
- }
+ @Override
+ protected String loadSortOrder() {
+ return PreferenceUtil.getInstance(getActivity()).getAlbumSortOrder();
+ }
- @Override
- protected void setSortOrder(String sortOrder) {
- presenter.loadAlbums();
- }
+ @Override
+ protected void saveSortOrder(String sortOrder) {
+ PreferenceUtil.getInstance(getActivity()).setAlbumSortOrder(sortOrder);
+ }
- @Override
- protected String loadSortOrder() {
- return PreferenceUtil.getInstance(getActivity()).getAlbumSortOrder();
- }
+ @Override
+ protected int loadGridSize() {
+ return PreferenceUtil.getInstance(getActivity()).getAlbumGridSize(getActivity());
+ }
- @Override
- protected void saveSortOrder(String sortOrder) {
- PreferenceUtil.getInstance(getActivity()).setAlbumSortOrder(sortOrder);
- }
+ @Override
+ protected void saveGridSize(int gridSize) {
+ PreferenceUtil.getInstance(getActivity()).setAlbumGridSize(gridSize);
+ }
- @Override
- protected int loadGridSize() {
- return PreferenceUtil.getInstance(getActivity()).getAlbumGridSize(getActivity());
- }
+ @Override
+ protected int loadGridSizeLand() {
+ return PreferenceUtil.getInstance(getActivity()).getAlbumGridSizeLand(getActivity());
+ }
- @Override
- protected void saveGridSize(int gridSize) {
- PreferenceUtil.getInstance(getActivity()).setAlbumGridSize(gridSize);
- }
+ @Override
+ protected void saveGridSizeLand(int gridSize) {
+ PreferenceUtil.getInstance(getActivity()).setAlbumGridSizeLand(gridSize);
+ }
- @Override
- protected int loadGridSizeLand() {
- return PreferenceUtil.getInstance(getActivity()).getAlbumGridSizeLand(getActivity());
- }
+ @Override
+ protected void saveUsePalette(boolean usePalette) {
+ PreferenceUtil.getInstance(getActivity()).setAlbumColoredFooters(usePalette);
+ }
- @Override
- protected void saveGridSizeLand(int gridSize) {
- PreferenceUtil.getInstance(getActivity()).setAlbumGridSizeLand(gridSize);
- }
+ @Override
+ public void onMediaStoreChanged() {
+ presenter.loadAlbums();
+ }
- @Override
- protected void saveUsePalette(boolean usePalette) {
- PreferenceUtil.getInstance(getActivity()).setAlbumColoredFooters(usePalette);
- }
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ presenter = new AlbumPresenter(this);
+ }
- @Override
- public void onMediaStoreChanged() {
- presenter.loadAlbums();
+ @Override
+ public void setMenuVisibility(boolean menuVisible) {
+ super.setMenuVisibility(menuVisible);
+ if (menuVisible) {
+ getLibraryFragment().setTitle(
+ PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
+ : R.string.albums);
}
+ }
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- presenter = new AlbumPresenter(this);
+ @Override
+ public void onResume() {
+ super.onResume();
+ getLibraryFragment().setTitle(
+ PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.albums);
+ if (getAdapter().getDataSet().isEmpty()) {
+ presenter.subscribe();
}
+ }
- @Override
- public void setMenuVisibility(boolean menuVisible) {
- super.setMenuVisibility(menuVisible);
- if (menuVisible) {
- getLibraryFragment().getToolbar().setTitle(
- PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
- : R.string.albums);
- }
- }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ presenter.unsubscribe();
+ }
- @Override
- public void onResume() {
- super.onResume();
- getLibraryFragment().getToolbar().setTitle(
- PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.albums);
- if (getAdapter().getDataSet().isEmpty()) {
- presenter.subscribe();
- }
- }
+ @Override
+ public void loading() {
+ }
- @Override
- public void onDestroy() {
- super.onDestroy();
- presenter.unsubscribe();
- }
+ @Override
+ public void showEmptyView() {
+ getAdapter().swapDataSet(new ArrayList<>());
+ }
- @Override
- public void loading() {
- }
+ @Override
+ public void completed() {
+ }
- @Override
- public void showEmptyView() {
- getAdapter().swapDataSet(new ArrayList<>());
- }
-
- @Override
- public void completed() {
- }
-
- @Override
- public void showData(ArrayList albums) {
- getAdapter().swapDataSet(albums);
- }
+ @Override
+ public void showData(ArrayList albums) {
+ getAdapter().swapDataSet(albums);
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java
index 82069802..86554410 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/ArtistsFragment.java
@@ -4,9 +4,6 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
-
-import java.util.ArrayList;
-
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.Artist;
import code.name.monkey.retromusic.mvp.contract.ArtistContract;
@@ -14,160 +11,161 @@ import code.name.monkey.retromusic.mvp.presenter.ArtistPresenter;
import code.name.monkey.retromusic.ui.adapter.artist.ArtistAdapter;
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.util.PreferenceUtil;
+import java.util.ArrayList;
public class ArtistsFragment extends
- AbsLibraryPagerRecyclerViewCustomGridSizeFragment implements
- ArtistContract.ArtistView {
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment implements
+ ArtistContract.ArtistView {
- public static final String TAG = ArtistsFragment.class.getSimpleName();
- private ArtistPresenter presenter;
+ public static final String TAG = ArtistsFragment.class.getSimpleName();
+ private ArtistPresenter presenter;
- public static ArtistsFragment newInstance() {
+ public static ArtistsFragment newInstance() {
- Bundle args = new Bundle();
+ Bundle args = new Bundle();
- ArtistsFragment fragment = new ArtistsFragment();
- fragment.setArguments(args);
- return fragment;
+ ArtistsFragment fragment = new ArtistsFragment();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ presenter = new ArtistPresenter(this);
+ }
+
+ @NonNull
+ @Override
+ protected GridLayoutManager createLayoutManager() {
+ return new GridLayoutManager(getActivity(), getGridSize());
+ }
+
+ @NonNull
+ @Override
+ protected ArtistAdapter createAdapter() {
+ int itemLayoutRes = getItemLayoutRes();
+ notifyLayoutResChanged(itemLayoutRes);
+ if (itemLayoutRes != R.layout.item_list) {
+ itemLayoutRes = PreferenceUtil.getInstance(getContext()).getArtistGridStyle(getContext());
}
+ ArrayList dataSet =
+ getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
+ return new ArtistAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
+ loadUsePalette(), getLibraryFragment());
+ }
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- presenter = new ArtistPresenter(this);
+ @Override
+ protected int getEmptyMessage() {
+ return R.string.no_artists;
+ }
+
+ @Override
+ public void onMediaStoreChanged() {
+ presenter.loadArtists();
+ }
+
+ @Override
+ protected int loadGridSize() {
+ return PreferenceUtil.getInstance(getActivity()).getArtistGridSize(getActivity());
+ }
+
+ @Override
+ protected void saveGridSize(int gridSize) {
+ PreferenceUtil.getInstance(getActivity()).setArtistGridSize(gridSize);
+ }
+
+ @Override
+ protected int loadGridSizeLand() {
+ return PreferenceUtil.getInstance(getActivity()).getArtistGridSizeLand(getActivity());
+ }
+
+ @Override
+ protected void saveGridSizeLand(int gridSize) {
+ PreferenceUtil.getInstance(getActivity()).setArtistGridSizeLand(gridSize);
+ }
+
+ @Override
+ protected void saveUsePalette(boolean usePalette) {
+ PreferenceUtil.getInstance(getActivity()).setArtistColoredFooters(usePalette);
+ }
+
+ @Override
+ public boolean loadUsePalette() {
+ return PreferenceUtil.getInstance(getActivity()).artistColoredFooters();
+ }
+
+ @Override
+ protected void setUsePalette(boolean usePalette) {
+ getAdapter().usePalette(usePalette);
+ }
+
+ @Override
+ protected void setGridSize(int gridSize) {
+ getLayoutManager().setSpanCount(gridSize);
+ getAdapter().notifyDataSetChanged();
+ }
+
+
+ @Override
+ protected String loadSortOrder() {
+ return PreferenceUtil.getInstance(getActivity()).getArtistSortOrder();
+ }
+
+ @Override
+ protected void saveSortOrder(String sortOrder) {
+ PreferenceUtil.getInstance(getActivity()).setArtistSortOrder(sortOrder);
+ }
+
+ @Override
+ protected void setSortOrder(String sortOrder) {
+ presenter.loadArtists();
+ }
+
+
+ @Override
+ public void setMenuVisibility(boolean menuVisible) {
+ super.setMenuVisibility(menuVisible);
+ if (menuVisible) {
+ getLibraryFragment().setTitle(
+ PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
+ : R.string.artists);
}
+ }
- @NonNull
- @Override
- protected GridLayoutManager createLayoutManager() {
- return new GridLayoutManager(getActivity(), getGridSize());
+ @Override
+ public void onResume() {
+ super.onResume();
+ getLibraryFragment().setTitle(
+ PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.artists);
+ if (getAdapter().getDataSet().isEmpty()) {
+ presenter.subscribe();
}
+ }
- @NonNull
- @Override
- protected ArtistAdapter createAdapter() {
- int itemLayoutRes = getItemLayoutRes();
- notifyLayoutResChanged(itemLayoutRes);
- if (itemLayoutRes != R.layout.item_list) {
- itemLayoutRes = PreferenceUtil.getInstance(getContext()).getArtistGridStyle(getContext());
- }
- ArrayList dataSet =
- getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
- return new ArtistAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
- loadUsePalette(), getLibraryFragment());
- }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ presenter.unsubscribe();
+ }
- @Override
- protected int getEmptyMessage() {
- return R.string.no_artists;
- }
+ @Override
+ public void loading() {
+ }
- @Override
- public void onMediaStoreChanged() {
- presenter.loadArtists();
- }
+ @Override
+ public void showEmptyView() {
+ getAdapter().swapDataSet(new ArrayList<>());
+ }
- @Override
- protected int loadGridSize() {
- return PreferenceUtil.getInstance(getActivity()).getArtistGridSize(getActivity());
- }
+ @Override
+ public void completed() {
- @Override
- protected void saveGridSize(int gridSize) {
- PreferenceUtil.getInstance(getActivity()).setArtistGridSize(gridSize);
- }
+ }
- @Override
- protected int loadGridSizeLand() {
- return PreferenceUtil.getInstance(getActivity()).getArtistGridSizeLand(getActivity());
- }
-
- @Override
- protected void saveGridSizeLand(int gridSize) {
- PreferenceUtil.getInstance(getActivity()).setArtistGridSizeLand(gridSize);
- }
-
- @Override
- protected void saveUsePalette(boolean usePalette) {
- PreferenceUtil.getInstance(getActivity()).setArtistColoredFooters(usePalette);
- }
-
- @Override
- public boolean loadUsePalette() {
- return PreferenceUtil.getInstance(getActivity()).artistColoredFooters();
- }
-
- @Override
- protected void setUsePalette(boolean usePalette) {
- getAdapter().usePalette(usePalette);
- }
-
- @Override
- protected void setGridSize(int gridSize) {
- getLayoutManager().setSpanCount(gridSize);
- getAdapter().notifyDataSetChanged();
- }
-
-
- @Override
- protected String loadSortOrder() {
- return PreferenceUtil.getInstance(getActivity()).getArtistSortOrder();
- }
-
- @Override
- protected void saveSortOrder(String sortOrder) {
- PreferenceUtil.getInstance(getActivity()).setArtistSortOrder(sortOrder);
- }
-
- @Override
- protected void setSortOrder(String sortOrder) {
- presenter.loadArtists();
- }
-
-
- @Override
- public void setMenuVisibility(boolean menuVisible) {
- super.setMenuVisibility(menuVisible);
- if (menuVisible) {
- getLibraryFragment().getToolbar().setTitle(
- PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
- : R.string.artists);
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- getLibraryFragment().getToolbar().setTitle(
- PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.artists);
- if (getAdapter().getDataSet().isEmpty()) {
- presenter.subscribe();
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- presenter.unsubscribe();
- }
-
- @Override
- public void loading() {
- }
-
- @Override
- public void showEmptyView() {
- getAdapter().swapDataSet(new ArrayList<>());
- }
-
- @Override
- public void completed() {
-
- }
-
- @Override
- public void showData(ArrayList artists) {
- getAdapter().swapDataSet(artists);
- }
+ @Override
+ public void showData(ArrayList artists) {
+ getAdapter().swapDataSet(artists);
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java
index 9925b60f..5f973bf1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/GenreFragment.java
@@ -39,7 +39,7 @@ public class GenreFragment extends
public void setMenuVisibility(boolean menuVisible) {
super.setMenuVisibility(menuVisible);
if (menuVisible) {
- getLibraryFragment().getToolbar().setTitle(
+ getLibraryFragment().setTitle(
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
: R.string.genres);
}
@@ -48,7 +48,7 @@ public class GenreFragment extends
@Override
public void onResume() {
super.onResume();
- getLibraryFragment().getToolbar().setTitle(
+ getLibraryFragment().setTitle(
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.genres);
if (getAdapter().getDataSet().isEmpty()) {
mPresenter.subscribe();
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java
index 77e94be9..92553498 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/LibraryFragment.java
@@ -5,7 +5,9 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
import android.support.design.widget.AppBarLayout;
+import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
@@ -17,11 +19,6 @@ import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
-
-import com.afollestad.materialcab.MaterialCab;
-
-import java.util.Objects;
-
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
@@ -37,422 +34,422 @@ import code.name.monkey.retromusic.helper.SortOrder;
import code.name.monkey.retromusic.interfaces.CabHolder;
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks;
import code.name.monkey.retromusic.loaders.SongLoader;
-import code.name.monkey.retromusic.ui.activities.SearchActivity;
import code.name.monkey.retromusic.ui.activities.SettingsActivity;
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.ui.fragments.base.AbsMainActivityFragment;
import code.name.monkey.retromusic.util.NavigationUtil;
import code.name.monkey.retromusic.util.RetroColorUtil;
import code.name.monkey.retromusic.util.RetroUtil;
-import code.name.monkey.retromusic.views.SansFontCollapsingToolbarLayout;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.schedulers.Schedulers;
+import com.afollestad.materialcab.MaterialCab;
public class LibraryFragment extends AbsMainActivityFragment implements CabHolder,
- MainActivityFragmentCallbacks {
+ MainActivityFragmentCallbacks {
- private static final String TAG = "LibraryFragment";
- private static final String CURRENT_TAB_ID = "current_tab_id";
- @BindView(R.id.toolbar)
- Toolbar toolbar;
- @BindView(R.id.appbar)
- AppBarLayout appbar;
- @BindView(R.id.collapsing_toolbar)
- SansFontCollapsingToolbarLayout collapsingToolbar;
+ private static final String TAG = "LibraryFragment";
+ private static final String CURRENT_TAB_ID = "current_tab_id";
+ @BindView(R.id.toolbar)
+ Toolbar toolbar;
+ @BindView(R.id.app_bar)
+ AppBarLayout appbar;
+ @BindView(R.id.collapsing_toolbar)
+ CollapsingToolbarLayout collapsingToolbarLayout;
- private Unbinder unBinder;
- private MaterialCab cab;
- private FragmentManager fragmentManager;
- public static Fragment newInstance(int tab) {
- Bundle args = new Bundle();
- args.putInt(CURRENT_TAB_ID, tab);
- LibraryFragment fragment = new LibraryFragment();
- fragment.setArguments(args);
- return fragment;
+ private Unbinder unBinder;
+ private MaterialCab cab;
+ private FragmentManager fragmentManager;
+
+ public static Fragment newInstance(int tab) {
+ Bundle args = new Bundle();
+ args.putInt(CURRENT_TAB_ID, tab);
+ LibraryFragment fragment = new LibraryFragment();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ public void setTitle(@StringRes int name) {
+ collapsingToolbarLayout.setTitle(getString(name));
+ }
+
+ public void addOnAppBarOffsetChangedListener(
+ AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
+ appbar.addOnOffsetChangedListener(onOffsetChangedListener);
+ }
+
+ public void removeOnAppBarOffsetChangedListener(
+ AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
+ appbar.removeOnOffsetChangedListener(onOffsetChangedListener);
+ }
+
+ public int getTotalAppBarScrollingRange() {
+ return appbar.getTotalScrollRange();
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_library, container, false);
+ unBinder = ButterKnife.bind(this, view);
+ return view;
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ setStatusbarColorAuto(view);
+ getMainActivity().setBottomBarVisibility(View.VISIBLE);
+ setupToolbar();
+
+ inflateFragment();
+ }
+
+ private void inflateFragment() {
+ if (getArguments() == null) {
+ selectedFragment(SongsFragment.newInstance());
+ return;
+ }
+ switch (getArguments().getInt(CURRENT_TAB_ID)) {
+ default:
+ case R.id.action_song:
+ selectedFragment(SongsFragment.newInstance());
+ break;
+ case R.id.action_album:
+ selectedFragment(AlbumsFragment.newInstance());
+ break;
+ case R.id.action_artist:
+ selectedFragment(ArtistsFragment.newInstance());
+ break;
+ case R.id.action_playlist:
+ selectedFragment(PlaylistsFragment.newInstance());
+ break;
+ }
+ }
+
+ @SuppressWarnings("ConstantConditions")
+ private void setupToolbar() {
+ int primaryColor = ThemeStore.primaryColor(getContext());
+ appbar.setBackgroundColor(primaryColor);
+ toolbar.setBackgroundColor(primaryColor);
+ appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) ->
+ getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext())));
+ getMainActivity().setTitle(R.string.app_name);
+ getMainActivity().setSupportActionBar(toolbar);
+ }
+
+ public Fragment getCurrentFragment() {
+ if (fragmentManager == null) {
+ return SongsFragment.newInstance();
+ }
+ return fragmentManager.findFragmentByTag(LibraryFragment.TAG);
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ unBinder.unbind();
+ }
+
+ @Override
+ public boolean handleBackPress() {
+ if (cab != null && cab.isActive()) {
+ cab.finish();
+ return true;
+ }
+ return false;
+ }
+
+ public void selectedFragment(Fragment fragment) {
+ fragmentManager = getChildFragmentManager();
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+
+ fragmentTransaction
+ .replace(R.id.fragment_container, fragment, TAG)
+ .commit();
+ }
+
+ @NonNull
+ @Override
+ public MaterialCab openCab(int menuRes, MaterialCab.Callback callback) {
+ if (cab != null && cab.isActive()) {
+ cab.finish();
+ }
+ //noinspection ConstantConditions
+ cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
+ .setMenu(menuRes)
+ .setCloseDrawableRes(R.drawable.ic_close_white_24dp)
+ .setBackgroundColor(
+ RetroColorUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(getActivity())))
+ .start(callback);
+ return cab;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
+ inflater.inflate(R.menu.menu_main, menu);
+
+ Fragment currentFragment = getCurrentFragment();
+ if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment
+ && currentFragment.isAdded()) {
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
+
+ MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
+ if (RetroUtil.isLandscape(getResources())) {
+ gridSizeItem.setTitle(R.string.action_grid_size_land);
+ }
+ setUpGridSizeMenu(fragment, gridSizeItem.getSubMenu());
+
+ setUpSortOrderMenu(fragment, menu.findItem(R.id.action_sort_order).getSubMenu());
+
+ } else {
+ menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
+ menu.removeItem(R.id.action_grid_size);
+ }
+ Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
+ ToolbarContentTintHelper.handleOnCreateOptionsMenu(getActivity(), toolbar, menu,
+ ATHToolbarActivity.getToolbarBackgroundColor(toolbar));
+ }
+
+ private void setUpSortOrderMenu(
+ @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
+ @NonNull SubMenu sortOrderMenu) {
+ String currentSortOrder = fragment.getSortOrder();
+ sortOrderMenu.clear();
+
+ if (fragment instanceof AlbumsFragment) {
+ sortOrderMenu.add(0, R.id.action_album_sort_order_asc, 0, R.string.sort_order_a_z)
+ .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_A_Z));
+ sortOrderMenu.add(0, R.id.action_album_sort_order_desc, 1, R.string.sort_order_z_a)
+ .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_Z_A));
+ sortOrderMenu.add(0, R.id.action_album_sort_order_artist, 2, R.string.sort_order_artist)
+ .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_ARTIST));
+ sortOrderMenu.add(0, R.id.action_album_sort_order_year, 3, R.string.sort_order_year)
+ .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_YEAR));
+ } else if (fragment instanceof ArtistsFragment) {
+ sortOrderMenu.add(0, R.id.action_artist_sort_order_asc, 0, R.string.sort_order_a_z)
+ .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_A_Z));
+ sortOrderMenu.add(0, R.id.action_artist_sort_order_desc, 1, R.string.sort_order_z_a)
+ .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_Z_A));
+ } else if (fragment instanceof SongsFragment) {
+ sortOrderMenu.add(0, R.id.action_song_sort_order_asc, 0, R.string.sort_order_a_z)
+ .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_A_Z));
+ sortOrderMenu.add(0, R.id.action_song_sort_order_desc, 1, R.string.sort_order_z_a)
+ .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_Z_A));
+ sortOrderMenu.add(0, R.id.action_song_sort_order_artist, 2, R.string.sort_order_artist)
+ .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ARTIST));
+ sortOrderMenu.add(0, R.id.action_song_sort_order_album, 3, R.string.sort_order_album)
+ .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ALBUM));
+ sortOrderMenu.add(0, R.id.action_song_sort_order_year, 4, R.string.sort_order_year)
+ .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_YEAR));
+ sortOrderMenu.add(0, R.id.action_song_sort_order_date, 4, R.string.sort_order_date)
+ .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_DATE));
}
- public SansFontCollapsingToolbarLayout getToolbar() {
- return collapsingToolbar;
+ sortOrderMenu.setGroupCheckable(0, true, true);
+ }
+
+ private boolean handleSortOrderMenuItem(
+ @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, @NonNull MenuItem item) {
+ String sortOrder = null;
+ if (fragment instanceof AlbumsFragment) {
+ switch (item.getItemId()) {
+ case R.id.action_album_sort_order_asc:
+ sortOrder = SortOrder.AlbumSortOrder.ALBUM_A_Z;
+ break;
+ case R.id.action_album_sort_order_desc:
+ sortOrder = SortOrder.AlbumSortOrder.ALBUM_Z_A;
+ break;
+ case R.id.action_album_sort_order_artist:
+ sortOrder = SortOrder.AlbumSortOrder.ALBUM_ARTIST;
+ break;
+ case R.id.action_album_sort_order_year:
+ sortOrder = SortOrder.AlbumSortOrder.ALBUM_YEAR;
+ break;
+ }
+ } else if (fragment instanceof ArtistsFragment) {
+ switch (item.getItemId()) {
+ case R.id.action_artist_sort_order_asc:
+ sortOrder = SortOrder.ArtistSortOrder.ARTIST_A_Z;
+ break;
+ case R.id.action_artist_sort_order_desc:
+ sortOrder = SortOrder.ArtistSortOrder.ARTIST_Z_A;
+ break;
+ }
+ } else if (fragment instanceof SongsFragment) {
+ switch (item.getItemId()) {
+ case R.id.action_song_sort_order_asc:
+ sortOrder = SortOrder.SongSortOrder.SONG_A_Z;
+ break;
+ case R.id.action_song_sort_order_desc:
+ sortOrder = SortOrder.SongSortOrder.SONG_Z_A;
+ break;
+ case R.id.action_song_sort_order_artist:
+ sortOrder = SortOrder.SongSortOrder.SONG_ARTIST;
+ break;
+ case R.id.action_song_sort_order_album:
+ sortOrder = SortOrder.SongSortOrder.SONG_ALBUM;
+ break;
+ case R.id.action_song_sort_order_year:
+ sortOrder = SortOrder.SongSortOrder.SONG_YEAR;
+ break;
+ case R.id.action_song_sort_order_date:
+ sortOrder = SortOrder.SongSortOrder.SONG_DATE;
+ break;
+ }
}
- public void addOnAppBarOffsetChangedListener(
- AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
- appbar.addOnOffsetChangedListener(onOffsetChangedListener);
+ if (sortOrder != null) {
+ item.setChecked(true);
+ fragment.setAndSaveSortOrder(sortOrder);
+ return true;
}
- public void removeOnAppBarOffsetChangedListener(
- AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
- appbar.removeOnOffsetChangedListener(onOffsetChangedListener);
+ return false;
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ super.onPrepareOptionsMenu(menu);
+ Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
+ ToolbarContentTintHelper.handleOnPrepareOptionsMenu(activity, toolbar);
+ }
+
+ @SuppressWarnings("ConstantConditions")
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ //if (pager == null) return false;
+ Fragment currentFragment = getCurrentFragment();
+ if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
+ if (handleGridSizeMenuItem(fragment, item)) {
+ return true;
+ }
+ if (handleSortOrderMenuItem(fragment, item)) {
+ return true;
+ }
+ }
+ int id = item.getItemId();
+ switch (id) {
+ case R.id.action_new_playlist:
+ CreatePlaylistDialog.create().show(getChildFragmentManager(), "CREATE_PLAYLIST");
+ return true;
+ case R.id.action_shuffle_all:
+ MusicPlayerRemote.openAndShuffleQueue(SongLoader.getAllSongs(getContext())
+ .blockingFirst(), true);
+ return true;
+ case R.id.action_search:
+ NavigationUtil.goToSearch(getMainActivity());
+ break;
+ case R.id.action_equalizer:
+ NavigationUtil.openEqualizer(getActivity());
+ return true;
+ case R.id.action_sleep_timer:
+ if (getFragmentManager() != null) {
+ new SleepTimerDialog().show(getFragmentManager(), TAG);
+ }
+ return true;
+ case R.id.action_settings:
+ startActivity(new Intent(getContext(), SettingsActivity.class));
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ private void setUpGridSizeMenu(
+ @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
+ @NonNull SubMenu gridSizeMenu) {
+ switch (fragment.getGridSize()) {
+ case 1:
+ gridSizeMenu.findItem(R.id.action_grid_size_1).setChecked(true);
+ break;
+ case 2:
+ gridSizeMenu.findItem(R.id.action_grid_size_2).setChecked(true);
+ break;
+ case 3:
+ gridSizeMenu.findItem(R.id.action_grid_size_3).setChecked(true);
+ break;
+ case 4:
+ gridSizeMenu.findItem(R.id.action_grid_size_4).setChecked(true);
+ break;
+ case 5:
+ gridSizeMenu.findItem(R.id.action_grid_size_5).setChecked(true);
+ break;
+ case 6:
+ gridSizeMenu.findItem(R.id.action_grid_size_6).setChecked(true);
+ break;
+ case 7:
+ gridSizeMenu.findItem(R.id.action_grid_size_7).setChecked(true);
+ break;
+ case 8:
+ gridSizeMenu.findItem(R.id.action_grid_size_8).setChecked(true);
+ break;
+ }
+ int maxGridSize = fragment.getMaxGridSize();
+ if (maxGridSize < 8) {
+ gridSizeMenu.findItem(R.id.action_grid_size_8).setVisible(false);
+ }
+ if (maxGridSize < 7) {
+ gridSizeMenu.findItem(R.id.action_grid_size_7).setVisible(false);
+ }
+ if (maxGridSize < 6) {
+ gridSizeMenu.findItem(R.id.action_grid_size_6).setVisible(false);
+ }
+ if (maxGridSize < 5) {
+ gridSizeMenu.findItem(R.id.action_grid_size_5).setVisible(false);
+ }
+ if (maxGridSize < 4) {
+ gridSizeMenu.findItem(R.id.action_grid_size_4).setVisible(false);
+ }
+ if (maxGridSize < 3) {
+ gridSizeMenu.findItem(R.id.action_grid_size_3).setVisible(false);
+ }
+ }
+
+
+ private boolean handleGridSizeMenuItem(
+ @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, @NonNull MenuItem item) {
+ int gridSize = 0;
+ switch (item.getItemId()) {
+ case R.id.action_grid_size_1:
+ gridSize = 1;
+ break;
+ case R.id.action_grid_size_2:
+ gridSize = 2;
+ break;
+ case R.id.action_grid_size_3:
+ gridSize = 3;
+ break;
+ case R.id.action_grid_size_4:
+ gridSize = 4;
+ break;
+ case R.id.action_grid_size_5:
+ gridSize = 5;
+ break;
+ case R.id.action_grid_size_6:
+ gridSize = 6;
+ break;
+ case R.id.action_grid_size_7:
+ gridSize = 7;
+ break;
+ case R.id.action_grid_size_8:
+ gridSize = 8;
+ break;
}
- public int getTotalAppBarScrollingRange() {
- return appbar.getTotalScrollRange();
- }
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_library, container, false);
- unBinder = ButterKnife.bind(this, view);
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- setStatusbarColorAuto(view);
-
- getMainActivity().setBottomBarVisibility(View.VISIBLE);
- setupToolbar();
- if (getArguments() == null) {
- selectedFragment(SongsFragment.newInstance());
- return;
- }
- switch (getArguments().getInt(CURRENT_TAB_ID)) {
- default:
- case R.id.action_song:
- selectedFragment(SongsFragment.newInstance());
- break;
- case R.id.action_album:
- selectedFragment(AlbumsFragment.newInstance());
- break;
- case R.id.action_artist:
- selectedFragment(ArtistsFragment.newInstance());
- break;
- case R.id.action_playlist:
- selectedFragment(PlaylistsFragment.newInstance());
- break;
- }
- }
-
- private void setupToolbar() {
- //noinspection ConstantConditions
- int primaryColor = ThemeStore.primaryColor(getContext());
- appbar.setBackgroundColor(primaryColor);
- toolbar.setBackgroundColor(primaryColor);
- toolbar.setTitle(R.string.library);
- appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) ->
- getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext())));
- Objects.requireNonNull(getActivity()).setTitle(R.string.app_name);
- getMainActivity().setSupportActionBar(toolbar);
- }
-
- public Fragment getCurrentFragment() {
- if (fragmentManager == null) {
- return SongsFragment.newInstance();
- }
- return fragmentManager.findFragmentByTag(LibraryFragment.TAG);
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- unBinder.unbind();
- }
-
- @Override
- public boolean handleBackPress() {
- if (cab != null && cab.isActive()) {
- cab.finish();
- return true;
- }
- return false;
- }
-
- public void selectedFragment(Fragment fragment) {
- fragmentManager = getChildFragmentManager();
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
-
- fragmentTransaction
- .replace(R.id.fragment_container, fragment, TAG)
- .commit();
- }
-
- @NonNull
- @Override
- public MaterialCab openCab(int menuRes, MaterialCab.Callback callback) {
- if (cab != null && cab.isActive()) {
- cab.finish();
- }
- //noinspection ConstantConditions
- cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
- .setMenu(menuRes)
- .setCloseDrawableRes(R.drawable.ic_close_white_24dp)
- .setBackgroundColor(
- RetroColorUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(getActivity())))
- .start(callback);
- return cab;
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- super.onCreateOptionsMenu(menu, inflater);
- inflater.inflate(R.menu.menu_main, menu);
-
- Fragment currentFragment = getCurrentFragment();
- if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment
- && currentFragment.isAdded()) {
- AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
-
- MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
- if (RetroUtil.isLandscape(getResources())) {
- gridSizeItem.setTitle(R.string.action_grid_size_land);
- }
- setUpGridSizeMenu(fragment, gridSizeItem.getSubMenu());
-
- setUpSortOrderMenu(fragment, menu.findItem(R.id.action_sort_order).getSubMenu());
-
- } else {
- menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
- menu.removeItem(R.id.action_grid_size);
- }
- Activity activity = getActivity();
- if (activity == null) {
- return;
- }
- ToolbarContentTintHelper.handleOnCreateOptionsMenu(getActivity(), toolbar, menu,
- ATHToolbarActivity.getToolbarBackgroundColor(toolbar));
- }
-
- private void setUpSortOrderMenu(
- @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
- @NonNull SubMenu sortOrderMenu) {
- String currentSortOrder = fragment.getSortOrder();
- sortOrderMenu.clear();
-
- if (fragment instanceof AlbumsFragment) {
- sortOrderMenu.add(0, R.id.action_album_sort_order_asc, 0, R.string.sort_order_a_z)
- .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_A_Z));
- sortOrderMenu.add(0, R.id.action_album_sort_order_desc, 1, R.string.sort_order_z_a)
- .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_Z_A));
- sortOrderMenu.add(0, R.id.action_album_sort_order_artist, 2, R.string.sort_order_artist)
- .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_ARTIST));
- sortOrderMenu.add(0, R.id.action_album_sort_order_year, 3, R.string.sort_order_year)
- .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_YEAR));
- } else if (fragment instanceof ArtistsFragment) {
- sortOrderMenu.add(0, R.id.action_artist_sort_order_asc, 0, R.string.sort_order_a_z)
- .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_A_Z));
- sortOrderMenu.add(0, R.id.action_artist_sort_order_desc, 1, R.string.sort_order_z_a)
- .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_Z_A));
- } else if (fragment instanceof SongsFragment) {
- sortOrderMenu.add(0, R.id.action_song_sort_order_asc, 0, R.string.sort_order_a_z)
- .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_A_Z));
- sortOrderMenu.add(0, R.id.action_song_sort_order_desc, 1, R.string.sort_order_z_a)
- .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_Z_A));
- sortOrderMenu.add(0, R.id.action_song_sort_order_artist, 2, R.string.sort_order_artist)
- .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ARTIST));
- sortOrderMenu.add(0, R.id.action_song_sort_order_album, 3, R.string.sort_order_album)
- .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ALBUM));
- sortOrderMenu.add(0, R.id.action_song_sort_order_year, 4, R.string.sort_order_year)
- .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_YEAR));
- sortOrderMenu.add(0, R.id.action_song_sort_order_date, 4, R.string.sort_order_date)
- .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_DATE));
- }
-
- sortOrderMenu.setGroupCheckable(0, true, true);
- }
-
- private boolean handleSortOrderMenuItem(
- @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, @NonNull MenuItem item) {
- String sortOrder = null;
- if (fragment instanceof AlbumsFragment) {
- switch (item.getItemId()) {
- case R.id.action_album_sort_order_asc:
- sortOrder = SortOrder.AlbumSortOrder.ALBUM_A_Z;
- break;
- case R.id.action_album_sort_order_desc:
- sortOrder = SortOrder.AlbumSortOrder.ALBUM_Z_A;
- break;
- case R.id.action_album_sort_order_artist:
- sortOrder = SortOrder.AlbumSortOrder.ALBUM_ARTIST;
- break;
- case R.id.action_album_sort_order_year:
- sortOrder = SortOrder.AlbumSortOrder.ALBUM_YEAR;
- break;
- }
- } else if (fragment instanceof ArtistsFragment) {
- switch (item.getItemId()) {
- case R.id.action_artist_sort_order_asc:
- sortOrder = SortOrder.ArtistSortOrder.ARTIST_A_Z;
- break;
- case R.id.action_artist_sort_order_desc:
- sortOrder = SortOrder.ArtistSortOrder.ARTIST_Z_A;
- break;
- }
- } else if (fragment instanceof SongsFragment) {
- switch (item.getItemId()) {
- case R.id.action_song_sort_order_asc:
- sortOrder = SortOrder.SongSortOrder.SONG_A_Z;
- break;
- case R.id.action_song_sort_order_desc:
- sortOrder = SortOrder.SongSortOrder.SONG_Z_A;
- break;
- case R.id.action_song_sort_order_artist:
- sortOrder = SortOrder.SongSortOrder.SONG_ARTIST;
- break;
- case R.id.action_song_sort_order_album:
- sortOrder = SortOrder.SongSortOrder.SONG_ALBUM;
- break;
- case R.id.action_song_sort_order_year:
- sortOrder = SortOrder.SongSortOrder.SONG_YEAR;
- break;
- case R.id.action_song_sort_order_date:
- sortOrder = SortOrder.SongSortOrder.SONG_DATE;
- break;
- }
- }
-
- if (sortOrder != null) {
- item.setChecked(true);
- fragment.setAndSaveSortOrder(sortOrder);
- return true;
- }
-
- return false;
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
- Activity activity = getActivity();
- if (activity == null) {
- return;
- }
- ToolbarContentTintHelper.handleOnPrepareOptionsMenu(activity, toolbar);
- }
-
- @Override
- public boolean onOptionsItemSelected(@NonNull MenuItem item) {
- //if (pager == null) return false;
- Fragment currentFragment = getCurrentFragment();
- if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
- AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
- if (handleGridSizeMenuItem(fragment, item)) {
- return true;
- }
- if (handleSortOrderMenuItem(fragment, item)) {
- return true;
- }
- }
- int id = item.getItemId();
- switch (id) {
- case R.id.action_new_playlist:
- CreatePlaylistDialog.create().show(getChildFragmentManager(), "CREATE_PLAYLIST");
- return true;
- case R.id.action_shuffle_all:
- //noinspection ConstantConditions
- SongLoader.getAllSongs(getContext()).subscribeOn(Schedulers.computation())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(songs -> MusicPlayerRemote.openAndShuffleQueue(songs, true));
- return true;
- case R.id.action_search:
- startActivity(new Intent(getActivity(), SearchActivity.class));
- return true;
- case R.id.action_equalizer:
- //noinspection ConstantConditions
- NavigationUtil.openEqualizer(getActivity());
- return true;
- case R.id.action_sleep_timer:
- if (getFragmentManager() != null) {
- new SleepTimerDialog().show(getFragmentManager(), TAG);
- }
- return true;
- case R.id.action_settings:
- startActivity(new Intent(getContext(), SettingsActivity.class));
- break;
- }
- return super.onOptionsItemSelected(item);
- }
-
- private void setUpGridSizeMenu(
- @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
- @NonNull SubMenu gridSizeMenu) {
- switch (fragment.getGridSize()) {
- case 1:
- gridSizeMenu.findItem(R.id.action_grid_size_1).setChecked(true);
- break;
- case 2:
- gridSizeMenu.findItem(R.id.action_grid_size_2).setChecked(true);
- break;
- case 3:
- gridSizeMenu.findItem(R.id.action_grid_size_3).setChecked(true);
- break;
- case 4:
- gridSizeMenu.findItem(R.id.action_grid_size_4).setChecked(true);
- break;
- case 5:
- gridSizeMenu.findItem(R.id.action_grid_size_5).setChecked(true);
- break;
- case 6:
- gridSizeMenu.findItem(R.id.action_grid_size_6).setChecked(true);
- break;
- case 7:
- gridSizeMenu.findItem(R.id.action_grid_size_7).setChecked(true);
- break;
- case 8:
- gridSizeMenu.findItem(R.id.action_grid_size_8).setChecked(true);
- break;
- }
- int maxGridSize = fragment.getMaxGridSize();
- if (maxGridSize < 8) {
- gridSizeMenu.findItem(R.id.action_grid_size_8).setVisible(false);
- }
- if (maxGridSize < 7) {
- gridSizeMenu.findItem(R.id.action_grid_size_7).setVisible(false);
- }
- if (maxGridSize < 6) {
- gridSizeMenu.findItem(R.id.action_grid_size_6).setVisible(false);
- }
- if (maxGridSize < 5) {
- gridSizeMenu.findItem(R.id.action_grid_size_5).setVisible(false);
- }
- if (maxGridSize < 4) {
- gridSizeMenu.findItem(R.id.action_grid_size_4).setVisible(false);
- }
- if (maxGridSize < 3) {
- gridSizeMenu.findItem(R.id.action_grid_size_3).setVisible(false);
- }
- }
-
-
- private boolean handleGridSizeMenuItem(
- @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, @NonNull MenuItem item) {
- int gridSize = 0;
- switch (item.getItemId()) {
- case R.id.action_grid_size_1:
- gridSize = 1;
- break;
- case R.id.action_grid_size_2:
- gridSize = 2;
- break;
- case R.id.action_grid_size_3:
- gridSize = 3;
- break;
- case R.id.action_grid_size_4:
- gridSize = 4;
- break;
- case R.id.action_grid_size_5:
- gridSize = 5;
- break;
- case R.id.action_grid_size_6:
- gridSize = 6;
- break;
- case R.id.action_grid_size_7:
- gridSize = 7;
- break;
- case R.id.action_grid_size_8:
- gridSize = 8;
- break;
- }
-
- if (gridSize > 0) {
- item.setChecked(true);
- fragment.setAndSaveGridSize(gridSize);
- return true;
- }
- return false;
+ if (gridSize > 0) {
+ item.setChecked(true);
+ fragment.setAndSaveGridSize(gridSize);
+ return true;
}
+ return false;
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java
index 2850ed94..2d220d98 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/PlaylistsFragment.java
@@ -54,14 +54,14 @@ public class PlaylistsFragment extends AbsLibraryPagerRecyclerViewFragment implements
- SongContract.SongView {
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment implements
+ SongContract.SongView {
- private static final String TAG = "Songs";
- private SongPresenter presenter;
+ private SongPresenter presenter;
- public SongsFragment() {
- // Required empty public constructor
+ public SongsFragment() {
+ // Required empty public constructor
+ }
+
+ public static SongsFragment newInstance() {
+ Bundle args = new Bundle();
+ SongsFragment fragment = new SongsFragment();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ presenter = new SongPresenter(this);
+ }
+
+ @NonNull
+ @Override
+ protected GridLayoutManager createLayoutManager() {
+ return new GridLayoutManager(getActivity(), getGridSize());
+ }
+
+ @Override
+ protected int getEmptyMessage() {
+ return R.string.no_songs;
+ }
+
+ @NonNull
+ @Override
+ protected SongAdapter createAdapter() {
+ int itemLayoutRes = getItemLayoutRes();
+ notifyLayoutResChanged(itemLayoutRes);
+ boolean usePalette = loadUsePalette();
+ ArrayList dataSet =
+ getAdapter() == null ? new ArrayList() : getAdapter().getDataSet();
+
+ if (getGridSize() <= getMaxGridSizeForList()) {
+ return new ShuffleButtonSongAdapter(getLibraryFragment().getMainActivity(), dataSet,
+ itemLayoutRes, usePalette, getLibraryFragment());
}
+ return new SongAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
+ usePalette, getLibraryFragment());
+ }
- public static SongsFragment newInstance() {
- Bundle args = new Bundle();
- SongsFragment fragment = new SongsFragment();
- fragment.setArguments(args);
- return fragment;
+ @Override
+ public void onMediaStoreChanged() {
+ presenter.loadSongs();
+ }
+
+ @Override
+ protected int loadGridSize() {
+ return PreferenceUtil.getInstance(getActivity()).getSongGridSize(getActivity());
+ }
+
+ @Override
+ protected void saveGridSize(int gridSize) {
+ PreferenceUtil.getInstance(getActivity()).setSongGridSize(gridSize);
+ }
+
+ @Override
+ protected int loadGridSizeLand() {
+ return PreferenceUtil.getInstance(getActivity()).getSongGridSizeLand(getActivity());
+ }
+
+ @Override
+ protected void saveGridSizeLand(int gridSize) {
+ PreferenceUtil.getInstance(getActivity()).setSongGridSizeLand(gridSize);
+ }
+
+ @Override
+ public void saveUsePalette(boolean usePalette) {
+ PreferenceUtil.getInstance(getActivity()).setSongColoredFooters(usePalette);
+ }
+
+ @Override
+ public boolean loadUsePalette() {
+ return PreferenceUtil.getInstance(getActivity()).songColoredFooters();
+ }
+
+ @Override
+ public void setUsePalette(boolean usePalette) {
+ getAdapter().usePalette(usePalette);
+ }
+
+ @Override
+ protected void setGridSize(int gridSize) {
+ getLayoutManager().setSpanCount(gridSize);
+ getAdapter().notifyDataSetChanged();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ getLibraryFragment().setTitle(
+ PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.songs);
+ if (getAdapter().getDataSet().isEmpty()) {
+ presenter.subscribe();
}
+ }
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- presenter = new SongPresenter(this);
+ @Override
+ public void setMenuVisibility(boolean menuVisible) {
+ super.setMenuVisibility(menuVisible);
+ if (menuVisible) {
+ getLibraryFragment().setTitle(
+ PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
+ : R.string.songs);
}
+ }
- @NonNull
- @Override
- protected GridLayoutManager createLayoutManager() {
- return new GridLayoutManager(getActivity(), getGridSize());
- }
+ @Override
+ public void onDestroy() {
+ presenter.unsubscribe();
+ super.onDestroy();
+ }
- @Override
- protected int getEmptyMessage() {
- return R.string.no_songs;
- }
+ @Override
+ public void loading() {
- @NonNull
- @Override
- protected SongAdapter createAdapter() {
- int itemLayoutRes = getItemLayoutRes();
- notifyLayoutResChanged(itemLayoutRes);
- boolean usePalette = loadUsePalette();
- ArrayList dataSet =
- getAdapter() == null ? new ArrayList() : getAdapter().getDataSet();
+ }
- if (getGridSize() <= getMaxGridSizeForList()) {
- return new ShuffleButtonSongAdapter(getLibraryFragment().getMainActivity(), dataSet,
- itemLayoutRes, usePalette, getLibraryFragment());
- }
- return new SongAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
- usePalette, getLibraryFragment());
- }
+ @Override
+ public void showData(ArrayList songs) {
+ getAdapter().swapDataSet(songs);
+ }
- @Override
- public void onMediaStoreChanged() {
- presenter.loadSongs();
- }
+ @Override
+ public void showEmptyView() {
+ getAdapter().swapDataSet(new ArrayList());
+ }
- @Override
- protected int loadGridSize() {
- return PreferenceUtil.getInstance(getActivity()).getSongGridSize(getActivity());
- }
+ @Override
+ public void completed() {
- @Override
- protected void saveGridSize(int gridSize) {
- PreferenceUtil.getInstance(getActivity()).setSongGridSize(gridSize);
- }
+ }
- @Override
- protected int loadGridSizeLand() {
- return PreferenceUtil.getInstance(getActivity()).getSongGridSizeLand(getActivity());
- }
+ @Override
+ protected String loadSortOrder() {
+ return PreferenceUtil.getInstance(getActivity()).getSongSortOrder();
+ }
- @Override
- protected void saveGridSizeLand(int gridSize) {
- PreferenceUtil.getInstance(getActivity()).setSongGridSizeLand(gridSize);
- }
+ @Override
+ protected void saveSortOrder(String sortOrder) {
+ PreferenceUtil.getInstance(getActivity()).setSongSortOrder(sortOrder);
+ }
- @Override
- public void saveUsePalette(boolean usePalette) {
- PreferenceUtil.getInstance(getActivity()).setSongColoredFooters(usePalette);
- }
-
- @Override
- public boolean loadUsePalette() {
- return PreferenceUtil.getInstance(getActivity()).songColoredFooters();
- }
-
- @Override
- public void setUsePalette(boolean usePalette) {
- getAdapter().usePalette(usePalette);
- }
-
- @Override
- protected void setGridSize(int gridSize) {
- getLayoutManager().setSpanCount(gridSize);
- getAdapter().notifyDataSetChanged();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- getLibraryFragment().getToolbar().setTitle(
- PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.songs);
- if (getAdapter().getDataSet().isEmpty()) {
- presenter.subscribe();
- }
- }
-
- @Override
- public void setMenuVisibility(boolean menuVisible) {
- super.setMenuVisibility(menuVisible);
- if (menuVisible) {
- getLibraryFragment().getToolbar().setTitle(
- PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
- : R.string.songs);
- }
- }
-
- @Override
- public void onDestroy() {
- presenter.unsubscribe();
- super.onDestroy();
- }
-
- @Override
- public void loading() {
-
- }
-
- @Override
- public void showData(ArrayList songs) {
- getAdapter().swapDataSet(songs);
- }
-
- @Override
- public void showEmptyView() {
- getAdapter().swapDataSet(new ArrayList());
- }
-
- @Override
- public void completed() {
-
- }
-
- @Override
- protected String loadSortOrder() {
- return PreferenceUtil.getInstance(getActivity()).getSongSortOrder();
- }
-
- @Override
- protected void saveSortOrder(String sortOrder) {
- PreferenceUtil.getInstance(getActivity()).setSongSortOrder(sortOrder);
- }
-
- @Override
- protected void setSortOrder(String sortOrder) {
- presenter.loadSongs();
- }
+ @Override
+ protected void setSortOrder(String sortOrder) {
+ presenter.loadSongs();
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java
index 3109a5f6..19a04fb4 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/folders/FoldersFragment.java
@@ -24,6 +24,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.webkit.MimeTypeMap;
import android.widget.PopupMenu;
+import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -31,6 +32,8 @@ import butterknife.Unbinder;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
import code.name.monkey.appthemehelper.util.ATHUtil;
+import code.name.monkey.appthemehelper.util.ColorUtil;
+import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
@@ -82,6 +85,8 @@ public class FoldersFragment extends AbsMainActivityFragment implements
CoordinatorLayout coordinatorLayout;
@BindView(R.id.container)
View container;
+ @BindView(R.id.title)
+ TextView title;
@BindView(android.R.id.empty)
View empty;
@BindView(R.id.toolbar)
@@ -90,10 +95,10 @@ public class FoldersFragment extends AbsMainActivityFragment implements
BreadCrumbLayout breadCrumbs;
@BindView(R.id.appbar)
AppBarLayout appbar;
- @BindView(R.id.status_bar)
- View statusBar;
+
@BindView(R.id.recycler_view)
FastScrollRecyclerView recyclerView;
+
Comparator fileComparator = (lhs, rhs) -> {
if (lhs.isDirectory() && !rhs.isDirectory()) {
return -1;
@@ -207,7 +212,6 @@ public class FoldersFragment extends AbsMainActivityFragment implements
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
setStatusbarColorAuto(view);
getMainActivity().getSlidingUpPanelLayout().setShadowHeight(0);
-
getMainActivity().setBottomBarVisibility(View.GONE);
setUpAppbarColor();
@@ -215,24 +219,29 @@ public class FoldersFragment extends AbsMainActivityFragment implements
setUpBreadCrumbs();
setUpRecyclerView();
setUpAdapter();
- ViewUtil.setStatusBarHeight(getContext(), statusBar);
+
}
private void setUpAppbarColor() {
//noinspection ConstantConditions
int primaryColor = ThemeStore.primaryColor(getActivity());
- appbar.setBackgroundColor(primaryColor);
- toolbar.setBackgroundColor(primaryColor);
+ TintHelper.setTintAuto(container, primaryColor, true);
+ appbar.setBackgroundColor(ColorUtil.darkenColor(primaryColor));
+ toolbar.setBackgroundColor(ColorUtil.darkenColor(primaryColor));
//breadCrumbs.setBackgroundColor(primaryColor);
breadCrumbs.setActivatedContentColor(
- ToolbarContentTintHelper.toolbarTitleColor(getActivity(), primaryColor));
+ ToolbarContentTintHelper
+ .toolbarTitleColor(getActivity(), ColorUtil.darkenColor(primaryColor)));
breadCrumbs.setDeactivatedContentColor(
- ToolbarContentTintHelper.toolbarSubtitleColor(getActivity(), primaryColor));
+ ToolbarContentTintHelper
+ .toolbarSubtitleColor(getActivity(), ColorUtil.darkenColor(primaryColor)));
appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> getMainActivity()
.setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext())));
}
private void setUpToolbar() {
+ //noinspection ConstantConditions
+ title.setTextColor(ThemeStore.textColorPrimary(getContext()));
toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp);
//noinspection ConstantConditions
getActivity().setTitle(R.string.folders);
diff --git a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java
index 803d45ed..8abe1dd6 100644
--- a/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java
+++ b/app/src/main/java/code/name/monkey/retromusic/ui/fragments/mainactivity/home/HomeFragment.java
@@ -1,8 +1,5 @@
package code.name.monkey.retromusic.ui.fragments.mainactivity.home;
-import static code.name.monkey.retromusic.Constants.USER_BANNER;
-import static code.name.monkey.retromusic.Constants.USER_PROFILE;
-
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
@@ -23,6 +20,15 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.engine.DiskCacheStrategy;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Random;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@@ -55,357 +61,354 @@ import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroUtil;
import code.name.monkey.retromusic.views.CircularImageView;
import code.name.monkey.retromusic.views.MetalRecyclerViewPager;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Random;
+
+import static code.name.monkey.retromusic.Constants.USER_BANNER;
+import static code.name.monkey.retromusic.Constants.USER_PROFILE;
public class HomeFragment extends AbsMainActivityFragment implements MainActivityFragmentCallbacks,
- HomeContract.HomeView {
+ HomeContract.HomeView {
- private static final String TAG = "HomeFragment";
- Unbinder unbinder;
- @BindView(R.id.home_toolbar)
- Toolbar toolbar;
- @BindView(R.id.appbar)
- AppBarLayout appbar;
- @BindView(R.id.image)
- ImageView imageView;
- @BindView(R.id.user_image)
- CircularImageView userImage;
- @BindView(R.id.collapsing_toolbar)
- CollapsingToolbarLayout toolbarLayout;
- @BindView(R.id.recycler_view)
- RecyclerView recentArtistRV;
- @BindView(R.id.recent_album)
- RecyclerView recentAlbumRV;
- @BindView(R.id.top_artist)
- RecyclerView topArtistRV;
- @BindView(R.id.top_album)
- MetalRecyclerViewPager topAlbumRV;
- @BindView(R.id.recent_artist_container)
- View recentArtistContainer;
- @BindView(R.id.recent_albums_container)
- View recentAlbumsContainer;
- @BindView(R.id.top_artist_container)
- View topArtistContainer;
- @BindView(R.id.top_albums_container)
- View topAlbumContainer;
- @BindView(R.id.genres)
- RecyclerView genresRecyclerView;
- @BindView(R.id.genre_container)
- LinearLayout genreContainer;
- @BindView(R.id.container)
- View container;
- @BindView(R.id.title)
- TextView title;
- @BindView(R.id.search)
- ImageView search;
+ private static final String TAG = "HomeFragment";
+ Unbinder unbinder;
+ @BindView(R.id.home_toolbar)
+ Toolbar toolbar;
+ @BindView(R.id.appbar)
+ AppBarLayout appbar;
+ @BindView(R.id.image)
+ ImageView imageView;
+ @BindView(R.id.user_image)
+ CircularImageView userImage;
+ @BindView(R.id.collapsing_toolbar)
+ CollapsingToolbarLayout toolbarLayout;
+ @BindView(R.id.recycler_view)
+ RecyclerView recentArtistRV;
+ @BindView(R.id.recent_album)
+ RecyclerView recentAlbumRV;
+ @BindView(R.id.top_artist)
+ RecyclerView topArtistRV;
+ @BindView(R.id.top_album)
+ MetalRecyclerViewPager topAlbumRV;
+ @BindView(R.id.recent_artist_container)
+ View recentArtistContainer;
+ @BindView(R.id.recent_albums_container)
+ View recentAlbumsContainer;
+ @BindView(R.id.top_artist_container)
+ View topArtistContainer;
+ @BindView(R.id.top_albums_container)
+ View topAlbumContainer;
+ @BindView(R.id.genres)
+ RecyclerView genresRecyclerView;
+ @BindView(R.id.genre_container)
+ LinearLayout genreContainer;
+ @BindView(R.id.container)
+ View container;
+ @BindView(R.id.title)
+ TextView title;
+ @BindView(R.id.search)
+ ImageView search;
- private HomePresenter homePresenter;
- private CompositeDisposable disposable;
+ private HomePresenter homePresenter;
+ private CompositeDisposable disposable;
- public static HomeFragment newInstance() {
- Bundle args = new Bundle();
- HomeFragment fragment = new HomeFragment();
- fragment.setArguments(args);
- return fragment;
- }
-
- private void getTimeOfTheDay() {
- Calendar c = Calendar.getInstance();
- int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
-
- String[] images = new String[]{};
- if (timeOfDay >= 0 && timeOfDay < 6) {
- images = getResources().getStringArray(R.array.night);
- } else if (timeOfDay >= 6 && timeOfDay < 12) {
- images = getResources().getStringArray(R.array.morning);
- } else if (timeOfDay >= 12 && timeOfDay < 16) {
- images = getResources().getStringArray(R.array.after_noon);
- } else if (timeOfDay >= 16 && timeOfDay < 20) {
- images = getResources().getStringArray(R.array.evening);
- } else if (timeOfDay >= 20 && timeOfDay < 24) {
- images = getResources().getStringArray(R.array.night);
- }
- String day = images[new Random().nextInt(images.length)];
- loadTimeImage(day);
- }
-
- private void loadTimeImage(String day) {
- //noinspection ConstantConditions
- if (PreferenceUtil.getInstance(getActivity()).getBannerImage().isEmpty()) {
- if (imageView != null) {
- Glide.with(getActivity()).load(day)
- .asBitmap()
- .placeholder(R.drawable.material_design_default)
- .diskCacheStrategy(DiskCacheStrategy.SOURCE)
- .into(imageView);
- }
- } else {
- loadBannerFromStorage();
- }
- }
-
- private void loadBannerFromStorage() {
- //noinspection ConstantConditions
- disposable.add(new Compressor(getContext())
- .setQuality(100)
- .setCompressFormat(Bitmap.CompressFormat.WEBP)
- .compressToBitmapAsFlowable(
- new File(PreferenceUtil.getInstance(getContext()).getBannerImage(), USER_BANNER))
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(imageView::setImageBitmap));
- }
-
- private void loadImageFromStorage(ImageView imageView) {
- //noinspection ConstantConditions
- disposable.add(new Compressor(getContext())
- .setMaxHeight(300)
- .setMaxWidth(300)
- .setQuality(75)
- .setCompressFormat(Bitmap.CompressFormat.WEBP)
- .compressToBitmapAsFlowable(
- new File(PreferenceUtil.getInstance(getContext()).getProfileImage(), USER_PROFILE))
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(imageView::setImageBitmap,
- throwable -> imageView.setImageDrawable(ContextCompat
- .getDrawable(getContext(), R.drawable.ic_person_flat))));
- }
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- disposable = new CompositeDisposable();
- //noinspection ConstantConditions
- homePresenter = new HomePresenter(this);
- }
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_home, container, false);
- unbinder = ButterKnife.bind(this, view);
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- getMainActivity().getSlidingUpPanelLayout().setShadowHeight(8);
- getMainActivity().setBottomBarVisibility(View.VISIBLE);
-
- setupToolbar();
- loadImageFromStorage(userImage);
-
- homePresenter.subscribe();
- checkPadding();
- getTimeOfTheDay();
- }
-
- @SuppressWarnings("ConstantConditions")
- private void setupToolbar() {
- if (!PreferenceUtil.getInstance(getContext()).getFullScreenMode()) {
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar
- .getLayoutParams();
- params.topMargin = RetroUtil.getStatusBarHeight(getContext());
- toolbar.setLayoutParams(params);
+ public static HomeFragment newInstance() {
+ Bundle args = new Bundle();
+ HomeFragment fragment = new HomeFragment();
+ fragment.setArguments(args);
+ return fragment;
}
- appbar.addOnOffsetChangedListener(new AppBarStateChangeListener() {
- @Override
- public void onStateChanged(AppBarLayout appBarLayout, State state) {
- int color;
- switch (state) {
- case COLLAPSED:
- getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext()));
- color = ThemeStore.textColorPrimary(getContext());
- break;
- default:
- case EXPANDED:
- case IDLE:
- getMainActivity().setLightStatusbar(false);
- color = ContextCompat.getColor(getContext(), R.color.md_white_1000);
- break;
+ private void getTimeOfTheDay() {
+ Calendar c = Calendar.getInstance();
+ int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
+
+ String[] images = new String[]{};
+ if (timeOfDay >= 0 && timeOfDay < 6) {
+ images = getResources().getStringArray(R.array.night);
+ } else if (timeOfDay >= 6 && timeOfDay < 12) {
+ images = getResources().getStringArray(R.array.morning);
+ } else if (timeOfDay >= 12 && timeOfDay < 16) {
+ images = getResources().getStringArray(R.array.after_noon);
+ } else if (timeOfDay >= 16 && timeOfDay < 20) {
+ images = getResources().getStringArray(R.array.evening);
+ } else if (timeOfDay >= 20 && timeOfDay < 24) {
+ images = getResources().getStringArray(R.array.night);
}
- TintHelper.setTintAuto(search, color, false);
- title.setTextColor(color);
- }
- });
-
- int primaryColor = ThemeStore.primaryColor(getContext());
-
- TintHelper.setTintAuto(container, primaryColor, true);
- toolbarLayout.setStatusBarScrimColor(primaryColor);
- toolbarLayout.setContentScrimColor(primaryColor);
-
- toolbar.setTitle(R.string.home);
- getMainActivity().setSupportActionBar(toolbar);
-
- }
-
- @Override
- public boolean handleBackPress() {
- return false;
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- unbinder.unbind();
- disposable.clear();
- homePresenter.unsubscribe();
- }
-
- @Override
- public void loading() {
-
- }
-
- @Override
- public void showEmptyView() {
-
- }
-
- @Override
- public void completed() {
-
- }
-
- @Override
- public void showData(ArrayList