File tree Expand file tree Collapse file tree 5 files changed +35
-11
lines changed
app/src/main/java/com/agrawalsuneet/loaders
src/main/java/com/agrawalsuneet/loaderspack Expand file tree Collapse file tree 5 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ Check all other loaders [here](https://agrawalsuneet.github.io/agrawalsuneet/ope
3232## How To use
3333include below dependency in build.gradle of application and compile it
3434```
35- implementation 'com.agrawalsuneet.androidlibs:loaderspack:1.2.2 '
35+ implementation 'com.agrawalsuneet.androidlibs:loaderspack:1.2.3 '
3636```
3737
3838
Original file line number Diff line number Diff line change @@ -4,22 +4,20 @@ import android.os.Bundle
44import android.os.Handler
55import android.support.v4.content.ContextCompat
66import android.support.v7.app.AppCompatActivity
7- import android.view.View
87import android.view.animation.Animation
98import android.view.animation.BounceInterpolator
109import android.view.animation.LinearInterpolator
1110import android.view.animation.RotateAnimation
1211import android.widget.LinearLayout
1312import com.agrawalsuneet.loaderspack.loaders.*
14- import kotlinx.android.synthetic.main.main_curves.*
1513
1614class MainActivity : AppCompatActivity () {
1715
1816 lateinit var containerLayout: LinearLayout
1917
2018 override fun onCreate (savedInstanceState : Bundle ? ) {
2119 super .onCreate(savedInstanceState)
22- setContentView(R .layout.main_curves )
20+ setContentView(R .layout.activity_main_circular )
2321
2422 supportActionBar?.setTitle(" CurvesLoader" )
2523
Original file line number Diff line number Diff line change @@ -8,19 +8,17 @@ repositories {
88ext {
99 PUBLISH_GROUP_ID = ' com.agrawalsuneet.androidlibs'
1010 PUBLISH_ARTIFACT_ID = ' loaderspack'
11- PUBLISH_VERSION = ' 1.2.2 '
11+ PUBLISH_VERSION = ' 1.2.3 '
1212}
1313
1414android {
1515 compileSdkVersion 28
16- buildToolsVersion ' 28.0.2'
17-
1816
1917 defaultConfig {
2018 minSdkVersion 16
2119 targetSdkVersion 28
22- versionCode 14
23- versionName " 1.2.2 "
20+ versionCode 15
21+ versionName " 1.2.3 "
2422 }
2523
2624 buildTypes {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import android.view.View
99import com.agrawalsuneet.dotsloader.utils.Helper
1010import com.agrawalsuneet.loaderspack.R
1111import com.agrawalsuneet.loaderspack.contracts.CircularSticksAbstractView
12+ import com.agrawalsuneet.loaderspack.utils.Utils
1213import java.util.*
1314
1415/* *
@@ -73,6 +74,9 @@ class CircularSticksLoader : CircularSticksAbstractView {
7374
7475 private var timer: Timer ? = null
7576
77+ var isAnimating: Boolean = false
78+ private set
79+
7680 constructor (context: Context ) : super (context) {
7781 initPaints()
7882 }
@@ -136,7 +140,8 @@ class CircularSticksLoader : CircularSticksAbstractView {
136140
137141 if (visibility != VISIBLE ) {
138142 timer?.cancel()
139- } else if (shouldAnimate) {
143+ isAnimating = false
144+ } else if (shouldAnimate) {
140145 scheduleTimer()
141146 }
142147 }
@@ -210,6 +215,7 @@ class CircularSticksLoader : CircularSticksAbstractView {
210215 fun stopAnimation () {
211216 shouldAnimate = false
212217 timer?.cancel()
218+ isAnimating = false
213219 }
214220
215221 private fun scheduleTimer () {
@@ -222,8 +228,10 @@ class CircularSticksLoader : CircularSticksAbstractView {
222228 selectedStickPos = 1
223229 }
224230
225- (context as Activity ) .runOnUiThread { invalidate() }
231+ (Utils .scanForActivity( context))? .runOnUiThread { invalidate() }
226232 }
227233 }, 0 , animDuration.toLong())
234+
235+ isAnimating = true
228236 }
229237}
Original file line number Diff line number Diff line change 1+ package com.agrawalsuneet.loaderspack.utils
2+
3+ import android.content.ContextWrapper
4+ import android.app.Activity
5+ import android.content.Context
6+
7+
8+ object Utils {
9+
10+ fun scanForActivity (context : Context ? ): Activity ? {
11+ return when (context) {
12+ null -> null
13+ is Activity -> context
14+ is ContextWrapper -> scanForActivity(context.baseContext)
15+ else -> null
16+ }
17+
18+ }
19+
20+ }
You can’t perform that action at this time.
0 commit comments