Skip to content

Commit 87ac2c3

Browse files
committed
feat : add kotlin support
1 parent 36ca0b9 commit 87ac2c3

23 files changed

Lines changed: 322 additions & 385 deletions

File tree

README.md

Whitespace-only changes.

app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
23

34
android {
45
compileSdkVersion 26
@@ -29,4 +30,8 @@ dependencies {
2930

3031
testCompile 'junit:junit:4.12'
3132
compile project(':timelineview')
33+
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34+
}
35+
repositories {
36+
mavenCentral()
3237
}

app/src/androidTest/java/me/jerryhanks/stepviewapp/ExampleInstrumentedTest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package me.jerryhanks.stepviewapp
2+
3+
import android.content.Context
4+
import android.support.test.InstrumentationRegistry
5+
import android.support.test.runner.AndroidJUnit4
6+
7+
import org.junit.Test
8+
import org.junit.runner.RunWith
9+
10+
import org.junit.Assert.*
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see [Testing documentation](http://d.android.com/tools/testing)
16+
*/
17+
@RunWith(AndroidJUnit4::class)
18+
class ExampleInstrumentedTest {
19+
@Test
20+
@Throws(Exception::class)
21+
fun useAppContext() {
22+
// Context of the app under test.
23+
val appContext = InstrumentationRegistry.getTargetContext()
24+
25+
assertEquals("me.jerryhanks.stepviewapp", appContext.packageName)
26+
}
27+
}

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

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package me.jerryhanks.stepviewapp
2+
3+
import android.support.v7.app.AppCompatActivity
4+
import android.os.Bundle
5+
import android.view.Gravity
6+
import android.view.View
7+
import android.view.ViewGroup
8+
import android.widget.FrameLayout
9+
import android.widget.TextView
10+
11+
import java.util.ArrayList
12+
13+
import me.jerryhanks.stepview.IndicatorAdapter
14+
import me.jerryhanks.stepview.TimeLineView
15+
import me.jerryhanks.stepview.interfaces.TimeLineViewCallback
16+
import me.jerryhanks.stepview.model.Status
17+
import me.jerryhanks.stepview.model.TimeLine
18+
19+
class MainActivity : AppCompatActivity() {
20+
21+
override fun onCreate(savedInstanceState: Bundle?) {
22+
super.onCreate(savedInstanceState)
23+
setContentView(R.layout.activity_main)
24+
25+
val timeLineView = findViewById<TimeLineView>(R.id.timeline_view)
26+
27+
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"))
35+
36+
37+
val adapter = IndicatorAdapter(timeLines, this, object : TimeLineViewCallback<MyTimeLine> {
38+
override fun onBindView(model: MyTimeLine, container: FrameLayout, position: Int): View {
39+
val view = layoutInflater
40+
.inflate(me.jerryhanks.stepview.R.layout.sample_time_line,
41+
container, false)
42+
(view.findViewById<View>(R.id.tv_title) as TextView).text = model.title
43+
(view.findViewById<View>(R.id.tv_content) as TextView).text = model.content
44+
45+
return view
46+
}
47+
})
48+
timeLineView.setIndicatorAdapter(adapter)
49+
adapter.swapItems(timeLines)
50+
}
51+
}

app/src/main/java/me/jerryhanks/stepviewapp/MyTimeLine.java

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package me.jerryhanks.stepviewapp
2+
3+
import me.jerryhanks.stepview.model.Status
4+
import me.jerryhanks.stepview.model.TimeLine
5+
6+
/**
7+
* @author <@Po10cio> on 10/18/17 for StepViewApp
8+
*/
9+
10+
class MyTimeLine(status: Status, var title: String?, var content: String?) : TimeLine(status) {
11+
12+
13+
override fun equals(o: Any?): Boolean {
14+
if (this === o) return true
15+
if (o !is MyTimeLine) return false
16+
17+
val that = o as MyTimeLine?
18+
19+
if (if (title != null) title != that!!.title else that!!.title != null) return false
20+
return if (content != null) content == that.content else that.content == null
21+
}
22+
23+
override fun hashCode(): Int {
24+
var result = if (title != null) title!!.hashCode() else 0
25+
result = 31 * result + if (content != null) content!!.hashCode() else 0
26+
return result
27+
}
28+
29+
override fun toString(): String {
30+
return "MyTimeLine{" +
31+
"title='" + title + '\'' +
32+
", content='" + content + '\'' +
33+
'}'
34+
}
35+
}

app/src/test/java/me/jerryhanks/stepviewapp/ExampleUnitTest.java

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package me.jerryhanks.stepviewapp
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* @see [Testing documentation](http://d.android.com/tools/testing)
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
@Throws(Exception::class)
15+
fun addition_isCorrect() {
16+
assertEquals(4, (2 + 2).toLong())
17+
}
18+
}

0 commit comments

Comments
 (0)