File tree Expand file tree Collapse file tree
codeview/src/main/java/io/github/kbiakov/codeview
java/io/github/kbiakov/codeviewexample Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ import android.view.LayoutInflater
66import android.view.View
77import android.view.ViewGroup
88import android.widget.TextView
9- import io.github.kbiakov.codeview.classifier.CodeProcessor
10- import io.github.kbiakov.codeview.highlight.*
119import io.github.kbiakov.codeview.Thread.async
1210import io.github.kbiakov.codeview.Thread.ui
1311import io.github.kbiakov.codeview.classifier.CodeClassifier
12+ import io.github.kbiakov.codeview.classifier.CodeProcessor
13+ import io.github.kbiakov.codeview.highlight.*
1414import java.util.*
1515
1616/* *
@@ -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 )
182182 }
183183
184184 holder.tvLineContent.text = html(codeLine)
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import android.view.ViewPropertyAnimator
1313import android.widget.RelativeLayout
1414import io.github.kbiakov.codeview.highlight.ColorTheme
1515import io.github.kbiakov.codeview.highlight.ColorThemeData
16- import io.github.kbiakov.codeview.highlight.color
1716import java.util.*
1817
1918/* *
@@ -186,7 +185,7 @@ class CodeView : RelativeLayout {
186185 * @param isVisible Shadows visibility
187186 */
188187 fun setShadowsVisible (isVisible : Boolean = true) = addTask {
189- val visibility = if (isVisible) View . VISIBLE else GONE
188+ val visibility = if (isVisible) VISIBLE else GONE
190189 vShadowRight.visibility = visibility
191190 vShadowBottomLine.visibility = visibility
192191 vShadowBottomContent.visibility = visibility
@@ -271,17 +270,16 @@ class CodeView : RelativeLayout {
271270
272271 vPlaceholder.layoutParams = RelativeLayout .LayoutParams (
273272 RelativeLayout .LayoutParams .MATCH_PARENT , height)
274- vPlaceholder.visibility = View .VISIBLE
273+
274+ vPlaceholder.alpha = 1f
275275 }
276276
277277 // - Animations
278278
279279 private fun hidePlaceholder () = vPlaceholder.animate()
280280 .setDuration(350 )
281281 .alpha(0f )
282- .didAnimated {
283- vPlaceholder.visibility = View .GONE
284- }
282+ .didAnimated { vPlaceholder.alpha = 0f }
285283
286284 private fun refreshAnimated () = animate()
287285 .setDuration(150 )
Original file line number Diff line number Diff line change 22
33import android .os .Bundle ;
44import android .support .annotation .Nullable ;
5- import android .support .v4 .content .ContextCompat ;
65import android .support .v7 .app .AppCompatActivity ;
76import android .util .Log ;
87
98import io .github .kbiakov .codeview .CodeView ;
9+ import io .github .kbiakov .codeview .OnCodeLineClickListener ;
1010import io .github .kbiakov .codeview .highlight .ColorTheme ;
1111
1212public class ListingsActivity extends AppCompatActivity {
@@ -18,7 +18,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
1818
1919 //int myColor = ContextCompat.getColor(this, R.color.code_content_background);
2020
21- CodeView codeView = (CodeView ) findViewById (R .id .code_view );
21+ final CodeView codeView = (CodeView ) findViewById (R .id .code_view );
2222
2323 // use chaining to build view
2424 codeView .highlightCode ("js" )
@@ -30,5 +30,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3030 codeView .setCodeContent (getString (R .string .listing_java ));
3131 codeView .setColorTheme (ColorTheme .DEFAULT );
3232 codeView .highlightCode ("java" );
33+
34+ codeView .setCodeListener (new OnCodeLineClickListener () {
35+ @ Override
36+ public void onCodeLineClicked (int n ) {
37+ Log .i ("example" , "Line: " + n );
38+ }
39+ });
3340 }
3441}
Original file line number Diff line number Diff line change 44 xmlns : tools =" http://schemas.android.com/tools"
55 android : layout_width =" match_parent"
66 android : layout_height =" match_parent"
7+ android : animateLayoutChanges =" true"
78 tools : context =" .ListingsActivity" >
89
910 <io .github.kbiakov.codeview.CodeView
You can’t perform that action at this time.
0 commit comments