Skip to content

Commit d6267e5

Browse files
committed
Code line click listener upgraded
1 parent 19f3dbc commit d6267e5

3 files changed

Lines changed: 3 additions & 5 deletions

File tree

codeview/src/main/java/io/github/kbiakov/codeview/CodeContentAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class CodeContentAdapter : RecyclerView.Adapter<CodeContentAdapter.ViewHolder> {
178178
holder.mItem = codeLine
179179

180180
holder.itemView.setOnClickListener {
181-
codeListener?.onCodeLineClicked(position)
181+
codeListener?.onCodeLineClicked(position + 1, codeLine)
182182
}
183183

184184
holder.tvLineContent.text = html(codeLine)

codeview/src/main/java/io/github/kbiakov/codeview/CodeView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class CodeView : RelativeLayout {
264264
val lineHeight = dpToPx(context, 24)
265265
val topPadding = dpToPx(context, 8)
266266

267-
// double padding (top & bottom) for big view, one is enough for small
267+
// double padding (top & bottom), one is enough for single line view
268268
val padding = (if (linesCount > 1) 2 else 1) * topPadding
269269

270270
val height = linesCount * lineHeight + padding
@@ -296,7 +296,7 @@ class CodeView : RelativeLayout {
296296
* Provides listener to code line clicks.
297297
*/
298298
interface OnCodeLineClickListener {
299-
fun onCodeLineClicked(n: Int)
299+
fun onCodeLineClicked(n: Int, line: String)
300300
}
301301

302302
/**

example/src/main/java/io/github/kbiakov/codeviewexample/ListingsActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import android.os.Bundle;
44
import android.support.annotation.Nullable;
5-
import android.support.v4.content.ContextCompat;
65
import android.support.v7.app.AppCompatActivity;
7-
import android.util.Log;
86

97
import io.github.kbiakov.codeview.CodeView;
108
import io.github.kbiakov.codeview.highlight.ColorTheme;

0 commit comments

Comments
 (0)