2
0

Resolve warnings and inspections.

This commit is contained in:
Maarten Billemont
2018-05-16 12:30:28 -04:00
parent c51262ccc2
commit 2db0bb35d5
17 changed files with 52 additions and 88 deletions

View File

@@ -86,7 +86,7 @@ public final class Preferences {
}
public Set<String> getTestsPassed() {
return prefs().getStringSet( PREF_TESTS_PASSED, ImmutableSet.<String>of() );
return prefs().getStringSet( PREF_TESTS_PASSED, ImmutableSet.of() );
}
public boolean setRememberFullName(final boolean enabled) {

View File

@@ -28,13 +28,12 @@ import android.view.View;
import android.widget.*;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.*;
import com.lyndir.lhunath.opal.system.logging.Logger;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -67,7 +66,7 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
private ListenableFuture<Boolean> testFuture;
@Nullable
private Runnable action;
private ImmutableSet<String> testNames;
private Set<String> testNames;
public static void startNoSkip(final Context context) {
context.startActivity( new Intent( context, TestActivity.class ) );
@@ -80,35 +79,22 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
setContentView( R.layout.activity_test );
ButterKnife.bind( this );
nativeKDFField.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
preferences.setNativeKDFEnabled( isChecked );
// TODO: MasterKey.setAllowNativeByDefault( isChecked );
}
nativeKDFField.setOnCheckedChangeListener( (buttonView, isChecked) -> {
preferences.setNativeKDFEnabled( isChecked );
// TODO: MasterKey.setAllowNativeByDefault( isChecked );
} );
try {
setStatus( 0, 0, null );
testSuite = new MPTestSuite();
testSuite.setListener( this );
testNames = FluentIterable.from( testSuite.getTests().getCases() ).transform(
new Function<MPTests.Case, String>() {
@Nullable
@Override
public String apply(@Nullable final MPTests.Case input) {
return (input == null)? null: input.identifier;
}
} ).filter( Predicates.notNull() ).toSet();
testNames = testSuite.getTests().getCases().stream()
.map( input -> (input == null)? null: input.identifier )
.filter( Objects::nonNull ).collect( Collectors.toSet() );
}
catch (final MPTestSuite.UnavailableException e) {
logger.err( e, "While loading test suite" );
setStatus( R.string.tests_unavailable, R.string.tests_btn_unavailable, new Runnable() {
@Override
public void run() {
finish();
}
} );
setStatus( R.string.tests_unavailable, R.string.tests_btn_unavailable, this::finish );
}
}
@@ -133,31 +119,18 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
@Override
public void onSuccess(@Nullable final Boolean result) {
if ((result != null) && result)
setStatus( R.string.tests_passed, R.string.tests_btn_passed, new Runnable() {
@Override
public void run() {
preferences.setTestsPassed( testNames );
finish();
}
setStatus( R.string.tests_passed, R.string.tests_btn_passed, () -> {
preferences.setTestsPassed( testNames );
finish();
} );
else
setStatus( R.string.tests_failed, R.string.tests_btn_failed, new Runnable() {
@Override
public void run() {
startTestSuite();
}
} );
setStatus( R.string.tests_failed, R.string.tests_btn_failed, () -> startTestSuite() );
}
@Override
public void onFailure(final Throwable t) {
logger.err( t, "While running test suite" );
setStatus( R.string.tests_failed, R.string.tests_btn_failed, new Runnable() {
@Override
public void run() {
finish();
}
} );
setStatus( R.string.tests_failed, R.string.tests_btn_failed, () -> finish() );
}
}, mainExecutor );
}
@@ -184,14 +157,11 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
@Override
public void progress(final int current, final int max, final String messageFormat, final Object... args) {
runOnUiThread( new Runnable() {
@Override
public void run() {
logView.append( strf( "%n" + messageFormat, args ) );
runOnUiThread( () -> {
logView.append( strf( "%n" + messageFormat, args ) );
progressView.setMax( max );
progressView.setProgress( current );
}
progressView.setMax( max );
progressView.setProgress( current );
} );
}
}