Skip to content

Commit 66d76b4

Browse files
authored
Merge pull request #17 from JDevZone/dev
#16 bug fixed & version bumped 😎
2 parents 025cac7 + 91e8417 commit 66d76b4

File tree

9 files changed

+250
-148
lines changed

9 files changed

+250
-148
lines changed

app/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ apply plugin: 'kotlin-android'
55
apply plugin: 'kotlin-android-extensions'
66

77
android {
8-
compileSdkVersion 29
8+
compileSdkVersion 30
99
buildToolsVersion "29.0.3"
1010
defaultConfig {
1111
applicationId "com.devzone.fillprogresslayout"
1212
minSdkVersion 17
13-
targetSdkVersion 29
13+
targetSdkVersion 30
1414
versionCode 1
1515
versionName "1.0"
1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -26,12 +26,12 @@ android {
2626

2727
dependencies {
2828
implementation fileTree(dir: 'libs', include: ['*.jar'])
29-
implementation 'androidx.appcompat:appcompat:1.1.0'
30-
implementation 'androidx.core:core-ktx:1.3.0'
29+
implementation 'androidx.appcompat:appcompat:1.2.0'
30+
implementation 'androidx.core:core-ktx:1.3.2'
3131
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3232
implementation project(path: ':fillprogresslayout')
3333

34-
testImplementation 'junit:junit:4.13'
35-
androidTestImplementation 'androidx.test:runner:1.2.0'
36-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
34+
testImplementation 'junit:junit:4.13.1'
35+
androidTestImplementation 'androidx.test:runner:1.3.0'
36+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3737
}

app/src/main/java/com/devzone/fpl_sample/MainActivity.kt

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.devzone.fpl_sample
22

3+
import android.graphics.PorterDuff
4+
import android.graphics.PorterDuffColorFilter
35
import android.os.Bundle
46
import android.view.View
57
import android.view.animation.LinearInterpolator
68
import android.widget.Button
79
import android.widget.SeekBar
810
import androidx.appcompat.app.AppCompatActivity
11+
import androidx.core.content.ContextCompat
12+
import com.devzone.fillprogresslayout.FillProgressLayout
913
import kotlinx.android.synthetic.main.activity_main.*
1014

1115
class MainActivity : AppCompatActivity() {
@@ -17,7 +21,15 @@ class MainActivity : AppCompatActivity() {
1721
setContentView(R.layout.activity_main)
1822
handlePreciseControls()
1923
fillNF.setAnimationInterpolator(LinearInterpolator())
20-
24+
fishCardFPL?.apply {
25+
setProgressUpdateListener { progress ->
26+
val color = if (progress > 60) R.color.colorBlue else R.color.colorRed
27+
fishIV?.colorFilter = PorterDuffColorFilter(
28+
ContextCompat.getColor(this@MainActivity, color),
29+
PorterDuff.Mode.SRC_IN
30+
)
31+
}
32+
}
2133

2234
}
2335

@@ -49,12 +61,9 @@ class MainActivity : AppCompatActivity() {
4961
private fun updateLargeProgress(progress: Int) {
5062
val isAnimated = animateCB.isChecked
5163
val isReverse = reverseCB.isChecked
52-
53-
if (isReverse) {
54-
val reverseProgress = kotlin.math.abs(100 - progress)
55-
fillB.setProgress(reverseProgress, isAnimated)
56-
} else
57-
fillB.setProgress(progress, isAnimated)
64+
val currentProgress = if (isReverse) kotlin.math.abs(100 - progress) else progress
65+
fillB.setProgress(currentProgress, isAnimated)
66+
fishCardFPL?.setProgress(currentProgress, isAnimated)
5867
}
5968

6069
fun toggleFill(view: View) {
@@ -69,4 +78,16 @@ class MainActivity : AppCompatActivity() {
6978
fillNF?.setProgress(if (isFilled) 100 else 0)
7079
fillL?.setProgressColors(intArrayOf(R.color.colorGradient1, R.color.colorGradient2))
7180
}
81+
82+
fun toggleFillLayout(view: View) {
83+
if(view !is FillProgressLayout) return
84+
val isAnimated = animateCB.isChecked
85+
view.apply {
86+
when (currentProgress){
87+
in 50..99,0 -> setProgress(100,isAnimated)
88+
in 0..50,100 -> setProgress(0,isAnimated)
89+
}
90+
}
91+
}
92+
7293
}

app/src/main/res/drawable/ic_fish.xml

Lines changed: 17 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 145 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,187 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
6-
android:layout_height="match_parent"
7-
android:orientation="vertical"
8-
tools:context=".MainActivity">
6+
android:layout_height="match_parent">
97

10-
<FrameLayout
8+
9+
<LinearLayout
1110
android:layout_width="match_parent"
1211
android:layout_height="wrap_content"
13-
android:background="@color/netflix_black">
12+
android:orientation="vertical"
13+
tools:context=".MainActivity">
14+
15+
<FrameLayout
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content"
18+
android:background="@color/netflix_black">
19+
20+
<com.devzone.fillprogresslayout.FillProgressLayout
21+
android:id="@+id/fillNF"
22+
android:layout_width="wrap_content"
23+
android:layout_height="wrap_content"
24+
android:layout_gravity="center_horizontal"
25+
android:layout_margin="20dp"
26+
android:gravity="center"
27+
app:fpl_backgroundColor="@color/netflix_gray"
28+
app:fpl_gradientMovement="true"
29+
app:fpl_isRounded="true"
30+
app:fpl_progress="0"
31+
app:fpl_progressColor="@color/netflix_white"
32+
app:fpl_progressDirection="left_to_right"
33+
app:fpl_progressDuration="2000"
34+
app:fpl_roundedCornerRadius="8"
35+
app:fpl_shouldRestart="false">
36+
37+
<TextView
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:layout_gravity="center"
41+
android:layout_marginStart="10dp"
42+
android:layout_marginEnd="20dp"
43+
android:drawableStart="@drawable/ic_play_vector"
44+
android:drawablePadding="10dp"
45+
android:gravity="center"
46+
android:padding="5dp"
47+
android:text="Next Episode"
48+
android:textColor="@color/netflix_black"
49+
android:textStyle="bold" />
50+
51+
</com.devzone.fillprogresslayout.FillProgressLayout>
52+
</FrameLayout>
1453

1554
<com.devzone.fillprogresslayout.FillProgressLayout
16-
android:id="@+id/fillNF"
17-
android:layout_width="wrap_content"
55+
android:id="@+id/fillL"
56+
android:layout_width="match_parent"
1857
android:layout_height="wrap_content"
19-
android:layout_gravity="center_horizontal"
20-
android:layout_margin="20dp"
21-
android:gravity="center"
22-
app:fpl_backgroundColor="@color/netflix_gray"
58+
android:layout_margin="30dp"
59+
app:fpl_backgroundColor="@color/colorRedTrans"
2360
app:fpl_gradientMovement="true"
2461
app:fpl_isRounded="true"
2562
app:fpl_progress="0"
26-
app:fpl_progressColor="@color/netflix_white"
63+
app:fpl_progressColor="@color/colorGreenTrans"
2764
app:fpl_progressDirection="left_to_right"
2865
app:fpl_progressDuration="2000"
29-
app:fpl_roundedCornerRadius="8"
66+
app:fpl_roundedCornerRadius="100"
3067
app:fpl_shouldRestart="false">
3168

3269
<TextView
3370
android:layout_width="wrap_content"
3471
android:layout_height="wrap_content"
35-
android:layout_gravity="center"
36-
android:layout_marginStart="10dp"
37-
android:layout_marginEnd="20dp"
38-
android:drawableStart="@drawable/ic_play_vector"
39-
android:drawablePadding="10dp"
72+
android:layout_gravity="center_vertical"
73+
android:layout_weight="1"
4074
android:gravity="center"
41-
android:padding="5dp"
42-
android:text="Next Episode"
43-
android:textColor="@color/netflix_black"
44-
android:textStyle="bold" />
75+
android:padding="10dp"
76+
android:text="@string/app_name" />
4577

78+
<TextView
79+
android:layout_width="wrap_content"
80+
android:layout_height="wrap_content"
81+
android:layout_gravity="center_vertical"
82+
android:layout_weight="1"
83+
android:gravity="center"
84+
android:padding="10dp"
85+
android:text="@string/app_name" />
4686
</com.devzone.fillprogresslayout.FillProgressLayout>
47-
</FrameLayout>
48-
49-
<com.devzone.fillprogresslayout.FillProgressLayout
50-
android:id="@+id/fillL"
51-
android:layout_width="match_parent"
52-
android:layout_height="wrap_content"
53-
android:layout_margin="30dp"
54-
app:fpl_backgroundColor="@color/colorRedTrans"
55-
app:fpl_gradientMovement="true"
56-
app:fpl_isRounded="true"
57-
app:fpl_progress="0"
58-
app:fpl_progressColor="@color/colorGreenTrans"
59-
app:fpl_progressDirection="left_to_right"
60-
app:fpl_progressDuration="2000"
61-
app:fpl_roundedCornerRadius="100"
62-
app:fpl_shouldRestart="false">
63-
64-
<TextView
65-
android:layout_width="wrap_content"
66-
android:layout_height="wrap_content"
67-
android:layout_gravity="center_vertical"
68-
android:layout_weight="1"
69-
android:gravity="center"
70-
android:padding="10dp"
71-
android:text="@string/app_name" />
7287

73-
<TextView
88+
<Button
7489
android:layout_width="wrap_content"
7590
android:layout_height="wrap_content"
76-
android:layout_gravity="center_vertical"
77-
android:layout_weight="1"
78-
android:gravity="center"
79-
android:padding="10dp"
80-
android:text="@string/app_name" />
81-
</com.devzone.fillprogresslayout.FillProgressLayout>
91+
android:layout_gravity="center_horizontal"
92+
android:layout_marginTop="20dp"
93+
android:layout_marginBottom="20dp"
94+
android:onClick="toggleFill"
95+
android:text="fill"
96+
tools:ignore="HardcodedText" />
8297

83-
<Button
84-
android:layout_width="wrap_content"
85-
android:layout_height="wrap_content"
86-
android:layout_gravity="center_horizontal"
87-
android:layout_marginTop="20dp"
88-
android:layout_marginBottom="20dp"
89-
android:onClick="toggleFill"
90-
android:text="fill"
91-
tools:ignore="HardcodedText" />
92-
93-
<RelativeLayout
94-
android:layout_width="match_parent"
95-
android:layout_height="wrap_content"
96-
android:layout_margin="20dp">
9798

9899
<com.devzone.fillprogresslayout.FillProgressLayout
99-
android:id="@+id/fillB"
100+
android:id="@+id/fishCardFPL"
100101
android:layout_width="match_parent"
101-
android:layout_height="wrap_content"
102-
android:layout_alignBottom="@+id/tv"
103-
android:layout_alignParentTop="true"
104-
app:fpl_gradientColors="@array/gradientColors"
105-
app:fpl_gradientMovement="false"
102+
android:layout_height="100dp"
103+
android:onClick="toggleFillLayout"
104+
android:layout_margin="30dp"
105+
app:fpl_backgroundColor="@color/colorRedTrans"
106+
app:fpl_gradientMovement="true"
106107
app:fpl_isRounded="true"
107-
app:fpl_roundedCornerRadius="20" />
108+
app:fpl_progress="0"
109+
app:fpl_progressColor="#2200AAFF"
110+
app:fpl_progressDirection="bottom_to_top"
111+
app:fpl_progressDuration="2000"
112+
app:fpl_roundedCornerRadius="10"
113+
app:fpl_shouldRestart="false">
108114

109-
<androidx.appcompat.widget.AppCompatTextView
110-
android:id="@+id/tv"
115+
<RelativeLayout
116+
android:layout_width="match_parent"
117+
android:layout_height="match_parent">
118+
119+
<androidx.appcompat.widget.AppCompatImageView
120+
android:id="@+id/fishIV"
121+
android:layout_width="wrap_content"
122+
android:layout_height="wrap_content"
123+
android:layout_centerInParent="true"
124+
app:srcCompat="@drawable/ic_fish" />
125+
</RelativeLayout>
126+
</com.devzone.fillprogresslayout.FillProgressLayout>
127+
128+
<RelativeLayout
111129
android:layout_width="match_parent"
112130
android:layout_height="wrap_content"
113-
android:gravity="center"
114-
android:padding="20dp"
115-
android:text="@string/app_name" />
116-
</RelativeLayout>
131+
android:layout_margin="20dp">
117132

118-
<RadioGroup
119-
android:layout_width="match_parent"
120-
android:layout_height="wrap_content"
121-
android:layout_margin="10dp"
122-
android:gravity="center"
123-
android:orientation="horizontal">
133+
<com.devzone.fillprogresslayout.FillProgressLayout
134+
android:id="@+id/fillB"
135+
android:layout_width="match_parent"
136+
android:layout_height="wrap_content"
137+
android:layout_alignBottom="@+id/tv"
138+
android:layout_alignParentTop="true"
139+
app:fpl_gradientColors="@array/gradientColors"
140+
app:fpl_gradientMovement="false"
141+
app:fpl_isRounded="true"
142+
app:fpl_roundedCornerRadius="15" />
143+
144+
<androidx.appcompat.widget.AppCompatTextView
145+
android:id="@+id/tv"
146+
android:layout_width="match_parent"
147+
android:layout_height="wrap_content"
148+
android:gravity="center"
149+
android:padding="20dp"
150+
android:text="@string/app_name" />
151+
</RelativeLayout>
124152

125-
<androidx.appcompat.widget.AppCompatCheckBox
126-
android:id="@+id/reverseCB"
127-
android:layout_width="wrap_content"
153+
<RadioGroup
154+
android:layout_width="match_parent"
128155
android:layout_height="wrap_content"
129-
android:layout_margin="5dp"
130-
android:text="Reverse" />
156+
android:layout_margin="10dp"
157+
android:gravity="center"
158+
android:orientation="horizontal">
131159

132-
<androidx.appcompat.widget.AppCompatCheckBox
133-
android:id="@+id/animateCB"
134-
android:layout_width="wrap_content"
135-
android:layout_height="wrap_content"
136-
android:layout_margin="5dp"
137-
android:text="Animate" />
138-
</RadioGroup>
160+
<androidx.appcompat.widget.AppCompatCheckBox
161+
android:id="@+id/reverseCB"
162+
android:layout_width="wrap_content"
163+
android:layout_height="wrap_content"
164+
android:layout_margin="5dp"
165+
android:text="Reverse" />
139166

167+
<androidx.appcompat.widget.AppCompatCheckBox
168+
android:id="@+id/animateCB"
169+
android:layout_width="wrap_content"
170+
android:layout_height="wrap_content"
171+
android:layout_margin="5dp"
172+
android:text="Animate" />
173+
</RadioGroup>
140174

141-
<SeekBar
142-
android:id="@+id/progressSeek"
143-
android:layout_width="match_parent"
144-
android:layout_height="wrap_content"
145-
android:layout_margin="10dp" />
175+
176+
<SeekBar
177+
android:id="@+id/progressSeek"
178+
android:layout_width="match_parent"
179+
android:layout_height="wrap_content"
180+
android:layout_margin="10dp" />
146181

147182

148-
</LinearLayout>
183+
<Space
184+
android:layout_width="match_parent"
185+
android:layout_height="40dp" />
186+
</LinearLayout>
187+
</ScrollView>

0 commit comments

Comments
 (0)