Skip to content

Commit 33c2a50

Browse files
committed
Added onDraw plugin.
1 parent eee571b commit 33c2a50

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import org.wordpress.aztec.handlers.ListItemHandler
7474
import org.wordpress.aztec.handlers.PreformatHandler
7575
import org.wordpress.aztec.handlers.QuoteHandler
7676
import org.wordpress.aztec.plugins.IAztecPlugin
77+
import org.wordpress.aztec.plugins.IOnDrawPlugin
7778
import org.wordpress.aztec.plugins.ITextPastePlugin
7879
import org.wordpress.aztec.plugins.IToolbarButton
7980
import org.wordpress.aztec.source.Format
@@ -313,6 +314,13 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
313314
var lastPressedXCoord: Int = 0
314315
var lastPressedYCoord: Int = 0
315316

317+
override fun onDraw(canvas: Canvas) {
318+
super.onDraw(canvas)
319+
plugins.filterIsInstance<IOnDrawPlugin>().forEach {
320+
it.onDraw(canvas)
321+
}
322+
}
323+
316324
interface OnSelectionChangedListener {
317325
fun onSelectionChanged(selStart: Int, selEnd: Int)
318326
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.wordpress.aztec.plugins
2+
3+
import android.graphics.Canvas
4+
5+
/**
6+
* Use this plugin in order to get access to canvas during drawing cycle of AztecText
7+
*/
8+
interface IOnDrawPlugin : IAztecPlugin {
9+
/**
10+
* This method is called when onDraw method of AztecText is called.
11+
* @param canvas canvas of AztecText
12+
* @return html of the result
13+
*/
14+
fun onDraw(canvas: Canvas)
15+
}

0 commit comments

Comments
 (0)