From 2e089feb29086507ccf64c9780a2eb438ca4f28b Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 7 Nov 2017 19:39:28 +0100 Subject: [PATCH] remove some redundant variable --- .../kotlin/com/simplemobiletools/draw/MyCanvas.kt | 13 +++---------- .../draw/activities/MainActivity.kt | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt b/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt index 83b0e9d..0b0bf7d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/MyCanvas.kt @@ -21,11 +21,12 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { var mPaths = LinkedHashMap() var mBackgroundBitmap: Bitmap? = null + var mListener: PathsChangedListener? = null + private var mPaint = Paint() private var mPath = MyPath() private var mPaintOptions = PaintOptions() - private var mListener: PathsChangedListener? = null private var mCurX = 0f private var mCurY = 0f private var mStartX = 0f @@ -48,10 +49,6 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { pathsUpdated() } - fun setListener(listener: PathsChangedListener) { - this.mListener = listener - } - fun undo() { if (mPaths.isEmpty()) return @@ -174,11 +171,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) { } private fun changePaint(paintOptions: PaintOptions) { - if (paintOptions.isEraser) - mPaint.color = mBackgroundColor - else - mPaint.color = paintOptions.color - + mPaint.color = if (paintOptions.isEraser) mBackgroundColor else paintOptions.color mPaint.strokeWidth = paintOptions.strokeWidth if (paintOptions.isEraser && mPaint.strokeWidth < MIN_ERASER_WIDTH) { mPaint.strokeWidth = MIN_ERASER_WIDTH diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt index d4b4d37..80f57cc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt @@ -47,7 +47,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) storeStoragePaths() - my_canvas.setListener(this) + my_canvas.mListener = this stroke_width_bar.setOnSeekBarChangeListener(onStrokeWidthBarChangeListener) setBackgroundColor(config.canvasBackgroundColor)