-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added contradicting dots indicator type
- Loading branch information
Showing
8 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
...t/src/main/java/host/capitalquiz/dotstablayout/indicatordrawer/ContractingDotIndicator.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package host.capitalquiz.dotstablayout.indicatordrawer | ||
|
||
import android.graphics.Canvas | ||
import android.graphics.Paint | ||
import host.capitalquiz.dotstablayout.DotHolder | ||
import host.capitalquiz.dotstablayout.DragState | ||
import kotlin.math.abs | ||
|
||
internal class ContractingDotIndicator(params: DotHolder) : BaseIndicator(params) { | ||
private val radius = params.dotSize() / 2 - params.dotStrokeWidth() + 1f | ||
override fun draw(canvas: Canvas, paint: Paint, dragState: DragState) { | ||
super.draw(canvas, paint, dragState) | ||
dragState.indicatorPosition { _, y, distanceFraction -> | ||
val current = params.currentDot() | ||
val next = params.nextDot() | ||
val currentCenter = current.left + current.width / 2f | ||
val fraction = abs(distanceFraction) | ||
if (fraction != 0f) { | ||
canvas.drawCircle(currentCenter, y, radius * (1f - fraction), paint) | ||
if (current != next) { | ||
val nextCenter = next.left + next.width / 2f | ||
canvas.drawCircle(nextCenter, y, radius * fraction, paint) | ||
} | ||
} else { | ||
canvas.drawCircle(currentCenter, y, radius, paint) | ||
} | ||
} | ||
} | ||
|
||
override fun durationPerDot(dotPosition: Int): Long = 300L | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.