@@ -19,22 +19,22 @@ Android Timeline View Library demonstrate the the power of ConstraintnLayout and
1919
2020** Using Gradle**
2121
22- Timelineview is currently available in on Jitpack so add the following line before every other thing if you have not done that already.
22+ TimelineView is currently available in on Jitpack so add the following line before every other thing if you have not done that already.
2323
2424``` gradle
2525allprojects {
26- repositories {
27- ...
28- maven { url 'https://jitpack.io' }
29- }
30- }
26+ repositories {
27+ ...
28+ maven { url 'https://jitpack.io' }
29+ }
30+ }
3131```
3232
3333Then add the following line
3434
3535``` gradle
3636dependencies {
37- compile 'com.github.po10cio:TimeLineView:1.0.0'
37+ compile 'com.github.po10cio:TimeLineView:1.0.0'
3838}
3939```
4040
@@ -44,138 +44,130 @@ Also add the following lines before adding the maven dependency
4444
4545``` maven
4646<repositories>
47- <repository>
48- <id>jitpack.io</id>
49- <url>https://jitpack.io</url>
50- </repository>
47+ <repository>
48+ <id>jitpack.io</id>
49+ <url>https://jitpack.io</url>
50+ </repository>
5151</repositories>
5252```
5353Then add the dependency
5454
5555``` maven
5656<dependency>
57- <groupId>com.github.po10cio</groupId>
58- <artifactId>TimeLineView</artifactId>
59- <version>1.0.0</version>
57+ <groupId>com.github.po10cio</groupId>
58+ <artifactId>TimeLineView</artifactId>
59+ <version>1.0.0</version>
6060</dependency>
6161```
6262
6363###2 . Usage
64- In your XML layout include the Timeline View as afollows :
64+ In your XML layout include the TimelineView as follows :
6565
6666``` xml
67- <me .jerryhanks.stepview.TimeLineView
68- android : id =" @+id/timelineView"
69- android : layout_width =" match_parent"
70- android : layout_height =" match_parent"
71- android : layout_marginBottom =" 8dp"
72- android : layout_marginLeft =" 8dp"
73- android : layout_marginRight =" 8dp"
74- android : layout_marginTop =" 16dp" >
75-
67+ <me .jerryhanks.stepview.TimeLineView
68+ android : id =" @+id/timelineView"
69+ android : layout_width =" match_parent"
70+ android : layout_height =" match_parent"
71+ android : layout_marginBottom =" 8dp"
72+ android : layout_marginLeft =" 8dp"
73+ android : layout_marginRight =" 8dp"
74+ android : layout_marginTop =" 16dp" >
75+
7676```
77- Then in your kotlin code, do the following:
77+ Then in your Kotlin code, do the following:
7878
79- ** Create a class that extends Timeline **
79+ ** Create a class that extends TimeLine **
8080
8181``` kotlin
8282class MyTimeLine (status : Status , var title : String? , var content : String? ) : TimeLine(status) {
83-
84-
85- override fun equals (other : Any? ): Boolean {
86- if (this == = other) return true
87- if (javaClass != other?.javaClass) return false
88-
83+ override fun equals (other : Any? ): Boolean {
84+ if (this == = other) return true
85+ if (javaClass != other?.javaClass) return false
8986 other as MyTimeLine
87+
88+ if (title != other.title) return false
89+ if (content != other.content) return false
9090
91- if (title != other.title) return false
92- if (content != other.content) return false
93-
94- return true
95- }
96-
97-
98- override fun hashCode (): Int {
99- var result = if (title != null ) title!! .hashCode() else 0
100- result = 31 * result + if (content != null ) content!! .hashCode() else 0
101- return result
102- }
103-
104- override fun toString (): String {
105- return " MyTimeLine{" +
106- " title='" + title + ' \' ' +
107- " , content='" + content + ' \' ' +
108- ' }'
109- }
110-
111-
91+ return true
92+ }
93+
94+ override fun hashCode (): Int {
95+ var result = if (title != null ) title!! .hashCode() else 0
96+ result = 31 * result + if (content != null ) content!! .hashCode() else 0
97+
98+ return result
99+ }
100+
101+ override fun toString (): String {
102+ return " MyTimeLine{" +
103+ " title='" + title + ' \' ' +
104+ " , content='" + content + ' \' ' +
105+ ' }'
106+ }
112107}
113108```
114109
115110
116- Timeline has three Statuses:
111+ TimeLine has three Statuses:
117112
118113- Status.COMPLETED
119114- Status.UN_COMPLETED
120115- Status.ATTENTION
121116
122- You can choose from any of the statuses depending on the status of the itme you want to represent.
117+ You can choose from any of the statuses depending on the status of the item you want to represent.
123118
124- ** Create an Array of your Timelines **
119+ ** Create an Array of your TimeLine **
125120
126121``` kotlin
127122 val timeLines = mutableListOf<MyTimeLine >()
128- .apply {
129- add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_1), getString(R .string.s_content_1)))
130- add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_2), getString(R .string.s_content_2)))
131- add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_3), getString(R .string.s_content_3)))
132- add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_4), getString(R .string.s_content_4)))
133- add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_5), getString(R .string.s_content_5)))
134- add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_6), getString(R .string.s_content_6)))
135- add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_7), getString(R .string.s_content_7)))
136-
137- }
138-
139-
123+ .apply {
124+ add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_1), getString(R .string.s_content_1)))
125+ add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_2), getString(R .string.s_content_2)))
126+ add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_3), getString(R .string.s_content_3)))
127+ add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_4), getString(R .string.s_content_4)))
128+ add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_5), getString(R .string.s_content_5)))
129+ add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_6), getString(R .string.s_content_6)))
130+ add(MyTimeLine (Status .COMPLETED , getString(R .string.s_title_7), getString(R .string.s_content_7)))
131+ }
140132```
141133
142- ** Create the IndicatorAdapter and add it to the TimelineView **
134+ ** Create the IndicatorAdapter and add it to the TimeLineView **
143135
144136``` kotlin
145- val adapter = IndicatorAdapter (mutableListOf (), this , object : TimeLineViewCallback <MyTimeLine > {
146- override fun onBindView (model : MyTimeLine , container : FrameLayout , position : Int ): View {
147- val view = layoutInflater
148- .inflate(R .layout.sample_time_line,
149- container, false )
150-
151- (view.findViewById<TextView >(R .id.tv_title)).text = model.title
152- (view.findViewById<TextView >(R .id.tv_content)).text = model.content
153-
154- return view
155- }
156- })
157- timelineView.setIndicatorAdapter(adapter)
158- adapter.swapItems(timeLines)
137+ val adapter = IndicatorAdapter (mutableListOf (), this , object : TimeLineViewCallback <MyTimeLine > {
138+ override fun onBindView (model : MyTimeLine , container : FrameLayout , position : Int ): View {
139+ val view = layoutInflater
140+ .inflate(R .layout.sample_time_line,
141+ container, false )
142+
143+ (view.findViewById<TextView >(R .id.tv_title)).text = model.title
144+ (view.findViewById<TextView >(R .id.tv_content)).text = model.content
145+
146+ return view
147+ }
148+ })
149+
150+ timelineView.setIndicatorAdapter(adapter)
151+ adapter.swapItems(timeLines)
159152```
153+
160154** IndicatorAdapter**
161155This extends RecyclerView.Adapter and exposes the following functions:
162156
163157- Swaps the old items with the new items
158+ ``` kotlin
159+ fun swapItems (timeLines : List <T >)
160+ ```
164161
165- ```kotlin
166- fun swapItems(timeLines: List<T>)
167- ```
168- - Update a single item given teh index
162+ - Update a single item given the index
163+ ``` kotlin
164+ fun updateItem ( timeline : T , position : Int )
165+ ```
169166
170- ```kotlin
171- fun updatItem(timeline: T, position: Int)
172- ```
173167- Adds a list of items to the list
174-
175- ```kotlin
176- fun addItems(vararg items: T)
177- ```
178-
168+ ``` kotlin
169+ fun addItems (vararg items : T )
170+ ```
179171
180172## Changelog
181173
@@ -184,4 +176,4 @@ See the [changelog](/CHANGELOG.md) file.
184176
185177## License
186178
187- Time is distributed under the MIT license. [ See LICENSE] ( https://github.com/po10cio/TimeLineView/blob/master/LICENSE.md ) for details.
179+ Time is distributed under the MIT license. [ See LICENSE] ( https://github.com/po10cio/TimeLineView/blob/master/LICENSE.md ) for details.
0 commit comments