Skip to content

Commit

Permalink
Initial Kotlin conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Vasco committed Jul 19, 2017
1 parent df7114b commit 7c890cb
Show file tree
Hide file tree
Showing 33 changed files with 1,513 additions and 1,828 deletions.
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.gradle
.*
!.git*
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
build
/captures
.svn
build_resources
deployment
/.project
*.iml
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Lightstreamer - Stock-List Demo - Android Client
# Lightstreamer - Stock-List Demo - Android Kotlin Client


This project contains a full example of an Android application that employs the [Lightstreamer Android Client library](http://docs.lightstreamer.com/api/ls-android-client/latest/) to subscribe to real-time updates.
This project contains a full example of an Android application (Kotlin version) that employs the [Lightstreamer Android Client library](http://docs.lightstreamer.com/api/ls-android-client/latest/) to subscribe to real-time updates.
An equivalent version based on Java instead of Kotlin is [available](https://github.com/Lightstreamer/Lightstreamer-example-AdvStockList-client-android) as well.

An extended version, including support for GCM push notifications is also available: [Stock-List Demo with GCM Push Notifications - Android Client](https://github.com/Lightstreamer/Lightstreamer-example-MPNStockList-client-android)
An extended version, including support for GCM push notifications (Java version) is also available: [Stock-List Demo with GCM Push Notifications - Android Client](https://github.com/Lightstreamer/Lightstreamer-example-MPNStockList-client-android)


## Live Demo
Expand All @@ -20,22 +21,22 @@ An extended version, including support for GCM push notifications is also availa

## Details

This is a Java-for-Android version of the [Lightstreamer - Basic Stock-List Demo - HTML client](https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-javascript#basic-stock-list-demo---html-client).<br>
This is a Kotlin-for-Android version of the [Lightstreamer - Basic Stock-List Demo - HTML client](https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-javascript#basic-stock-list-demo---html-client).<br>
This app uses the <b>Android Client API for Lightstreamer</b> to handle the communications with Lightstreamer Server. A simple user interface is implemented to display the real-time data received from Lightstreamer Server.<br>

Touch a row opens a new panel with the detailed information, updated in real-time, of the stock.

### Dig the Code

* `StockListDemoApplication.java` is the class representing the application itself. It creates and manage the LightstreamerClient instance
* `StockListDemoApplication.kt` is the class representing the application itself. It creates and manage the LightstreamerClient instance
that is shared by the other classes. A proxy to such instance is exposed as a singleton to the entire application.
* `StockListDemo.java` is the entry point and only `Activity` of the application. It contains two `Fragment`s, the manu bar for
* `StockListDemo.kt` is the entry point and only `Activity` of the application. It contains two `Fragment`s, the manu bar for
the app and listens to LightstreamerClient status events to show the connection status to the user. The two `Fragment` are both visible
if the application runs on tablet; on the contrary, only one `Fragment` is visible and are exchanged based on the user interaction
* `SubscriptionFragment.java` represents a `Fragment` containing a subscription that is started/stopped based on the lifecycle of
* `SubscriptionFragment.kt` represents a `Fragment` containing a subscription that is started/stopped based on the lifecycle of
the `Fragment`. Please note that this class does not actually extend `Fragment`.
* `StocksFragment.java` and `DetailsFragment.java` are the classes representing the two fragments of the application.
* `Chart.java` wraps the AndroidPlot APIs to plot the real-time chart on the details fragment.
* `StocksFragment.kt` and `DetailsFragment.kt` are the classes representing the two fragments of the application.
* `Chart.kt` wraps the AndroidPlot APIs to plot the real-time chart on the details fragment.


Check out the sources for further explanations.
Expand All @@ -51,7 +52,7 @@ an [Android Virtual Device](http://developer.android.com/tools/devices/emulator.
has to be deployed on your local Lightstreamer Server instance. Please check out that project and follow the installation
instructions provided with it.
* Launch Lightstreamer Server.
* Download the `deploy.zip` file, which you can find in the [deploy release](https://github.com/Lightstreamer/Lightstreamer-example-AdvStockList-client-android/releases)
* Download the `deploy.zip` file, which you can find in the [deploy release](https://github.com/Lightstreamer/Lightstreamer-example-AdvStockList-client-android-kotlin/releases)
of this project and extract the `Android_StockListDemo.apk` file.
* Locate or install the [Android SDK](http://developer.android.com/sdk/index.html)
* Install the `Android_StockListDemo.apk` in your emulator:
Expand All @@ -71,7 +72,7 @@ of this project and extract the `Android_StockListDemo.apk` file.
Note that you can skip this section and build the application without using any IDE.
To open the project in [Android Studio](https://developer.android.com/sdk/installing/studio.html), import the provided Gradle project.
To open the project in [Android Studio](https://developer.android.com/sdk/installing/studio.html), install Kotlin plugin (if missing), import the provided Gradle project.
### Deploy
Expand Down Expand Up @@ -99,6 +100,7 @@ You might also use a different build tool (e.g.: Maven, Ant, etc.) by converting
### Related Projects
* [Lightstreamer - Stock-List Demos - HTML Clients](https://github.com/Lightstreamer/Lightstreamer-example-Stocklist-client-javascript)
* [Lightstreamer - Stock-List Demo - Android Java Client](https://github.com/Lightstreamer/Lightstreamer-example-AdvStockList-client-android)
* [Lightstreamer - Stock-List Demo with GCM Push Notifications - Android Client](https://github.com/Lightstreamer/Lightstreamer-example-MPNStockList-client-android)
## Lightstreamer Compatibility Notes
Expand All @@ -107,4 +109,3 @@ You might also use a different build tool (e.g.: Maven, Ant, etc.) by converting
* For Lightstreamer Allegro (+ Android Client API support), Presto, Vivace.
* For a version of this example compatible with Lightstreamer Android Client API version 2, please refer to [this tag](https://github.com/Lightstreamer/Lightstreamer-example-AdvStockList-client-android/tree/latest-for-client-2).
* For a version of this example compatible with Lightstreamer Android Client API version 1.1, please refer to [this tag](https://github.com/Lightstreamer/Lightstreamer-example-AdvStockList-client-android/tree/latest-for-client-1.x).
93 changes: 50 additions & 43 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.lightstreamer.simple_demo.android"
minSdkVersion 10
targetSdkVersion 22
versionCode 12
versionName "2.1.0"
}
/*signingConfigs {
release {
storeFile file(System.getenv("KSTORE"))
storePassword System.getenv("KSTOREPWD")
keyAlias "LS"
keyPassword System.getenv("KEYPWD")
}
}*/
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
}
packagingOptions {
pickFirst 'build.number'
pickFirst 'version.number'
pickFirst 'compatibility_version.number'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/io.netty.versions.properties'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.androidplot:androidplot-core:0.6.1'
compile 'com.lightstreamer:ls-android-client:3.0.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 22
buildToolsVersion '25.0.0'

defaultConfig {
applicationId "com.lightstreamer.simple_demo.android"
minSdkVersion 10
targetSdkVersion 22
versionCode 12
versionName "2.1.0"
}
/*signingConfigs {
release {
storeFile file(System.getenv("KSTORE"))
storePassword System.getenv("KSTOREPWD")
keyAlias "LS"
keyPassword System.getenv("KEYPWD")
}
}*/
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
}
packagingOptions {
pickFirst 'build.number'
pickFirst 'version.number'
pickFirst 'compatibility_version.number'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/io.netty.versions.properties'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.androidplot:androidplot-core:0.6.1'
compile 'com.lightstreamer:ls-android-client:3.1.3'
}

repositories {
mavenCentral()
maven { url "http://www.lightstreamer.com/repo/maven" }
}
34 changes: 17 additions & 17 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Mone\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Mone\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Loading

0 comments on commit 7c890cb

Please sign in to comment.