-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up initial contract to autocomplete places (#1)
* improve demo sample to test textView observable * define contract for api and implement initial unit tests with mocks * creating entities to deserialize json data into domain objects * add google maps api with retrofit implementation * create unit tests to cover query window behavior * add requested changes * add .travis.yml * simplify travis.yml * add jdk to travis.yml * handle local.properties absece * solve lint problems * fix travis.yml to accept all licenses * fix travis.yml again * remove constraint layout from dependencies
- Loading branch information
1 parent
aa96c7e
commit 7df3230
Showing
23 changed files
with
636 additions
and
132 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,31 @@ | ||
language: android | ||
|
||
android: | ||
components: | ||
# Uncomment the lines below if you want to | ||
# use the latest revision of Android SDK Tools | ||
- tools | ||
- build-tools-25.0.3 | ||
- platform-tools | ||
- extra-android-m2repository | ||
- extra-google-android-support | ||
|
||
- android-25 | ||
|
||
licenses: | ||
- android-sdk-license-.+ | ||
- '.+' | ||
|
||
cache: | ||
directories: | ||
- $HOME/.gradle/caches/2.8 | ||
- $HOME/.gradle/caches/jars-1 | ||
- $HOME/.gradle/daemon | ||
- $HOME/.gradle/native | ||
- $HOME/.gradle/wrapper | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
script: | ||
- ./gradlew test |
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
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
26 changes: 0 additions & 26 deletions
26
demo/src/androidTest/java/com/a99/rxplaces/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,55 @@ | ||
package com.a99.rxplaces.demo | ||
|
||
import android.os.Bundle | ||
import android.support.v7.app.AppCompatActivity | ||
import android.view.View | ||
import android.view.View.GONE | ||
import android.view.View.VISIBLE | ||
import android.widget.EditText | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import com.a99.rxplaces.AutocompleteState | ||
import com.a99.rxplaces.Prediction | ||
import com.a99.rxplaces.RxAutocomplete | ||
import rx.android.schedulers.AndroidSchedulers | ||
|
||
class DemoActivity : AppCompatActivity() { | ||
|
||
val editText by lazy { findViewById(R.id.input) as EditText } | ||
val loading: View by lazy { findViewById(R.id.loading) } | ||
val outputContainer by lazy { findViewById(R.id.outputContainer) as LinearLayout } | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_demo) | ||
|
||
val rxAutocomplete = RxAutocomplete.create(BuildConfig.GOOGLE_MAPS_API_KEY) | ||
|
||
rxAutocomplete.stateStream() | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribe { autocompleteState -> | ||
loading.visibility = when (autocompleteState) { | ||
AutocompleteState.QUERYING -> VISIBLE | ||
else -> GONE | ||
} | ||
} | ||
|
||
rxAutocomplete.observe(editText) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribe { showData(it) } | ||
} | ||
|
||
private fun showData(predictions: List<Prediction>) { | ||
outputContainer.removeAllViews() | ||
|
||
predictions | ||
.map { createTextView(it) } | ||
.forEach { outputContainer.addView(it) } | ||
} | ||
|
||
private fun createTextView(it: Prediction): TextView { | ||
val textView = TextView(this) | ||
textView.text = it.description | ||
return textView | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.a99.rxplaces.DemoActivity"> | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
<EditText | ||
android:id="@+id/input" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="@string/hint"/> | ||
|
||
<ProgressBar | ||
android:id="@+id/loading" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</android.support.constraint.ConstraintLayout> | ||
android:visibility="gone"/> | ||
|
||
<LinearLayout | ||
android:id="@+id/outputContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" /> | ||
|
||
</LinearLayout> |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<resources> | ||
<string name="app_name">RxPlaces</string> | ||
<string name="hint">Where do you want to go?</string> | ||
</resources> |
This file was deleted.
Oops, something went wrong.
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
26 changes: 0 additions & 26 deletions
26
library/src/androidTest/java/com/a99/rxplaces/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.