Skip to content

Commit ab02f00

Browse files
committed
Example app with same counter as test
1 parent d3b047e commit ab02f00

File tree

25 files changed

+333
-1
lines changed

25 files changed

+333
-1
lines changed

.idea/gradle.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
4+
android {
5+
compileSdkVersion 23
6+
buildToolsVersion "23.0.3"
7+
8+
defaultConfig {
9+
applicationId "com.bkase.cyklic.example.app"
10+
minSdkVersion 16
11+
targetSdkVersion 23
12+
versionCode 1
13+
versionName "1.0"
14+
}
15+
buildTypes {
16+
release {
17+
minifyEnabled false
18+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19+
}
20+
}
21+
sourceSets {
22+
main.java.srcDirs += 'src/main/kotlin'
23+
}
24+
}
25+
26+
dependencies {
27+
compile fileTree(dir: 'libs', include: ['*.jar'])
28+
compile project(path: ':lib')
29+
testCompile 'junit:junit:4.12'
30+
compile 'com.android.support:appcompat-v7:23.2.1'
31+
compile 'com.android.support:design:23.2.1'
32+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
33+
}
34+
buildscript {
35+
ext.kotlin_version = '1.0.1-1'
36+
repositories {
37+
mavenCentral()
38+
}
39+
dependencies {
40+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
41+
}
42+
}
43+
repositories {
44+
mavenCentral()
45+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/bkase/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.bkase.cyklic.example.app;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.bkase.cyklic.example.app">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity
12+
android:name=".MainActivity"
13+
android:label="@string/app_name"
14+
android:theme="@style/AppTheme.NoActionBar">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.bkase.cyklic.example.app
2+
3+
import android.os.Bundle
4+
import android.support.v7.app.AppCompatActivity
5+
import android.support.v7.widget.Toolbar
6+
import android.view.Menu
7+
import android.view.MenuItem
8+
import android.widget.Button
9+
import android.widget.TextView
10+
import com.bkase.cyklic.example.SimpleCounter
11+
import com.bkase.cyklic.example.app.R
12+
import com.jakewharton.rxbinding.view.clicks
13+
14+
class MainActivity : AppCompatActivity() {
15+
16+
val incButton by lazy {
17+
findViewById(R.id.increment) as Button
18+
}
19+
20+
val decButton by lazy {
21+
findViewById(R.id.decrement) as Button
22+
}
23+
24+
val countView by lazy {
25+
findViewById(R.id.count) as TextView
26+
}
27+
28+
val component by lazy {
29+
val viewish = object: SimpleCounter.Viewish {
30+
override fun setCount(count: Int) {
31+
countView.text = count.toString()
32+
}
33+
}
34+
35+
SimpleCounter.SimpleCounterComponent(
36+
SimpleCounter.ViewIntentions(
37+
incButton.clicks(),
38+
decButton.clicks()
39+
), viewish
40+
)
41+
}
42+
43+
override fun onCreate(savedInstanceState: Bundle?) {
44+
super.onCreate(savedInstanceState)
45+
setContentView(R.layout.activity_main)
46+
val toolbar = findViewById(R.id.toolbar) as Toolbar?
47+
setSupportActionBar(toolbar)
48+
}
49+
50+
override fun onResume() {
51+
super.onResume()
52+
53+
component.start()
54+
}
55+
56+
override fun onPause() {
57+
component.stop()
58+
59+
super.onPause()
60+
}
61+
62+
override fun onCreateOptionsMenu(menu: Menu): Boolean {
63+
// Inflate the menu; this adds items to the action bar if it is present.
64+
menuInflater.inflate(R.menu.menu_main, menu)
65+
return true
66+
}
67+
68+
override fun onOptionsItemSelected(item: MenuItem): Boolean {
69+
// Handle action bar item clicks here. The action bar will
70+
// automatically handle clicks on the Home/Up button, so long
71+
// as you specify a parent activity in AndroidManifest.xml.
72+
val id = item.itemId
73+
74+
//noinspection SimplifiableIfStatement
75+
if (id == R.id.action_settings) {
76+
return true
77+
}
78+
79+
return super.onOptionsItemSelected(item)
80+
}
81+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:fitsSystemWindows="true"
8+
tools:context=".MainActivity">
9+
10+
<android.support.design.widget.AppBarLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:theme="@style/AppTheme.AppBarOverlay">
14+
15+
<android.support.v7.widget.Toolbar
16+
android:id="@+id/toolbar"
17+
android:layout_width="match_parent"
18+
android:layout_height="?attr/actionBarSize"
19+
android:background="?attr/colorPrimary"
20+
app:popupTheme="@style/AppTheme.PopupOverlay" />
21+
22+
</android.support.design.widget.AppBarLayout>
23+
24+
<include layout="@layout/content_main" />
25+
26+
</android.support.design.widget.CoordinatorLayout>
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:paddingBottom="@dimen/activity_vertical_margin"
8+
android:paddingLeft="@dimen/activity_horizontal_margin"
9+
android:paddingRight="@dimen/activity_horizontal_margin"
10+
android:paddingTop="@dimen/activity_vertical_margin"
11+
android:orientation="vertical"
12+
app:layout_behavior="@string/appbar_scrolling_view_behavior"
13+
tools:context=".MainActivity"
14+
tools:showIn="@layout/activity_main">
15+
16+
<Button
17+
android:id="@+id/increment"
18+
android:layout_width="match_parent"
19+
android:layout_height="wrap_content"
20+
android:text="@string/increment"/>
21+
<LinearLayout
22+
android:gravity="center"
23+
android:layout_width="match_parent"
24+
android:layout_height="wrap_content"
25+
android:orientation="horizontal">
26+
<TextView
27+
android:textSize="32sp"
28+
android:layout_width="wrap_content"
29+
android:layout_height="wrap_content"
30+
android:text="@string/count_label" />
31+
<TextView
32+
android:id="@+id/count"
33+
android:textSize="32sp"
34+
android:layout_width="wrap_content"
35+
android:layout_height="wrap_content"
36+
android:paddingLeft="10dp"
37+
android:text="" />
38+
</LinearLayout>
39+
<Button
40+
android:id="@+id/decrement"
41+
android:layout_width="match_parent"
42+
android:layout_height="wrap_content"
43+
android:text="@string/decrement"/>
44+
</LinearLayout>

app/src/main/res/menu/menu_main.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
tools:context="com.bkase.cyklic.example.app.MainActivity">
5+
<item
6+
android:id="@+id/action_settings"
7+
android:orderInCategory="100"
8+
android:title="@string/action_settings"
9+
app:showAsAction="never" />
10+
</menu>
3.34 KB
Loading
2.15 KB
Loading
4.73 KB
Loading
7.54 KB
Loading
10.2 KB
Loading
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<resources>>
2+
3+
<style name="AppTheme.NoActionBar">
4+
<item name="windowActionBar">false</item>
5+
<item name="windowNoTitle">true</item>
6+
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
7+
<item name="android:statusBarColor">@android:color/transparent</item>
8+
</style>
9+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
3+
(such as screen margins) for screens with more than 820dp of available width. This
4+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
5+
<dimen name="activity_horizontal_margin">64dp</dimen>
6+
</resources>

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

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
</resources>

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

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Default screen margins, per the Android Design guidelines. -->
3+
<dimen name="activity_horizontal_margin">16dp</dimen>
4+
<dimen name="activity_vertical_margin">16dp</dimen>
5+
<dimen name="fab_margin">16dp</dimen>
6+
</resources>

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

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<resources>
2+
<string name="app_name">Cyklic Example</string>
3+
<string name="action_settings">Settings</string>
4+
<string name="increment">Increment</string>
5+
<string name="count_label">Count:</string>
6+
<string name="decrement">Decrement</string>
7+
</resources>

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

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
</style>
10+
11+
<style name="AppTheme.NoActionBar">
12+
<item name="windowActionBar">false</item>
13+
<item name="windowNoTitle">true</item>
14+
</style>
15+
16+
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
17+
18+
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
19+
20+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.bkase.cyklic.example.app;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* To work on unit tests, switch the Test Artifact in the Build Variants view.
9+
*/
10+
public class ExampleUnitTest {
11+
@Test
12+
public void addition_isCorrect() throws Exception {
13+
assertEquals(4, 2 + 2);
14+
}
15+
}

lib/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dependencies {
4040
compile 'io.reactivex:rxjava:1.1.2'
4141
compile 'io.reactivex:rxandroid:1.1.0'
4242
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
43+
compile 'com.jakewharton.rxbinding:rxbinding-kotlin:0.4.0'
4344
}
4445
repositories {
4546
mavenCentral()

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':lib'
1+
include ':lib', ':app'

0 commit comments

Comments
 (0)