code refactor
parent
8d9fb4c0df
commit
4aa0ccc283
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="RetroMusicPlayer" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="java-gradle" name="Java-Gradle">
|
|
||||||
<configuration>
|
|
||||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
|
||||||
<option name="BUILDABLE" value="false" />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="WizardSettings">
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="imageWizard">
|
||||||
|
<value>
|
||||||
|
<PersistentState />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -1,9 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Gradle: __local_aars__:/Users/hemanths/Desktop/KeepSafe/RetroMusicPlayer/app/libs/jsoup-1.11.2.jar:unspecified@jar">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$PROJECT_DIR$/app/libs/jsoup-1.11.2.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,11 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Gradle: com.mpatric:mp3agic:0.8.3@jar">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.mpatric/mp3agic/0.8.3/ddbccc4219ef1bd38f7f6ed6fa0a5374159f9b9f/mp3agic-0.8.3.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.mpatric/mp3agic/0.8.3/bfd1267d2d5bdf5fa8ce9a4197cdfc0ed9bc5205/mp3agic-0.8.3-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,14 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Gradle: jp.wasabeef:glide-transformations-2.0.2">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/glide-transformations-2.0.2.aar/a8e2dae52526ebad94e3e6c842f0daec/res" />
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/glide-transformations-2.0.2.aar/a8e2dae52526ebad94e3e6c842f0daec/jars/classes.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/jp.wasabeef/glide-transformations/2.0.2/d77158225e8aff098f2269c5b42cebb8cd1ebc6f/glide-transformations-2.0.2-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/jp.wasabeef/glide-transformations/2.0.2/87061eb6c96686339ab1a2d30dbd77c247486014/glide-transformations-2.0.2-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -5,25 +5,32 @@
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
<option name="myNullables">
|
<option name="myNullables">
|
||||||
<value>
|
<value>
|
||||||
<list size="5">
|
<list size="6">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="myNotNulls">
|
<option name="myNotNulls">
|
||||||
<value>
|
<value>
|
||||||
<list size="4">
|
<list size="5">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8 (4)" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -2,7 +2,7 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/RetroMusicPlayer.iml" filepath="$PROJECT_DIR$/.idea/RetroMusicPlayer.iml" />
|
<module fileurl="file://$PROJECT_DIR$/RetroMusicPlayer.iml" filepath="$PROJECT_DIR$/RetroMusicPlayer.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/appthemehelper/appthemehelper.iml" filepath="$PROJECT_DIR$/appthemehelper/appthemehelper.iml" />
|
<module fileurl="file://$PROJECT_DIR$/appthemehelper/appthemehelper.iml" filepath="$PROJECT_DIR$/appthemehelper/appthemehelper.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
|
|
|
@ -2,6 +2,5 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -13,7 +13,7 @@
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="jdk" jdkName="1.8 (4)" jdkType="JavaSDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -130,6 +130,8 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-libraries" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||||
|
@ -141,11 +143,16 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_merged_manifests" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_merged_manifests" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/linked_res_for_bundle" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/module_bundle" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/processed_res" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/processed_res" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
|
||||||
|
@ -159,7 +166,7 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 28 Platform (1)" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.github.bumptech.glide:okhttp3-integration:1.5.0@jar" level="project" />
|
<orderEntry type="library" name="Gradle: com.github.bumptech.glide:okhttp3-integration:1.5.0@jar" level="project" />
|
||||||
|
|
|
@ -11,8 +11,8 @@ android {
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|
||||||
applicationId "code.name.monkey.retromusic"
|
applicationId "code.name.monkey.retromusic"
|
||||||
versionCode 206
|
versionCode 207
|
||||||
versionName 'R - 1.7.10'
|
versionName '1.7.10'
|
||||||
|
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
||||||
|
|
|
@ -9,15 +9,15 @@ import code.name.monkey.retromusic.util.schedulers.SchedulerProvider;
|
||||||
|
|
||||||
public class Injection {
|
public class Injection {
|
||||||
|
|
||||||
public static Repository provideRepository() {
|
public static Repository provideRepository() {
|
||||||
return RepositoryImpl.getInstance();
|
return RepositoryImpl.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BaseSchedulerProvider provideSchedulerProvider() {
|
public static BaseSchedulerProvider provideSchedulerProvider() {
|
||||||
return SchedulerProvider.getInstance();
|
return SchedulerProvider.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KuGouApiService provideKuGouApiService() {
|
public static KuGouApiService provideKuGouApiService() {
|
||||||
return new KogouClient().getApiService();
|
return new KogouClient().getApiService();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package code.name.monkey.retromusic.swipebtn;
|
|
||||||
|
|
||||||
public interface OnActiveListener {
|
|
||||||
void onActive();
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package code.name.monkey.retromusic.swipebtn;
|
|
||||||
|
|
||||||
public interface OnStateChangeListener {
|
|
||||||
void onStateChange(boolean active);
|
|
||||||
}
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -77,9 +77,6 @@ public abstract class AbsThemeActivity extends ATHToolbarActivity implements Run
|
||||||
: ContextCompat.getDrawable(this, R.drawable.square_window);
|
: ContextCompat.getDrawable(this, R.drawable.square_window);
|
||||||
background = TintHelper.createTintedDrawable(background, ThemeStore.primaryColor(this));
|
background = TintHelper.createTintedDrawable(background, ThemeStore.primaryColor(this));
|
||||||
getWindow().setBackgroundDrawable(background);
|
getWindow().setBackgroundDrawable(background);
|
||||||
//View decor = getWindow().getDecorView();
|
|
||||||
//GradientDrawable gradientDrawable = (GradientDrawable) decor.getBackground();
|
|
||||||
//gradientDrawable.setColor(ThemeStore.primaryColor(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDrawUnderStatusBar(boolean drawUnderStatusbar) {
|
protected void setDrawUnderStatusBar(boolean drawUnderStatusbar) {
|
||||||
|
|
|
@ -120,7 +120,7 @@ public abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A extend
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
applyRecyclerViewPaddingForLayoutRes(getRecyclerView(), currentLayoutRes);
|
applyRecyclerViewPaddingForLayoutRes(getRecyclerView(), currentLayoutRes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.Unbinder;
|
import butterknife.Unbinder;
|
||||||
|
@ -22,141 +19,143 @@ import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||||
import code.name.monkey.retromusic.util.ViewUtil;
|
import code.name.monkey.retromusic.util.ViewUtil;
|
||||||
|
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
|
||||||
|
|
||||||
|
|
||||||
public abstract class AbsLibraryPagerRecyclerViewFragment<A extends RecyclerView.Adapter, LM extends RecyclerView.LayoutManager> extends
|
public abstract class AbsLibraryPagerRecyclerViewFragment<A extends RecyclerView.Adapter, LM extends RecyclerView.LayoutManager> extends
|
||||||
AbsLibraryPagerFragment implements OnOffsetChangedListener {
|
AbsLibraryPagerFragment implements OnOffsetChangedListener {
|
||||||
|
|
||||||
public static final String TAG = AbsLibraryPagerRecyclerViewFragment.class.getSimpleName();
|
public static final String TAG = AbsLibraryPagerRecyclerViewFragment.class.getSimpleName();
|
||||||
@BindView(R.id.container)
|
@BindView(R.id.container)
|
||||||
ViewGroup container;
|
ViewGroup container;
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
@BindView(android.R.id.empty)
|
@BindView(android.R.id.empty)
|
||||||
TextView empty;
|
TextView empty;
|
||||||
|
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
private A adapter;
|
private A adapter;
|
||||||
private LM layoutManager;
|
private LM layoutManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(getLayoutRes(), container, false);
|
View view = inflater.inflate(getLayoutRes(), container, false);
|
||||||
unbinder = ButterKnife.bind(this, view);
|
unbinder = ButterKnife.bind(this, view);
|
||||||
return 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
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
public void onQueueChanged() {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onQueueChanged();
|
||||||
getLibraryFragment().addOnAppBarOffsetChangedListener(this);
|
checkForPadding();
|
||||||
initLayoutManager();
|
}
|
||||||
initAdapter();
|
|
||||||
setUpRecyclerView();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpRecyclerView() {
|
@Override
|
||||||
if (recyclerView instanceof FastScrollRecyclerView) {
|
public void onServiceConnected() {
|
||||||
//noinspection ConstantConditions
|
super.onServiceConnected();
|
||||||
ViewUtil.setUpFastScrollRecyclerViewColor(getActivity(),
|
checkForPadding();
|
||||||
((FastScrollRecyclerView) recyclerView), ThemeStore.accentColor(getActivity()));
|
}
|
||||||
}
|
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
|
||||||
recyclerView.setAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private void checkForPadding() {
|
||||||
public void onQueueChanged() {
|
int height = (MusicPlayerRemote.getPlayingQueue().isEmpty() ? getResources()
|
||||||
super.onQueueChanged();
|
.getDimensionPixelSize(R.dimen.mini_player_height) : 0);
|
||||||
checkForPadding();
|
recyclerView.setPadding(0, 0, 0, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void invalidateLayoutManager() {
|
||||||
public void onServiceConnected() {
|
initLayoutManager();
|
||||||
super.onServiceConnected();
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
checkForPadding();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void checkForPadding() {
|
protected void invalidateAdapter() {
|
||||||
int height = (MusicPlayerRemote.getPlayingQueue().isEmpty() ? getResources().getDimensionPixelSize(R.dimen.mini_player_height) : 0);
|
initAdapter();
|
||||||
recyclerView.setPadding(0, 0, 0, height);
|
checkIsEmpty();
|
||||||
}
|
recyclerView.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
protected void invalidateLayoutManager() {
|
private void initAdapter() {
|
||||||
initLayoutManager();
|
adapter = createAdapter();
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||||
}
|
@Override
|
||||||
|
public void onChanged() {
|
||||||
protected void invalidateAdapter() {
|
super.onChanged();
|
||||||
initAdapter();
|
|
||||||
checkIsEmpty();
|
checkIsEmpty();
|
||||||
recyclerView.setAdapter(adapter);
|
checkForPadding();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void initAdapter() {
|
private void initLayoutManager() {
|
||||||
adapter = createAdapter();
|
layoutManager = createLayoutManager();
|
||||||
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
}
|
||||||
@Override
|
|
||||||
public void onChanged() {
|
|
||||||
super.onChanged();
|
|
||||||
checkIsEmpty();
|
|
||||||
checkForPadding();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initLayoutManager() {
|
protected A getAdapter() {
|
||||||
layoutManager = createLayoutManager();
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected A getAdapter() {
|
protected LM getLayoutManager() {
|
||||||
return adapter;
|
return layoutManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LM getLayoutManager() {
|
protected RecyclerView getRecyclerView() {
|
||||||
return layoutManager;
|
return recyclerView;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RecyclerView getRecyclerView() {
|
public ViewGroup getContainer() {
|
||||||
return recyclerView;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewGroup getContainer() {
|
@Override
|
||||||
return container;
|
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
|
||||||
}
|
container.setPadding(container.getPaddingLeft(), container.getPaddingTop(),
|
||||||
|
container.getPaddingRight(), getLibraryFragment().getTotalAppBarScrollingRange() + i);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private void checkIsEmpty() {
|
||||||
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
|
empty.setText(getEmptyMessage());
|
||||||
container.setPadding(container.getPaddingLeft(), container.getPaddingTop(),
|
empty.setVisibility(adapter == null || adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||||
container.getPaddingRight(), getLibraryFragment().getTotalAppBarScrollingRange() + i);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void checkIsEmpty() {
|
@StringRes
|
||||||
empty.setText(getEmptyMessage());
|
protected int getEmptyMessage() {
|
||||||
empty.setVisibility(adapter == null || adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
return R.string.empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@LayoutRes
|
||||||
protected int getEmptyMessage() {
|
protected int getLayoutRes() {
|
||||||
return R.string.empty;
|
return R.layout.fragment_main_activity_recycler_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LayoutRes
|
protected abstract LM createLayoutManager();
|
||||||
protected int getLayoutRes() {
|
|
||||||
return R.layout.fragment_main_activity_recycler_view;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract LM createLayoutManager();
|
@NonNull
|
||||||
|
protected abstract A createAdapter();
|
||||||
|
|
||||||
@NonNull
|
@Override
|
||||||
protected abstract A createAdapter();
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
@Override
|
getLibraryFragment().removeOnAppBarOffsetChangedListener(this);
|
||||||
public void onDestroyView() {
|
unbinder.unbind();
|
||||||
super.onDestroyView();
|
}
|
||||||
getLibraryFragment().removeOnAppBarOffsetChangedListener(this);
|
|
||||||
unbinder.unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,6 @@ import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.model.Album;
|
import code.name.monkey.retromusic.model.Album;
|
||||||
import code.name.monkey.retromusic.mvp.contract.AlbumContract;
|
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.adapter.album.AlbumAdapter;
|
||||||
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class AlbumsFragment extends
|
public class AlbumsFragment extends
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager> implements
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager> implements
|
||||||
AlbumContract.AlbumView {
|
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() {
|
public static AlbumsFragment newInstance() {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
AlbumsFragment fragment = new AlbumsFragment();
|
AlbumsFragment fragment = new AlbumsFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
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<Album> dataSet =
|
||||||
|
getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
|
||||||
|
return new AlbumAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
|
||||||
|
loadUsePalette(), getLibraryFragment());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GridLayoutManager createLayoutManager() {
|
protected int getEmptyMessage() {
|
||||||
return new GridLayoutManager(getActivity(), getGridSize());
|
return R.string.no_albums;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@Override
|
||||||
@Override
|
public boolean loadUsePalette() {
|
||||||
protected AlbumAdapter createAdapter() {
|
return PreferenceUtil.getInstance(getActivity()).albumColoredFooters();
|
||||||
int itemLayoutRes = getItemLayoutRes();
|
}
|
||||||
notifyLayoutResChanged(itemLayoutRes);
|
|
||||||
if (itemLayoutRes != R.layout.item_list) {
|
|
||||||
itemLayoutRes = PreferenceUtil.getInstance(getContext()).getAlbumGridStyle(getContext());
|
|
||||||
}
|
|
||||||
ArrayList<Album> dataSet =
|
|
||||||
getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
|
|
||||||
return new AlbumAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
|
|
||||||
loadUsePalette(), getLibraryFragment());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getEmptyMessage() {
|
protected void setUsePalette(boolean usePalette) {
|
||||||
return R.string.no_albums;
|
getAdapter().usePalette(usePalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadUsePalette() {
|
protected void setGridSize(int gridSize) {
|
||||||
return PreferenceUtil.getInstance(getActivity()).albumColoredFooters();
|
getLayoutManager().setSpanCount(gridSize);
|
||||||
}
|
getAdapter().notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUsePalette(boolean usePalette) {
|
protected void setSortOrder(String sortOrder) {
|
||||||
getAdapter().usePalette(usePalette);
|
presenter.loadAlbums();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setGridSize(int gridSize) {
|
protected String loadSortOrder() {
|
||||||
getLayoutManager().setSpanCount(gridSize);
|
return PreferenceUtil.getInstance(getActivity()).getAlbumSortOrder();
|
||||||
getAdapter().notifyDataSetChanged();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setSortOrder(String sortOrder) {
|
protected void saveSortOrder(String sortOrder) {
|
||||||
presenter.loadAlbums();
|
PreferenceUtil.getInstance(getActivity()).setAlbumSortOrder(sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String loadSortOrder() {
|
protected int loadGridSize() {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getAlbumSortOrder();
|
return PreferenceUtil.getInstance(getActivity()).getAlbumGridSize(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveSortOrder(String sortOrder) {
|
protected void saveGridSize(int gridSize) {
|
||||||
PreferenceUtil.getInstance(getActivity()).setAlbumSortOrder(sortOrder);
|
PreferenceUtil.getInstance(getActivity()).setAlbumGridSize(gridSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int loadGridSize() {
|
protected int loadGridSizeLand() {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getAlbumGridSize(getActivity());
|
return PreferenceUtil.getInstance(getActivity()).getAlbumGridSizeLand(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveGridSize(int gridSize) {
|
protected void saveGridSizeLand(int gridSize) {
|
||||||
PreferenceUtil.getInstance(getActivity()).setAlbumGridSize(gridSize);
|
PreferenceUtil.getInstance(getActivity()).setAlbumGridSizeLand(gridSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int loadGridSizeLand() {
|
protected void saveUsePalette(boolean usePalette) {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getAlbumGridSizeLand(getActivity());
|
PreferenceUtil.getInstance(getActivity()).setAlbumColoredFooters(usePalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveGridSizeLand(int gridSize) {
|
public void onMediaStoreChanged() {
|
||||||
PreferenceUtil.getInstance(getActivity()).setAlbumGridSizeLand(gridSize);
|
presenter.loadAlbums();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveUsePalette(boolean usePalette) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
PreferenceUtil.getInstance(getActivity()).setAlbumColoredFooters(usePalette);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
presenter = new AlbumPresenter(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMediaStoreChanged() {
|
public void setMenuVisibility(boolean menuVisible) {
|
||||||
presenter.loadAlbums();
|
super.setMenuVisibility(menuVisible);
|
||||||
|
if (menuVisible) {
|
||||||
|
getLibraryFragment().setTitle(
|
||||||
|
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
|
||||||
|
: R.string.albums);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onResume() {
|
||||||
super.onCreate(savedInstanceState);
|
super.onResume();
|
||||||
presenter = new AlbumPresenter(this);
|
getLibraryFragment().setTitle(
|
||||||
|
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.albums);
|
||||||
|
if (getAdapter().getDataSet().isEmpty()) {
|
||||||
|
presenter.subscribe();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMenuVisibility(boolean menuVisible) {
|
public void onDestroy() {
|
||||||
super.setMenuVisibility(menuVisible);
|
super.onDestroy();
|
||||||
if (menuVisible) {
|
presenter.unsubscribe();
|
||||||
getLibraryFragment().getToolbar().setTitle(
|
}
|
||||||
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
|
|
||||||
: R.string.albums);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void loading() {
|
||||||
super.onResume();
|
}
|
||||||
getLibraryFragment().getToolbar().setTitle(
|
|
||||||
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.albums);
|
|
||||||
if (getAdapter().getDataSet().isEmpty()) {
|
|
||||||
presenter.subscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void showEmptyView() {
|
||||||
super.onDestroy();
|
getAdapter().swapDataSet(new ArrayList<>());
|
||||||
presenter.unsubscribe();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loading() {
|
public void completed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showEmptyView() {
|
public void showData(ArrayList<Album> albums) {
|
||||||
getAdapter().swapDataSet(new ArrayList<>());
|
getAdapter().swapDataSet(albums);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void completed() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showData(ArrayList<Album> albums) {
|
|
||||||
getAdapter().swapDataSet(albums);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,6 @@ import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.model.Artist;
|
import code.name.monkey.retromusic.model.Artist;
|
||||||
import code.name.monkey.retromusic.mvp.contract.ArtistContract;
|
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.adapter.artist.ArtistAdapter;
|
||||||
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ArtistsFragment extends
|
public class ArtistsFragment extends
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager> implements
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager> implements
|
||||||
ArtistContract.ArtistView {
|
ArtistContract.ArtistView {
|
||||||
|
|
||||||
public static final String TAG = ArtistsFragment.class.getSimpleName();
|
public static final String TAG = ArtistsFragment.class.getSimpleName();
|
||||||
private ArtistPresenter presenter;
|
private ArtistPresenter presenter;
|
||||||
|
|
||||||
public static ArtistsFragment newInstance() {
|
public static ArtistsFragment newInstance() {
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
ArtistsFragment fragment = new ArtistsFragment();
|
ArtistsFragment fragment = new ArtistsFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
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<Artist> dataSet =
|
||||||
|
getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
|
||||||
|
return new ArtistAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
|
||||||
|
loadUsePalette(), getLibraryFragment());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
protected int getEmptyMessage() {
|
||||||
super.onCreate(savedInstanceState);
|
return R.string.no_artists;
|
||||||
presenter = new ArtistPresenter(this);
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
@Override
|
public void onResume() {
|
||||||
protected GridLayoutManager createLayoutManager() {
|
super.onResume();
|
||||||
return new GridLayoutManager(getActivity(), getGridSize());
|
getLibraryFragment().setTitle(
|
||||||
|
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.artists);
|
||||||
|
if (getAdapter().getDataSet().isEmpty()) {
|
||||||
|
presenter.subscribe();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@Override
|
||||||
@Override
|
public void onDestroy() {
|
||||||
protected ArtistAdapter createAdapter() {
|
super.onDestroy();
|
||||||
int itemLayoutRes = getItemLayoutRes();
|
presenter.unsubscribe();
|
||||||
notifyLayoutResChanged(itemLayoutRes);
|
}
|
||||||
if (itemLayoutRes != R.layout.item_list) {
|
|
||||||
itemLayoutRes = PreferenceUtil.getInstance(getContext()).getArtistGridStyle(getContext());
|
|
||||||
}
|
|
||||||
ArrayList<Artist> dataSet =
|
|
||||||
getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
|
|
||||||
return new ArtistAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
|
|
||||||
loadUsePalette(), getLibraryFragment());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getEmptyMessage() {
|
public void loading() {
|
||||||
return R.string.no_artists;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMediaStoreChanged() {
|
public void showEmptyView() {
|
||||||
presenter.loadArtists();
|
getAdapter().swapDataSet(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int loadGridSize() {
|
public void completed() {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getArtistGridSize(getActivity());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
protected void saveGridSize(int gridSize) {
|
|
||||||
PreferenceUtil.getInstance(getActivity()).setArtistGridSize(gridSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int loadGridSizeLand() {
|
public void showData(ArrayList<Artist> artists) {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getArtistGridSizeLand(getActivity());
|
getAdapter().swapDataSet(artists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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<Artist> artists) {
|
|
||||||
getAdapter().swapDataSet(artists);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class GenreFragment extends
|
||||||
public void setMenuVisibility(boolean menuVisible) {
|
public void setMenuVisibility(boolean menuVisible) {
|
||||||
super.setMenuVisibility(menuVisible);
|
super.setMenuVisibility(menuVisible);
|
||||||
if (menuVisible) {
|
if (menuVisible) {
|
||||||
getLibraryFragment().getToolbar().setTitle(
|
getLibraryFragment().setTitle(
|
||||||
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
|
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
|
||||||
: R.string.genres);
|
: R.string.genres);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class GenreFragment extends
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
getLibraryFragment().getToolbar().setTitle(
|
getLibraryFragment().setTitle(
|
||||||
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.genres);
|
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.genres);
|
||||||
if (getAdapter().getDataSet().isEmpty()) {
|
if (getAdapter().getDataSet().isEmpty()) {
|
||||||
mPresenter.subscribe();
|
mPresenter.subscribe();
|
||||||
|
|
|
@ -5,7 +5,9 @@ import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
import android.support.design.widget.AppBarLayout;
|
import android.support.design.widget.AppBarLayout;
|
||||||
|
import android.support.design.widget.CollapsingToolbarLayout;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
@ -17,11 +19,6 @@ import android.view.MenuItem;
|
||||||
import android.view.SubMenu;
|
import android.view.SubMenu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.afollestad.materialcab.MaterialCab;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.Unbinder;
|
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.CabHolder;
|
||||||
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks;
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks;
|
||||||
import code.name.monkey.retromusic.loaders.SongLoader;
|
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.activities.SettingsActivity;
|
||||||
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
||||||
import code.name.monkey.retromusic.ui.fragments.base.AbsMainActivityFragment;
|
import code.name.monkey.retromusic.ui.fragments.base.AbsMainActivityFragment;
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil;
|
import code.name.monkey.retromusic.util.NavigationUtil;
|
||||||
import code.name.monkey.retromusic.util.RetroColorUtil;
|
import code.name.monkey.retromusic.util.RetroColorUtil;
|
||||||
import code.name.monkey.retromusic.util.RetroUtil;
|
import code.name.monkey.retromusic.util.RetroUtil;
|
||||||
import code.name.monkey.retromusic.views.SansFontCollapsingToolbarLayout;
|
import com.afollestad.materialcab.MaterialCab;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
public class LibraryFragment extends AbsMainActivityFragment implements CabHolder,
|
public class LibraryFragment extends AbsMainActivityFragment implements CabHolder,
|
||||||
MainActivityFragmentCallbacks {
|
MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
private static final String TAG = "LibraryFragment";
|
private static final String TAG = "LibraryFragment";
|
||||||
private static final String CURRENT_TAB_ID = "current_tab_id";
|
private static final String CURRENT_TAB_ID = "current_tab_id";
|
||||||
@BindView(R.id.toolbar)
|
@BindView(R.id.toolbar)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.appbar)
|
@BindView(R.id.app_bar)
|
||||||
AppBarLayout appbar;
|
AppBarLayout appbar;
|
||||||
@BindView(R.id.collapsing_toolbar)
|
@BindView(R.id.collapsing_toolbar)
|
||||||
SansFontCollapsingToolbarLayout collapsingToolbar;
|
CollapsingToolbarLayout collapsingToolbarLayout;
|
||||||
|
|
||||||
private Unbinder unBinder;
|
|
||||||
private MaterialCab cab;
|
|
||||||
private FragmentManager fragmentManager;
|
|
||||||
|
|
||||||
public static Fragment newInstance(int tab) {
|
private Unbinder unBinder;
|
||||||
Bundle args = new Bundle();
|
private MaterialCab cab;
|
||||||
args.putInt(CURRENT_TAB_ID, tab);
|
private FragmentManager fragmentManager;
|
||||||
LibraryFragment fragment = new LibraryFragment();
|
|
||||||
fragment.setArguments(args);
|
public static Fragment newInstance(int tab) {
|
||||||
return fragment;
|
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() {
|
sortOrderMenu.setGroupCheckable(0, true, true);
|
||||||
return collapsingToolbar;
|
}
|
||||||
|
|
||||||
|
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(
|
if (sortOrder != null) {
|
||||||
AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
item.setChecked(true);
|
||||||
appbar.addOnOffsetChangedListener(onOffsetChangedListener);
|
fragment.setAndSaveSortOrder(sortOrder);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeOnAppBarOffsetChangedListener(
|
return false;
|
||||||
AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
}
|
||||||
appbar.removeOnOffsetChangedListener(onOffsetChangedListener);
|
|
||||||
|
@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() {
|
if (gridSize > 0) {
|
||||||
return appbar.getTotalScrollRange();
|
item.setChecked(true);
|
||||||
}
|
fragment.setAndSaveGridSize(gridSize);
|
||||||
|
return true;
|
||||||
@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;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,14 +54,14 @@ public class PlaylistsFragment extends AbsLibraryPagerRecyclerViewFragment<Playl
|
||||||
public void setMenuVisibility(boolean menuVisible) {
|
public void setMenuVisibility(boolean menuVisible) {
|
||||||
super.setMenuVisibility(menuVisible);
|
super.setMenuVisibility(menuVisible);
|
||||||
if (menuVisible) {
|
if (menuVisible) {
|
||||||
getLibraryFragment().getToolbar().setTitle(PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.playlists);
|
getLibraryFragment().setTitle(PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.playlists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
getLibraryFragment().getToolbar().setTitle(PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.playlists);
|
getLibraryFragment().setTitle(PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library : R.string.playlists);
|
||||||
if (getAdapter().getDataSet().isEmpty()) {
|
if (getAdapter().getDataSet().isEmpty()) {
|
||||||
presenter.subscribe();
|
presenter.subscribe();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.model.Song;
|
import code.name.monkey.retromusic.model.Song;
|
||||||
import code.name.monkey.retromusic.mvp.contract.SongContract;
|
import code.name.monkey.retromusic.mvp.contract.SongContract;
|
||||||
|
@ -13,166 +12,164 @@ import code.name.monkey.retromusic.ui.adapter.song.ShuffleButtonSongAdapter;
|
||||||
import code.name.monkey.retromusic.ui.adapter.song.SongAdapter;
|
import code.name.monkey.retromusic.ui.adapter.song.SongAdapter;
|
||||||
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
public class SongsFragment extends
|
public class SongsFragment extends
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager> implements
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager> implements
|
||||||
SongContract.SongView {
|
SongContract.SongView {
|
||||||
|
|
||||||
private static final String TAG = "Songs";
|
private SongPresenter presenter;
|
||||||
private SongPresenter presenter;
|
|
||||||
|
|
||||||
public SongsFragment() {
|
public SongsFragment() {
|
||||||
// Required empty public constructor
|
// 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<Song> dataSet =
|
||||||
|
getAdapter() == null ? new ArrayList<Song>() : 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() {
|
@Override
|
||||||
Bundle args = new Bundle();
|
public void onMediaStoreChanged() {
|
||||||
SongsFragment fragment = new SongsFragment();
|
presenter.loadSongs();
|
||||||
fragment.setArguments(args);
|
}
|
||||||
return fragment;
|
|
||||||
|
@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
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void setMenuVisibility(boolean menuVisible) {
|
||||||
super.onCreate(savedInstanceState);
|
super.setMenuVisibility(menuVisible);
|
||||||
presenter = new SongPresenter(this);
|
if (menuVisible) {
|
||||||
|
getLibraryFragment().setTitle(
|
||||||
|
PreferenceUtil.getInstance(getContext()).tabTitles() ? R.string.library
|
||||||
|
: R.string.songs);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@Override
|
||||||
@Override
|
public void onDestroy() {
|
||||||
protected GridLayoutManager createLayoutManager() {
|
presenter.unsubscribe();
|
||||||
return new GridLayoutManager(getActivity(), getGridSize());
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getEmptyMessage() {
|
public void loading() {
|
||||||
return R.string.no_songs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
}
|
||||||
@Override
|
|
||||||
protected SongAdapter createAdapter() {
|
|
||||||
int itemLayoutRes = getItemLayoutRes();
|
|
||||||
notifyLayoutResChanged(itemLayoutRes);
|
|
||||||
boolean usePalette = loadUsePalette();
|
|
||||||
ArrayList<Song> dataSet =
|
|
||||||
getAdapter() == null ? new ArrayList<Song>() : getAdapter().getDataSet();
|
|
||||||
|
|
||||||
if (getGridSize() <= getMaxGridSizeForList()) {
|
@Override
|
||||||
return new ShuffleButtonSongAdapter(getLibraryFragment().getMainActivity(), dataSet,
|
public void showData(ArrayList<Song> songs) {
|
||||||
itemLayoutRes, usePalette, getLibraryFragment());
|
getAdapter().swapDataSet(songs);
|
||||||
}
|
}
|
||||||
return new SongAdapter(getLibraryFragment().getMainActivity(), dataSet, itemLayoutRes,
|
|
||||||
usePalette, getLibraryFragment());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMediaStoreChanged() {
|
public void showEmptyView() {
|
||||||
presenter.loadSongs();
|
getAdapter().swapDataSet(new ArrayList<Song>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int loadGridSize() {
|
public void completed() {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getSongGridSize(getActivity());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
protected void saveGridSize(int gridSize) {
|
|
||||||
PreferenceUtil.getInstance(getActivity()).setSongGridSize(gridSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int loadGridSizeLand() {
|
protected String loadSortOrder() {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getSongGridSizeLand(getActivity());
|
return PreferenceUtil.getInstance(getActivity()).getSongSortOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveGridSizeLand(int gridSize) {
|
protected void saveSortOrder(String sortOrder) {
|
||||||
PreferenceUtil.getInstance(getActivity()).setSongGridSizeLand(gridSize);
|
PreferenceUtil.getInstance(getActivity()).setSongSortOrder(sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveUsePalette(boolean usePalette) {
|
protected void setSortOrder(String sortOrder) {
|
||||||
PreferenceUtil.getInstance(getActivity()).setSongColoredFooters(usePalette);
|
presenter.loadSongs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@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<Song> songs) {
|
|
||||||
getAdapter().swapDataSet(songs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showEmptyView() {
|
|
||||||
getAdapter().swapDataSet(new ArrayList<Song>());
|
|
||||||
}
|
|
||||||
|
|
||||||
@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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
@ -31,6 +32,8 @@ import butterknife.Unbinder;
|
||||||
import code.name.monkey.appthemehelper.ThemeStore;
|
import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
|
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
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.appthemehelper.util.ToolbarContentTintHelper;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||||
|
@ -82,6 +85,8 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@BindView(R.id.container)
|
@BindView(R.id.container)
|
||||||
View container;
|
View container;
|
||||||
|
@BindView(R.id.title)
|
||||||
|
TextView title;
|
||||||
@BindView(android.R.id.empty)
|
@BindView(android.R.id.empty)
|
||||||
View empty;
|
View empty;
|
||||||
@BindView(R.id.toolbar)
|
@BindView(R.id.toolbar)
|
||||||
|
@ -90,10 +95,10 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
BreadCrumbLayout breadCrumbs;
|
BreadCrumbLayout breadCrumbs;
|
||||||
@BindView(R.id.appbar)
|
@BindView(R.id.appbar)
|
||||||
AppBarLayout appbar;
|
AppBarLayout appbar;
|
||||||
@BindView(R.id.status_bar)
|
|
||||||
View statusBar;
|
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
FastScrollRecyclerView recyclerView;
|
FastScrollRecyclerView recyclerView;
|
||||||
|
|
||||||
Comparator<File> fileComparator = (lhs, rhs) -> {
|
Comparator<File> fileComparator = (lhs, rhs) -> {
|
||||||
if (lhs.isDirectory() && !rhs.isDirectory()) {
|
if (lhs.isDirectory() && !rhs.isDirectory()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -207,7 +212,6 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
setStatusbarColorAuto(view);
|
setStatusbarColorAuto(view);
|
||||||
getMainActivity().getSlidingUpPanelLayout().setShadowHeight(0);
|
getMainActivity().getSlidingUpPanelLayout().setShadowHeight(0);
|
||||||
|
|
||||||
getMainActivity().setBottomBarVisibility(View.GONE);
|
getMainActivity().setBottomBarVisibility(View.GONE);
|
||||||
|
|
||||||
setUpAppbarColor();
|
setUpAppbarColor();
|
||||||
|
@ -215,24 +219,29 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
setUpBreadCrumbs();
|
setUpBreadCrumbs();
|
||||||
setUpRecyclerView();
|
setUpRecyclerView();
|
||||||
setUpAdapter();
|
setUpAdapter();
|
||||||
ViewUtil.setStatusBarHeight(getContext(), statusBar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpAppbarColor() {
|
private void setUpAppbarColor() {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
int primaryColor = ThemeStore.primaryColor(getActivity());
|
int primaryColor = ThemeStore.primaryColor(getActivity());
|
||||||
appbar.setBackgroundColor(primaryColor);
|
TintHelper.setTintAuto(container, primaryColor, true);
|
||||||
toolbar.setBackgroundColor(primaryColor);
|
appbar.setBackgroundColor(ColorUtil.darkenColor(primaryColor));
|
||||||
|
toolbar.setBackgroundColor(ColorUtil.darkenColor(primaryColor));
|
||||||
//breadCrumbs.setBackgroundColor(primaryColor);
|
//breadCrumbs.setBackgroundColor(primaryColor);
|
||||||
breadCrumbs.setActivatedContentColor(
|
breadCrumbs.setActivatedContentColor(
|
||||||
ToolbarContentTintHelper.toolbarTitleColor(getActivity(), primaryColor));
|
ToolbarContentTintHelper
|
||||||
|
.toolbarTitleColor(getActivity(), ColorUtil.darkenColor(primaryColor)));
|
||||||
breadCrumbs.setDeactivatedContentColor(
|
breadCrumbs.setDeactivatedContentColor(
|
||||||
ToolbarContentTintHelper.toolbarSubtitleColor(getActivity(), primaryColor));
|
ToolbarContentTintHelper
|
||||||
|
.toolbarSubtitleColor(getActivity(), ColorUtil.darkenColor(primaryColor)));
|
||||||
appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> getMainActivity()
|
appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> getMainActivity()
|
||||||
.setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext())));
|
.setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpToolbar() {
|
private void setUpToolbar() {
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||||
toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp);
|
toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp);
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
getActivity().setTitle(R.string.folders);
|
getActivity().setTitle(R.string.folders);
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package code.name.monkey.retromusic.ui.fragments.mainactivity.home;
|
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.app.Activity;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -23,6 +20,15 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
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.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
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.util.RetroUtil;
|
||||||
import code.name.monkey.retromusic.views.CircularImageView;
|
import code.name.monkey.retromusic.views.CircularImageView;
|
||||||
import code.name.monkey.retromusic.views.MetalRecyclerViewPager;
|
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.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import static code.name.monkey.retromusic.Constants.USER_BANNER;
|
||||||
import java.util.Calendar;
|
import static code.name.monkey.retromusic.Constants.USER_PROFILE;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class HomeFragment extends AbsMainActivityFragment implements MainActivityFragmentCallbacks,
|
public class HomeFragment extends AbsMainActivityFragment implements MainActivityFragmentCallbacks,
|
||||||
HomeContract.HomeView {
|
HomeContract.HomeView {
|
||||||
|
|
||||||
private static final String TAG = "HomeFragment";
|
private static final String TAG = "HomeFragment";
|
||||||
Unbinder unbinder;
|
Unbinder unbinder;
|
||||||
@BindView(R.id.home_toolbar)
|
@BindView(R.id.home_toolbar)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.appbar)
|
@BindView(R.id.appbar)
|
||||||
AppBarLayout appbar;
|
AppBarLayout appbar;
|
||||||
@BindView(R.id.image)
|
@BindView(R.id.image)
|
||||||
ImageView imageView;
|
ImageView imageView;
|
||||||
@BindView(R.id.user_image)
|
@BindView(R.id.user_image)
|
||||||
CircularImageView userImage;
|
CircularImageView userImage;
|
||||||
@BindView(R.id.collapsing_toolbar)
|
@BindView(R.id.collapsing_toolbar)
|
||||||
CollapsingToolbarLayout toolbarLayout;
|
CollapsingToolbarLayout toolbarLayout;
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
RecyclerView recentArtistRV;
|
RecyclerView recentArtistRV;
|
||||||
@BindView(R.id.recent_album)
|
@BindView(R.id.recent_album)
|
||||||
RecyclerView recentAlbumRV;
|
RecyclerView recentAlbumRV;
|
||||||
@BindView(R.id.top_artist)
|
@BindView(R.id.top_artist)
|
||||||
RecyclerView topArtistRV;
|
RecyclerView topArtistRV;
|
||||||
@BindView(R.id.top_album)
|
@BindView(R.id.top_album)
|
||||||
MetalRecyclerViewPager topAlbumRV;
|
MetalRecyclerViewPager topAlbumRV;
|
||||||
@BindView(R.id.recent_artist_container)
|
@BindView(R.id.recent_artist_container)
|
||||||
View recentArtistContainer;
|
View recentArtistContainer;
|
||||||
@BindView(R.id.recent_albums_container)
|
@BindView(R.id.recent_albums_container)
|
||||||
View recentAlbumsContainer;
|
View recentAlbumsContainer;
|
||||||
@BindView(R.id.top_artist_container)
|
@BindView(R.id.top_artist_container)
|
||||||
View topArtistContainer;
|
View topArtistContainer;
|
||||||
@BindView(R.id.top_albums_container)
|
@BindView(R.id.top_albums_container)
|
||||||
View topAlbumContainer;
|
View topAlbumContainer;
|
||||||
@BindView(R.id.genres)
|
@BindView(R.id.genres)
|
||||||
RecyclerView genresRecyclerView;
|
RecyclerView genresRecyclerView;
|
||||||
@BindView(R.id.genre_container)
|
@BindView(R.id.genre_container)
|
||||||
LinearLayout genreContainer;
|
LinearLayout genreContainer;
|
||||||
@BindView(R.id.container)
|
@BindView(R.id.container)
|
||||||
View container;
|
View container;
|
||||||
@BindView(R.id.title)
|
@BindView(R.id.title)
|
||||||
TextView title;
|
TextView title;
|
||||||
@BindView(R.id.search)
|
@BindView(R.id.search)
|
||||||
ImageView search;
|
ImageView search;
|
||||||
|
|
||||||
|
|
||||||
private HomePresenter homePresenter;
|
private HomePresenter homePresenter;
|
||||||
private CompositeDisposable disposable;
|
private CompositeDisposable disposable;
|
||||||
|
|
||||||
public static HomeFragment newInstance() {
|
public static HomeFragment newInstance() {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
HomeFragment fragment = new HomeFragment();
|
HomeFragment fragment = new HomeFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
appbar.addOnOffsetChangedListener(new AppBarStateChangeListener() {
|
private void getTimeOfTheDay() {
|
||||||
@Override
|
Calendar c = Calendar.getInstance();
|
||||||
public void onStateChanged(AppBarLayout appBarLayout, State state) {
|
int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
|
||||||
int color;
|
|
||||||
switch (state) {
|
String[] images = new String[]{};
|
||||||
case COLLAPSED:
|
if (timeOfDay >= 0 && timeOfDay < 6) {
|
||||||
getMainActivity().setLightStatusbar(!ATHUtil.isWindowBackgroundDark(getContext()));
|
images = getResources().getStringArray(R.array.night);
|
||||||
color = ThemeStore.textColorPrimary(getContext());
|
} else if (timeOfDay >= 6 && timeOfDay < 12) {
|
||||||
break;
|
images = getResources().getStringArray(R.array.morning);
|
||||||
default:
|
} else if (timeOfDay >= 12 && timeOfDay < 16) {
|
||||||
case EXPANDED:
|
images = getResources().getStringArray(R.array.after_noon);
|
||||||
case IDLE:
|
} else if (timeOfDay >= 16 && timeOfDay < 20) {
|
||||||
getMainActivity().setLightStatusbar(false);
|
images = getResources().getStringArray(R.array.evening);
|
||||||
color = ContextCompat.getColor(getContext(), R.color.md_white_1000);
|
} else if (timeOfDay >= 20 && timeOfDay < 24) {
|
||||||
break;
|
images = getResources().getStringArray(R.array.night);
|
||||||
}
|
}
|
||||||
TintHelper.setTintAuto(search, color, false);
|
String day = images[new Random().nextInt(images.length)];
|
||||||
title.setTextColor(color);
|
loadTimeImage(day);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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<Object> homes) {
|
|
||||||
//homeAdapter.swapDataSet(homes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMediaStoreChanged() {
|
|
||||||
super.onMediaStoreChanged();
|
|
||||||
homePresenter.subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceConnected() {
|
|
||||||
super.onServiceConnected();
|
|
||||||
checkPadding();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onQueueChanged() {
|
|
||||||
super.onQueueChanged();
|
|
||||||
checkPadding();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkPadding() {
|
|
||||||
int height = getResources().getDimensionPixelSize(R.dimen.mini_player_height);
|
|
||||||
container.setPadding(0, 0, 0, MusicPlayerRemote.getPlayingQueue().isEmpty() ? height * 2 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recentArtist(ArrayList<Artist> artists) {
|
|
||||||
recentArtistContainer.setVisibility(View.VISIBLE);
|
|
||||||
recentArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(),
|
|
||||||
1, GridLayoutManager.HORIZONTAL, false));
|
|
||||||
ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists,
|
|
||||||
R.layout.item_artist, false, null);
|
|
||||||
recentArtistRV.setAdapter(artistAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recentAlbum(ArrayList<Album> albums) {
|
|
||||||
recentAlbumsContainer.setVisibility(View.VISIBLE);
|
|
||||||
AlbumFullWithAdapter artistAdapter = new AlbumFullWithAdapter(getMainActivity(),
|
|
||||||
getDisplayMetrics());
|
|
||||||
artistAdapter.swapData(albums);
|
|
||||||
recentAlbumRV.setAdapter(artistAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void topArtists(ArrayList<Artist> artists) {
|
|
||||||
topArtistContainer.setVisibility(View.VISIBLE);
|
|
||||||
topArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(),
|
|
||||||
1, GridLayoutManager.HORIZONTAL, false));
|
|
||||||
ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists,
|
|
||||||
R.layout.item_artist, false, null);
|
|
||||||
topArtistRV.setAdapter(artistAdapter);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void topAlbums(ArrayList<Album> albums) {
|
|
||||||
topAlbumContainer.setVisibility(View.VISIBLE);
|
|
||||||
AlbumFullWithAdapter artistAdapter = new AlbumFullWithAdapter(getMainActivity(),
|
|
||||||
getDisplayMetrics());
|
|
||||||
artistAdapter.swapData(albums);
|
|
||||||
topAlbumRV.setAdapter(artistAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DisplayMetrics getDisplayMetrics() {
|
|
||||||
Display display = getMainActivity().getWindowManager().getDefaultDisplay();
|
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
|
||||||
display.getMetrics(metrics);
|
|
||||||
|
|
||||||
return metrics;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void suggestions(ArrayList<Playlist> playlists) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void geners(ArrayList<Genre> genres) {
|
|
||||||
genreContainer.setVisibility(View.VISIBLE);
|
|
||||||
genresRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
GenreAdapter genreAdapter = new GenreAdapter(getActivity(), genres, R.layout.item_list);
|
|
||||||
genresRecyclerView.setAdapter(genreAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@OnClick({R.id.last_added, R.id.top_played, R.id.action_shuffle, R.id.history,
|
|
||||||
R.id.user_image, R.id.search})
|
|
||||||
void startUserInfo(View view) {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.action_shuffle:
|
|
||||||
MusicPlayerRemote
|
|
||||||
.openAndShuffleQueue(SongLoader.getAllSongs(activity).blockingFirst(), true);
|
|
||||||
break;
|
|
||||||
case R.id.last_added:
|
|
||||||
NavigationUtil.goToPlaylistNew(activity, new LastAddedPlaylist(activity));
|
|
||||||
break;
|
|
||||||
case R.id.top_played:
|
|
||||||
NavigationUtil.goToPlaylistNew(activity, new MyTopTracksPlaylist(activity));
|
|
||||||
break;
|
|
||||||
case R.id.history:
|
|
||||||
NavigationUtil.goToPlaylistNew(activity, new HistoryPlaylist(activity));
|
|
||||||
break;
|
|
||||||
case R.id.search:
|
|
||||||
NavigationUtil.goToSearch(activity);
|
|
||||||
break;
|
|
||||||
case R.id.user_image:
|
|
||||||
new HomeOptionDialog().show(getFragmentManager(), TAG);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private void loadTimeImage(String day) {
|
||||||
public void onPlayingMetaChanged() {
|
//noinspection ConstantConditions
|
||||||
super.onPlayingMetaChanged();
|
if (PreferenceUtil.getInstance(getActivity()).getBannerImage().isEmpty()) {
|
||||||
homePresenter.loadRecentArtists();
|
if (imageView != null) {
|
||||||
homePresenter.loadRecentAlbums();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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<Object> homes) {
|
||||||
|
//homeAdapter.swapDataSet(homes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMediaStoreChanged() {
|
||||||
|
super.onMediaStoreChanged();
|
||||||
|
homePresenter.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected() {
|
||||||
|
super.onServiceConnected();
|
||||||
|
checkPadding();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onQueueChanged() {
|
||||||
|
super.onQueueChanged();
|
||||||
|
checkPadding();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkPadding() {
|
||||||
|
int height = getResources().getDimensionPixelSize(R.dimen.mini_player_height);
|
||||||
|
container.setPadding(0, 0, 0, MusicPlayerRemote.getPlayingQueue().isEmpty() ? height * 2 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recentArtist(ArrayList<Artist> artists) {
|
||||||
|
recentArtistContainer.setVisibility(View.VISIBLE);
|
||||||
|
recentArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(),
|
||||||
|
1, GridLayoutManager.HORIZONTAL, false));
|
||||||
|
ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists,
|
||||||
|
R.layout.item_artist, false, null);
|
||||||
|
recentArtistRV.setAdapter(artistAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recentAlbum(ArrayList<Album> albums) {
|
||||||
|
recentAlbumsContainer.setVisibility(View.VISIBLE);
|
||||||
|
AlbumFullWithAdapter artistAdapter = new AlbumFullWithAdapter(getMainActivity(),
|
||||||
|
getDisplayMetrics());
|
||||||
|
artistAdapter.swapData(albums);
|
||||||
|
recentAlbumRV.setAdapter(artistAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void topArtists(ArrayList<Artist> artists) {
|
||||||
|
topArtistContainer.setVisibility(View.VISIBLE);
|
||||||
|
topArtistRV.setLayoutManager(new GridLayoutManager(getMainActivity(),
|
||||||
|
1, GridLayoutManager.HORIZONTAL, false));
|
||||||
|
ArtistAdapter artistAdapter = new ArtistAdapter(getMainActivity(), artists,
|
||||||
|
R.layout.item_artist, false, null);
|
||||||
|
topArtistRV.setAdapter(artistAdapter);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void topAlbums(ArrayList<Album> albums) {
|
||||||
|
topAlbumContainer.setVisibility(View.VISIBLE);
|
||||||
|
AlbumFullWithAdapter artistAdapter = new AlbumFullWithAdapter(getMainActivity(),
|
||||||
|
getDisplayMetrics());
|
||||||
|
artistAdapter.swapData(albums);
|
||||||
|
topAlbumRV.setAdapter(artistAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DisplayMetrics getDisplayMetrics() {
|
||||||
|
Display display = getMainActivity().getWindowManager().getDefaultDisplay();
|
||||||
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
display.getMetrics(metrics);
|
||||||
|
|
||||||
|
return metrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void suggestions(ArrayList<Playlist> playlists) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void geners(ArrayList<Genre> genres) {
|
||||||
|
genreContainer.setVisibility(View.VISIBLE);
|
||||||
|
genresRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
GenreAdapter genreAdapter = new GenreAdapter(getActivity(), genres, R.layout.item_list);
|
||||||
|
genresRecyclerView.setAdapter(genreAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OnClick({R.id.last_added, R.id.top_played, R.id.action_shuffle, R.id.history,
|
||||||
|
R.id.user_image, R.id.search})
|
||||||
|
void startUserInfo(View view) {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
switch (view.getId()) {
|
||||||
|
case R.id.action_shuffle:
|
||||||
|
MusicPlayerRemote
|
||||||
|
.openAndShuffleQueue(SongLoader.getAllSongs(activity).blockingFirst(), true);
|
||||||
|
break;
|
||||||
|
case R.id.last_added:
|
||||||
|
NavigationUtil.goToPlaylistNew(activity, new LastAddedPlaylist(activity));
|
||||||
|
break;
|
||||||
|
case R.id.top_played:
|
||||||
|
NavigationUtil.goToPlaylistNew(activity, new MyTopTracksPlaylist(activity));
|
||||||
|
break;
|
||||||
|
case R.id.history:
|
||||||
|
NavigationUtil.goToPlaylistNew(activity, new HistoryPlaylist(activity));
|
||||||
|
break;
|
||||||
|
case R.id.search:
|
||||||
|
NavigationUtil.goToSearch(activity);
|
||||||
|
break;
|
||||||
|
case R.id.user_image:
|
||||||
|
new HomeOptionDialog().show(getFragmentManager(), TAG);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayingMetaChanged() {
|
||||||
|
super.onPlayingMetaChanged();
|
||||||
|
homePresenter.loadRecentArtists();
|
||||||
|
homePresenter.loadRecentAlbums();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -16,20 +16,19 @@ import android.view.animation.LinearInterpolator;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
|
||||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
|
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import butterknife.Unbinder;
|
import butterknife.Unbinder;
|
||||||
|
import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||||
|
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||||
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
|
||||||
|
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper;
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper;
|
||||||
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener;
|
||||||
import code.name.monkey.retromusic.service.MusicService;
|
import code.name.monkey.retromusic.service.MusicService;
|
||||||
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment;
|
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment;
|
||||||
import code.name.monkey.retromusic.util.MusicUtil;
|
import code.name.monkey.retromusic.util.MusicUtil;
|
||||||
|
@ -41,284 +40,297 @@ import code.name.monkey.retromusic.views.PlayPauseDrawable;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlainPlaybackControlsFragment extends AbsPlayerControlsFragment {
|
public class PlainPlaybackControlsFragment extends AbsPlayerControlsFragment {
|
||||||
@BindView(R.id.player_play_pause_button)
|
|
||||||
ImageButton playPauseFab;
|
|
||||||
@BindView(R.id.player_prev_button)
|
|
||||||
ImageButton prevButton;
|
|
||||||
@BindView(R.id.player_next_button)
|
|
||||||
ImageButton nextButton;
|
|
||||||
@BindView(R.id.player_repeat_button)
|
|
||||||
ImageButton repeatButton;
|
|
||||||
@BindView(R.id.player_shuffle_button)
|
|
||||||
ImageButton shuffleButton;
|
|
||||||
@BindView(R.id.player_progress_slider)
|
|
||||||
SeekBar progressSlider;
|
|
||||||
@BindView(R.id.player_song_total_time)
|
|
||||||
TextView songTotalTime;
|
|
||||||
@BindView(R.id.player_song_current_progress)
|
|
||||||
TextView songCurrentProgress;
|
|
||||||
@BindView(R.id.volume_fragment_container)
|
|
||||||
View volumeContainer;
|
|
||||||
private Unbinder unbinder;
|
|
||||||
private PlayPauseDrawable playerFabPlayPauseDrawable;
|
|
||||||
private int lastPlaybackControlsColor;
|
|
||||||
private int lastDisabledPlaybackControlsColor;
|
|
||||||
private MusicProgressViewUpdateHelper progressViewUpdateHelper;
|
|
||||||
|
|
||||||
@Override
|
@BindView(R.id.player_play_pause_button)
|
||||||
public void onPlayStateChanged() {
|
ImageButton playPauseFab;
|
||||||
updatePlayPauseDrawableState(true);
|
@BindView(R.id.player_prev_button)
|
||||||
|
ImageButton prevButton;
|
||||||
|
@BindView(R.id.player_next_button)
|
||||||
|
ImageButton nextButton;
|
||||||
|
@BindView(R.id.player_repeat_button)
|
||||||
|
ImageButton repeatButton;
|
||||||
|
@BindView(R.id.player_shuffle_button)
|
||||||
|
ImageButton shuffleButton;
|
||||||
|
@BindView(R.id.player_progress_slider)
|
||||||
|
SeekBar progressSlider;
|
||||||
|
@BindView(R.id.player_song_total_time)
|
||||||
|
TextView songTotalTime;
|
||||||
|
@BindView(R.id.player_song_current_progress)
|
||||||
|
TextView songCurrentProgress;
|
||||||
|
@BindView(R.id.volume_fragment_container)
|
||||||
|
View volumeContainer;
|
||||||
|
private Unbinder unbinder;
|
||||||
|
private PlayPauseDrawable playerFabPlayPauseDrawable;
|
||||||
|
private int lastPlaybackControlsColor;
|
||||||
|
private int lastDisabledPlaybackControlsColor;
|
||||||
|
private MusicProgressViewUpdateHelper progressViewUpdateHelper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayStateChanged() {
|
||||||
|
updatePlayPauseDrawableState(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRepeatModeChanged() {
|
||||||
|
updateRepeatState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShuffleModeChanged() {
|
||||||
|
updateShuffleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected() {
|
||||||
|
updatePlayPauseDrawableState(false);
|
||||||
|
updateRepeatState();
|
||||||
|
updateShuffleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
progressViewUpdateHelper = new MusicProgressViewUpdateHelper(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
unbinder.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
|
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_plain_controls_fragment, container, false);
|
||||||
|
unbinder = ButterKnife.bind(this, view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
progressViewUpdateHelper.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
progressViewUpdateHelper.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
setUpMusicControllers();
|
||||||
|
if (PreferenceUtil.getInstance(getContext()).getVolumeToggle()) {
|
||||||
|
volumeContainer.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
volumeContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private void setUpMusicControllers() {
|
||||||
public void onRepeatModeChanged() {
|
setUpPlayPauseFab();
|
||||||
updateRepeatState();
|
setUpPrevNext();
|
||||||
|
setUpRepeatButton();
|
||||||
|
setUpShuffleButton();
|
||||||
|
setUpProgressSlider();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpPrevNext() {
|
||||||
|
updatePrevNextColor();
|
||||||
|
nextButton.setOnClickListener(v -> MusicPlayerRemote.playNextSong());
|
||||||
|
prevButton.setOnClickListener(v -> MusicPlayerRemote.back());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePrevNextColor() {
|
||||||
|
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
prevButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpShuffleButton() {
|
||||||
|
shuffleButton.setOnClickListener(v -> MusicPlayerRemote.toggleShuffleMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateShuffleState() {
|
||||||
|
switch (MusicPlayerRemote.getShuffleMode()) {
|
||||||
|
case MusicService.SHUFFLE_MODE_SHUFFLE:
|
||||||
|
shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private void setUpRepeatButton() {
|
||||||
public void onShuffleModeChanged() {
|
repeatButton.setOnClickListener(v -> MusicPlayerRemote.cycleRepeatMode());
|
||||||
updateShuffleState();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateRepeatState() {
|
||||||
|
switch (MusicPlayerRemote.getRepeatMode()) {
|
||||||
|
case MusicService.REPEAT_MODE_NONE:
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
||||||
|
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
case MusicService.REPEAT_MODE_ALL:
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
case MusicService.REPEAT_MODE_THIS:
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp);
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceConnected() {
|
@Override
|
||||||
updatePlayPauseDrawableState(false);
|
protected void show() {
|
||||||
updateRepeatState();
|
playPauseFab.animate()
|
||||||
updateShuffleState();
|
.scaleX(1f)
|
||||||
|
.scaleY(1f)
|
||||||
|
.rotation(360f)
|
||||||
|
.setInterpolator(new DecelerateInterpolator())
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void hide() {
|
||||||
|
if (playPauseFab != null) {
|
||||||
|
playPauseFab.setScaleX(0f);
|
||||||
|
playPauseFab.setScaleY(0f);
|
||||||
|
playPauseFab.setRotation(0f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
protected void setUpProgressSlider() {
|
||||||
super.onCreate(savedInstanceState);
|
progressSlider.setOnSeekBarChangeListener(new SimpleOnSeekbarChangeListener() {
|
||||||
progressViewUpdateHelper = new MusicProgressViewUpdateHelper(this);
|
@Override
|
||||||
}
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
if (fromUser) {
|
||||||
@Override
|
MusicPlayerRemote.seekTo(progress);
|
||||||
public void onDestroyView() {
|
onUpdateProgressViews(MusicPlayerRemote.getSongProgressMillis(),
|
||||||
super.onDestroyView();
|
MusicPlayerRemote.getSongDurationMillis());
|
||||||
unbinder.unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
|
||||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
||||||
View view = inflater.inflate(R.layout.fragment_plain_controls_fragment, container, false);
|
|
||||||
unbinder = ButterKnife.bind(this, view);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
progressViewUpdateHelper.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
progressViewUpdateHelper.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
setUpMusicControllers();
|
|
||||||
if (PreferenceUtil.getInstance(getContext()).getVolumeToggle()) {
|
|
||||||
volumeContainer.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
volumeContainer.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showBouceAnimation() {
|
||||||
|
playPauseFab.clearAnimation();
|
||||||
|
|
||||||
|
playPauseFab.setScaleX(0.9f);
|
||||||
|
playPauseFab.setScaleY(0.9f);
|
||||||
|
playPauseFab.setVisibility(View.VISIBLE);
|
||||||
|
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
||||||
|
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
||||||
|
|
||||||
|
playPauseFab.animate()
|
||||||
|
.setDuration(200)
|
||||||
|
.setInterpolator(new DecelerateInterpolator())
|
||||||
|
.scaleX(1.1f)
|
||||||
|
.scaleY(1.1f)
|
||||||
|
.withEndAction(() -> playPauseFab.animate()
|
||||||
|
.setDuration(200)
|
||||||
|
.setInterpolator(new AccelerateInterpolator())
|
||||||
|
.scaleX(1f)
|
||||||
|
.scaleY(1f)
|
||||||
|
.alpha(1f)
|
||||||
|
.start())
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.player_play_pause_button)
|
||||||
|
void showAnimation() {
|
||||||
|
if (MusicPlayerRemote.isPlaying()) {
|
||||||
|
MusicPlayerRemote.pauseSong();
|
||||||
|
} else {
|
||||||
|
MusicPlayerRemote.resumePlaying();
|
||||||
|
}
|
||||||
|
showBouceAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdateProgressViews(int progress, int total) {
|
||||||
|
progressSlider.setMax(total);
|
||||||
|
|
||||||
|
ObjectAnimator animator = ObjectAnimator.ofInt(progressSlider, "progress", progress);
|
||||||
|
animator.setDuration(1500);
|
||||||
|
animator.setInterpolator(new LinearInterpolator());
|
||||||
|
animator.start();
|
||||||
|
|
||||||
|
songTotalTime.setText(MusicUtil.getReadableDurationString(total));
|
||||||
|
songCurrentProgress.setText(MusicUtil.getReadableDurationString(progress));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDark(int dark) {
|
||||||
|
int color = ATHUtil.resolveColor(getActivity(), android.R.attr.colorBackground);
|
||||||
|
if (ColorUtil.isColorLight(color)) {
|
||||||
|
lastPlaybackControlsColor =
|
||||||
|
MaterialValueHelper.getSecondaryTextColor(getActivity(), true);
|
||||||
|
lastDisabledPlaybackControlsColor =
|
||||||
|
MaterialValueHelper.getSecondaryDisabledTextColor(getActivity(), true);
|
||||||
|
} else {
|
||||||
|
lastPlaybackControlsColor =
|
||||||
|
MaterialValueHelper.getPrimaryTextColor(getActivity(), false);
|
||||||
|
lastDisabledPlaybackControlsColor =
|
||||||
|
MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpMusicControllers() {
|
if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) {
|
||||||
setUpPlayPauseFab();
|
TintHelper.setTintAuto(playPauseFab,
|
||||||
setUpPrevNext();
|
MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)),
|
||||||
setUpRepeatButton();
|
false);
|
||||||
setUpShuffleButton();
|
TintHelper.setTintAuto(playPauseFab, dark, true);
|
||||||
setUpProgressSlider();
|
setProgressBarColor(dark);
|
||||||
|
} else {
|
||||||
|
int accentColor = ThemeStore.accentColor(getContext());
|
||||||
|
setProgressBarColor(accentColor);
|
||||||
|
TintHelper.setTintAuto(playPauseFab,
|
||||||
|
MaterialValueHelper
|
||||||
|
.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(accentColor)),
|
||||||
|
false);
|
||||||
|
TintHelper.setTintAuto(playPauseFab, accentColor, true);
|
||||||
}
|
}
|
||||||
|
updateRepeatState();
|
||||||
|
updateShuffleState();
|
||||||
|
updatePrevNextColor();
|
||||||
|
}
|
||||||
|
|
||||||
private void setUpPrevNext() {
|
public void setProgressBarColor(int newColor) {
|
||||||
updatePrevNextColor();
|
LayerDrawable ld = (LayerDrawable) progressSlider.getProgressDrawable();
|
||||||
nextButton.setOnClickListener(v -> MusicPlayerRemote.playNextSong());
|
ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
|
||||||
prevButton.setOnClickListener(v -> MusicPlayerRemote.back());
|
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePrevNextColor() {
|
private void setUpPlayPauseFab() {
|
||||||
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity());
|
||||||
prevButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpShuffleButton() {
|
playPauseFab.setImageDrawable(
|
||||||
shuffleButton.setOnClickListener(v -> MusicPlayerRemote.toggleShuffleMode());
|
playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
|
||||||
}
|
//playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
|
||||||
|
//playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
|
||||||
@Override
|
playPauseFab.post(() -> {
|
||||||
protected void updateShuffleState() {
|
if (playPauseFab != null) {
|
||||||
switch (MusicPlayerRemote.getShuffleMode()) {
|
|
||||||
case MusicService.SHUFFLE_MODE_SHUFFLE:
|
|
||||||
shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpRepeatButton() {
|
|
||||||
repeatButton.setOnClickListener(v -> MusicPlayerRemote.cycleRepeatMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateRepeatState() {
|
|
||||||
switch (MusicPlayerRemote.getRepeatMode()) {
|
|
||||||
case MusicService.REPEAT_MODE_NONE:
|
|
||||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
|
||||||
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
case MusicService.REPEAT_MODE_ALL:
|
|
||||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
|
||||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
case MusicService.REPEAT_MODE_THIS:
|
|
||||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp);
|
|
||||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void show() {
|
|
||||||
playPauseFab.animate()
|
|
||||||
.scaleX(1f)
|
|
||||||
.scaleY(1f)
|
|
||||||
.rotation(360f)
|
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
|
||||||
.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void hide() {
|
|
||||||
if (playPauseFab != null) {
|
|
||||||
playPauseFab.setScaleX(0f);
|
|
||||||
playPauseFab.setScaleY(0f);
|
|
||||||
playPauseFab.setRotation(0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUpProgressSlider() {
|
|
||||||
progressSlider.setOnSeekBarChangeListener(new SimpleOnSeekbarChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
||||||
if (fromUser) {
|
|
||||||
MusicPlayerRemote.seekTo(progress);
|
|
||||||
onUpdateProgressViews(MusicPlayerRemote.getSongProgressMillis(), MusicPlayerRemote.getSongDurationMillis());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showBouceAnimation() {
|
|
||||||
playPauseFab.clearAnimation();
|
|
||||||
|
|
||||||
playPauseFab.setScaleX(0.9f);
|
|
||||||
playPauseFab.setScaleY(0.9f);
|
|
||||||
playPauseFab.setVisibility(View.VISIBLE);
|
|
||||||
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
||||||
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
playPauseFab.animate()
|
protected void updatePlayPauseDrawableState(boolean animate) {
|
||||||
.setDuration(200)
|
if (MusicPlayerRemote.isPlaying()) {
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
playerFabPlayPauseDrawable.setPause(animate);
|
||||||
.scaleX(1.1f)
|
} else {
|
||||||
.scaleY(1.1f)
|
playerFabPlayPauseDrawable.setPlay(animate);
|
||||||
.withEndAction(() -> playPauseFab.animate()
|
|
||||||
.setDuration(200)
|
|
||||||
.setInterpolator(new AccelerateInterpolator())
|
|
||||||
.scaleX(1f)
|
|
||||||
.scaleY(1f)
|
|
||||||
.alpha(1f)
|
|
||||||
.start())
|
|
||||||
.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.player_play_pause_button)
|
|
||||||
void showAnimation() {
|
|
||||||
if (MusicPlayerRemote.isPlaying()) {
|
|
||||||
MusicPlayerRemote.pauseSong();
|
|
||||||
} else {
|
|
||||||
MusicPlayerRemote.resumePlaying();
|
|
||||||
}
|
|
||||||
showBouceAnimation();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateProgressViews(int progress, int total) {
|
|
||||||
progressSlider.setMax(total);
|
|
||||||
|
|
||||||
ObjectAnimator animator = ObjectAnimator.ofInt(progressSlider, "progress", progress);
|
|
||||||
animator.setDuration(1500);
|
|
||||||
animator.setInterpolator(new LinearInterpolator());
|
|
||||||
animator.start();
|
|
||||||
|
|
||||||
songTotalTime.setText(MusicUtil.getReadableDurationString(total));
|
|
||||||
songCurrentProgress.setText(MusicUtil.getReadableDurationString(progress));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDark(int dark) {
|
|
||||||
int color = ATHUtil.resolveColor(getActivity(), android.R.attr.colorBackground);
|
|
||||||
if (ColorUtil.isColorLight(color)) {
|
|
||||||
lastPlaybackControlsColor =
|
|
||||||
MaterialValueHelper.getSecondaryTextColor(getActivity(), true);
|
|
||||||
lastDisabledPlaybackControlsColor =
|
|
||||||
MaterialValueHelper.getSecondaryDisabledTextColor(getActivity(), true);
|
|
||||||
} else {
|
|
||||||
lastPlaybackControlsColor =
|
|
||||||
MaterialValueHelper.getPrimaryTextColor(getActivity(), false);
|
|
||||||
lastDisabledPlaybackControlsColor =
|
|
||||||
MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) {
|
|
||||||
TintHelper.setTintAuto(playPauseFab, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)), false);
|
|
||||||
TintHelper.setTintAuto(playPauseFab, dark, true);
|
|
||||||
setProgressBarColor(progressSlider, dark);
|
|
||||||
}
|
|
||||||
updateRepeatState();
|
|
||||||
updateShuffleState();
|
|
||||||
updatePrevNextColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProgressBarColor(SeekBar progressBar, int newColor) {
|
|
||||||
LayerDrawable ld = (LayerDrawable) progressBar.getProgressDrawable();
|
|
||||||
ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
|
|
||||||
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpPlayPauseFab() {
|
|
||||||
playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity());
|
|
||||||
|
|
||||||
playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
|
|
||||||
//playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
|
|
||||||
//playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
|
|
||||||
playPauseFab.post(() -> {
|
|
||||||
if (playPauseFab != null) {
|
|
||||||
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
|
||||||
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updatePlayPauseDrawableState(boolean animate) {
|
|
||||||
if (MusicPlayerRemote.isPlaying()) {
|
|
||||||
playerFabPlayPauseDrawable.setPause(animate);
|
|
||||||
} else {
|
|
||||||
playerFabPlayPauseDrawable.setPlay(animate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package code.name.monkey.retromusic.ui.fragments.player.simple;
|
package code.name.monkey.retromusic.ui.fragments.player.simple;
|
||||||
|
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.ClipDrawable;
|
|
||||||
import android.graphics.drawable.LayerDrawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -12,9 +10,7 @@ import android.view.ViewGroup;
|
||||||
import android.view.animation.AccelerateInterpolator;
|
import android.view.animation.AccelerateInterpolator;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
@ -39,281 +35,288 @@ import code.name.monkey.retromusic.views.PlayPauseDrawable;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SimplePlaybackControlsFragment extends AbsPlayerControlsFragment {
|
public class SimplePlaybackControlsFragment extends AbsPlayerControlsFragment {
|
||||||
@BindView(R.id.player_play_pause_button)
|
|
||||||
ImageButton playPauseFab;
|
@BindView(R.id.player_play_pause_button)
|
||||||
@BindView(R.id.player_prev_button)
|
ImageButton playPauseFab;
|
||||||
ImageButton prevButton;
|
@BindView(R.id.player_prev_button)
|
||||||
@BindView(R.id.player_next_button)
|
ImageButton prevButton;
|
||||||
ImageButton nextButton;
|
@BindView(R.id.player_next_button)
|
||||||
@BindView(R.id.player_repeat_button)
|
ImageButton nextButton;
|
||||||
ImageButton repeatButton;
|
@BindView(R.id.player_repeat_button)
|
||||||
@BindView(R.id.player_shuffle_button)
|
ImageButton repeatButton;
|
||||||
ImageButton shuffleButton;
|
@BindView(R.id.player_shuffle_button)
|
||||||
@BindView(R.id.player_song_current_progress)
|
ImageButton shuffleButton;
|
||||||
TextView songCurrentProgress;
|
@BindView(R.id.player_song_current_progress)
|
||||||
@BindView(R.id.volume_fragment_container)
|
TextView songCurrentProgress;
|
||||||
View volumeContainer;
|
@BindView(R.id.volume_fragment_container)
|
||||||
@BindView(R.id.title)
|
View volumeContainer;
|
||||||
TextView title;
|
@BindView(R.id.title)
|
||||||
@BindView(R.id.text)
|
TextView title;
|
||||||
TextView text;
|
@BindView(R.id.text)
|
||||||
private Unbinder unbinder;
|
TextView text;
|
||||||
private PlayPauseDrawable playerFabPlayPauseDrawable;
|
private Unbinder unbinder;
|
||||||
private int lastPlaybackControlsColor;
|
private PlayPauseDrawable playerFabPlayPauseDrawable;
|
||||||
private int lastDisabledPlaybackControlsColor;
|
private int lastPlaybackControlsColor;
|
||||||
private MusicProgressViewUpdateHelper progressViewUpdateHelper;
|
private int lastDisabledPlaybackControlsColor;
|
||||||
|
private MusicProgressViewUpdateHelper progressViewUpdateHelper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayStateChanged() {
|
public void onPlayStateChanged() {
|
||||||
updatePlayPauseDrawableState(true);
|
updatePlayPauseDrawableState(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRepeatModeChanged() {
|
||||||
|
updateRepeatState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShuffleModeChanged() {
|
||||||
|
updateShuffleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected() {
|
||||||
|
updatePlayPauseDrawableState(false);
|
||||||
|
updateRepeatState();
|
||||||
|
updateShuffleState();
|
||||||
|
updateSong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
progressViewUpdateHelper = new MusicProgressViewUpdateHelper(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
unbinder.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_simple_controls_fragment, container, false);
|
||||||
|
unbinder = ButterKnife.bind(this, view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
progressViewUpdateHelper.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
progressViewUpdateHelper.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
setUpMusicControllers();
|
||||||
|
volumeContainer.setVisibility(
|
||||||
|
PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpMusicControllers() {
|
||||||
|
setUpPlayPauseFab();
|
||||||
|
setUpPrevNext();
|
||||||
|
setUpRepeatButton();
|
||||||
|
setUpShuffleButton();
|
||||||
|
setUpProgressSlider();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpPrevNext() {
|
||||||
|
updatePrevNextColor();
|
||||||
|
nextButton.setOnClickListener(v -> MusicPlayerRemote.playNextSong());
|
||||||
|
prevButton.setOnClickListener(v -> MusicPlayerRemote.back());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePrevNextColor() {
|
||||||
|
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
prevButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpShuffleButton() {
|
||||||
|
shuffleButton.setOnClickListener(v -> MusicPlayerRemote.toggleShuffleMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateShuffleState() {
|
||||||
|
switch (MusicPlayerRemote.getShuffleMode()) {
|
||||||
|
case MusicService.SHUFFLE_MODE_SHUFFLE:
|
||||||
|
shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpRepeatButton() {
|
||||||
|
repeatButton.setOnClickListener(v -> MusicPlayerRemote.cycleRepeatMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateRepeatState() {
|
||||||
|
switch (MusicPlayerRemote.getRepeatMode()) {
|
||||||
|
case MusicService.REPEAT_MODE_NONE:
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
||||||
|
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
case MusicService.REPEAT_MODE_ALL:
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
case MusicService.REPEAT_MODE_THIS:
|
||||||
|
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp);
|
||||||
|
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSong() {
|
||||||
|
Song song = MusicPlayerRemote.getCurrentSong();
|
||||||
|
title.setText(song.title);
|
||||||
|
text.setText(song.artistName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayingMetaChanged() {
|
||||||
|
super.onPlayingMetaChanged();
|
||||||
|
updateSong();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUpProgressSlider() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void show() {
|
||||||
|
playPauseFab.animate()
|
||||||
|
.scaleX(1f)
|
||||||
|
.scaleY(1f)
|
||||||
|
.rotation(360f)
|
||||||
|
.setInterpolator(new DecelerateInterpolator())
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void hide() {
|
||||||
|
if (playPauseFab != null) {
|
||||||
|
playPauseFab.setScaleX(0f);
|
||||||
|
playPauseFab.setScaleY(0f);
|
||||||
|
playPauseFab.setRotation(0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void showBouceAnimation() {
|
||||||
|
playPauseFab.clearAnimation();
|
||||||
|
|
||||||
|
playPauseFab.setScaleX(0.9f);
|
||||||
|
playPauseFab.setScaleY(0.9f);
|
||||||
|
playPauseFab.setVisibility(View.VISIBLE);
|
||||||
|
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
||||||
|
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
||||||
|
|
||||||
|
playPauseFab.animate()
|
||||||
|
.setDuration(200)
|
||||||
|
.setInterpolator(new DecelerateInterpolator())
|
||||||
|
.scaleX(1.1f)
|
||||||
|
.scaleY(1.1f)
|
||||||
|
.withEndAction(() -> playPauseFab.animate()
|
||||||
|
.setDuration(200)
|
||||||
|
.setInterpolator(new AccelerateInterpolator())
|
||||||
|
.scaleX(1f)
|
||||||
|
.scaleY(1f)
|
||||||
|
.alpha(1f)
|
||||||
|
.start())
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.player_play_pause_button)
|
||||||
|
void showAnimation() {
|
||||||
|
if (MusicPlayerRemote.isPlaying()) {
|
||||||
|
MusicPlayerRemote.pauseSong();
|
||||||
|
} else {
|
||||||
|
MusicPlayerRemote.resumePlaying();
|
||||||
|
}
|
||||||
|
showBouceAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdateProgressViews(int progress, int total) {
|
||||||
|
songCurrentProgress
|
||||||
|
.setText(String.format("%s / %s", MusicUtil.getReadableDurationString(progress),
|
||||||
|
MusicUtil.getReadableDurationString(total)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDark(int dark) {
|
||||||
|
int color = ATHUtil.resolveColor(getActivity(), android.R.attr.colorBackground);
|
||||||
|
if (ColorUtil.isColorLight(color)) {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper
|
||||||
|
.getSecondaryTextColor(getActivity(), true);
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper
|
||||||
|
.getSecondaryDisabledTextColor(getActivity(), true);
|
||||||
|
} else {
|
||||||
|
lastPlaybackControlsColor = MaterialValueHelper
|
||||||
|
.getPrimaryTextColor(getActivity(), false);
|
||||||
|
lastDisabledPlaybackControlsColor = MaterialValueHelper
|
||||||
|
.getPrimaryDisabledTextColor(getActivity(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) {
|
||||||
public void onRepeatModeChanged() {
|
TintHelper.setTintAuto(playPauseFab,
|
||||||
updateRepeatState();
|
MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)),
|
||||||
|
false);
|
||||||
|
TintHelper.setTintAuto(playPauseFab, dark, true);
|
||||||
|
text.setTextColor(dark);
|
||||||
|
} else {
|
||||||
|
int accentColor = ThemeStore.accentColor(getContext());
|
||||||
|
text.setTextColor(accentColor);
|
||||||
|
TintHelper.setTintAuto(playPauseFab,
|
||||||
|
MaterialValueHelper
|
||||||
|
.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(accentColor)),
|
||||||
|
false);
|
||||||
|
TintHelper.setTintAuto(playPauseFab, accentColor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
updateRepeatState();
|
||||||
public void onShuffleModeChanged() {
|
updateShuffleState();
|
||||||
updateShuffleState();
|
updatePrevNextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setUpPlayPauseFab() {
|
||||||
public void onServiceConnected() {
|
playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity());
|
||||||
updatePlayPauseDrawableState(false);
|
|
||||||
updateRepeatState();
|
|
||||||
updateShuffleState();
|
|
||||||
updateSong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
playPauseFab.setImageDrawable(
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
|
||||||
super.onCreate(savedInstanceState);
|
//playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
|
||||||
progressViewUpdateHelper = new MusicProgressViewUpdateHelper(this);
|
//playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
|
||||||
}
|
playPauseFab.post(() -> {
|
||||||
|
if (playPauseFab != null) {
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
super.onDestroyView();
|
|
||||||
unbinder.unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
||||||
View view = inflater.inflate(R.layout.fragment_simple_controls_fragment, container, false);
|
|
||||||
unbinder = ButterKnife.bind(this, view);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
progressViewUpdateHelper.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
progressViewUpdateHelper.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
setUpMusicControllers();
|
|
||||||
volumeContainer.setVisibility(PreferenceUtil.getInstance(getContext()).getVolumeToggle() ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpMusicControllers() {
|
|
||||||
setUpPlayPauseFab();
|
|
||||||
setUpPrevNext();
|
|
||||||
setUpRepeatButton();
|
|
||||||
setUpShuffleButton();
|
|
||||||
setUpProgressSlider();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpPrevNext() {
|
|
||||||
updatePrevNextColor();
|
|
||||||
nextButton.setOnClickListener(v -> MusicPlayerRemote.playNextSong());
|
|
||||||
prevButton.setOnClickListener(v -> MusicPlayerRemote.back());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePrevNextColor() {
|
|
||||||
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
prevButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpShuffleButton() {
|
|
||||||
shuffleButton.setOnClickListener(v -> MusicPlayerRemote.toggleShuffleMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateShuffleState() {
|
|
||||||
switch (MusicPlayerRemote.getShuffleMode()) {
|
|
||||||
case MusicService.SHUFFLE_MODE_SHUFFLE:
|
|
||||||
shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpRepeatButton() {
|
|
||||||
repeatButton.setOnClickListener(v -> MusicPlayerRemote.cycleRepeatMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateRepeatState() {
|
|
||||||
switch (MusicPlayerRemote.getRepeatMode()) {
|
|
||||||
case MusicService.REPEAT_MODE_NONE:
|
|
||||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
|
||||||
repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
case MusicService.REPEAT_MODE_ALL:
|
|
||||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp);
|
|
||||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
case MusicService.REPEAT_MODE_THIS:
|
|
||||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp);
|
|
||||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSong() {
|
|
||||||
Song song = MusicPlayerRemote.getCurrentSong();
|
|
||||||
title.setText(song.title);
|
|
||||||
text.setText(song.artistName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayingMetaChanged() {
|
|
||||||
super.onPlayingMetaChanged();
|
|
||||||
updateSong();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUpProgressSlider() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void show() {
|
|
||||||
playPauseFab.animate()
|
|
||||||
.scaleX(1f)
|
|
||||||
.scaleY(1f)
|
|
||||||
.rotation(360f)
|
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
|
||||||
.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void hide() {
|
|
||||||
if (playPauseFab != null) {
|
|
||||||
playPauseFab.setScaleX(0f);
|
|
||||||
playPauseFab.setScaleY(0f);
|
|
||||||
playPauseFab.setRotation(0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void showBouceAnimation() {
|
|
||||||
playPauseFab.clearAnimation();
|
|
||||||
|
|
||||||
playPauseFab.setScaleX(0.9f);
|
|
||||||
playPauseFab.setScaleY(0.9f);
|
|
||||||
playPauseFab.setVisibility(View.VISIBLE);
|
|
||||||
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
||||||
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
playPauseFab.animate()
|
protected void updatePlayPauseDrawableState(boolean animate) {
|
||||||
.setDuration(200)
|
if (MusicPlayerRemote.isPlaying()) {
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
playerFabPlayPauseDrawable.setPause(animate);
|
||||||
.scaleX(1.1f)
|
} else {
|
||||||
.scaleY(1.1f)
|
playerFabPlayPauseDrawable.setPlay(animate);
|
||||||
.withEndAction(() -> playPauseFab.animate()
|
|
||||||
.setDuration(200)
|
|
||||||
.setInterpolator(new AccelerateInterpolator())
|
|
||||||
.scaleX(1f)
|
|
||||||
.scaleY(1f)
|
|
||||||
.alpha(1f)
|
|
||||||
.start())
|
|
||||||
.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.player_play_pause_button)
|
|
||||||
void showAnimation() {
|
|
||||||
if (MusicPlayerRemote.isPlaying()) {
|
|
||||||
MusicPlayerRemote.pauseSong();
|
|
||||||
} else {
|
|
||||||
MusicPlayerRemote.resumePlaying();
|
|
||||||
}
|
|
||||||
showBouceAnimation();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateProgressViews(int progress, int total) {
|
|
||||||
songCurrentProgress.setText(String.format("%s / %s", MusicUtil.getReadableDurationString(progress),
|
|
||||||
MusicUtil.getReadableDurationString(total)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDark(int dark) {
|
|
||||||
int color = ATHUtil.resolveColor(getActivity(), android.R.attr.colorBackground);
|
|
||||||
if (ColorUtil.isColorLight(color)) {
|
|
||||||
lastPlaybackControlsColor = MaterialValueHelper
|
|
||||||
.getSecondaryTextColor(getActivity(), true);
|
|
||||||
lastDisabledPlaybackControlsColor = MaterialValueHelper
|
|
||||||
.getSecondaryDisabledTextColor(getActivity(), true);
|
|
||||||
} else {
|
|
||||||
lastPlaybackControlsColor = MaterialValueHelper
|
|
||||||
.getPrimaryTextColor(getActivity(), false);
|
|
||||||
lastDisabledPlaybackControlsColor = MaterialValueHelper
|
|
||||||
.getPrimaryDisabledTextColor(getActivity(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) {
|
|
||||||
TintHelper.setTintAuto(playPauseFab, MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(dark)), false);
|
|
||||||
TintHelper.setTintAuto(playPauseFab, dark, true);
|
|
||||||
text.setTextColor(dark);
|
|
||||||
} else {
|
|
||||||
text.setTextColor(ThemeStore.accentColor(getContext()));
|
|
||||||
}
|
|
||||||
|
|
||||||
updateRepeatState();
|
|
||||||
updateShuffleState();
|
|
||||||
updatePrevNextColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProgressBarColor(SeekBar progressBar, int newColor) {
|
|
||||||
LayerDrawable ld = (LayerDrawable) progressBar.getProgressDrawable();
|
|
||||||
ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
|
|
||||||
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpPlayPauseFab() {
|
|
||||||
playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity());
|
|
||||||
|
|
||||||
playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
|
|
||||||
//playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
|
|
||||||
//playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
|
|
||||||
playPauseFab.post(() -> {
|
|
||||||
if (playPauseFab != null) {
|
|
||||||
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
|
|
||||||
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updatePlayPauseDrawableState(boolean animate) {
|
|
||||||
if (MusicPlayerRemote.isPlaying()) {
|
|
||||||
playerFabPlayPauseDrawable.setPause(animate);
|
|
||||||
} else {
|
|
||||||
playerFabPlayPauseDrawable.setPlay(animate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,18 +87,15 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/aapt_friendly_merged_manifests" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/aapt_friendly_merged_manifests" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotation_processor_list" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotation_processor_list" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations_typedef_file" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations_zip" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/consumer_proguard_file" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/consumer_proguard_file" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_and_local_jars_jni" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_assets" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/library_assets" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged-classes" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged_res" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged_res" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/platform_r_txt" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/platform_r_txt" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/public_res" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/public_res" />
|
||||||
|
@ -111,7 +108,7 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 27 Platform (1)" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:transition-27.1.1" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:transition-27.1.1" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
|
||||||
|
|
|
@ -7,7 +7,7 @@ buildscript {
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.0-alpha15'
|
classpath 'com.android.tools.build:gradle:3.2.0-alpha18'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
#Mon May 14 20:13:41 IST 2018
|
#Fri Jul 27 20:58:25 IST 2018
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
|
@ -6,42 +6,6 @@
|
||||||
##
|
##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS=""
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn ( ) {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die ( ) {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
PRG="$0"
|
||||||
|
@ -60,6 +24,46 @@ cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
APP_HOME="`pwd -P`"
|
APP_HOME="`pwd -P`"
|
||||||
cd "$SAVED" >/dev/null
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
|
@ -85,7 +89,7 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
@ -150,11 +154,19 @@ if $cygwin ; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
# Escape application args
|
||||||
function splitJvmOpts() {
|
save () {
|
||||||
JVM_OPTS=("$@")
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
}
|
}
|
||||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
APP_ARGS=$(save "$@")
|
||||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
|
||||||
|
|
||||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS=
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
@ -46,10 +46,9 @@ echo location of your Java installation.
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
:init
|
||||||
@rem Get command-line arguments, handling Windowz variants
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
|
||||||
|
|
||||||
:win9xME_args
|
:win9xME_args
|
||||||
@rem Slurp the command line arguments.
|
@rem Slurp the command line arguments.
|
||||||
|
@ -60,11 +59,6 @@ set _SKIP=2
|
||||||
if "x%~1" == "x" goto execute
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
set CMD_LINE_ARGS=%*
|
||||||
goto execute
|
|
||||||
|
|
||||||
:4NT_args
|
|
||||||
@rem Get arguments from the 4NT Shell from JP Software
|
|
||||||
set CMD_LINE_ARGS=%$
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# This API key is provided for convenience. Please go to https://www.last.fm/api/account/create and create your own.
|
|
||||||
|
|
||||||
GOOGLE_PLAY_LICENSE_KEY = MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnWuCg0k+BBB25J7vZUZeTf5sxzSzJhXLdyj9zRKr2k0Xf/RNAmqSXTfshQiP5dZyTeJ+cpRP4xeKijW66/bTwKgH3h0x48pgn7tQMIEdH9KaZUlPzHH9pcp+N9iJlKhX+vacZUpbnlOp0PjrJXP1Xg6gz1gs3nMDhX1z5Tr4vPKd+Wf7E3tyTc15jpfqSKSzqYzIlT4VFdcmLcPypCwRzgRzWOGqj3/oz8rxLCQ4bxtDHwtZhHAz/N6go5oZodpfrA2ETiyeNsqta2Xmwt38CyYukSQ+eYJ2irZ5wqnr1iN9duzZRfMi7id+tgC8iwicDSanUiYFt/r43C0UkGNx6wIDAQAB
|
|
||||||
LASTFM_API_KEY=206993ea109315882749d5bc7b2e704d
|
|
||||||
LASTFM_API_KEY_NEW=17c9e96bc741842d7fc84d3961a25a04
|
|
Loading…
Reference in New Issue