remove some redundant variable
This commit is contained in:
parent
e9393e0cfc
commit
2e089feb29
|
@ -21,11 +21,12 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||||
|
|
||||||
var mPaths = LinkedHashMap<MyPath, PaintOptions>()
|
var mPaths = LinkedHashMap<MyPath, PaintOptions>()
|
||||||
var mBackgroundBitmap: Bitmap? = null
|
var mBackgroundBitmap: Bitmap? = null
|
||||||
|
var mListener: PathsChangedListener? = null
|
||||||
|
|
||||||
private var mPaint = Paint()
|
private var mPaint = Paint()
|
||||||
private var mPath = MyPath()
|
private var mPath = MyPath()
|
||||||
private var mPaintOptions = PaintOptions()
|
private var mPaintOptions = PaintOptions()
|
||||||
|
|
||||||
private var mListener: PathsChangedListener? = null
|
|
||||||
private var mCurX = 0f
|
private var mCurX = 0f
|
||||||
private var mCurY = 0f
|
private var mCurY = 0f
|
||||||
private var mStartX = 0f
|
private var mStartX = 0f
|
||||||
|
@ -48,10 +49,6 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||||
pathsUpdated()
|
pathsUpdated()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setListener(listener: PathsChangedListener) {
|
|
||||||
this.mListener = listener
|
|
||||||
}
|
|
||||||
|
|
||||||
fun undo() {
|
fun undo() {
|
||||||
if (mPaths.isEmpty())
|
if (mPaths.isEmpty())
|
||||||
return
|
return
|
||||||
|
@ -174,11 +171,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changePaint(paintOptions: PaintOptions) {
|
private fun changePaint(paintOptions: PaintOptions) {
|
||||||
if (paintOptions.isEraser)
|
mPaint.color = if (paintOptions.isEraser) mBackgroundColor else paintOptions.color
|
||||||
mPaint.color = mBackgroundColor
|
|
||||||
else
|
|
||||||
mPaint.color = paintOptions.color
|
|
||||||
|
|
||||||
mPaint.strokeWidth = paintOptions.strokeWidth
|
mPaint.strokeWidth = paintOptions.strokeWidth
|
||||||
if (paintOptions.isEraser && mPaint.strokeWidth < MIN_ERASER_WIDTH) {
|
if (paintOptions.isEraser && mPaint.strokeWidth < MIN_ERASER_WIDTH) {
|
||||||
mPaint.strokeWidth = MIN_ERASER_WIDTH
|
mPaint.strokeWidth = MIN_ERASER_WIDTH
|
||||||
|
|
|
@ -47,7 +47,7 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
storeStoragePaths()
|
storeStoragePaths()
|
||||||
my_canvas.setListener(this)
|
my_canvas.mListener = this
|
||||||
stroke_width_bar.setOnSeekBarChangeListener(onStrokeWidthBarChangeListener)
|
stroke_width_bar.setOnSeekBarChangeListener(onStrokeWidthBarChangeListener)
|
||||||
|
|
||||||
setBackgroundColor(config.canvasBackgroundColor)
|
setBackgroundColor(config.canvasBackgroundColor)
|
||||||
|
|
Loading…
Reference in New Issue