Skip to content

Commit

Permalink
added leakcanary library and refactored customview
Browse files Browse the repository at this point in the history
  • Loading branch information
apprajapati9 committed Sep 30, 2023
1 parent 4eb729c commit 4bcd150
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ dependencies {
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
//Gson - converterfactor
implementation ("com.squareup.retrofit2:converter-gson:2.9.0")
debugImplementation ("com.squareup.leakcanary:leakcanary-android:2.12")
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ import android.os.Looper
import android.util.AttributeSet
import android.util.Log
import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator
import android.view.animation.AccelerateInterpolator
import android.view.animation.AlphaAnimation
import android.view.animation.AnticipateInterpolator
import android.view.animation.DecelerateInterpolator
import androidx.core.content.ContextCompat
import androidx.core.graphics.blue
import androidx.core.graphics.green
import androidx.core.graphics.red
import androidx.core.view.updateLayoutParams

class CircularLoadingView(context: Context, attributeSet: AttributeSet) :
View(context, attributeSet), Runnable {
View(context, attributeSet) {

private val centerXY = PointF(0f, 0f)

Expand All @@ -29,13 +34,9 @@ class CircularLoadingView(context: Context, attributeSet: AttributeSet) :
set(value) {
field = value //value can only be changed when that's above 100.
}

val viewRect: RectF = RectF()
var radius = 0f
var outerCircleRadius = 0f

var valueAnimator = ValueAnimator()
var fadeAnimator = ValueAnimator()
var circleColor = Color.WHITE
var animationDuration = 1000
var circleWidth = 15f
Expand Down Expand Up @@ -103,8 +104,8 @@ class CircularLoadingView(context: Context, attributeSet: AttributeSet) :
}

fun PointF.getCenterXY() {
x = width.toFloat().div(2) //width/2).toFloat()
y = height.toFloat().div(2) //height/2).toFloat()
x = width.toFloat().div(2)
y = height.toFloat().div(2)
}

private fun getColorRange(): PropertyValuesHolder {
Expand All @@ -122,15 +123,14 @@ class CircularLoadingView(context: Context, attributeSet: AttributeSet) :

handler.postDelayed({
shownOuter = true
}, 500)
}, 300)

valueAnimator = ValueAnimator().apply {
val valueAnimator = ValueAnimator().apply {
setValues(valuesHolder, colorValues)
duration = animationDuration.toLong()
repeatCount = ValueAnimator.INFINITE

interpolator = DecelerateInterpolator(2f) //10f does give some interesting effects

addUpdateListener {
val colors = it.getAnimatedValue("colorValues") as Int
mCirclePaint.color = Color.rgb(colors, colors, colors)
Expand All @@ -145,13 +145,4 @@ class CircularLoadingView(context: Context, attributeSet: AttributeSet) :
valueAnimator.start()
}


override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
valueAnimator.end()
}

override fun run() {
TODO("Not yet implemented")
}
}

0 comments on commit 4bcd150

Please sign in to comment.