Skip to content

Commit 8cb027a

Browse files
committed
fix : typo
1 parent c76ba5b commit 8cb027a

4 files changed

Lines changed: 78 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
sjdbksb
1+
Change Log
2+
==========
3+
4+
Version 1.0.0 *(2017-11-23)*
5+
----------------------------
6+
7+
- Initial release.
8+
9+
Version 1.0.1 *(2017-12-06)*
10+
----------------------------
11+
12+
- imeLineViewCallback callback now returns a view
File renamed without changes.

README.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# TimeLineView
2-
Android Timeline View Library demostratgin the the power of ConstraintnLayout and RecyclerView.
2+
Android Timeline View Library demonstrate the the power of ConstraintnLayout and RecyclerView.
33

44

55

@@ -8,15 +8,18 @@ Android Timeline View Library demostratgin the the power of ConstraintnLayout an
88

99

1010
##Showcase
11+
12+
1113
<img src="sc/sc1.png" alt="ExampleMain" width="240">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1214
<img src="sc/sc2.png" alt="ExampleMain" width="240">
1315

16+
1417
##Quick Setup
1518
### 1. Include library
1619

1720
**Using Gradle**
1821

19-
Timelineview is currently available in on Gitpack 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.
2023

2124
```gradle
2225
allprojects {
@@ -27,7 +30,7 @@ allprojects {
2730
}
2831
```
2932

30-
Then add the followinf line
33+
Then add the following line
3134

3235
``` gradle
3336
dependencies {
@@ -57,18 +60,6 @@ Then add the dependency
5760
</dependency>
5861
```
5962

60-
61-
#### Manual:
62-
**Manual - Using [Android Studio](https://developer.android.com/sdk/installing/studio.html):**
63-
* Download the library folder and import to your root application folder.
64-
You can manually achieve this step with 3 steps:
65-
66-
1. Paste the folder library into your application at the same level of your app, build and gradle folder
67-
2. Add to your settings.gradle file the following code line: "include ':app', ':timelineview'"
68-
3. Rebuild the project
69-
* File → Project Structure → in Modules section click on "app" → Click on tab "Dependecies" → Click on the green plus → Module Dependecy → Select ":library"
70-
* Done
71-
7263
###2. Usage
7364
In your XML layout include the Timeline View as afollows:
7465

@@ -100,22 +91,19 @@ class MyTimeLine(status: Status, var title: String?, var content: String?) : Tim
10091
if (if (title != null) title != that!!.title else that!!.title != null) return false
10192
return if (content != null) content == that.content else that.content == null
10293
}
103-
104-
override fun hashCode(): Int {
105-
var result = if (title != null) title!!.hashCode() else 0
106-
result = 31 * result + if (content != null) content!!.hashCode() else 0
107-
return result
108-
}
109-
110-
override fun toString(): String {
111-
return "MyTimeLine{" +
112-
"title='" + title + '\'' +
113-
", content='" + content + '\'' +
114-
'}'
11594
}
116-
}
11795

11896
```
97+
98+
99+
Timeline has three Statuses:
100+
101+
- Status.COMPLETED
102+
- Status.UN_COMPLETED
103+
- Status.ATTENTION
104+
105+
You can choose from any of the statuses depending on the status of the itme you want to represent.
106+
119107
**Create an Array of your Timelines**
120108

121109
```kotlin
@@ -150,7 +138,26 @@ val adapter = IndicatorAdapter(timeLines, this, object : TimeLineViewCallback<My
150138
adapter.swapItems(timeLines)
151139

152140
```
141+
**IndicatorAdapter**
142+
This extends RecyclerView.Adapter and exposes the following functions:
143+
144+
- Swaps the old items with the new items
153145

146+
```kotlin
147+
fun swapItems(timeLines: List<T>)
148+
```
149+
- Update a single item given teh index
150+
151+
```kotlin
152+
fun updatItem(timeline: T, position: Int)
153+
```
154+
- Adds a list of items to the list
155+
156+
```kotlin
157+
fun addItems(vararg items: T)
158+
```
159+
160+
154161
## Changelog
155162

156163
See the [changelog](/CHANGELOG.md) file.

timelineview/src/main/java/me/jerryhanks/stepview/IndicatorAdapter.kt

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ import me.jerryhanks.stepview.interfaces.TimeLineViewCallback
1515
import me.jerryhanks.stepview.model.Status
1616
import me.jerryhanks.stepview.model.TimeLine
1717

18-
class IndicatorAdapter<in T : TimeLine>(timeLines: List<T>, private val context: Context, private val _callback: TimeLineViewCallback<T>?) : RecyclerView.Adapter<IndicatorHolder>() {
19-
20-
private var timeLines: List<T> = ArrayList()
21-
22-
init {
23-
this.timeLines = timeLines
24-
}
18+
class IndicatorAdapter<in T : TimeLine>(private val timeLines: MutableList<T>, private val context: Context, private val _callback: TimeLineViewCallback<T>?) : RecyclerView.Adapter<IndicatorHolder>() {
2519

2620
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IndicatorHolder {
2721
val view = LayoutInflater.from(parent.context).inflate(R.layout.timeline_indicator, parent, false)
@@ -76,8 +70,37 @@ class IndicatorAdapter<in T : TimeLine>(timeLines: List<T>, private val context:
7670
return this.timeLines.size
7771
}
7872

73+
/**
74+
* Swaps the old items with the new one
75+
*
76+
* @param timeLines The List of the new items that we want to swap
77+
* */
7978
fun swapItems(timeLines: List<T>) {
80-
this.timeLines = timeLines
79+
this.timeLines.clear()
80+
this.timeLines.addAll(timeLines)
81+
notifyDataSetChanged()
82+
}
83+
84+
/**
85+
* Replaces the item at the given position with the
86+
* given item
87+
*
88+
* @param timeline The item to be replaces
89+
* @param position The index of the item to be replaced
90+
* */
91+
fun updatItem(timeline: T, position: Int) {
92+
this.timeLines[position] = timeline
93+
notifyItemChanged(position)
94+
}
95+
96+
97+
/**
98+
* Adds all the given item to the list
99+
*
100+
* @param items List of items to be added
101+
* */
102+
fun addItems(vararg items: T) {
103+
this.timeLines.addAll(items)
81104
notifyDataSetChanged()
82105
}
83106
}

0 commit comments

Comments
 (0)