Another small refactoring to make control flow easier to understand.

This commit is contained in:
akwizgran
2021-04-09 11:09:54 +01:00
committed by Torsten Grote
parent 6ee57315dd
commit cdae8b35f5
2 changed files with 7 additions and 6 deletions

View File

@@ -72,9 +72,12 @@ public class AddNearbyContactIntroFragment extends BaseFragment {
false); false);
scrollView = v.findViewById(R.id.scrollView); scrollView = v.findViewById(R.id.scrollView);
View button = v.findViewById(R.id.continueButton); View button = v.findViewById(R.id.continueButton);
button.setOnClickListener(view -> viewModel.onContinueClicked(() -> button.setOnClickListener(view -> {
permissionManager.checkPermissions() viewModel.onContinueClicked();
)); if (permissionManager.checkPermissions()) {
viewModel.showQrCodeFragmentIfAllowed();
}
});
return v; return v;
} }

View File

@@ -65,7 +65,6 @@ import javax.inject.Provider;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.UiThread; import androidx.annotation.UiThread;
import androidx.core.util.Supplier;
import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
@@ -211,12 +210,11 @@ class AddNearbyContactViewModel extends AndroidViewModel
} }
@UiThread @UiThread
void onContinueClicked(Supplier<Boolean> checkPermissions) { void onContinueClicked() {
if (bluetoothDecision == REFUSED) { if (bluetoothDecision == REFUSED) {
bluetoothDecision = UNKNOWN; // Ask again bluetoothDecision = UNKNOWN; // Ask again
} }
wasContinueClicked = true; wasContinueClicked = true;
if (checkPermissions.get()) showQrCodeFragmentIfAllowed();
} }
@UiThread @UiThread