I have a warning in my logcat:
W/art: Verification of void com.myapp.LoginFragment$override.lambda$logIn$5(com.myapp.LoginFragment, java.lang.Throwable) took 217.578ms
Here is the code:
subscription = viewModel.logIn() .observeOn(AndroidSchedulers.mainThread()) .subscribe( this::showStudioSelection, error -> { ErrorResponse errorResponse = ErrorResponseFactory.create(error); if (errorResponse.code() == ApiResult.BAD_REQUEST) { Snackbar.make(getView(), R.string.login_bad_credentials, Snackbar.LENGTH_LONG) .setAction(android.R.string.ok, v -> {}) .show(); } else { Snackbar.make(getView(), "Unknown error " + errorResponse.code(), Snackbar.LENGTH_LONG) .setAction(android.R.string.ok, v -> {}) .show(); } viewModel.updateLoginButtonState(); } );
220 ms is quite a lot (and I feel that I notice lagging behind the launch of this fragment).
I use RxJava and retrolambda, but this is not the only place this message appears, so I donβt think it is directly connected.
How can I affect the scan time? Is it worth it?
This seems to be due to cyclical complexity, since I could get rid of waring by deleting the calls to Snackbar.make in if with even drier code:
String errorMessage; if (errorResponse.code() == ApiResult.BAD_REQUEST) { errorMessage = getString(R.string.login_bad_credentials); } else { errorMessage = "Unknown error " + errorResponse.code(); }
performance android android-runtime
Lovis
source share