Skip to content

Commit 6413773

Browse files
committed
Fixed most of lint warnings
1 parent 4b6e761 commit 6413773

File tree

11 files changed

+19
-42
lines changed

11 files changed

+19
-42
lines changed

codeview/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
xmlns:android="http://schemas.android.com/apk/res/android">
33

44
<application
5-
android:allowBackup="true"
65
android:label="@string/app_name"
76
android:supportsRtl="true">
87

codeview/src/main/java/io/github/kbiakov/codeview/highlight/CodeHighlighter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ object CodeHighlighter {
3232
// - Helpers
3333

3434
/**
35-
* Parse user input by extracting highlighted content.
35+
* Parse input by extracting highlighted content.
3636
*
3737
* @param result Syntax unit
38-
* @return Parsed content to highlight
38+
* @return Content to highlight
3939
*/
4040
private infix fun String.highlight(result: ParseResult) = safeLT {
4141
substring(result.offset, result.offset + result.length)

codeview/src/main/java/io/github/kbiakov/codeview/views/LineDiffView.kt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ import io.github.kbiakov.codeview.highlight.FontCache
1515
*
1616
* @author Kirill Biakov
1717
*/
18-
class LineDiffView : RelativeLayout {
18+
class LineDiffView(context: Context) : RelativeLayout(context) {
1919

2020
private val tvLineDiff: TextView
2121
private val tvLineContent: TextView
2222

23-
/**
24-
* Default constructor.
25-
*/
26-
constructor(context: Context) : super(context) {
23+
init {
2724
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
2825
inflater.inflate(R.layout.item_code_diff, this, true)
2926

@@ -39,19 +36,16 @@ class LineDiffView : RelativeLayout {
3936
* @param model Diff model
4037
* @return Created line diff view
4138
*/
42-
fun create(context: Context, model: DiffModel): LineDiffView {
43-
val diffView = LineDiffView(context)
44-
diffView.tvLineDiff.text = if (model.isAddition) "+" else "-"
45-
diffView.tvLineContent.text = model.content
46-
diffView.tvLineContent.typeface = FontCache.get(context).getTypeface(context)
39+
fun create(context: Context, model: DiffModel) = LineDiffView(context).apply {
40+
tvLineDiff.text = if (model.isAddition) "+" else "-"
41+
tvLineContent.text = model.content
42+
tvLineContent.typeface = FontCache.get(context).getTypeface(context)
4743

48-
diffView.setBackgroundColor(ContextCompat.getColor(context,
44+
setBackgroundColor(ContextCompat.getColor(context,
4945
if (model.isAddition)
5046
R.color.diff_add_background
5147
else
5248
R.color.diff_del_background))
53-
54-
return diffView
5549
}
5650
}
5751
}

codeview/src/main/res/layout/item_code_diff.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@
99
android:layout_width="@dimen/line_num_width"
1010
android:layout_height="@dimen/line_height"
1111
android:gravity="center"
12-
android:fontFamily="monospace"
1312
android:textSize="@dimen/line_text_size"
1413
android:text="@string/stub_line_num"/>
1514

1615
<TextView
1716
android:id="@+id/tv_line_content"
1817
android:layout_width="wrap_content"
1918
android:layout_height="@dimen/line_height"
20-
android:layout_marginLeft="16dp"
21-
android:layout_marginRight="16dp"
19+
android:layout_marginLeft="@dimen/default_margin"
20+
android:layout_marginRight="@dimen/default_margin"
21+
android:layout_toEndOf="@+id/tv_line_diff"
2222
android:layout_toRightOf="@+id/tv_line_diff"
2323
android:gravity="center_vertical"
24-
android:fontFamily="monospace"
25-
android:singleLine="true"
24+
android:maxLines="1"
2625
android:textSize="@dimen/line_text_size"
2726
android:text="@string/stub_line_content"/>
2827

codeview/src/main/res/layout/item_code_line.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
android:id="@+id/tv_line_content"
1818
android:layout_width="wrap_content"
1919
android:layout_height="match_parent"
20-
android:layout_marginLeft="16dp"
21-
android:layout_marginRight="16dp"
20+
android:layout_marginLeft="@dimen/default_margin"
21+
android:layout_marginRight="@dimen/default_margin"
22+
android:layout_toEndOf="@+id/tv_line_num"
2223
android:layout_toRightOf="@+id/tv_line_num"
2324
android:gravity="center_vertical"
2425
android:maxLines="1"

codeview/src/main/res/layout/layout_code_view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
android:id="@+id/shadow_right_border"
2424
android:layout_width="@dimen/shadow_width"
2525
android:layout_height="match_parent"
26+
android:layout_alignParentEnd="true"
2627
android:layout_alignParentRight="true"/>
2728

2829
<LinearLayout
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<color name="code_num">#99a8b7</color>
4-
<color name="code_num_background">#f2f2f6</color>
5-
<color name="code_content">#2c2d30</color>
6-
<color name="code_content_background">#e9edf4</color>
7-
<color name="note">#4c5d6e</color>
8-
93
<color name="diff_add_background">#EAFFEA</color>
104
<color name="diff_del_background">#FFECEC</color>
115
</resources>

codeview/src/main/res/values/dimens.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<dimen name="default_margin">16dp</dimen>
34
<dimen name="line_num_width">32dp</dimen>
45
<dimen name="line_height">24dp</dimen>
56
<dimen name="line_border_height">4dp</dimen>

example/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<application
66
android:name=".BaseApplication"
7-
android:allowBackup="true"
87
android:icon="@mipmap/ic_launcher"
98
android:label="@string/app_name"
109
android:supportsRtl="true"
@@ -19,4 +18,4 @@
1918

2019
</application>
2120

22-
</manifest>
21+
</manifest>

example/src/main/res/values-w820dp/dimens.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)