Skip to content

Commit 8f5b6c3

Browse files
committed
Revert change to task click handler, since it's not leaking.
1 parent bc58e15 commit 8f5b6c3

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
542542
exclusiveBlockStyles = BlockFormatter.ExclusiveBlockStyles(styles.getBoolean(R.styleable.AztecText_exclusiveBlocks, false), verticalParagraphPadding),
543543
paragraphStyle = BlockFormatter.ParagraphStyle(verticalParagraphMargin)
544544
)
545-
EnhancedMovementMethod.setTaskListClickHandler(TaskListClickHandler(listStyle))
545+
EnhancedMovementMethod.taskListClickHandler = TaskListClickHandler(listStyle)
546546

547547
linkFormatter = LinkFormatter(this, LinkFormatter.LinkStyle(styles.getColor(
548548
R.styleable.AztecText_linkColor, 0),
@@ -955,7 +955,6 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
955955
blockEditorDialog!!.dismiss()
956956
}
957957
EnhancedMovementMethod.setLinkTappedListener(null)
958-
EnhancedMovementMethod.setTaskListClickHandler(null)
959958
}
960959

961960
// We are exposing this method in order to allow subclasses to set their own alpha value

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ import java.lang.ref.WeakReference
1515
* http://stackoverflow.com/a/23566268/569430
1616
*/
1717
object EnhancedMovementMethod : ArrowKeyMovementMethod() {
18-
private var taskListClickHandlerRef: WeakReference<TaskListClickHandler?> = WeakReference(null)
18+
var taskListClickHandler: TaskListClickHandler? = null
1919
private var linkTappedListenerRef: WeakReference<AztecText.OnLinkTappedListener?> = WeakReference(null)
2020
var isLinkTapEnabled = false
2121

22-
fun setTaskListClickHandler(handler: TaskListClickHandler?) {
23-
taskListClickHandlerRef = WeakReference(handler)
24-
}
2522

2623
fun setLinkTappedListener(listener: AztecText.OnLinkTappedListener?) {
2724
linkTappedListenerRef = WeakReference(listener)
@@ -47,7 +44,7 @@ object EnhancedMovementMethod : ArrowKeyMovementMethod() {
4744
val off = layout.getOffsetForHorizontal(line, x.toFloat())
4845

4946
// This handles the case when the task list checkbox is clicked
50-
if (taskListClickHandlerRef.get()?.handleTaskListClick(text, off, x, widget.totalPaddingStart) == true) {
47+
if (taskListClickHandler?.handleTaskListClick(text, off, x, widget.totalPaddingStart) == true) {
5148
return true
5249
}
5350

0 commit comments

Comments
 (0)