Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fui_auth_method_picker_layout); FlowParameters params = getFlowParams(); mHandler = ViewModelProviders.of(this).get(SimpleProvidersHandler.class); mHandler.init(params); populateIdpList(params.providerInfo, mHandler); int logoId = params.logoId; if (logoId == AuthUI.NO_LOGO) { findViewById(R.id.logo).setVisibility(View.GONE); ConstraintLayout layout = findViewById(R.id.root); ConstraintSet constraints = new ConstraintSet(); constraints.clone(layout); constraints.setHorizontalBias(R.id.container, 0.5f); constraints.setVerticalBias(R.id.container, 0.5f); constraints.applyTo(layout); } else { ImageView logo = findViewById(R.id.logo); logo.setImageResource(logoId); } mHandler.getOperation().observe(this, new Observer<Resource<IdpResponse>>() { @Override public void onChanged(Resource<IdpResponse> resource) { if (resource.getState() == State.LOADING) { getDialogHolder().showLoadingDialog(R.string.fui_progress_dialog_signing_in); return; } getDialogHolder().dismissDialog(); <START> if (resource.isUsed()) { return; } <END> if (resource.getState() == State.SUCCESS) { startSaveCredentials(mHandler.getCurrentUser(), null, resource.getValue()); } else { Exception e = resource.getException(); if (!FlowUtils.handleError(AuthMethodPickerActivity.this, e) && e.getLocalizedMessage() != null) { Toast.makeText(AuthMethodPickerActivity.this, R.string.fui_error_unknown, Toast.LENGTH_SHORT).show(); } } } }); }</code><technical_language>this pattern, I if this cleaner: * Introduce a new UsableResource class * states now, a state work? worse</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fui_auth_method_picker_layout); FlowParameters params = getFlowParams(); mHandler = ViewModelProviders.of(this).get(SocialProviderResponseHandler.class); mHandler.init(params); populateIdpList(params.providerInfo, mHandler); int logoId = params.logoId; if (logoId == AuthUI.NO_LOGO) { findViewById(R.id.logo).setVisibility(View.GONE); ConstraintLayout layout = findViewById(R.id.root); ConstraintSet constraints = new ConstraintSet(); constraints.clone(layout); constraints.setHorizontalBias(R.id.container, 0.5f); constraints.setVerticalBias(R.id.container, 0.5f); constraints.applyTo(layout); } else { ImageView logo = findViewById(R.id.logo); logo.setImageResource(logoId); } mHandler.getOperation().observe(this, new Observer<Resource<IdpResponse>>() { @Override public void onChanged(Resource<IdpResponse> resource) { if (resource.getState() == State.LOADING) { getDialogHolder().showLoadingDialog(R.string.fui_progress_dialog_signing_in); return; } getDialogHolder().dismissDialog(); if (resource.getState() == State.SUCCESS) { startSaveCredentials(mHandler.getCurrentUser(), null, resource.getValue()); } else if (resource.getState() == State.FAILURE) { Exception e = resource.getException(); if (!FlowUtils.handleError(AuthMethodPickerActivity.this, e) && !(e instanceof UserCancellationException)) { Toast.makeText(AuthMethodPickerActivity.this, R.string.fui_error_unknown, Toast.LENGTH_SHORT).show(); } } } }); }