Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/mcbfc/llms.txt
Use this file to discover all available pages before exploring further.
BlockCodeEntry (package com.srm.markdown_render) extends MarkwonAdapter.Entry<FencedCodeBlock, BlockCodeEntry.Holder> and tells MarkwonAdapter how to inflate and bind the custom fenced_code_view.xml layout for every FencedCodeBlock node encountered in a parsed markdown document. It is responsible for both inflating the view hierarchy and wiring the copy-to-clipboard ImageButton at bind time via the nested Holder.
Class constructor
The Android
Context stored as a public property on the class. It is forwarded to every Holder instance created by createHolder so the click listener inside Holder.init can call ctx.getSystemService(Context.CLIPBOARD_SERVICE) to obtain a ClipboardManager and Toast.makeText(ctx, …) to display confirmation feedback to the user.createHolder
Overrides MarkwonAdapter.Entry.createHolder to inflate the fenced-code item layout and wrap it in a Holder.
p0.inflate(R.layout.fenced_code_view, p1, false) to produce a non-attached root View, then passes that view together with ctx into Holder(…). The resulting Holder is returned to MarkwonAdapter, which retains it in the RecyclerView pool for reuse.
bindHolder
Overrides MarkwonAdapter.Entry.bindHolder to render the FencedCodeBlock AST node into the Holder’s TextView.
p0.setParsedMarkdown(p1.commandText, p0.render(p2)) — p0.render(p2) converts the FencedCodeBlock node into Android Spanned text (applying Markwon’s code-block spans), and setParsedMarkdown applies that Spanned result directly to p1.commandText without triggering another parse pass.
Holder class
BlockCodeEntry.Holder extends MarkwonAdapter.Holder and owns the two interactive views inside fenced_code_view.xml.
Fields
Bound to
R.id.command via requireView<TextView>(R.id.command). Receives the rendered Spanned code text in bindHolder and its .text property is read by the copy button click listener.Bound to
R.id.copyCommand via requireView<ImageButton>(R.id.copyCommand). The copy action OnClickListener is attached to this button inside the init block.init block — copy button wiring
The init block calls btnCopy.setOnClickListener { v -> … } with the following steps:
- Reads
commandText.text.trim()to obtain the code text with leading/trailing whitespace removed. - Obtains
ClipboardManagerviactx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager. - Creates a
ClipDatawithClipData.newPlainText("Command", text). - Calls
clipBoard.setPrimaryClip(textClip)to write to the system clipboard. - Shows a confirmation
ToastwithToast.LENGTH_LONGthat includes the first 7 characters of the copied text:"Code copied to clipboard! ${text.subSequence(1..7)} ...".
Full source
BlockCodeEntry.kt