]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java
move previous transaction lookup progress bar to the fragment
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionFragment.java
index 55b0e6106c91ac3d0b22337df5def7f8072522d3..1074bcb98f6b30a660f13a3c309eaf4e8e182bb2 100644 (file)
@@ -26,6 +26,7 @@ import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ProgressBar;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
@@ -58,6 +59,7 @@ import java.util.Date;
  */
 
 // TODO: offer to undo account remove-on-swipe
+// TODO: transaction-level comment
 
 public class NewTransactionFragment extends Fragment {
     private NewTransactionItemsAdapter listAdapter;
@@ -105,6 +107,7 @@ public class NewTransactionFragment extends Fragment {
 
         list = activity.findViewById(R.id.new_transaction_accounts);
         viewModel = new ViewModelProvider(activity).get(NewTransactionModel.class);
+        viewModel.observeDataProfile(this);
         mProfile = Data.profile.getValue();
         listAdapter = new NewTransactionItemsAdapter(viewModel, mProfile);
         list.setAdapter(listAdapter);
@@ -128,7 +131,7 @@ public class NewTransactionFragment extends Fragment {
                          }
                      }
                  });
-        viewModel.checkTransactionSubmittable(listAdapter);
+//        viewModel.checkTransactionSubmittable(listAdapter);
 
         fab = activity.findViewById(R.id.fab);
         fab.setOnClickListener(v -> onFabPressed());
@@ -157,6 +160,21 @@ public class NewTransactionFragment extends Fragment {
         else {
             viewModel.setFocusedItem(focused);
         }
+
+        ProgressBar p = activity.findViewById(R.id.progressBar);
+        viewModel.observeBusyFlag(getViewLifecycleOwner(), isBusy -> {
+            if (isBusy) {
+//                Handler h = new Handler();
+//                h.postDelayed(() -> {
+//                    if (viewModel.getBusyFlag())
+//                        p.setVisibility(View.VISIBLE);
+//
+//                }, 10);
+                        p.setVisibility(View.VISIBLE);
+            }
+            else
+                p.setVisibility(View.INVISIBLE);
+        });
     }
     @Override
     public void onSaveInstanceState(@NonNull Bundle outState) {