Skip to content

Commit 9cc31ef

Browse files
committed
Fixed build by updating android gradle plugin version.
Infer nullability annotation.
1 parent c3b614a commit 9cc31ef

15 files changed

+268
-107
lines changed

bolts-applinks/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies {
2828

2929
testCompile 'junit:junit:4.12'
3030

31-
androidTestCompile 'com.android.support:support-v4:23.0.1'
31+
androidTestCompile 'com.android.support:support-v4:28.0.0'
3232
}
3333

3434
android.libraryVariants.all { variant ->

bolts-tasks/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ configurations {
99

1010
android {
1111
compileSdkVersion rootProject.ext.compileSdkVersion
12-
buildToolsVersion rootProject.ext.buildToolsVersion
1312

1413
defaultConfig {
1514
minSdkVersion rootProject.ext.minSdkVersion
@@ -24,6 +23,7 @@ sourceSets {
2423

2524
dependencies {
2625
testCompile 'junit:junit:4.12'
26+
implementation 'com.android.support:support-annotations:28.0.0'
2727
}
2828

2929
//region Maven

bolts-tasks/src/main/java/com/anchorfree/bolts/AggregateException.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
package com.anchorfree.bolts;
1111

12+
import android.support.annotation.NonNull;
13+
import android.support.annotation.Nullable;
1214
import java.io.PrintStream;
1315
import java.io.PrintWriter;
1416
import java.util.ArrayList;
@@ -51,7 +53,7 @@ public AggregateException(String detailMessage, Throwable[] innerThrowables) {
5153
* @param innerThrowables
5254
* The exceptions that are the cause of the current exception.
5355
*/
54-
public AggregateException(String detailMessage, List<? extends Throwable> innerThrowables) {
56+
public AggregateException(String detailMessage, @Nullable List<? extends Throwable> innerThrowables) {
5557
super(detailMessage,
5658
innerThrowables != null && innerThrowables.size() > 0 ? innerThrowables.get(0) : null);
5759
this.innerThrowables = Collections.unmodifiableList(innerThrowables);
@@ -77,7 +79,7 @@ public List<Throwable> getInnerThrowables() {
7779
}
7880

7981
@Override
80-
public void printStackTrace(PrintStream err) {
82+
public void printStackTrace(@NonNull PrintStream err) {
8183
super.printStackTrace(err);
8284

8385
int currentIndex = -1;
@@ -92,7 +94,7 @@ public void printStackTrace(PrintStream err) {
9294
}
9395

9496
@Override
95-
public void printStackTrace(PrintWriter err) {
97+
public void printStackTrace(@NonNull PrintWriter err) {
9698
super.printStackTrace(err);
9799

98100
int currentIndex = -1;
@@ -109,6 +111,7 @@ public void printStackTrace(PrintWriter err) {
109111
/**
110112
* @deprecated Please use {@link #getInnerThrowables()} instead.
111113
*/
114+
@NonNull
112115
@Deprecated
113116
public List<Exception> getErrors() {
114117
List<Exception> errors = new ArrayList<Exception>();

bolts-tasks/src/main/java/com/anchorfree/bolts/AndroidExecutors.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.os.Handler;
1515
import android.os.Looper;
1616

17+
import android.support.annotation.NonNull;
1718
import java.util.concurrent.Executor;
1819
import java.util.concurrent.ExecutorService;
1920
import java.util.concurrent.LinkedBlockingQueue;
@@ -39,7 +40,7 @@
3940

4041
private static final AndroidExecutors INSTANCE = new AndroidExecutors();
4142

42-
private final Executor uiThread;
43+
@NonNull private final Executor uiThread;
4344

4445
private AndroidExecutors() {
4546
uiThread = new UIThreadExecutor();
@@ -70,6 +71,7 @@ private AndroidExecutors() {
7071
*
7172
* @return the newly created thread pool
7273
*/
74+
@NonNull
7375
public static ExecutorService newCachedThreadPool() {
7476
ThreadPoolExecutor executor = new ThreadPoolExecutor(
7577
CORE_POOL_SIZE,
@@ -93,6 +95,7 @@ public static ExecutorService newCachedThreadPool() {
9395
* @param threadFactory the factory to use when creating new threads
9496
* @return the newly created thread pool
9597
*/
98+
@NonNull
9699
public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory) {
97100
ThreadPoolExecutor executor = new ThreadPoolExecutor(
98101
CORE_POOL_SIZE,
@@ -116,7 +119,7 @@ public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory) {
116119
* @param value true if should time out, else false
117120
*/
118121
@SuppressLint("NewApi")
119-
public static void allowCoreThreadTimeout(ThreadPoolExecutor executor, boolean value) {
122+
public static void allowCoreThreadTimeout(@NonNull ThreadPoolExecutor executor, boolean value) {
120123
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
121124
executor.allowCoreThreadTimeOut(value);
122125
}
@@ -125,6 +128,7 @@ public static void allowCoreThreadTimeout(ThreadPoolExecutor executor, boolean v
125128
/**
126129
* An {@link java.util.concurrent.Executor} that executes tasks on the UI thread.
127130
*/
131+
@NonNull
128132
public static Executor uiThread() {
129133
return INSTANCE.uiThread;
130134
}

bolts-tasks/src/main/java/com/anchorfree/bolts/BoltsExecutors.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.anchorfree.bolts;
22

3+
import android.support.annotation.NonNull;
34
import java.util.Locale;
45
import java.util.concurrent.Executor;
56
import java.util.concurrent.ExecutorService;
@@ -21,9 +22,9 @@ private static boolean isAndroidRuntime() {
2122
return javaRuntimeName.toLowerCase(Locale.US).contains("android");
2223
}
2324

24-
private final ExecutorService background;
25+
@NonNull private final ExecutorService background;
2526
private final ScheduledExecutorService scheduled;
26-
private final Executor immediate;
27+
@NonNull private final Executor immediate;
2728

2829
private BoltsExecutors() {
2930
background = !isAndroidRuntime()
@@ -36,6 +37,7 @@ private BoltsExecutors() {
3637
/**
3738
* An {@link java.util.concurrent.Executor} that executes tasks in parallel.
3839
*/
40+
@NonNull
3941
public static ExecutorService background() {
4042
return INSTANCE.background;
4143
}
@@ -49,7 +51,8 @@ public static ExecutorService background() {
4951
* the stack runs too deep, at which point it will delegate to {@link BoltsExecutors#background}
5052
* in order to trim the stack.
5153
*/
52-
/* package */ static Executor immediate() {
54+
/* package */ @NonNull
55+
static Executor immediate() {
5356
return INSTANCE.immediate;
5457
}
5558

@@ -61,7 +64,7 @@ public static ExecutorService background() {
6164
*/
6265
private static class ImmediateExecutor implements Executor {
6366
private static final int MAX_DEPTH = 15;
64-
private ThreadLocal<Integer> executionDepth = new ThreadLocal<>();
67+
@NonNull private ThreadLocal<Integer> executionDepth = new ThreadLocal<>();
6568

6669
/**
6770
* Increments the depth.
@@ -98,7 +101,7 @@ private int decrementDepth() {
98101
}
99102

100103
@Override
101-
public void execute(Runnable command) {
104+
public void execute(@NonNull Runnable command) {
102105
int depth = incrementDepth();
103106
try {
104107
if (depth <= MAX_DEPTH) {

bolts-tasks/src/main/java/com/anchorfree/bolts/CancellationToken.java

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package com.anchorfree.bolts;
1111

12+
import android.support.annotation.NonNull;
1213
import java.util.Locale;
1314
import java.util.concurrent.CancellationException;
1415

@@ -61,6 +62,7 @@ public void throwIfCancellationRequested() throws CancellationException {
6162
tokenSource.throwIfCancellationRequested();
6263
}
6364

65+
@NonNull
6466
@Override
6567
public String toString() {
6668
return String.format(Locale.US, "%s@%s[cancellationRequested=%s]",

bolts-tasks/src/main/java/com/anchorfree/bolts/CancellationTokenRegistration.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package com.anchorfree.bolts;
1111

12+
import android.support.annotation.Nullable;
1213
import java.io.Closeable;
1314

1415
/**
@@ -19,8 +20,8 @@
1920
public class CancellationTokenRegistration implements Closeable {
2021

2122
private final Object lock = new Object();
22-
private CancellationTokenSource tokenSource;
23-
private Runnable action;
23+
@Nullable private CancellationTokenSource tokenSource;
24+
@Nullable private Runnable action;
2425
private boolean closed;
2526

2627
/* package */ CancellationTokenRegistration(CancellationTokenSource tokenSource, Runnable action) {

bolts-tasks/src/main/java/com/anchorfree/bolts/CancellationTokenSource.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
package com.anchorfree.bolts;
1111

12+
import android.support.annotation.NonNull;
13+
import android.support.annotation.Nullable;
1214
import java.io.Closeable;
1315
import java.util.ArrayList;
1416
import java.util.List;
@@ -31,7 +33,7 @@ public class CancellationTokenSource implements Closeable {
3133
private final Object lock = new Object();
3234
private final List<CancellationTokenRegistration> registrations = new ArrayList<>();
3335
private final ScheduledExecutorService executor = BoltsExecutors.scheduled();
34-
private ScheduledFuture<?> scheduledCancellation;
36+
@Nullable private ScheduledFuture<?> scheduledCancellation;
3537
private boolean cancellationRequested;
3638
private boolean closed;
3739

@@ -54,6 +56,7 @@ public boolean isCancellationRequested() {
5456
/**
5557
* @return the token that can be passed to asynchronous method to control cancellation.
5658
*/
59+
@NonNull
5760
public CancellationToken getToken() {
5861
synchronized (lock) {
5962
throwIfClosed();
@@ -184,6 +187,7 @@ private void notifyListeners(List<CancellationTokenRegistration> registrations)
184187
}
185188
}
186189

190+
@NonNull
187191
@Override
188192
public String toString() {
189193
return String.format(Locale.US, "%s@%s[cancellationRequested=%s]",

bolts-tasks/src/main/java/com/anchorfree/bolts/Continuation.java

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
package com.anchorfree.bolts;
1111

12+
import android.support.annotation.Nullable;
13+
1214
/**
1315
* A function to be called after a task completes.
1416
*
@@ -18,5 +20,6 @@
1820
* @see Task
1921
*/
2022
public interface Continuation<TTaskResult, TContinuationResult> {
23+
@Nullable
2124
TContinuationResult then(Task<TTaskResult> task) throws Exception;
2225
}

0 commit comments

Comments
 (0)