Skip to content

Commit

Permalink
Revert change to task click handler, since it's not leaking.
Browse files Browse the repository at this point in the history
  • Loading branch information
khaykov committed Jul 18, 2024
1 parent bc58e15 commit 8f5b6c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
exclusiveBlockStyles = BlockFormatter.ExclusiveBlockStyles(styles.getBoolean(R.styleable.AztecText_exclusiveBlocks, false), verticalParagraphPadding),
paragraphStyle = BlockFormatter.ParagraphStyle(verticalParagraphMargin)
)
EnhancedMovementMethod.setTaskListClickHandler(TaskListClickHandler(listStyle))
EnhancedMovementMethod.taskListClickHandler = TaskListClickHandler(listStyle)

linkFormatter = LinkFormatter(this, LinkFormatter.LinkStyle(styles.getColor(
R.styleable.AztecText_linkColor, 0),
Expand Down Expand Up @@ -955,7 +955,6 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
blockEditorDialog!!.dismiss()
}
EnhancedMovementMethod.setLinkTappedListener(null)
EnhancedMovementMethod.setTaskListClickHandler(null)
}

// We are exposing this method in order to allow subclasses to set their own alpha value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ import java.lang.ref.WeakReference
* http://stackoverflow.com/a/23566268/569430
*/
object EnhancedMovementMethod : ArrowKeyMovementMethod() {
private var taskListClickHandlerRef: WeakReference<TaskListClickHandler?> = WeakReference(null)
var taskListClickHandler: TaskListClickHandler? = null
private var linkTappedListenerRef: WeakReference<AztecText.OnLinkTappedListener?> = WeakReference(null)
var isLinkTapEnabled = false

fun setTaskListClickHandler(handler: TaskListClickHandler?) {
taskListClickHandlerRef = WeakReference(handler)
}

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

// This handles the case when the task list checkbox is clicked
if (taskListClickHandlerRef.get()?.handleTaskListClick(text, off, x, widget.totalPaddingStart) == true) {
if (taskListClickHandler?.handleTaskListClick(text, off, x, widget.totalPaddingStart) == true) {
return true
}

Expand Down

0 comments on commit 8f5b6c3

Please sign in to comment.