-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added attrManager to handle xml styledAttrs.
- Loading branch information
1 parent
f5a2296
commit a7f86ec
Showing
9 changed files
with
79 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 30 additions & 5 deletions
35
library/src/main/java/com/carlosmuvi/segmentedprogressbar/PropertiesModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
package com.carlosmuvi.segmentedprogressbar | ||
|
||
import android.content.Context | ||
import android.graphics.Color | ||
import android.util.AttributeSet | ||
|
||
|
||
data class PropertiesModel( | ||
var segmentCount : Int = 5, | ||
var containerColor : Int = Color.LTGRAY, | ||
var fillColor : Int = Color.BLUE | ||
) | ||
data class PropertiesModel(val context: Context, val attrs: AttributeSet?) { | ||
|
||
var segmentCount: Int | ||
var containerColor: Int | ||
var fillColor: Int | ||
var segmentGapWidth: Int | ||
|
||
init { | ||
if (attrs != null) { | ||
val styledAttrs = context.theme.obtainStyledAttributes(attrs, R.styleable.SegmentedProgressBar, 0, 0) | ||
segmentCount = styledAttrs.getInt(R.styleable.SegmentedProgressBar_segment_count, 5) | ||
containerColor = styledAttrs.getColor(R.styleable.SegmentedProgressBar_container_color, Color.LTGRAY) | ||
fillColor = styledAttrs.getColor(R.styleable.SegmentedProgressBar_fill_color, Color.BLUE) | ||
segmentGapWidth = styledAttrs.getDimensionPixelSize(R.styleable.SegmentedProgressBar_gap_size, dpToPx(1)) | ||
} else { | ||
segmentCount = 5 | ||
containerColor = Color.LTGRAY | ||
fillColor = Color.BLUE | ||
segmentGapWidth = dpToPx(1) | ||
} | ||
} | ||
|
||
private fun dpToPx(valueInDp: Int): Int { | ||
val density = context.resources.displayMetrics.density | ||
return (valueInDp * density).toInt() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters