From e335887e78a1c1f370d4e6eb49a1111074ed1834 Mon Sep 17 00:00:00 2001 From: patloew Date: Sat, 18 Nov 2017 17:54:59 +0100 Subject: [PATCH] Remove retrolambda. Update dependencies. --- .travis.yml | 4 +-- CHANGELOG.md | 5 ++++ README.md | 8 ++++- build.gradle | 12 +++----- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 25 +++++++--------- .../rxlocation/ActivityOnSubscribeTest.java | 12 ++++++-- .../com/patloew/rxlocation/ActivityTest.java | 4 +-- .../rxlocation/BaseOnSubscribeTest.java | 5 ++-- .../java/com/patloew/rxlocation/BaseTest.java | 5 ++-- .../patloew/rxlocation/GeofencingTest.java | 6 ++-- .../LocationSettingsActivityTest.java | 4 +-- .../com/patloew/rxlocation/LocationTest.java | 18 ++++++------ .../RxLocationFlowableOnSubscribeTest.java | 8 ++--- .../RxLocationMaybeOnSubscribeTest.java | 8 ++--- .../RxLocationSingleOnSubscribeTest.java | 8 ++--- .../com/patloew/rxlocation/SettingsTest.java | 12 ++++---- sample/build.gradle | 29 ++++++++----------- .../rxlocationsample/MainActivity.java | 6 ++-- 19 files changed, 93 insertions(+), 88 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b7f981..d081ea2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ android: - tools # The BuildTools version used by your project - - build-tools-25.0.2 + - build-tools-26.0.3 # The SDK version used to compile your project - - android-25 + - android-26 # Additional components - extra-google-google_play_services diff --git a/CHANGELOG.md b/CHANGELOG.md index 61de5b0..fed7a4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Version 1.0.4 + +* Update dependencies +* BREAKING: Removed Retrolambda. Since this library uses Java 8 features, from v1.0.4 on, only Android gradle plugin 3.0.0 or higher is supported. + ## Version 1.0.3 * Update dependencies (Play Services 10.2.1) diff --git a/README.md b/README.md index 57161d6..b22e1ee 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,11 @@ A basic sample app is available in the `sample` project. The lib is available on jCenter. Add the following to your `build.gradle`: dependencies { - compile 'com.patloew.rxlocation:rxlocation:1.0.2' + compile 'com.patloew.rxlocation:rxlocation:1.0.4' } +From v1.0.4 on, RxLocation only works with Android gradle plugin 3.0.0 or higher, since it uses Java 8 language features. + # Testing When unit testing your app's classes, RxLocation behavior can be mocked easily. See the `MainPresenterTest` in the `sample` project for an example test. @@ -90,6 +92,10 @@ When unit testing your app's classes, RxLocation behavior can be mocked easily. The code for managing the GoogleApiClient was adapted from the [Android-ReactiveLocation](https://github.com/mcharmas/Android-ReactiveLocation) library by Michał Charmas, which is licensed under the Apache License, Version 2.0. +# Donations + +If you like the library and want to support the creator for development/maintenance, you can make a donation in Bitcoin to [1HSPW3NUZjfzsrkVxToWhiScfCnW7adwxk](bitcoin:1HSPW3NUZjfzsrkVxToWhiScfCnW7adwxk). Thank you! + # License Copyright 2016 Patrick Löwenstein diff --git a/build.gradle b/build.gradle index 04c541d..11069d0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,17 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.github.ben-manes.versions' buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' - - classpath 'me.tatarka:gradle-retrolambda:3.6.0' + classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath "com.github.dcendents:android-maven-gradle-plugin:1.5" - classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' - - classpath 'com.github.ben-manes:gradle-versions-plugin:0.14.0' - + classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -26,6 +21,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 85335bb..af9b2f0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip diff --git a/library/build.gradle b/library/build.gradle index d0238aa..f1ae324 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,22 +1,21 @@ apply plugin: 'com.android.library' -apply plugin: 'me.tatarka.retrolambda' apply plugin: 'jacoco-android' apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.dcendents.android-maven' group = 'com.patloew.rxlocation' -version = '1.0.3' +version = '1.0.4' project.archivesBaseName = 'rxlocation' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.3" defaultConfig { minSdkVersion 14 - targetSdkVersion 25 - versionCode 3 - versionName "1.0.3" + targetSdkVersion 26 + versionCode 4 + versionName "1.0.4" } buildTypes { release { @@ -37,19 +36,15 @@ android { } } -retrolambda { - javaVersion JavaVersion.VERSION_1_6 -} - dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'io.reactivex.rxjava2:rxjava:2.0.7' + compile 'io.reactivex.rxjava2:rxjava:2.1.6' compile 'com.google.android.gms:play-services-location:10.2.1' testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' - testCompile "org.powermock:powermock-module-junit4:1.6.5" - testCompile "org.powermock:powermock-api-mockito:1.6.5" + testCompile 'org.mockito:mockito-core:2.11.0' + testCompile "org.powermock:powermock-module-junit4:2.0.0-beta.5" + testCompile "org.powermock:powermock-api-mockito2:2.0.0-beta.5" } task generateSourcesJar(type: Jar) { diff --git a/library/src/test/java/com/patloew/rxlocation/ActivityOnSubscribeTest.java b/library/src/test/java/com/patloew/rxlocation/ActivityOnSubscribeTest.java index 37361e2..d0800a0 100644 --- a/library/src/test/java/com/patloew/rxlocation/ActivityOnSubscribeTest.java +++ b/library/src/test/java/com/patloew/rxlocation/ActivityOnSubscribeTest.java @@ -1,23 +1,29 @@ package com.patloew.rxlocation; import android.app.PendingIntent; +import android.content.Context; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.Status; import com.google.android.gms.location.LocationServices; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.mockito.MockitoSession; +import org.mockito.quality.Strictness; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareOnlyThisForTest; import org.powermock.modules.junit4.PowerMockRunner; import io.reactivex.Single; -import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.doReturn; +import static org.powermock.api.mockito.PowerMockito.when; @SuppressWarnings("MissingPermission") @RunWith(PowerMockRunner.class) @@ -40,8 +46,8 @@ public void ActivityRequestUpdatesSingle_Success() { ActivityRequestUpdatesSingleOnSubscribe single = PowerMockito.spy(new ActivityRequestUpdatesSingleOnSubscribe(rxLocation, 1L, pendingIntent, null, null)); setPendingResultValue(status); - when(status.isSuccess()).thenReturn(true); - when(activityRecognitionApi.requestActivityUpdates(apiClient, 1L, pendingIntent)).thenReturn(pendingResult); + doReturn(true).when(status).isSuccess(); + doReturn(pendingResult).when(activityRecognitionApi).requestActivityUpdates(apiClient, 1L, pendingIntent); setupBaseSingleSuccess(single); diff --git a/library/src/test/java/com/patloew/rxlocation/ActivityTest.java b/library/src/test/java/com/patloew/rxlocation/ActivityTest.java index 0a8fdc6..d44a045 100644 --- a/library/src/test/java/com/patloew/rxlocation/ActivityTest.java +++ b/library/src/test/java/com/patloew/rxlocation/ActivityTest.java @@ -46,7 +46,7 @@ public void Activity_RequestUpdates() throws Exception { rxLocation.activity().requestUpdates(detectionIntervalMillis,pendingIntent); rxLocation.activity().requestUpdates(detectionIntervalMillis,pendingIntent, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); ActivityRequestUpdatesSingleOnSubscribe single = captor.getAllValues().get(0); @@ -69,7 +69,7 @@ public void Activity_RemoveUpdates() throws Exception { rxLocation.activity().removeUpdates(pendingIntent); rxLocation.activity().removeUpdates(pendingIntent, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); ActivityRemoveUpdatesSingleOnSubscribe single = captor.getAllValues().get(0); diff --git a/library/src/test/java/com/patloew/rxlocation/BaseOnSubscribeTest.java b/library/src/test/java/com/patloew/rxlocation/BaseOnSubscribeTest.java index 97b306d..a06fa84 100644 --- a/library/src/test/java/com/patloew/rxlocation/BaseOnSubscribeTest.java +++ b/library/src/test/java/com/patloew/rxlocation/BaseOnSubscribeTest.java @@ -27,8 +27,9 @@ import io.reactivex.observers.TestObserver; import io.reactivex.subscribers.TestSubscriber; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; +import static org.powermock.api.mockito.PowerMockito.doAnswer; +import static org.powermock.api.mockito.PowerMockito.doReturn; + public abstract class BaseOnSubscribeTest extends BaseTest { diff --git a/library/src/test/java/com/patloew/rxlocation/BaseTest.java b/library/src/test/java/com/patloew/rxlocation/BaseTest.java index 039f241..6511c36 100644 --- a/library/src/test/java/com/patloew/rxlocation/BaseTest.java +++ b/library/src/test/java/com/patloew/rxlocation/BaseTest.java @@ -9,7 +9,8 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNull; -import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.doReturn; +import static org.powermock.api.mockito.PowerMockito.mock; public abstract class BaseTest { @@ -22,7 +23,7 @@ public abstract class BaseTest { @CallSuper public void setup() throws Exception { - when(ctx.getApplicationContext()).thenReturn(ctx); + doReturn(ctx).when(ctx).getApplicationContext(); rxLocation = new RxLocation(ctx); } diff --git a/library/src/test/java/com/patloew/rxlocation/GeofencingTest.java b/library/src/test/java/com/patloew/rxlocation/GeofencingTest.java index b5c4491..32f0eba 100644 --- a/library/src/test/java/com/patloew/rxlocation/GeofencingTest.java +++ b/library/src/test/java/com/patloew/rxlocation/GeofencingTest.java @@ -53,7 +53,7 @@ public void Add() throws Exception { rxLocation.geofencing().add(geofencingRequest, pendingIntent); rxLocation.geofencing().add(geofencingRequest, pendingIntent, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); GeofencingAddSingleOnSubscribe single = captor.getAllValues().get(0); @@ -76,7 +76,7 @@ public void Remove_PendingIntent() throws Exception { rxLocation.geofencing().remove(pendingIntent); rxLocation.geofencing().remove(pendingIntent, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); GeofencingRemoveSingleOnSubscribe single = captor.getAllValues().get(0); @@ -97,7 +97,7 @@ public void Remove_IdList() throws Exception { rxLocation.geofencing().remove(geofenceRequestIds); rxLocation.geofencing().remove(geofenceRequestIds, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); GeofencingRemoveSingleOnSubscribe single = captor.getAllValues().get(0); diff --git a/library/src/test/java/com/patloew/rxlocation/LocationSettingsActivityTest.java b/library/src/test/java/com/patloew/rxlocation/LocationSettingsActivityTest.java index 7e35752..2f85870 100644 --- a/library/src/test/java/com/patloew/rxlocation/LocationSettingsActivityTest.java +++ b/library/src/test/java/com/patloew/rxlocation/LocationSettingsActivityTest.java @@ -90,7 +90,7 @@ public void onActivityResult_wrongRequestCode() { public void setResolutionResultAndFinish_OK() { activity.setResolutionResultAndFinish(Activity.RESULT_OK); - PowerMockito.verifyStatic(); + PowerMockito.verifyStatic(SettingsCheckHandleSingleOnSubscribe.class); SettingsCheckHandleSingleOnSubscribe.onResolutionResult(observableId, Activity.RESULT_OK); verify(activity).finish(); @@ -100,7 +100,7 @@ public void setResolutionResultAndFinish_OK() { public void setResolutionResultAndFinish_Canceled() { activity.setResolutionResultAndFinish(Activity.RESULT_CANCELED); - PowerMockito.verifyStatic(); + PowerMockito.verifyStatic(SettingsCheckHandleSingleOnSubscribe.class); SettingsCheckHandleSingleOnSubscribe.onResolutionResult(observableId, Activity.RESULT_CANCELED); verify(activity).finish(); diff --git a/library/src/test/java/com/patloew/rxlocation/LocationTest.java b/library/src/test/java/com/patloew/rxlocation/LocationTest.java index ebfc446..759cca5 100644 --- a/library/src/test/java/com/patloew/rxlocation/LocationTest.java +++ b/library/src/test/java/com/patloew/rxlocation/LocationTest.java @@ -56,7 +56,7 @@ public void Flush() throws Exception { rxLocation.location().flush(); rxLocation.location().flush(TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); LocationFlushSingleOnSubscribe single = captor.getAllValues().get(0); @@ -72,7 +72,7 @@ public void LastLocation() throws Exception { rxLocation.location().lastLocation(); - PowerMockito.verifyStatic(times(1)); + PowerMockito.verifyStatic(Maybe.class, times(1)); Maybe.create(captor.capture()); LocationLastMaybeOnSubscribe single = captor.getAllValues().get(0); @@ -85,7 +85,7 @@ public void LocationAvailable() throws Exception { rxLocation.location().isLocationAvailable(); - PowerMockito.verifyStatic(times(1)); + PowerMockito.verifyStatic(Single.class, times(1)); Single.create(captor.capture()); LocationAvailabilitySingleOnSubscribe single = captor.getAllValues().get(0); @@ -99,7 +99,7 @@ public void RequestUpdates() throws Exception { rxLocation.location().requestUpdates(locationRequest, pendingIntent); rxLocation.location().requestUpdates(locationRequest, pendingIntent, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); LocationRequestUpdatesSingleOnSubscribe single = captor.getAllValues().get(0); @@ -120,7 +120,7 @@ public void RemoveUpdates() throws Exception { rxLocation.location().removeUpdates(pendingIntent); rxLocation.location().removeUpdates(pendingIntent, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); LocationRemoveUpdatesSingleOnSubscribe single = captor.getAllValues().get(0); @@ -141,7 +141,7 @@ public void LocationUpdates() throws Exception { rxLocation.location().updates(locationRequest); rxLocation.location().updates(locationRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Flowable.class, times(2)); Flowable.create(captor.capture(), eq(BackpressureStrategy.MISSING)); LocationUpdatesFlowableOnSubscribe single = captor.getAllValues().get(0); @@ -162,7 +162,7 @@ public void LocationUpdates_Looper() throws Exception { rxLocation.location().updates(locationRequest, looper); rxLocation.location().updates(locationRequest, looper, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Flowable.class, times(2)); Flowable.create(captor.capture(), eq(BackpressureStrategy.MISSING)); LocationUpdatesFlowableOnSubscribe single = captor.getAllValues().get(0); @@ -183,7 +183,7 @@ public void LocationUpdates_BackpressureStrategy() throws Exception { rxLocation.location().updates(locationRequest, BackpressureStrategy.LATEST); rxLocation.location().updates(locationRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT, BackpressureStrategy.LATEST); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Flowable.class, times(2)); Flowable.create(captor.capture(), eq(BackpressureStrategy.LATEST)); LocationUpdatesFlowableOnSubscribe single = captor.getAllValues().get(0); @@ -204,7 +204,7 @@ public void LocationUpdates_Looper_BackpressureStrategy() throws Exception { rxLocation.location().updates(locationRequest, looper, BackpressureStrategy.LATEST); rxLocation.location().updates(locationRequest, looper, TIMEOUT_TIME, TIMEOUT_TIMEUNIT, BackpressureStrategy.LATEST); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Flowable.class, times(2)); Flowable.create(captor.capture(), eq(BackpressureStrategy.LATEST)); LocationUpdatesFlowableOnSubscribe single = captor.getAllValues().get(0); diff --git a/library/src/test/java/com/patloew/rxlocation/RxLocationFlowableOnSubscribeTest.java b/library/src/test/java/com/patloew/rxlocation/RxLocationFlowableOnSubscribeTest.java index a5e9151..f9b2b7d 100644 --- a/library/src/test/java/com/patloew/rxlocation/RxLocationFlowableOnSubscribeTest.java +++ b/library/src/test/java/com/patloew/rxlocation/RxLocationFlowableOnSubscribeTest.java @@ -51,7 +51,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, FlowableEmitter }); doAnswer(invocation -> { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnected(null); return apiClient; @@ -74,7 +74,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, FlowableEmitter }); doAnswer(invocation -> { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnected(null); return apiClient; @@ -102,7 +102,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, FlowableEmitter doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnectionSuspended(0); return apiClient; @@ -129,7 +129,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, FlowableEmitter doReturn(false).when(connectionResult).hasResolution(); doAnswer(invocation -> { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnectionFailed(connectionResult); return apiClient; diff --git a/library/src/test/java/com/patloew/rxlocation/RxLocationMaybeOnSubscribeTest.java b/library/src/test/java/com/patloew/rxlocation/RxLocationMaybeOnSubscribeTest.java index c77d1a9..60eb6eb 100644 --- a/library/src/test/java/com/patloew/rxlocation/RxLocationMaybeOnSubscribeTest.java +++ b/library/src/test/java/com/patloew/rxlocation/RxLocationMaybeOnSubscribeTest.java @@ -48,7 +48,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, MaybeEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnected(null); return apiClient; @@ -69,7 +69,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, MaybeEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnected(null); return apiClient; @@ -94,7 +94,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, MaybeEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnectionSuspended(0); return apiClient; @@ -119,7 +119,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, MaybeEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnectionFailed(connectionResult); return apiClient; diff --git a/library/src/test/java/com/patloew/rxlocation/RxLocationSingleOnSubscribeTest.java b/library/src/test/java/com/patloew/rxlocation/RxLocationSingleOnSubscribeTest.java index 710bdd3..4dda24d 100644 --- a/library/src/test/java/com/patloew/rxlocation/RxLocationSingleOnSubscribeTest.java +++ b/library/src/test/java/com/patloew/rxlocation/RxLocationSingleOnSubscribeTest.java @@ -47,7 +47,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnected(null); return apiClient; @@ -67,7 +67,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnected(null); return apiClient; @@ -92,7 +92,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnectionSuspended(0); return apiClient; @@ -117,7 +117,7 @@ protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter { - RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgumentAt(0, RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks.class); + RxLocationBaseOnSubscribe.ApiClientConnectionCallbacks callbacks = invocation.getArgument(0); callbacks.setClient(apiClient); callbacks.onConnectionFailed(connectionResult); return apiClient; diff --git a/library/src/test/java/com/patloew/rxlocation/SettingsTest.java b/library/src/test/java/com/patloew/rxlocation/SettingsTest.java index 5f9ffe4..fb984e0 100644 --- a/library/src/test/java/com/patloew/rxlocation/SettingsTest.java +++ b/library/src/test/java/com/patloew/rxlocation/SettingsTest.java @@ -55,7 +55,7 @@ public void Check_LocationRequest() throws Exception { settings.check(locationRequest); settings.check(locationRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); SettingsCheckSingleOnSubscribe single = captor.getAllValues().get(0); @@ -74,7 +74,7 @@ public void Check_LocationSettingsRequest() throws Exception { rxLocation.settings().check(locationSettingsRequest); rxLocation.settings().check(locationSettingsRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); SettingsCheckSingleOnSubscribe single = captor.getAllValues().get(0); @@ -99,7 +99,7 @@ public void CheckAndHandleResolution_Completable_LocationRequest() throws Except settings.checkAndHandleResolutionCompletable(locationRequest); settings.checkAndHandleResolutionCompletable(locationRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); SettingsCheckHandleSingleOnSubscribe single = captor.getAllValues().get(0); @@ -124,7 +124,7 @@ public void CheckAndHandleResolution_LocationRequest() throws Exception { settings.checkAndHandleResolution(locationRequest); settings.checkAndHandleResolution(locationRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); SettingsCheckHandleSingleOnSubscribe single = captor.getAllValues().get(0); @@ -143,7 +143,7 @@ public void CheckAndHandleResolution_Completable_LocationSettingsRequest() throw rxLocation.settings().checkAndHandleResolutionCompletable(locationSettingsRequest); rxLocation.settings().checkAndHandleResolutionCompletable(locationSettingsRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); SettingsCheckHandleSingleOnSubscribe single = captor.getAllValues().get(0); @@ -162,7 +162,7 @@ public void CheckAndHandleResolution_LocationSettingsRequest() throws Exception rxLocation.settings().checkAndHandleResolution(locationSettingsRequest); rxLocation.settings().checkAndHandleResolution(locationSettingsRequest, TIMEOUT_TIME, TIMEOUT_TIMEUNIT); - PowerMockito.verifyStatic(times(2)); + PowerMockito.verifyStatic(Single.class, times(2)); Single.create(captor.capture()); SettingsCheckHandleSingleOnSubscribe single = captor.getAllValues().get(0); diff --git a/sample/build.gradle b/sample/build.gradle index f049d0c..bb37f62 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,9 +1,8 @@ apply plugin: 'com.android.application' -apply plugin: 'me.tatarka.retrolambda' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.3" defaultConfig { applicationId "com.patloew.rxlocationsample" @@ -30,33 +29,29 @@ android { } } -retrolambda { - javaVersion JavaVersion.VERSION_1_6 -} - dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:25.3.0' - compile 'com.android.support:support-v4:25.3.0' - compile "com.android.support:design:25.3.0" - compile "com.android.support:cardview-v7:25.3.0" + compile 'com.android.support:appcompat-v7:26.1.0' + compile 'com.android.support:support-v4:26.1.0' + compile "com.android.support:design:26.1.0" + compile "com.android.support:cardview-v7:26.1.0" compile project(':library') - //compile 'com.patloew.rxlocation:rxlocation:1.0.3' + //compile 'com.patloew.rxlocation:rxlocation:1.0.4' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' - compile 'io.reactivex.rxjava2:rxjava:2.0.7' + compile 'io.reactivex.rxjava2:rxjava:2.1.6' - compile 'com.google.android.gms:play-services-location:10.2.1' + compile 'com.google.android.gms:play-services-location:11.6.0' compile('com.mikepenz:aboutlibraries:5.9.4@aar') { transitive = true } - debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5' - releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' + debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4' + releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4' testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'org.mockito:mockito-core:2.11.0' } diff --git a/sample/src/main/java/com/patloew/rxlocationsample/MainActivity.java b/sample/src/main/java/com/patloew/rxlocationsample/MainActivity.java index 3a47db1..de03203 100644 --- a/sample/src/main/java/com/patloew/rxlocationsample/MainActivity.java +++ b/sample/src/main/java/com/patloew/rxlocationsample/MainActivity.java @@ -49,9 +49,9 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - lastUpdate = (TextView) findViewById(R.id.tv_last_update); - locationText = (TextView) findViewById(R.id.tv_current_location); - addressText = (TextView) findViewById(R.id.tv_current_address); + lastUpdate = findViewById(R.id.tv_last_update); + locationText = findViewById(R.id.tv_current_location); + addressText = findViewById(R.id.tv_current_address); rxLocation = new RxLocation(this); rxLocation.setDefaultTimeout(15, TimeUnit.SECONDS);