Skip to content

Commit f034347

Browse files
committed
update readme
1 parent 9e34317 commit f034347

1 file changed

Lines changed: 39 additions & 20 deletions

File tree

README.md

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Then add the following line
3535

3636
``` gradle
3737
dependencies {
38-
compile 'com.github.po10cio:TimeLineView:1.0.0'
38+
compile 'com.github.po10cio:TimeLineView:1.0.1'
3939
}
4040
```
4141

@@ -57,7 +57,7 @@ Then add the dependency
5757
<dependency>
5858
<groupId>com.github.po10cio</groupId>
5959
<artifactId>TimeLineView</artifactId>
60-
<version>1.0.0</version>
60+
<version>1.0.1</version>
6161
</dependency>
6262
```
6363

@@ -83,17 +83,34 @@ Then in your kotlin code, do the following:
8383
class MyTimeLine(status: Status, var title: String?, var content: String?) : TimeLine(status) {
8484

8585

86-
override fun equals(o: Any?): Boolean {
87-
if (this === o) return true
88-
if (o !is MyTimeLine) return false
86+
override fun equals(other: Any?): Boolean {
87+
if (this === other) return true
88+
if (javaClass != other?.javaClass) return false
8989

90-
val that = o as MyTimeLine?
90+
other as MyTimeLine
9191

92-
if (if (title != null) title != that!!.title else that!!.title != null) return false
93-
return if (content != null) content == that.content else that.content == null
92+
if (title != other.title) return false
93+
if (content != other.content) return false
94+
95+
return true
96+
}
97+
98+
99+
override fun hashCode(): Int {
100+
var result = if (title != null) title!!.hashCode() else 0
101+
result = 31 * result + if (content != null) content!!.hashCode() else 0
102+
return result
94103
}
104+
105+
override fun toString(): String {
106+
return "MyTimeLine{" +
107+
"title='" + title + '\'' +
108+
", content='" + content + '\'' +
109+
'}'
95110
}
96111

112+
113+
}
97114
```
98115

99116

@@ -108,36 +125,38 @@ You can choose from any of the statuses depending on the status of the itme you
108125
**Create an Array of your Timelines**
109126

110127
```kotlin
111-
val timeLines = ArrayList<MyTimeLine>()
112-
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_1), getString(R.string.content_1)))
113-
timeLines.add(MyTimeLine(Status.UN_COMPLETED, getString(R.string.title_2), getString(R.string.content_2)))
114-
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_3), getString(R.string.content_3)))
115-
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_4), getString(R.string.content_4)))
116-
timeLines.add(MyTimeLine(Status.ATTENTION, getString(R.string.title_5), getString(R.string.content_5)))
117-
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_6), getString(R.string.content_6)))
128+
val timeLines = mutableListOf<MyTimeLine>()
129+
.apply {
130+
add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_1), getString(R.string.s_content_1)))
131+
add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_2), getString(R.string.s_content_2)))
132+
add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_3), getString(R.string.s_content_3)))
133+
add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_4), getString(R.string.s_content_4)))
134+
add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_5), getString(R.string.s_content_5)))
135+
add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_6), getString(R.string.s_content_6)))
136+
add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_7), getString(R.string.s_content_7)))
137+
138+
}
139+
118140

119141
```
120142

121143
**Create the IndicatorAdapter and add it to the TimelineView**
122144

123145
```kotlin
124-
val adapter = IndicatorAdapter(timeLines, this, object : TimeLineViewCallback<MyTimeLine> {
146+
val adapter = IndicatorAdapter(mutableListOf(), this, object : TimeLineViewCallback<MyTimeLine> {
125147
override fun onBindView(model: MyTimeLine, container: FrameLayout, position: Int): View {
126148
val view = layoutInflater
127149
.inflate(R.layout.sample_time_line,
128150
container, false)
151+
129152
(view.findViewById<TextView>(R.id.tv_title)).text = model.title
130153
(view.findViewById<TextView>(R.id.tv_content)).text = model.content
131154

132-
//Note, you can set your onclick listeners
133-
//and do other manipulations here
134-
135155
return view
136156
}
137157
})
138158
timelineView.setIndicatorAdapter(adapter)
139159
adapter.swapItems(timeLines)
140-
141160
```
142161
**IndicatorAdapter**
143162
This extends RecyclerView.Adapter and exposes the following functions:

0 commit comments

Comments
 (0)