Skip to content

Commit 5b24740

Browse files
committed
feat : mock timeline
1 parent 87ac2c3 commit 5b24740

5 files changed

Lines changed: 71 additions & 22 deletions

File tree

app/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33

4+
apply plugin: 'kotlin-android-extensions'
5+
46
android {
5-
compileSdkVersion 26
7+
compileSdkVersion 27
68
buildToolsVersion "26.0.2"
79
defaultConfig {
810
applicationId "me.jerryhanks.stepviewapp"
911
minSdkVersion 16
10-
targetSdkVersion 26
12+
targetSdkVersion 27
1113
versionCode 1
1214
versionName "1.0"
1315
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -18,6 +20,11 @@ android {
1820
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1921
}
2022
}
23+
24+
androidExtensions {
25+
experimental = true
26+
}
27+
2128
}
2229

2330
dependencies {

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
11
package me.jerryhanks.stepviewapp
22

3-
import android.support.v7.app.AppCompatActivity
43
import android.os.Bundle
5-
import android.view.Gravity
4+
import android.support.v7.app.AppCompatActivity
65
import android.view.View
7-
import android.view.ViewGroup
86
import android.widget.FrameLayout
97
import android.widget.TextView
10-
11-
import java.util.ArrayList
12-
8+
import kotlinx.android.synthetic.main.activity_main.*
139
import me.jerryhanks.stepview.IndicatorAdapter
14-
import me.jerryhanks.stepview.TimeLineView
1510
import me.jerryhanks.stepview.interfaces.TimeLineViewCallback
1611
import me.jerryhanks.stepview.model.Status
17-
import me.jerryhanks.stepview.model.TimeLine
12+
import java.util.*
1813

1914
class MainActivity : AppCompatActivity() {
2015

2116
override fun onCreate(savedInstanceState: Bundle?) {
2217
super.onCreate(savedInstanceState)
2318
setContentView(R.layout.activity_main)
2419

25-
val timeLineView = findViewById<TimeLineView>(R.id.timeline_view)
20+
val timeLineView = timelineView
2621

2722
val timeLines = ArrayList<MyTimeLine>()
28-
timeLines.add(MyTimeLine(Status.COMPLETED, "Sample Title 1", "Sample content 1"))
29-
timeLines.add(MyTimeLine(Status.UN_COMPLETED, "Sample Title 2", "Sample contentlnldnfln 2sjnlf dfnldnlfndlnf dlflsnfndlnfd fdlfndnlfdf ldnflndlnfd fdlnfldnf dlnflndlfnld"))
30-
timeLines.add(MyTimeLine(Status.COMPLETED, "Sample Title 3", "Sample content 3 kdkjsnxjnfs s f sf snfnslkdnflndlkfnd fdnlfndlnflndfldnflndlnf dfldnfndlnfldf dfnldnflndlnfd fndlnfdnlfd lfndnflndf dlnfldnlfnd fdnlfnd"))
31-
timeLines.add(MyTimeLine(Status.COMPLETED, "Sample Title 4", "Sample content 4 sjdnlsnfndlnflndlfndllnfdnlfknd"))
32-
timeLines.add(MyTimeLine(Status.ATTENTION, "Sample Title 5", "Sample content 5"))
33-
timeLines.add(MyTimeLine(Status.COMPLETED, "Sample Title 6", "Sample content 6 dflndlnfndlnflnd dlnflndlnldnfl dlfndnlndlnldnlfndlnfldnlfndln"))
34-
timeLines.add(MyTimeLine(Status.UN_COMPLETED, "Sample Title 7", "Sample content 7 sdpfjdfpdfjpdjpojdpofm;dfpmpmdpkdk[k[kdfm;dfm[l[dfl][kdf[omd[pkfkdkf'mdmf';mmvwejfopj2wpowmlskbokr"))
23+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_1), getString(R.string.content_1)))
24+
timeLines.add(MyTimeLine(Status.UN_COMPLETED, getString(R.string.title_2), getString(R.string.content_2)))
25+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_3), getString(R.string.content_3)))
26+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_4), getString(R.string.content_4)))
27+
timeLines.add(MyTimeLine(Status.ATTENTION, getString(R.string.title_5), getString(R.string.content_5)))
28+
timeLines.add(MyTimeLine(Status.COMPLETED, getString(R.string.title_6), getString(R.string.content_6)))
3529

3630

3731
val adapter = IndicatorAdapter(timeLines, this, object : TimeLineViewCallback<MyTimeLine> {
3832
override fun onBindView(model: MyTimeLine, container: FrameLayout, position: Int): View {
3933
val view = layoutInflater
40-
.inflate(me.jerryhanks.stepview.R.layout.sample_time_line,
34+
.inflate(R.layout.sample_time_line,
4135
container, false)
4236
(view.findViewById<View>(R.id.tv_title) as TextView).text = model.title
4337
(view.findViewById<View>(R.id.tv_content) as TextView).text = model.content

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,36 @@
66
android:layout_height="match_parent"
77
tools:context="me.jerryhanks.stepviewapp.MainActivity">
88

9+
<TextView
10+
android:id="@+id/textView"
11+
android:layout_width="wrap_content"
12+
android:layout_height="wrap_content"
13+
android:layout_alignParentLeft="true"
14+
android:layout_alignParentStart="true"
15+
android:layout_alignParentTop="true"
16+
android:layout_marginEnd="8dp"
17+
android:layout_marginStart="8dp"
18+
android:layout_marginTop="8dp"
19+
android:text="Timeline of World War I"
20+
android:textAppearance="@style/TextAppearance.AppCompat.Light.SearchResult.Title"
21+
app:layout_constraintEnd_toEndOf="parent"
22+
app:layout_constraintStart_toStartOf="parent"
23+
app:layout_constraintTop_toTopOf="parent" />
24+
925
<me.jerryhanks.stepview.TimeLineView
10-
android:id="@+id/timeline_view"
26+
android:id="@+id/timelineView"
1127
android:layout_width="0dp"
1228
android:layout_height="0dp"
1329
android:layout_marginBottom="8dp"
1430
android:layout_marginLeft="8dp"
1531
android:layout_marginRight="8dp"
16-
android:layout_marginTop="8dp"
32+
android:layout_marginTop="16dp"
1733
app:layout_constraintBottom_toBottomOf="parent"
1834
app:layout_constraintLeft_toLeftOf="parent"
1935
app:layout_constraintRight_toRightOf="parent"
20-
app:layout_constraintTop_toTopOf="parent">
36+
app:layout_constraintTop_toBottomOf="@+id/textView"
37+
app:layout_constraintVertical_bias="0.0">
38+
2139

2240
</me.jerryhanks.stepview.TimeLineView>
2341

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
11
<resources>
22
<string name="app_name">StepViewApp</string>
3+
<string name="title_1">1914</string>
4+
<string name="title_2">1915</string>
5+
<string name="title_3">1916</string>
6+
<string name="title_4">1917</string>
7+
<string name="title_5">1918</string>
8+
<string name="title_6">1919</string>
9+
<string name="content_1">Assassination of Archduke Franz Ferdinand of Austria, heir to the
10+
Austro-Hungarian throne, who was killed in Sarajevo along with his wife Duchess Sophie by Bosnian\n\nGermany declares war on France.[11] Belgium denies permission for German forces to pass through to the French border
11+
</string>
12+
13+
<string name="content_2">
14+
First Zeppelin raid on Great Britain. Italy declares war on Australia-Hungary\n\nKosovo Offensive, a phase of the Central Powers invasion of Serbia, Serbians
15+
pushed into Albania.</string>
16+
17+
<string name="content_3">
18+
The Gallipoli Campaign ends in an Allied defeat and an Ottoman victory.\n\nBattle of Doberdo, part of the Sixth Battle of Isonzo.\n\nAllies capture Yanbu. Grigori Rasputin, Russia's éminence grise, is assassinated.
19+
</string>
20+
21+
<string name="content_4">
22+
British raid the Ancre. France: Paul Painlevé is replaced by Georges Clemenceau as Prime Minister.\n\nArmistice between Russia and the Central Powers, to take effect on December 17.
23+
</string>
24+
25+
<string name="content_5">
26+
Woodrow Wilson outlines his Fourteen Points. Operation Faustschlag, last offensive on Eastern Front.\n\nYugoslav independence proclaimed.
27+
</string>
28+
29+
<string name="content_6">
30+
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
31+
</string>
332
</resources>

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ buildscript {
1010
classpath 'com.android.tools.build:gradle:3.0.1'
1111
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13+
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
1314

1415
// NOTE: Do not place your application dependencies here; they belong
1516
// in the individual module build.gradle files

0 commit comments

Comments
 (0)