Skip to content

Commit c76ba5b

Browse files
committed
feat : add readme
1 parent 5b24740 commit c76ba5b

10 files changed

Lines changed: 222 additions & 10 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sjdbksb

LICENCE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Jerry Hanks
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# TimeLineView
2+
Android Timeline View Library demostratgin the the power of ConstraintnLayout and RecyclerView.
3+
4+
5+
6+
[![](https://jitpack.io/v/po10cio/TimeLineView.svg)](https://jitpack.io/#po10cio/TimeLineView)
7+
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/po10cio/TimeLineView/blob/master/LICENSE.md)
8+
9+
10+
##Showcase
11+
<img src="sc/sc1.png" alt="ExampleMain" width="240">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
12+
<img src="sc/sc2.png" alt="ExampleMain" width="240">
13+
14+
##Quick Setup
15+
### 1. Include library
16+
17+
**Using Gradle**
18+
19+
Timelineview is currently available in on Gitpack so add the following line before every other thing if you have not done that already.
20+
21+
```gradle
22+
allprojects {
23+
repositories {
24+
...
25+
maven { url 'https://jitpack.io' }
26+
}
27+
}
28+
```
29+
30+
Then add the followinf line
31+
32+
``` gradle
33+
dependencies {
34+
compile 'com.github.po10cio:TimeLineView:1.0.0'
35+
}
36+
```
37+
38+
**Using Maven**
39+
40+
Also add the following lines before adding the maven dependency
41+
42+
```maven
43+
<repositories>
44+
<repository>
45+
<id>jitpack.io</id>
46+
<url>https://jitpack.io</url>
47+
</repository>
48+
</repositories>
49+
```
50+
Then add the dependency
51+
52+
``` maven
53+
<dependency>
54+
<groupId>com.github.po10cio</groupId>
55+
<artifactId>TimeLineView</artifactId>
56+
<version>1.0.0</version>
57+
</dependency>
58+
```
59+
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+
72+
###2. Usage
73+
In your XML layout include the Timeline View as afollows:
74+
75+
```xml
76+
<me.jerryhanks.stepview.TimeLineView
77+
android:id="@+id/timelineView"
78+
android:layout_width="match_parent"
79+
android:layout_height="match_parent"
80+
android:layout_marginBottom="8dp"
81+
android:layout_marginLeft="8dp"
82+
android:layout_marginRight="8dp"
83+
android:layout_marginTop="16dp">
84+
85+
```
86+
Then in your kotlin code, do the following:
87+
88+
**Create a class that extends Timeline**
89+
90+
```kotlin
91+
class MyTimeLine(status: Status, var title: String?, var content: String?) : TimeLine(status) {
92+
93+
94+
override fun equals(o: Any?): Boolean {
95+
if (this === o) return true
96+
if (o !is MyTimeLine) return false
97+
98+
val that = o as MyTimeLine?
99+
100+
if (if (title != null) title != that!!.title else that!!.title != null) return false
101+
return if (content != null) content == that.content else that.content == null
102+
}
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+
'}'
115+
}
116+
}
117+
118+
```
119+
**Create an Array of your Timelines**
120+
121+
```kotlin
122+
val timeLines = ArrayList<MyTimeLine>()
123+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_1), getString(R.string.content_1)))
124+
timeLines.add(MyTimeLine(Status.UN_COMPLETED, getString(R.string.title_2), getString(R.string.content_2)))
125+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_3), getString(R.string.content_3)))
126+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_4), getString(R.string.content_4)))
127+
timeLines.add(MyTimeLine(Status.ATTENTION, getString(R.string.title_5), getString(R.string.content_5)))
128+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_6), getString(R.string.content_6)))
129+
130+
```
131+
132+
**Create the IndicatorAdapter and add it to the TimelineView**
133+
134+
```kotlin
135+
val adapter = IndicatorAdapter(timeLines, this, object : TimeLineViewCallback<MyTimeLine> {
136+
override fun onBindView(model: MyTimeLine, container: FrameLayout, position: Int): View {
137+
val view = layoutInflater
138+
.inflate(R.layout.sample_time_line,
139+
container, false)
140+
(view.findViewById<TextView>(R.id.tv_title)).text = model.title
141+
(view.findViewById<TextView>(R.id.tv_content)).text = model.content
142+
143+
//Note, you can set your onclick listeners
144+
//and do other manipulations here
145+
146+
return view
147+
}
148+
})
149+
timelineView.setIndicatorAdapter(adapter)
150+
adapter.swapItems(timeLines)
151+
152+
```
153+
154+
## Changelog
155+
156+
See the [changelog](/CHANGELOG.md) file.
157+
158+
159+
## License
160+
161+
Time is distributed under the MIT license. [See LICENSE](https://github.com/po10cio/TimeLineView/blob/master/LICENSE.md) for details.

app/src/main/java/me/jerryhanks/stepviewapp/MainActivity.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class MainActivity : AppCompatActivity() {
1717
super.onCreate(savedInstanceState)
1818
setContentView(R.layout.activity_main)
1919

20-
val timeLineView = timelineView
21-
2220
val timeLines = ArrayList<MyTimeLine>()
2321
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_1), getString(R.string.content_1)))
2422
timeLines.add(MyTimeLine(Status.UN_COMPLETED, getString(R.string.title_2), getString(R.string.content_2)))
@@ -27,19 +25,33 @@ class MainActivity : AppCompatActivity() {
2725
timeLines.add(MyTimeLine(Status.ATTENTION, getString(R.string.title_5), getString(R.string.content_5)))
2826
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_6), getString(R.string.content_6)))
2927

28+
//
29+
// timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_1), getString(R.string.s_content_1)))
30+
// timeLines.add(MyTimeLine(Status.UN_COMPLETED, getString(R.string.s_title_2), getString(R.string.s_content_2)))
31+
// timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_3), getString(R.string.s_content_3)))
32+
// timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_4), getString(R.string.s_content_4)))
33+
// timeLines.add(MyTimeLine(Status.ATTENTION, getString(R.string.s_title_5), getString(R.string.s_content_5)))
34+
// timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.s_title_6), getString(R.string.s_content_6)))
35+
3036

3137
val adapter = IndicatorAdapter(timeLines, this, object : TimeLineViewCallback<MyTimeLine> {
3238
override fun onBindView(model: MyTimeLine, container: FrameLayout, position: Int): View {
3339
val view = layoutInflater
3440
.inflate(R.layout.sample_time_line,
3541
container, false)
36-
(view.findViewById<View>(R.id.tv_title) as TextView).text = model.title
37-
(view.findViewById<View>(R.id.tv_content) as TextView).text = model.content
42+
43+
(view.findViewById<TextView>(R.id.tv_title)).text = model.title
44+
(view.findViewById<TextView>(R.id.tv_content)).text = model.content
3845

3946
return view
4047
}
4148
})
42-
timeLineView.setIndicatorAdapter(adapter)
49+
timelineView.setIndicatorAdapter(adapter)
4350
adapter.swapItems(timeLines)
51+
52+
//set the title
53+
caption.text = getString(R.string.timeline_of_world_war_i)
54+
// caption.text = getString(R.string.delivery_status)
55+
4456
}
4557
}

app/src/main/res/layout/activity_main.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
tools:context="me.jerryhanks.stepviewapp.MainActivity">
88

99
<TextView
10-
android:id="@+id/textView"
10+
android:id="@+id/caption"
1111
android:layout_width="wrap_content"
1212
android:layout_height="wrap_content"
1313
android:layout_alignParentLeft="true"
@@ -16,11 +16,11 @@
1616
android:layout_marginEnd="8dp"
1717
android:layout_marginStart="8dp"
1818
android:layout_marginTop="8dp"
19-
android:text="Timeline of World War I"
2019
android:textAppearance="@style/TextAppearance.AppCompat.Light.SearchResult.Title"
2120
app:layout_constraintEnd_toEndOf="parent"
2221
app:layout_constraintStart_toStartOf="parent"
23-
app:layout_constraintTop_toTopOf="parent" />
22+
app:layout_constraintTop_toTopOf="parent"
23+
tools:text="@string/delivery_status" />
2424

2525
<me.jerryhanks.stepview.TimeLineView
2626
android:id="@+id/timelineView"
@@ -33,7 +33,7 @@
3333
app:layout_constraintBottom_toBottomOf="parent"
3434
app:layout_constraintLeft_toLeftOf="parent"
3535
app:layout_constraintRight_toRightOf="parent"
36-
app:layout_constraintTop_toBottomOf="@+id/textView"
36+
app:layout_constraintTop_toBottomOf="@+id/caption"
3737
app:layout_constraintVertical_bias="0.0">
3838

3939

app/src/main/res/values/strings.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,20 @@
2929
<string name="content_6">
3030
Fakhri Pasha surrenders at Medina. Treaty of Versailles between the Allies and Germany: the Peace Conference opens in Paris\n\nThe United Kingdom ratifies the Treaty of Versailles
3131
</string>
32+
33+
<string name="s_title_1">UnAssigned</string>
34+
<string name="s_title_2">Assigned</string>
35+
<string name="s_title_3">Acknowledged</string>
36+
<string name="s_title_4">Arrived Pickup</string>
37+
<string name="s_title_5">Pickup</string>
38+
<string name="s_title_6">Arrived Delivery</string>
39+
<string name="s_title_7">Delivered</string>
40+
<string name="s_content_1">Oct 30, 2017 @ 3:30 PM</string>
41+
<string name="s_content_2">Oct 30, 2017 @ 3:33 PM</string>
42+
<string name="s_content_3">Oct 30, 2017 @ 3:35 PM</string>
43+
<string name="s_content_4">Oct 30, 2017 @ 3:40 PM</string>
44+
<string name="s_content_5">Oct 30, 2017 @ 3:50 PM</string>
45+
<string name="s_content_6">Oct 30, 2017 @ 4:30 PM</string>
46+
<string name="timeline_of_world_war_i">Timeline of World War I</string>
47+
<string name="delivery_status">Delivery Statuses</string>
3248
</resources>

sc/sc1.png

215 KB
Loading

sc/sc2.png

178 KB
Loading

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class TimeLineView : RelativeLayout {
3434
private fun init() {
3535
View.inflate(context, R.layout.timeline_view, this)
3636
recyclerView = findViewById(R.id.recycler)
37+
recyclerView.isNestedScrollingEnabled = true
3738
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
3839
}
3940

0 commit comments

Comments
 (0)