如何获取图形触摸的所有x,y坐标并将其发送给MainActivity?

我正在开发一个图形应用程序,我想获取图形的所有x,y坐标并将其发送给MainActivity。该项目分为两类,负责管理功能的MainActivity和负责屏幕绘图的MyCanvas。

主要活性:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    appLaunched(BuildConfig.APPLICATION_ID)
    my_canvas.mListener = this
    setBackgroundColor(config.canvasBackgroundColor)
    setColor(config.brushColor)
    defaultPath = config.lastSaveFolder
    defaultExtension = config.lastSaveExtension
    brushSize = config.brushSize

    undo.setOnClickListener { my_canvas.undo() }
    eraser.setOnClickListener { eraserClicked() }
    redo.setOnClickListener { my_canvas.redo() }

    checkIntents()
    if (!isImageCaptureIntent) {
        checkWhatsNewDialog()
    }

    val fab: View = findViewById(R.id.fab)
    fab.setOnClickListener { view ->
        Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show()
    }
}

和MyCanvas

var mCurX = 0f
var mCurY = 0f
var mStartX = 0f
var mStartY = 0f
private var mCurrBrushSize = 0f
private var mAllowZooming = true
private var mIsEraserOn = false
private var mWasMultitouch = false
private var mBackgroundColor = 0
private var mCenter: PointF? = null

private var mScaleDetector: ScaleGestureDetector? = null
private var mScaleFactor = 1f

init {
    mPaint.apply {
        color = mPaintOptions.color
        style = Paint.Style.STROKE
        strokeJoin = Paint.Join.ROUND
        strokeCap = Paint.Cap.ROUND
        strokeWidth = mPaintOptions.strokeWidth
        isAntiAlias = true
    }

    mScaleDetector = ScaleGestureDetector(context, ScaleListener())
    pathsUpdated()
}

fun undo() {
    if (mPaths.isEmpty() && mLastPaths.isNotEmpty()) {
        mPaths = mLastPaths.clone() as LinkedHashMap<MyPath, PaintOptions>
        mBackgroundBitmap = mLastBackgroundBitmap
        mLastPaths.clear()
        pathsUpdated()
        invalidate()
        return
    }

    if (mPaths.isEmpty()) {
        return
    }

    val lastPath = mPaths.values.lastOrNull()
    val lastKey = mPaths.keys.lastOrNull()

    mPaths.remove(lastKey)
    if (lastPath != null && lastKey != null) {
        mUndonePaths[lastKey] = lastPath
        mListener?.toggleRedoVisibility(true)
    }
    pathsUpdated()
    invalidate()
}

fun redo() {
    if (mUndonePaths.keys.isEmpty()) {
        mListener?.toggleRedoVisibility(false)
        return
    }

    val lastKey = mUndonePaths.keys.last()
    addPath(lastKey, mUndonePaths.values.last())
    mUndonePaths.remove(lastKey)
    if (mUndonePaths.isEmpty()) {
        mListener?.toggleRedoVisibility(false)
    }
    invalidate()
}

fun toggleEraser(isEraserOn: Boolean) {
    mIsEraserOn = isEraserOn
    mPaintOptions.isEraser = isEraserOn
    invalidate()
}

fun setColor(newColor: Int) {
    mPaintOptions.color = newColor
}

fun updateBackgroundColor(newColor: Int) {
    mBackgroundColor = newColor
    setBackgroundColor(newColor)
    mBackgroundBitmap = null
}

fun setBrushSize(newBrushSize: Float) {
    mCurrBrushSize = newBrushSize
    mPaintOptions.strokeWidth = resources.getDimension(R.dimen.full_brush_size) * (newBrushSize / mScaleFactor / 100f)
}

fun setAllowZooming(allowZooming: Boolean) {
    mAllowZooming = allowZooming
}

fun getBitmap(): Bitmap {
    val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
    val canvas = Canvas(bitmap)
    canvas.drawColor(Color.WHITE)
    draw(canvas)
    return bitmap
}

fun drawBitmap(activity: Activity, path: Any) {
    Thread {
        val size = Point()
        activity.windowManager.defaultDisplay.getSize(size)
        val options = RequestOptions()
                .format(DecodeFormat.PREFER_ARGB_8888)
                .disallowHardwareConfig()
                .fitCenter()

        try {
            val builder = Glide.with(context)
                    .asBitmap()
                    .load(path)
                    .apply(options)
                    .into(size.x, size.y)

            mBackgroundBitmap = builder.get()
            activity.runOnUiThread {
                invalidate()
            }
        } catch (e: ExecutionException) {
            val errorMsg = String.format(activity.getString(R.string.failed_to_load_image), path)
            activity.toast(errorMsg)
        }
    }.start()
}
fun actionMove(x: Float, y: Float) {
    mPath.quadTo(mCurX, mCurY, (x + mCurX) / 2, (y + mCurY) / 2)
    mCurX = x
    mCurY = y
    Log.i("coordinates", mCurX.toString()+"\n"+mCurY.toString())
}

退出日志是所有坐标绘制。

如何在MainActivity类的屏幕图形中获得所有的x,y坐标?