-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9023607
Showing
88 changed files
with
5,976 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
language: android | ||
jdk: | ||
- oraclejdk8 | ||
android: | ||
components: | ||
# Uncomment the lines below if you want to | ||
# use the latest revision of Android SDK Tools | ||
- platform-tools | ||
- tools | ||
|
||
# The BuildTools version used by your project | ||
- build-tools-23.0.2 | ||
|
||
# The SDK version used to compile your project | ||
- android-23 | ||
|
||
# Additional components | ||
- extra-google-google_play_services | ||
- extra-google-m2repository | ||
- extra-android-m2repository | ||
- addon-google_apis-google-23 | ||
|
||
before_install: | ||
- export JAVA8_HOME=/usr/lib/jvm/java-8-oracle | ||
- export JAVA_HOME=$JAVA8_HOME | ||
before_cache: | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
cache: | ||
directories: | ||
- $HOME/.gradle/caches/ | ||
- $HOME/.gradle/wrapper/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2016 Patrick Löwenstein | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
RxWear | ||
Copyright 2016 Patrick Löwenstein | ||
|
||
=========================== | ||
Apache License, Version 2.0 | ||
=========================== | ||
|
||
The following components are provided under the Apache License, Version 2.0. See project link for details. | ||
|
||
------ | ||
RxJava | ||
------ | ||
|
||
io.reactivex:rxjava | ||
https://github.com/ReactiveX/RxJava | ||
|
||
Copyright 2013 Netflix, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
|
||
|
||
------------------------ | ||
Android-ReactiveLocation | ||
------------------------ | ||
|
||
pl.charmas.android:android-reactive-location | ||
https://github.com/mcharmas/Android-ReactiveLocation | ||
|
||
|
||
Copyright (C) 2015 Michał Charmas (http://blog.charmas.pl) | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Reactive Wearable API Library for Android | ||
|
||
[![Build Status](https://travis-ci.org/patloew/RxWear.svg?branch=master)](https://travis-ci.org/patloew/RxWear) [ ![Download](https://api.bintray.com/packages/patloew/maven/com.patloew.rxwear/images/download.svg) ](https://bintray.com/patloew/maven/com.patloew.rxwear/_latestVersion) [![API](https://img.shields.io/badge/API-9%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=9) | ||
|
||
This library wraps the Wearable API in [RxJava](https://github.com/ReactiveX/RxJava) Observables. No more managing GoogleApiClients! Also, there are some helper classes, which ease communication between phone and wear app. | ||
|
||
# Usage | ||
|
||
Initialize RxWear once, preferably in your Application `onCreate()` via `RxWear.init(...)`. The RxWear class is very similar to the Wearable class provided by the Wearable API. Instead of `Wearable.MessageApi.sendMessage(apiClient, nodeId, path, data)` you can use `RxWear.Message.send(nodeId, path, data)`. | ||
|
||
There are also some helper classes to ease the putting/sending of data: | ||
* `RxWear.Data.PutDataMap`: Use this to put a DataItem containing a DataMap to a path or a pathPrefix with an auto appended ID. | ||
* `RxWear.Data.PutSerializable`: Use this to put a DataItem containing a Serializable object to a path or a pathPrefix with an auto appended ID. | ||
* `RxWear.Message.SendDataMap`: Use this to send a message containing a DataMap to either one specific node or all remote nodes. | ||
* `RxWear.Message.SendSerializable`: Use this to send a message containing a Serializable object to either one specific node or all remote nodes. | ||
|
||
And a few Transformers to ease fetching the data: | ||
* `DataEventGetDataMap`: Use this Transformer to get the DataMap from a DataEvent and optionally filter the events. | ||
* `DataEventGetSerializable`: Use this Transformer to get a Serializable object from a DataEvent and optionally filter the events. | ||
* `DataItemGetDataMap`: Use this Transformer to get the DataMap from a DataItem and optionally filter the items. | ||
* `DataItemGetSerializable`: Use this Transformer to get a Serializable object from a DataItems and optionally filter the items. | ||
* `MessageEventGetDataMap`: Use this Transformer to get the DataMap from a MessageEvent and optionally filter the events. | ||
* `MessageEventGetSerializable`: Use this Transformer to get a Serializable object from a MessageEvent and optionally filter the events. | ||
|
||
Example: | ||
|
||
```java | ||
RxWear.init(context); | ||
|
||
// Phone App | ||
|
||
RxWear.Message.SendDataMap.toAllRemoteNodes("/dataMap") | ||
.putString("title", "Title") | ||
.putString("message", "My message") | ||
.toObservable() | ||
.subscribe(requestId -> { | ||
/* do something */ | ||
}); | ||
|
||
RxWear.Data.PutSerializable.urgentTo("/serializable", serializable) | ||
.subscribe(dataItem -> { | ||
/* do something */ | ||
}); | ||
|
||
// Wear App | ||
|
||
RxWear.Message.listen() | ||
.compose(MessageEventGetDataMap.filterByPath("/dataMap")) | ||
.subscribe(dataMap -> { | ||
String title = dataMap.getString("title", getString(R.string.no_message)); | ||
String message = dataMap.getString("message", getString(R.string.no_message_info)); | ||
/* do something */ | ||
}); | ||
|
||
RxWear.Data.listen() | ||
.compose(DataEventGetSerializable.<MySerializableType>filterByPathAndType("/serializable", DataEvent.TYPE_CHANGED)) | ||
.subscribe(serializable -> { | ||
/* do something */ | ||
}); | ||
|
||
``` | ||
|
||
An optional global default timeout for all Wearable API requests made through the library can be set via `RxWear.setDefaultTimeout(...)`. In addition, timeouts can be set when creating a new Observable by providing timeout parameters, e.g. `RxWear.Message.send(nodeId, path, data, 15, TimeUnit.SECONDS)`. These parameters override the default timeout. When a timeout occurs, a StatusException is provided via `onError()`. The timeouts specified here are only used for calls to the Wearable API, e.g. a timeout will not occur when a listener does not emit an item within the specified timeout. The RxJava timeout operators can be used for this use case. | ||
|
||
You can also obtain an `Observable<GoogleApiClient>`, which connects on subscribe and disconnects on unsubscribe via `GoogleAPIClientObservable.create(...)`. | ||
|
||
The following Exceptions are thrown in the lib and provided via `onError()`: | ||
|
||
* `StatusException`: When the call to the Wearable API was not successful or timed out | ||
* `GoogleAPIConnectionException`: When connecting to the GoogleAPIClient was not successful. | ||
* `GoogleAPIConnectionSuspendedException`: When the GoogleApiClient connection was suspended. | ||
|
||
# Sample | ||
|
||
A basic sample app is available in the `sample` and `wearsample` projects. | ||
|
||
# Setup | ||
|
||
Add the following to your `build.gradle`: | ||
|
||
repositories { | ||
maven { url 'https://dl.bintray.com/patloew/maven' } | ||
} | ||
|
||
dependencies { | ||
compile 'com.patloew.rxwear:rxwear:1.0.0' | ||
} | ||
|
||
# Credits | ||
|
||
The code for managing the GoogleApiClient is taken from the [Android-ReactiveLocation](https://github.com/mcharmas/Android-ReactiveLocation) library by Michał Charmas, which is licensed under the Apache License, Version 2.0. | ||
|
||
# License | ||
|
||
Copyright 2016 Patrick Löwenstein | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.0.0-beta6' | ||
|
||
classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4' | ||
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2' | ||
|
||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' | ||
classpath "com.github.dcendents:android-maven-gradle-plugin:1.3" | ||
|
||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
|
||
configurations.classpath.exclude group: 'com.android.tools.external.lombok' | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Project-wide Gradle settings. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
# Default value: -Xmx10248m -XX:MaxPermSize=256m | ||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Mon Dec 28 10:00:20 PST 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip |
Oops, something went wrong.