Skip to content

Commit

Permalink
Merge pull request #6 from JDevZone/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JDevZone authored Sep 18, 2019
2 parents aa45ad7 + 8486dbf commit 0b514e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/src/main/java/com/devzone/fpl_sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.devzone.fpl_sample

import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.AppCompatButton
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
Expand All @@ -17,12 +17,13 @@ class MainActivity : AppCompatActivity() {
}

fun toggleFill(view: View) {
val button: AppCompatButton = view as AppCompatButton
val button: Button = view as Button
button.isEnabled = false

isFilled = !isFilled
fillL.setProgress(if (isFilled) 100 else 0)
fillL.setDoOnProgressEnd { v ->
fillB.setProgress(if (isFilled) 100 else 0)
fillB.setDoOnProgressEnd { v ->
button.isEnabled = true;button.text = if (isFilled) "Unfill" else "Fill"
}

Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
android:layout_margin="30dp"
app:fpl_backgroundColor="@color/colorRedTrans"
app:fpl_progressColor="@color/colorGreenTrans"
app:fpl_isRounded="false"
app:fpl_isRounded="true"
app:fpl_roundedCornerRadius="100"
app:fpl_progress="0"
app:fpl_progressDuration="2000"
app:fpl_progressDirection="left_to_right"
Expand Down Expand Up @@ -44,6 +45,8 @@
<com.devzone.fillprogresslayout.FillProgressLayout
android:layout_alignBottom="@+id/tv"
android:layout_alignParentTop="true"
app:fpl_roundedCornerRadius="100"
app:fpl_isRounded="true"
android:id="@+id/fillB"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Expand All @@ -57,7 +60,7 @@
android:layout_height="wrap_content"/>
</RelativeLayout>

<androidx.appcompat.widget.AppCompatButton
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ class FillProgressLayout : LinearLayout {
super.onDetachedFromWindow()
}

override fun dispatchDraw(canvas: Canvas?) { // child clipping done here
if(isRounded)
canvas?.clipPath(clipPath)
super.dispatchDraw(canvas)
}

//---------------------public setters--------------------------------------------------------------------//

fun setProgress(p: Int) {
Expand All @@ -210,12 +216,14 @@ class FillProgressLayout : LinearLayout {
fun setProgressBackgroundColor(@ColorRes resId: Int) {
if (isValidRes(resId)) {
mBackgroundColor = ContextCompat.getColor(context, resId)
initPaint()
}
}

fun setProgressColor(@ColorRes resId: Int) {
if (isValidRes(resId)) {
mProgressColor = ContextCompat.getColor(context, resId)
initPaint()
}
}

Expand Down

0 comments on commit 0b514e9

Please sign in to comment.