Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[google_sign_in] Fix Android Java warnings #3762

Merged
merged 6 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.1.11

* Fixes Java warnings.

## 6.1.10

* Sets an explicit Java compatibility version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ android {
checkAllWarnings true
warningsAsErrors true
disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency'
baseline file("lint-baseline.xml")
}


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.plugins.googlesignin;

import androidx.annotation.NonNull;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.concurrent.BlockingQueue;
Expand Down Expand Up @@ -31,7 +32,7 @@ public interface Callback<T> {
* the future is guaranteed not to block). If the future completed with an exception, then
* {@code get()} will throw an {@code ExecutionException}.
*/
void run(Future<T> future);
void run(@NonNull Future<T> future);
}

private final ThreadPoolExecutor executor;
Expand All @@ -53,16 +54,9 @@ public BackgroundTaskRunner(int threads) {
*
* <p>The callback will be notified on the UI thread.
*/
public <T> void runInBackground(Callable<T> task, final Callback<T> callback) {
public <T> void runInBackground(@NonNull Callable<T> task, final @NonNull Callback<T> callback) {
final ListenableFuture<T> future = runInBackground(task);
future.addListener(
new Runnable() {
@Override
public void run() {
callback.run(future);
}
},
Executors.uiThreadExecutor());
future.addListener(() -> callback.run(future), Executors.uiThreadExecutor());
}

/**
Expand All @@ -72,19 +66,16 @@ public void run() {
* <p>Note: the future will be notified on the background thread. To be notified on the UI thread,
* use {@link #runInBackground(Callable,Callback)}.
*/
public <T> ListenableFuture<T> runInBackground(final Callable<T> task) {
public @NonNull <T> ListenableFuture<T> runInBackground(final @NonNull Callable<T> task) {
final SettableFuture<T> future = SettableFuture.create();

executor.execute(
new Runnable() {
@Override
public void run() {
if (!future.isCancelled()) {
try {
future.set(task.call());
} catch (Throwable t) {
future.setException(t);
}
() -> {
if (!future.isCancelled()) {
try {
future.set(task.call());
} catch (Throwable t) {
future.setException(t);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import java.util.concurrent.Executor;

/**
Expand All @@ -16,7 +17,7 @@
*/
public final class Executors {

private static final class UiThreadExecutor implements Executor {
static final class UiThreadExecutor implements Executor {
private static final Handler UI_THREAD = new Handler(Looper.getMainLooper());

@Override
Expand All @@ -26,7 +27,7 @@ public void execute(Runnable command) {
}

/** Returns an {@code Executor} that will post commands to the UI thread. */
public static Executor uiThreadExecutor() {
public static @NonNull Executor uiThreadExecutor() {
return new UiThreadExecutor();
}

Expand Down
Loading