package net.ktnx.mobileledger.ui.new_transaction;
+import android.content.Context;
import android.content.Intent;
import android.database.AbstractCursor;
import android.database.Cursor;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.MatchedTemplate;
+import net.ktnx.mobileledger.ui.FabManager;
import net.ktnx.mobileledger.ui.QR;
import net.ktnx.mobileledger.ui.activity.ProfileThemedActivity;
import net.ktnx.mobileledger.ui.templates.TemplatesActivity;
public class NewTransactionActivity extends ProfileThemedActivity
implements TaskCallback, NewTransactionFragment.OnNewTransactionFragmentInteractionListener,
- QR.QRScanTrigger, QR.QRScanResultReceiver, DescriptionSelectedCallback {
+ QR.QRScanTrigger, QR.QRScanResultReceiver, DescriptionSelectedCallback,
+ FabManager.FabHandler {
private NavController navController;
private NewTransactionModel model;
private ActivityResultLauncher<Void> qrScanLauncher;
private ActivityNewTransactionBinding b;
+ private FabManager fabManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
qrScanLauncher = QR.registerLauncher(this, this);
+ fabManager = new FabManager(b.fabAdd);
+
model.isSubmittable()
.observe(this, isSubmittable -> {
if (isSubmittable) {
- b.fabAdd.show();
+ fabManager.showFab();
}
else {
- b.fabAdd.hide();
+ fabManager.hideFab();
}
});
// viewModel.checkTransactionSubmittable(listAdapter);
b.fabAdd.setOnClickListener(v -> onFabPressed());
-
-
}
@Override
protected void initProfile() {
onTransactionSave(tr);
}
+ @Override
+ public Context getContext() {
+ return this;
+ }
+ @Override
+ public void showManagedFab() {
+ if (Objects.requireNonNull(model.isSubmittable()
+ .getValue()))
+ fabManager.showFab();
+ }
+ @Override
+ public void hideManagedFab() {
+ fabManager.hideFab();
+ }
}
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
+import net.ktnx.mobileledger.ui.FabManager;
import net.ktnx.mobileledger.ui.QR;
import net.ktnx.mobileledger.utils.Logger;
else
p.setVisibility(View.INVISIBLE);
});
+
+ if (activity instanceof FabManager.FabHandler)
+ FabManager.handle((FabManager.FabHandler) activity, list);
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {