From 2fad73bd1bd4c4adbe8aa53a0c4e3a7e0c5cbe3a Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Mon, 29 Mar 2021 20:05:09 -0400 Subject: [PATCH] Convert BaseShape's endDraw to a function extension --- app/src/main/java/com/benny/pxerstudio/shape/BaseShape.kt | 8 ++++---- .../main/java/com/benny/pxerstudio/shape/EraserShape.kt | 2 +- .../java/com/benny/pxerstudio/shape/draw/LineShape.kt | 2 +- .../java/com/benny/pxerstudio/shape/draw/RectShape.kt | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/benny/pxerstudio/shape/BaseShape.kt b/app/src/main/java/com/benny/pxerstudio/shape/BaseShape.kt index 5b42261..e6453f7 100644 --- a/app/src/main/java/com/benny/pxerstudio/shape/BaseShape.kt +++ b/app/src/main/java/com/benny/pxerstudio/shape/BaseShape.kt @@ -34,13 +34,13 @@ abstract class BaseShape { return !hasEnded } - protected fun endDraw(previousPxer: ArrayList, pxerView: PxerView) { + protected fun PxerView.endDraw(previousPxer: ArrayList) { if (previousPxer.isEmpty()) { return } - pxerView.currentHistory.addAll(previousPxer) + this.currentHistory.addAll(previousPxer) previousPxer.clear() - pxerView.setUnrecordedChanges(true) - pxerView.finishAddHistory() + this.setUnrecordedChanges(true) + this.finishAddHistory() } } diff --git a/app/src/main/java/com/benny/pxerstudio/shape/EraserShape.kt b/app/src/main/java/com/benny/pxerstudio/shape/EraserShape.kt index 83c0c55..b1e58e4 100644 --- a/app/src/main/java/com/benny/pxerstudio/shape/EraserShape.kt +++ b/app/src/main/java/com/benny/pxerstudio/shape/EraserShape.kt @@ -58,7 +58,7 @@ class EraserShape : BaseShape() { override fun onDrawEnd(pxerView: PxerView) { super.onDrawEnd(pxerView) hasInit = false - endDraw(previousPxer, pxerView) + pxerView.endDraw(previousPxer) } init { diff --git a/app/src/main/java/com/benny/pxerstudio/shape/draw/LineShape.kt b/app/src/main/java/com/benny/pxerstudio/shape/draw/LineShape.kt index 9345560..675ccb6 100644 --- a/app/src/main/java/com/benny/pxerstudio/shape/draw/LineShape.kt +++ b/app/src/main/java/com/benny/pxerstudio/shape/draw/LineShape.kt @@ -68,7 +68,7 @@ class LineShape : DrawShape() { override fun onDrawEnd(pxerView: PxerView) { super.onDrawEnd(pxerView) hasInit = false - endDraw(previousPxer, pxerView) + pxerView.endDraw(previousPxer) } init { diff --git a/app/src/main/java/com/benny/pxerstudio/shape/draw/RectShape.kt b/app/src/main/java/com/benny/pxerstudio/shape/draw/RectShape.kt index 690033f..5044221 100644 --- a/app/src/main/java/com/benny/pxerstudio/shape/draw/RectShape.kt +++ b/app/src/main/java/com/benny/pxerstudio/shape/draw/RectShape.kt @@ -49,6 +49,6 @@ class RectShape : DrawShape() { override fun onDrawEnd(pxerView: PxerView) { super.onDrawEnd(pxerView) - endDraw(previousPxer, pxerView) + pxerView.endDraw(previousPxer) } }