Skip to content

Commit 0415540

Browse files
Piotr Zawadzkizawadz88
authored andcommitted
Migrated the sample app to Kotlin
1 parent 55cf558 commit 0415540

File tree

78 files changed

+1904
-2129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1904
-2129
lines changed

build.gradle

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
buildscript {
2+
ext.gradleAndroidVersion = '2.3.1'
3+
ext.kotlinVersion = '1.1.2-3'
4+
ext.bintrayVersion = '1.4'
5+
ext.mavenGradlePluginVersion = '1.4.1'
6+
27
repositories {
38
jcenter()
49
}
510
dependencies {
6-
classpath 'com.android.tools.build:gradle:2.3.0'
7-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
8-
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
9-
11+
classpath "com.android.tools.build:gradle:$gradleAndroidVersion"
12+
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintrayVersion"
13+
classpath "com.github.dcendents:android-maven-gradle-plugin:$mavenGradlePluginVersion"
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1015
}
1116
}
1217

@@ -22,17 +27,17 @@ configure(allprojects) {
2227
androidMinSdkVersion = 14
2328
androidTargetSdkVersion = 25
2429
androidCompileSdkVersion = 25
25-
androidBuildToolsVersion = "25.0.2"
26-
androidSupportLibraryVersion = "25.3.1"
30+
androidBuildToolsVersion = '25.0.2'
31+
androidSupportLibraryVersion = '25.3.1'
2732

28-
junitVersion = "4.12"
29-
mockitoVersion = "1.10.19"
30-
robolectricVersion = "3.3.1"
31-
assertjVersion = "1.1.1"
33+
junitVersion = '4.12'
34+
mockitoVersion = '1.10.19'
35+
robolectricVersion = '3.3.1'
36+
assertjVersion = '1.1.1'
3237

3338
/* Sample only */
34-
butterknifeVersion = "7.0.1"
35-
calligraphyVersion = "2.2.0"
39+
butterknifeVersion = '8.5.1'
40+
calligraphyVersion = '2.2.0'
3641
}
3742

3843
}

sample/build.gradle

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-kapt'
24

35
android {
46
compileSdkVersion project.androidCompileSdkVersion
@@ -21,12 +23,21 @@ android {
2123
}
2224
}
2325

24-
2526
dependencies {
27+
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
28+
2629
compile project(':material-stepper')
27-
compile ("com.android.support:appcompat-v7:$androidSupportLibraryVersion")
28-
compile ("com.android.support:recyclerview-v7:$androidSupportLibraryVersion")
29-
compile ("com.android.support:design:$androidSupportLibraryVersion")
30-
compile ("com.jakewharton:butterknife:$butterknifeVersion")
31-
compile ("uk.co.chrisjenx:calligraphy:$calligraphyVersion")
30+
compile "com.android.support:appcompat-v7:$androidSupportLibraryVersion"
31+
compile "com.android.support:recyclerview-v7:$androidSupportLibraryVersion"
32+
compile "com.android.support:design:$androidSupportLibraryVersion"
33+
34+
compile "com.jakewharton:butterknife:$butterknifeVersion"
35+
kapt "com.jakewharton:butterknife-compiler:$butterknifeVersion"
36+
37+
compile "uk.co.chrisjenx:calligraphy:$calligraphyVersion"
38+
39+
}
40+
41+
repositories {
42+
mavenCentral()
3243
}

sample/src/main/java/com/stepstone/stepper/sample/AbstractStepperActivity.java

Lines changed: 0 additions & 99 deletions
This file was deleted.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
Copyright 2016 StepStone Services
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package com.stepstone.stepper.sample
18+
19+
import android.os.Bundle
20+
import android.support.annotation.LayoutRes
21+
import android.support.v7.app.AppCompatActivity
22+
import android.view.View
23+
import android.widget.Toast
24+
import butterknife.BindView
25+
26+
import com.stepstone.stepper.StepperLayout
27+
import com.stepstone.stepper.VerificationError
28+
import com.stepstone.stepper.sample.adapter.SampleFragmentStepAdapter
29+
30+
import butterknife.ButterKnife
31+
32+
abstract class AbstractStepperActivity : AppCompatActivity(), StepperLayout.StepperListener, OnNavigationBarListener {
33+
34+
companion object {
35+
private const val CURRENT_STEP_POSITION_KEY = "position"
36+
}
37+
38+
@BindView(R.id.stepperLayout)
39+
lateinit var mStepperLayout: StepperLayout
40+
41+
@get:LayoutRes
42+
protected abstract val layoutResId: Int
43+
44+
override fun onCreate(savedInstanceState: Bundle?) {
45+
super.onCreate(savedInstanceState)
46+
title = "Stepper sample"
47+
48+
setContentView(layoutResId)
49+
50+
ButterKnife.bind(this)
51+
val startingStepPosition = savedInstanceState?.getInt(CURRENT_STEP_POSITION_KEY) ?: 0
52+
mStepperLayout.setAdapter(SampleFragmentStepAdapter(supportFragmentManager, this), startingStepPosition)
53+
54+
mStepperLayout.setListener(this)
55+
}
56+
57+
override fun onSaveInstanceState(outState: Bundle) {
58+
outState.putInt(CURRENT_STEP_POSITION_KEY, mStepperLayout.currentStepPosition)
59+
super.onSaveInstanceState(outState)
60+
}
61+
62+
override fun onBackPressed() {
63+
val currentStepPosition = mStepperLayout.currentStepPosition
64+
if (currentStepPosition > 0) {
65+
mStepperLayout.onBackClicked()
66+
} else {
67+
finish()
68+
}
69+
}
70+
71+
override fun onCompleted(completeButton: View) {
72+
Toast.makeText(this, "onCompleted!", Toast.LENGTH_SHORT).show()
73+
}
74+
75+
override fun onError(verificationError: VerificationError) {
76+
Toast.makeText(this, "onError! -> " + verificationError.errorMessage, Toast.LENGTH_SHORT).show()
77+
}
78+
79+
override fun onStepSelected(newStepPosition: Int) {
80+
Toast.makeText(this, "onStepSelected! -> " + newStepPosition, Toast.LENGTH_SHORT).show()
81+
}
82+
83+
override fun onReturn() {
84+
finish()
85+
}
86+
87+
override fun onChangeEndButtonsEnabled(enabled: Boolean) {
88+
mStepperLayout.setNextButtonVerificationFailed(!enabled)
89+
mStepperLayout.setCompleteButtonVerificationFailed(!enabled)
90+
}
91+
92+
}

sample/src/main/java/com/stepstone/stepper/sample/CombinationActivity.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

sample/src/main/java/com/stepstone/stepper/sample/StyledTabsActivity.java renamed to sample/src/main/java/com/stepstone/stepper/sample/CombinationActivity.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
limitations under the License.
1515
*/
1616

17-
package com.stepstone.stepper.sample;
17+
package com.stepstone.stepper.sample
1818

19-
public class StyledTabsActivity extends AbstractStepperActivity {
19+
class CombinationActivity : AbstractStepperActivity() {
2020

21-
@Override
22-
protected int getLayoutResId() {
23-
return R.layout.activity_styled_tabs;
24-
}
21+
override val layoutResId: Int
22+
get() = R.layout.activity_combination
2523

2624
}

0 commit comments

Comments
 (0)