Skip to content

Commit 63bf80e

Browse files
committed
finalized view
1 parent af919a3 commit 63bf80e

File tree

6 files changed

+88
-101
lines changed

6 files changed

+88
-101
lines changed

app/src/main/java/com/agrawalsuneet/squareloaders/MainActivity.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MainActivity : AppCompatActivity() {
2323

2424
setContentView(R.layout.activity_usainbolt)
2525

26-
supportActionBar?.title = "SquareGridLoader"
26+
supportActionBar?.title = "UsainBoltLoader"
2727

2828
container = findViewById(R.id.container)
2929

@@ -37,9 +37,21 @@ class MainActivity : AppCompatActivity() {
3737
//initControls();
3838

3939
//initSquareGridLoader()
40+
//initUsainBoltLoader()
4041
}
4142

42-
private fun initSquareGridLoader(){
43+
private fun initUsainBoltLoader() {
44+
val usainBoltLoader = UsainBoltLoader(this,
45+
60, ContextCompat.getColor(this, R.color.purple))
46+
.apply {
47+
animDuration = 1000
48+
interpolator = LinearInterpolator()
49+
}
50+
51+
container.addView(usainBoltLoader)
52+
}
53+
54+
private fun initSquareGridLoader() {
4355
val squareGridLoader = SquareGridLoader(
4456
this,
4557
3,

app/src/main/res/layout/activity_usainbolt.xml

Lines changed: 41 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,99 +7,61 @@
77
android:gravity="center"
88
android:orientation="vertical">
99

10-
<!-- <LinearLayout
11-
android:layout_width="match_parent"
12-
android:layout_height="wrap_content"
13-
android:layout_margin="16dp"
14-
android:gravity="center"
15-
android:orientation="horizontal">
16-
17-
18-
<com.agrawalsuneet.squareloaderspack.loaders.ZipZapLoader
19-
android:layout_width="wrap_content"
20-
android:layout_height="wrap_content"
21-
app:zipzap_animDuration="100"
22-
app:zipzap_firstSquareColor="@color/red"
23-
app:zipzap_forthSquareColor="@color/red"
24-
app:zipzap_fromScale="0.9"
25-
app:zipzap_secondSquareColor="@color/red"
26-
app:zipzap_squareLength="30dp"
27-
app:zipzap_startLoadingDefault="true"
28-
app:zipzap_thirdSquareColor="@color/red"
29-
app:zipzap_toScale="0.8" />
30-
31-
<com.agrawalsuneet.squareloaderspack.loaders.ZipZapLoader
32-
android:layout_width="wrap_content"
33-
android:layout_height="wrap_content"
34-
android:layout_marginLeft="16dp"
35-
android:layout_marginRight="16dp"
36-
app:zipzap_animDuration="100"
37-
app:zipzap_firstSquareColor="@color/amber"
38-
app:zipzap_forthSquareColor="@color/amber"
39-
app:zipzap_fromScale="0.9"
40-
app:zipzap_secondSquareColor="@color/amber"
41-
app:zipzap_squareLength="30dp"
42-
app:zipzap_startLoadingDefault="true"
43-
app:zipzap_thirdSquareColor="@color/amber"
44-
app:zipzap_toScale="0.8" />
45-
46-
<com.agrawalsuneet.squareloaderspack.loaders.ZipZapLoader
47-
android:layout_width="wrap_content"
48-
android:layout_height="wrap_content"
49-
app:zipzap_animDuration="100"
50-
app:zipzap_firstSquareColor="@color/green"
51-
app:zipzap_forthSquareColor="@color/green"
52-
app:zipzap_fromScale="0.9"
53-
app:zipzap_secondSquareColor="@color/green"
54-
app:zipzap_squareLength="30dp"
55-
app:zipzap_startLoadingDefault="true"
56-
app:zipzap_thirdSquareColor="@color/green"
57-
app:zipzap_toScale="0.8" />
58-
59-
60-
</LinearLayout>-->
61-
62-
<!--<RelativeLayout
63-
android:layout_width="160dp"
64-
android:layout_height="160dp">
10+
<LinearLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:layout_margin="16dp"
14+
android:gravity="center"
15+
android:orientation="horizontal">
6516

66-
<ImageView
67-
android:layout_width="16dp"
68-
android:layout_height="32dp"
69-
android:layout_alignParentBottom="true"
70-
android:layout_centerHorizontal="true"
71-
android:background="@color/green"/>
7217

73-
<LinearLayout
18+
<com.agrawalsuneet.squareloaderspack.loaders.UsainBoltLoader
7419
android:layout_width="wrap_content"
7520
android:layout_height="wrap_content"
76-
android:layout_centerHorizontal="true"
77-
android:paddingRight="32dp"
78-
>
21+
app:usainbolt_animDuration="500"
22+
app:usainbolt_interpolator="@android:interpolator/linear"
23+
app:usainbolt_rectangleColor="@color/red"
24+
app:usainbolt_rectangleWidth="6dp"
25+
android:layout_margin="8dp"/>
7926

80-
<ImageView
81-
android:layout_width="16dp"
82-
android:layout_height="32dp"
27+
<com.agrawalsuneet.squareloaderspack.loaders.UsainBoltLoader
28+
android:layout_width="wrap_content"
29+
android:layout_height="wrap_content"
30+
app:usainbolt_animDuration="500"
31+
app:usainbolt_interpolator="@android:interpolator/linear"
32+
app:usainbolt_rectangleColor="@color/amber"
33+
app:usainbolt_rectangleWidth="6dp"
34+
android:layout_margin="8dp"/>
8335

84-
android:background="@color/red" />
85-
</LinearLayout>
36+
<com.agrawalsuneet.squareloaderspack.loaders.UsainBoltLoader
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
app:usainbolt_animDuration="500"
40+
app:usainbolt_interpolator="@android:interpolator/linear"
41+
app:usainbolt_rectangleColor="@color/green"
42+
app:usainbolt_rectangleWidth="6dp"
43+
android:layout_margin="8dp"/>
8644

87-
</RelativeLayout>
8845

46+
</LinearLayout>
8947

90-
<com.agrawalsuneet.squareloaderspack.basicviews.LShapeView
48+
<com.agrawalsuneet.squareloaderspack.loaders.UsainBoltLoader
9149
android:layout_width="wrap_content"
9250
android:layout_height="wrap_content"
93-
android:layout_margin="16dp"
94-
app:baseRectHeight="16dp"
95-
app:baseRectWidth="72dp"
96-
app:lShapeColor="@color/indigo"
97-
app:verticalRectHeight="72dp"
98-
app:verticalRectWidth="16dp" />-->
51+
app:usainbolt_animDuration="400"
52+
app:usainbolt_interpolator="@android:interpolator/linear"
53+
app:usainbolt_rectangleColor="@color/blue"
54+
app:usainbolt_rectangleWidth="18dp"
55+
android:layout_margin="8dp"/>
9956

10057
<com.agrawalsuneet.squareloaderspack.loaders.UsainBoltLoader
10158
android:layout_width="wrap_content"
102-
android:layout_height="wrap_content" />
59+
android:layout_height="wrap_content"
60+
app:usainbolt_animDuration="300"
61+
app:usainbolt_interpolator="@android:interpolator/linear"
62+
app:usainbolt_rectangleColor="@color/grey"
63+
app:usainbolt_rectangleWidth="16dp"
64+
android:layout_margin="8dp"/>
10365

10466

10567
</LinearLayout>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.3.0'
10+
classpath 'com.android.tools.build:gradle:3.3.1'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

squareloaderspack/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ repositories {
88
ext {
99
PUBLISH_GROUP_ID = 'com.agrawalsuneet.androidlibs'
1010
PUBLISH_ARTIFACT_ID = 'squareloaderspack'
11-
PUBLISH_VERSION = '0.4'
11+
PUBLISH_VERSION = '0.5'
1212
}
1313

1414
android {
15-
compileSdkVersion 26
15+
compileSdkVersion 28
1616

1717
defaultConfig {
1818
minSdkVersion 16
19-
targetSdkVersion 26
20-
versionCode 4
21-
versionName "0.4"
19+
targetSdkVersion 28
20+
versionCode 5
21+
versionName "0.5"
2222
}
2323

2424
buildTypes {

squareloaderspack/src/main/java/com/agrawalsuneet/squareloaderspack/loaders/UsainBoltLoader.kt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import com.agrawalsuneet.squareloaderspack.basicviews.RectangleView
1616

1717
class UsainBoltLoader : LinearLayout, LoaderContract {
1818

19+
var rectangleWidth: Int = 60
1920
var rectangleColor = resources.getColor(android.R.color.darker_gray)
20-
var rectangleWidth: Int = 40
2121

2222
var animDuration: Int = 500
2323
var interpolator: Interpolator = LinearInterpolator()
@@ -41,7 +41,6 @@ class UsainBoltLoader : LinearLayout, LoaderContract {
4141
private var headCircleView: CircleView? = null
4242
private var headContainer: LinearLayout? = null
4343

44-
4544
constructor(context: Context) : super(context) {
4645
initView()
4746
}
@@ -56,20 +55,27 @@ class UsainBoltLoader : LinearLayout, LoaderContract {
5655
initView()
5756
}
5857

59-
override fun initAttributes(attrs: AttributeSet) {
60-
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.RotatingSquareLoader, 0, 0)
58+
constructor(context: Context?, rectangleWidth: Int, rectangleColor: Int) : super(context) {
59+
this.rectangleWidth = rectangleWidth
60+
this.rectangleColor = rectangleColor
61+
initView()
62+
}
6163

62-
/*this.squareSideLength = typedArray
63-
.getDimension(R.styleable.RotatingSquareLoader_rotatingsquare_squareSideLength, 200.0f)
64-
this.strokeWidth = typedArray
65-
.getDimension(R.styleable.RotatingSquareLoader_rotatingsquare_strokeWidth, 50.0f)
64+
override fun initAttributes(attrs: AttributeSet) {
65+
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.UsainBoltLoader, 0, 0)
6666

67+
this.rectangleWidth = typedArray
68+
.getDimensionPixelSize(R.styleable.UsainBoltLoader_usainbolt_rectangleWidth, 60)
69+
this.rectangleColor = typedArray
70+
.getColor(R.styleable.UsainBoltLoader_usainbolt_rectangleColor, resources.getColor(android.R.color.darker_gray))
6771

68-
this.squareColor = typedArray
69-
.getColor(R.styleable.RotatingSquareLoader_rotatingsquare_sqaureColor, resources.getColor(R.color.green))
7072

7173
this.animDuration = typedArray
72-
.getInteger(R.styleable.RotatingSquareLoader_rotatingsquare_animDuration, 2000)*/
74+
.getInteger(R.styleable.UsainBoltLoader_usainbolt_animDuration, 500)
75+
76+
this.interpolator = AnimationUtils.loadInterpolator(context,
77+
typedArray.getResourceId(R.styleable.UsainBoltLoader_usainbolt_interpolator,
78+
android.R.anim.linear_interpolator))
7379

7480
typedArray.recycle()
7581
}
@@ -88,15 +94,15 @@ class UsainBoltLoader : LinearLayout, LoaderContract {
8894
override fun onVisibilityChanged(changedView: View, visibility: Int) {
8995
super.onVisibilityChanged(changedView, visibility)
9096

91-
/*if (visibility != VISIBLE) {
97+
if (visibility == VISIBLE) {
9298
if (!shouldAnimate) {
9399
shouldAnimate = true
94100
initView()
95101
}
96102
} else {
97103
shouldAnimate = false
98104
initView()
99-
}*/
105+
}
100106
}
101107

102108
private fun initView() {

squareloaderspack/src/main/res/values/attrs.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,19 @@
8181
</declare-styleable>
8282

8383
<declare-styleable name="SquareGridLoader">
84-
<attr name="squaregrid_squareCount" format="integer"/>
84+
<attr name="squaregrid_squareCount" format="integer" />
8585
<attr name="squaregrid_squareLength" format="dimension" />
8686
<attr name="squaregrid_sqaureColor" format="color" />
8787
<attr name="squaregrid_animDuration" format="integer" />
8888
<attr name="squaregrid_animDelay" format="integer" />
8989
<attr name="squaregrid_interpolator" format="reference" />
9090
</declare-styleable>
9191

92+
<declare-styleable name="UsainBoltLoader">
93+
<attr name="usainbolt_rectangleWidth" format="dimension" />
94+
<attr name="usainbolt_rectangleColor" format="color" />
95+
<attr name="usainbolt_animDuration" format="integer" />
96+
<attr name="usainbolt_interpolator" format="reference" />
97+
</declare-styleable>
98+
9299
</resources>

0 commit comments

Comments
 (0)