Skip to content

Commit e91ec10

Browse files
authored
Merge pull request #1005 from wordpress-mobile/issue/add-plugin-for-intercepting-draw-cycle
Add onDraw plugin and header leading margin option
2 parents 79cfcff + 65fbaf8 commit e91ec10

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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+
plugins.filterIsInstance<IOnDrawPlugin>().forEach {
319+
it.onDraw(canvas)
320+
}
321+
super.onDraw(canvas)
322+
}
323+
316324
interface OnSelectionChangedListener {
317325
fun onSelectionChanged(selStart: Int, selEnd: Int)
318326
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 but before the super call.
11+
* @param canvas canvas of AztecText
12+
*/
13+
fun onDraw(canvas: Canvas)
14+
}

0 commit comments

Comments
 (0)