From e2bd48ad3d9f3a1a7e8e1da7279bcef2beb29db1 Mon Sep 17 00:00:00 2001 From: thrashedbrain <47290965+thrashedbrain@users.noreply.github.com> Date: Mon, 11 Jan 2021 04:01:05 +0700 Subject: [PATCH] Fix colorfade --- app/build.gradle | 3 ++- .../main/java/com/thrashedbrain/gradient/MainActivity.java | 2 +- .../gradientbackground/GradientBackground.java | 6 ++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index da2f4bf..75acdd4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,7 +27,8 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation 'com.github.thrashedbrain:GradientBackground:0.1' + implementation 'com.github.thrashedbrain:GradientBackground:0.2' + //implementation project (':gradientbackground') testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' diff --git a/app/src/main/java/com/thrashedbrain/gradient/MainActivity.java b/app/src/main/java/com/thrashedbrain/gradient/MainActivity.java index 41d92f6..4800b89 100644 --- a/app/src/main/java/com/thrashedbrain/gradient/MainActivity.java +++ b/app/src/main/java/com/thrashedbrain/gradient/MainActivity.java @@ -22,7 +22,7 @@ protected void onCreate(Bundle savedInstanceState) { gradBg = new GradientBackground.Builder() .addColor("#48cae4", "#023e8a") .addColor("#006400", "#38b000") - .setDuration(10000) + .setDuration(8000) .build(); gradBg.init(); gradBg.start(constraintLayout); diff --git a/gradientbackground/src/main/java/com/thrashedbrain/gradientbackground/GradientBackground.java b/gradientbackground/src/main/java/com/thrashedbrain/gradientbackground/GradientBackground.java index f7dda1b..356ecde 100644 --- a/gradientbackground/src/main/java/com/thrashedbrain/gradientbackground/GradientBackground.java +++ b/gradientbackground/src/main/java/com/thrashedbrain/gradientbackground/GradientBackground.java @@ -3,9 +3,6 @@ import android.graphics.Color; import android.graphics.drawable.AnimationDrawable; import android.view.View; -import android.widget.FrameLayout; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; import java.util.ArrayList; import java.util.List; @@ -74,10 +71,11 @@ public void init(int radius){ drawable.setCornerRadius((float) radius); animationDrawable.addFrame(drawable, duration); } - animationDrawable.setExitFadeDuration(duration); + } public void start(View view){ + animationDrawable.setExitFadeDuration(duration); view.setBackground(animationDrawable); }