diff --git a/.gradle/5.1.1/executionHistory/executionHistory.bin b/.gradle/5.1.1/executionHistory/executionHistory.bin
index b801bf6..52d68a9 100644
Binary files a/.gradle/5.1.1/executionHistory/executionHistory.bin and b/.gradle/5.1.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/5.1.1/executionHistory/executionHistory.lock b/.gradle/5.1.1/executionHistory/executionHistory.lock
index 1bfbac2..6bcd3fb 100644
Binary files a/.gradle/5.1.1/executionHistory/executionHistory.lock and b/.gradle/5.1.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/5.1.1/fileHashes/fileHashes.bin b/.gradle/5.1.1/fileHashes/fileHashes.bin
index fcb03c8..e6c41f8 100644
Binary files a/.gradle/5.1.1/fileHashes/fileHashes.bin and b/.gradle/5.1.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/5.1.1/fileHashes/fileHashes.lock b/.gradle/5.1.1/fileHashes/fileHashes.lock
index 58e966f..cf5bc1c 100644
Binary files a/.gradle/5.1.1/fileHashes/fileHashes.lock and b/.gradle/5.1.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/5.1.1/fileHashes/resourceHashesCache.bin b/.gradle/5.1.1/fileHashes/resourceHashesCache.bin
index cc01edb..e65c13e 100644
Binary files a/.gradle/5.1.1/fileHashes/resourceHashesCache.bin and b/.gradle/5.1.1/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/5.1.1/javaCompile/classAnalysis.bin b/.gradle/5.1.1/javaCompile/classAnalysis.bin
index cc1d19d..1841da3 100644
Binary files a/.gradle/5.1.1/javaCompile/classAnalysis.bin and b/.gradle/5.1.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/5.1.1/javaCompile/jarAnalysis.bin b/.gradle/5.1.1/javaCompile/jarAnalysis.bin
index 0eb407b..eed8bd5 100644
Binary files a/.gradle/5.1.1/javaCompile/jarAnalysis.bin and b/.gradle/5.1.1/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/5.1.1/javaCompile/javaCompile.lock b/.gradle/5.1.1/javaCompile/javaCompile.lock
index 6a8e842..3becbf9 100644
Binary files a/.gradle/5.1.1/javaCompile/javaCompile.lock and b/.gradle/5.1.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/5.1.1/javaCompile/taskHistory.bin b/.gradle/5.1.1/javaCompile/taskHistory.bin
index 3cdd701..3abd858 100644
Binary files a/.gradle/5.1.1/javaCompile/taskHistory.bin and b/.gradle/5.1.1/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index de811fe..d5ffb52 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 1a7ee69..8286c97 100644
Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/libraries/Gradle__androidx_annotation_annotation_1_0_2_jar.xml b/.idea/libraries/Gradle__androidx_annotation_annotation_1_0_2_jar.xml
new file mode 100644
index 0000000..ee64971
--- /dev/null
+++ b/.idea/libraries/Gradle__androidx_annotation_annotation_1_0_2_jar.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml b/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml
deleted file mode 100644
index ffab512..0000000
--- a/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__androidx_core_core_1_2_0_alpha03_aar.xml b/.idea/libraries/Gradle__androidx_core_core_1_0_2_aar.xml
similarity index 52%
rename from .idea/libraries/Gradle__androidx_core_core_1_2_0_alpha03_aar.xml
rename to .idea/libraries/Gradle__androidx_core_core_1_0_2_aar.xml
index 2a9a0c8..0236120 100644
--- a/.idea/libraries/Gradle__androidx_core_core_1_2_0_alpha03_aar.xml
+++ b/.idea/libraries/Gradle__androidx_core_core_1_0_2_aar.xml
@@ -1,15 +1,15 @@
-
+
-
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__androidx_core_core_ktx_1_0_2_aar.xml b/.idea/libraries/Gradle__androidx_core_core_ktx_1_0_2_aar.xml
new file mode 100644
index 0000000..6f02132
--- /dev/null
+++ b/.idea/libraries/Gradle__androidx_core_core_ktx_1_0_2_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__androidx_core_core_ktx_1_2_0_alpha03_aar.xml b/.idea/libraries/Gradle__androidx_core_core_ktx_1_2_0_alpha03_aar.xml
deleted file mode 100644
index 64faeac..0000000
--- a/.idea/libraries/Gradle__androidx_core_core_ktx_1_2_0_alpha03_aar.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_rc01_aar.xml b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_0_0_aar.xml
similarity index 54%
rename from .idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_rc01_aar.xml
rename to .idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_0_0_aar.xml
index e9d37ef..03ba165 100644
--- a/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_rc01_aar.xml
+++ b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_0_0_aar.xml
@@ -1,12 +1,12 @@
-
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8c80347..bdef86e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,7 +6,7 @@
-
+
@@ -50,8 +50,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -83,20 +98,66 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -106,9 +167,10 @@
@@ -129,6 +191,16 @@
mSqueezebarColor
getColor
MAX_WIDTH_SQUEEZEBAR
+ protected sy
+ onAttac
+ onWindowVisibilityChanged
+ onWin
+ context
+ inva
+ INVISIBLE
+ INVISIBL
+ mSqueezebarDisplacement
+ mSqueezebarAnimator
Squeeze
@@ -147,8 +219,6 @@
-
-
@@ -159,9 +229,19 @@
-
+
+
+
+
+
+
+
+
+
+
+
@@ -171,29 +251,39 @@
-
+
-
-
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
@@ -208,32 +298,31 @@
-
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
@@ -250,6 +339,14 @@
+
+
+
+
+
+
+
+
@@ -318,7 +415,7 @@
-
+
@@ -398,7 +495,7 @@
-
+
@@ -413,7 +510,7 @@
-
+
@@ -439,20 +536,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -572,95 +655,162 @@
-
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/app.iml b/app/app.iml
index 3d8e878..2151d7b 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -29,7 +29,7 @@
-
+
@@ -183,14 +183,10 @@
-
-
-
-
@@ -200,18 +196,22 @@
+
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index cd1182e..ca8db4e 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:gravity="center">
@@ -11,4 +11,5 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
+
\ No newline at end of file
diff --git a/squeezeloader/build.gradle b/squeezeloader/build.gradle
index 4dd42be..f083293 100644
--- a/squeezeloader/build.gradle
+++ b/squeezeloader/build.gradle
@@ -29,7 +29,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
- implementation "androidx.core:core-ktx:+"
+ implementation "androidx.core:core-ktx:1.0.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
diff --git a/squeezeloader/squeezeloader.iml b/squeezeloader/squeezeloader.iml
index 49d3e41..c5b0698 100644
--- a/squeezeloader/squeezeloader.iml
+++ b/squeezeloader/squeezeloader.iml
@@ -30,7 +30,7 @@
-
+
@@ -151,7 +151,6 @@
-
@@ -167,6 +166,7 @@
+
@@ -179,21 +179,21 @@
+
+
-
-
+
-
diff --git a/squeezeloader/src/main/java/com/mecofarid/squeezeloader/SqueezeLoader.kt b/squeezeloader/src/main/java/com/mecofarid/squeezeloader/SqueezeLoader.kt
index a9537f3..4a4b91a 100644
--- a/squeezeloader/src/main/java/com/mecofarid/squeezeloader/SqueezeLoader.kt
+++ b/squeezeloader/src/main/java/com/mecofarid/squeezeloader/SqueezeLoader.kt
@@ -3,16 +3,20 @@ package com.mecofarid.squeezeloader
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.*
+import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.View
+import android.widget.ProgressBar
+import androidx.annotation.UiThread
import androidx.core.content.ContextCompat
+import androidx.core.view.ViewCompat
import kotlin.math.min
class SqueezeLoader @kotlin.jvm.JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
- defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr) {
+ defStyleAttr: Int = 0): ProgressBar(context, attrs, defStyleAttr) {
// Min width of SqueezeLoader: 200dp
val MIN_WIDTH_SQUEEZELOADER = resources.getDimension(R.dimen.sl_default_squeezeloader_width).toInt()
@@ -30,11 +34,13 @@ class SqueezeLoader @kotlin.jvm.JvmOverloads constructor(
val attributes = context.obtainStyledAttributes(attrs, R.styleable.SqueezeLoader, defStyleAttr, 0)
val mSqueezebarColor = attributes.getColor(R.styleable.SqueezeLoader_sl_colorSqueezebar,
ContextCompat.getColor(context, R.color.sl_default_color))
+
// Animation duration cannot be less than minimum animation duration of this library
val mAnimatioDuration = Math.max(attributes.getInteger(R.styleable.SqueezeLoader_sl_animationDuration,
DEFAULT_ANIMATION_DURATION), DEFAULT_ANIMATION_DURATION).toLong()
+
// NOTE: maximum visible squeezebar width would be half of given value because the greatest squeezefactor
- // value is 0.5. That's why I'm multiplying it by 2 check out `squeezefactor` calculation logic in this file
+ // value is 0.5. That's why we're multiplying it by 2 check out `squeezefactor` calculation logic in this file
// PLUS: Max width of SqueezeBar cannot be biger than MAX_WIDTH_SQUEEZEBAR
val mSqueezebarWidth = 2 * min(
attributes.getDimension(R.styleable.SqueezeLoader_sl_squeezebarWidth, DEFAULT_WIDTH_SQUEEZEBAR),
@@ -46,11 +52,12 @@ class SqueezeLoader @kotlin.jvm.JvmOverloads constructor(
style = Paint.Style.FILL_AND_STROKE
strokeWidth = MIN_WIDTH_SQUEEZEBAR
}
+
var mSqueezebarAnimator: ValueAnimator? = null
private var mSqueezebarDisplacement = 0f
set(value) {
field = value
- invalidate()
+ ViewCompat.postInvalidateOnAnimation(this)
}
private var mAnimationFraction = 0f
private var mSqueezebarHeight = 0
@@ -65,18 +72,25 @@ class SqueezeLoader @kotlin.jvm.JvmOverloads constructor(
super.onDetachedFromWindow()
}
+ override fun onWindowVisibilityChanged(visibility: Int) {
+ super.onWindowVisibilityChanged(visibility)
+ mSqueezebarAnimator?.let {
+ if (it.isStarted && visibility in setOf(View.INVISIBLE, View.GONE)){
+ it.cancel()
+ }else if (it.isStarted.not() && visibility == View.VISIBLE) {
+ it.start()
+ }
+ }
+ }
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
- // Math squeezebar's height to SqueezzeLoader view's height
+ // Match squeezebar's height to SqueezzeLoader view's height
mSqueezebarHeight = Math.max(MIN_HEIGHT_SQUEEZEBAR, h)
mSqueezebarAnimator = ValueAnimator.ofFloat(0f, w.toFloat()).apply {
addUpdateListener {
mSqueezebarDisplacement = (it.animatedValue as Float)
mAnimationFraction = it.animatedFraction
- if (mSqueezebarDisplacement<=1 || (mSqueezebarDisplacement>=170&&mSqueezebarDisplacement<=190) ||
- (mSqueezebarDisplacement>=350&&mSqueezebarDisplacement<=370) ||
- (mSqueezebarDisplacement>=470&&mSqueezebarDisplacement<=490) || mSqueezebarDisplacement>=716) {
- println("Josiah time " + mAnimationFraction + " " + mSqueezebarDisplacement)
- }
+ println("Josiah animation ")
}
duration = mAnimatioDuration
repeatMode = ValueAnimator.REVERSE
@@ -86,8 +100,8 @@ class SqueezeLoader @kotlin.jvm.JvmOverloads constructor(
}
}
+ @Synchronized
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
-
val widthSize = MeasureSpec.getSize(widthMeasureSpec)
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
val heightSize = MeasureSpec.getSize(heightMeasureSpec)
@@ -102,13 +116,15 @@ class SqueezeLoader @kotlin.jvm.JvmOverloads constructor(
height = heightSize;
} else {
//Height cannot be less than minimum SqueezeLoader height
- height = Math.min(MIN_HEIGHT_SQUEEZEBAR, heightSize)
+ height = Math.min(MIN_HEIGHT_SQUEEZEBAR, heightSize)
}
//MUST CALL THIS
setMeasuredDimension(width, height)
}
+ @Synchronized
override fun onDraw(canvas: Canvas) {
+ println("Josiah ondraw")
super.onDraw(canvas)
//draw Squeezebar
val currentCenterPositionX = mSqueezebarDisplacement
diff --git a/squeezeloader/src/main/res/values/animator.xml b/squeezeloader/src/main/res/values/animator.xml
new file mode 100644
index 0000000..55344e5
--- /dev/null
+++ b/squeezeloader/src/main/res/values/animator.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file