Skip to content

Commit

Permalink
Remove retrolambda. Update dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
patloew committed Nov 18, 2017
1 parent cb2f98f commit e335887
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 88 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,6 +21,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 10 additions & 15 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
5 changes: 3 additions & 2 deletions library/src/test/java/com/patloew/rxlocation/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions library/src/test/java/com/patloew/rxlocation/LocationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit e335887

Please sign in to comment.