Skip to content

Commit 32467f7

Browse files
authored
Merge pull request #10 from lriccardo/release/1.1.1
Release/1.1.1
2 parents 6480b4b + f759c77 commit 32467f7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ allprojects {
5656

5757
```gradle
5858
dependencies {
59-
implementation 'com.github.lriccardo:TimelineView:1.1.0'
59+
implementation 'com.github.lriccardo:TimelineView:1.1.1'
6060
}
6161
```
6262

TimelineView/src/main/java/com/lriccardo/timelineview/TimelineDecorator.kt

+9-3
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ class TimelineDecorator(
5757
}
5858

5959
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
60+
c.save()
61+
c.clipRect(parent.paddingLeft, parent.paddingTop, parent.width, parent.height-parent.paddingBottom)
62+
6063
parent.children.forEach {
6164
val itemPosition = parent.getChildAdapterPosition(it)
6265

6366
if (itemPosition == RecyclerView.NO_POSITION)
6467
return
6568

6669
val timelineView = TimelineView(context = parent.context)
67-
(parent.adapter as? TimelineAdapter)?.run {
70+
71+
(parent.adapter as? TimelineAdapter ?: object : TimelineAdapter {}).run {
6872
getTimelineViewType(itemPosition)?.let {
6973
timelineView.viewType = it
7074
} ?: timelineView.setType(itemPosition, parent.adapter?.itemCount ?: -1)
@@ -95,6 +99,7 @@ class TimelineDecorator(
9599
timelineView.linePadding = it
96100
}
97101
}
102+
98103
timelineView.indicatorSize = indicatorSize
99104

100105
timelineView.indicatorYPosition = indicatorYPosition
@@ -127,16 +132,17 @@ class TimelineDecorator(
127132
c.save()
128133
when (position) {
129134
Position.Left -> {
130-
c.translate(padding, it.top.toFloat())
135+
c.translate(padding+parent.paddingLeft, it.top.toFloat())
131136
timelineView.layout(0, 0, timelineView.measuredWidth, it.measuredHeight)
132137
}
133138
Position.Right -> {
134-
c.translate(it.measuredWidth + padding, it.top.toFloat())
139+
c.translate(it.measuredWidth + padding + parent.paddingLeft, it.top.toFloat())
135140
timelineView.layout(0, 0, timelineView.measuredWidth, it.measuredHeight)
136141
}
137142
}
138143
timelineView.draw(c)
139144
c.restore()
140145
}
146+
c.restore()
141147
}
142148
}

0 commit comments

Comments
 (0)