Skip to content

Commit

Permalink
Convert BaseShape's endDraw to a function extension
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoTheDank committed Mar 30, 2021
1 parent c95bf51 commit 2fad73b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/com/benny/pxerstudio/shape/BaseShape.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ abstract class BaseShape {
return !hasEnded
}

protected fun endDraw(previousPxer: ArrayList<Pxer>, pxerView: PxerView) {
protected fun PxerView.endDraw(previousPxer: ArrayList<Pxer>) {
if (previousPxer.isEmpty()) {
return
}
pxerView.currentHistory.addAll(previousPxer)
this.currentHistory.addAll(previousPxer)
previousPxer.clear()
pxerView.setUnrecordedChanges(true)
pxerView.finishAddHistory()
this.setUnrecordedChanges(true)
this.finishAddHistory()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class EraserShape : BaseShape() {
override fun onDrawEnd(pxerView: PxerView) {
super.onDrawEnd(pxerView)
hasInit = false
endDraw(previousPxer, pxerView)
pxerView.endDraw(previousPxer)
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class LineShape : DrawShape() {
override fun onDrawEnd(pxerView: PxerView) {
super.onDrawEnd(pxerView)
hasInit = false
endDraw(previousPxer, pxerView)
pxerView.endDraw(previousPxer)
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ class RectShape : DrawShape() {

override fun onDrawEnd(pxerView: PxerView) {
super.onDrawEnd(pxerView)
endDraw(previousPxer, pxerView)
pxerView.endDraw(previousPxer)
}
}

0 comments on commit 2fad73b

Please sign in to comment.