]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java
drop unused code
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionActivity.java
index 660be19773891fa62c3cd85341719fef2e6752ff..89362d777b699780a508fe169a1b5045b2f5d9b2 100644 (file)
 
 package net.ktnx.mobileledger.ui.activity;
 
-import android.os.AsyncTask;
 import android.os.Bundle;
 import android.util.TypedValue;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.View;
 
 import androidx.appcompat.widget.Toolbar;
-import androidx.lifecycle.ViewModelProviders;
+import androidx.lifecycle.ViewModelProvider;
 import androidx.navigation.NavController;
 import androidx.navigation.Navigation;
 
@@ -39,13 +39,6 @@ import java.util.Objects;
 
 import static net.ktnx.mobileledger.utils.Logger.debug;
 
-/*
- * TODO: nicer progress while transaction is submitted
- * TODO: reports
- * TODO: get rid of the custom session/cookie and auth code?
- *         (the last problem with the POST was the missing content-length header)
- *  */
-
 public class NewTransactionActivity extends ProfileThemedActivity implements TaskCallback,
         NewTransactionFragment.OnNewTransactionFragmentInteractionListener {
     private NavController navController;
@@ -65,8 +58,7 @@ public class NewTransactionActivity extends ProfileThemedActivity implements Tas
         Objects.requireNonNull(getSupportActionBar())
                .setDisplayHomeAsUpEnabled(true);
 
-        model = ViewModelProviders.of(this)
-                                  .get(NewTransactionModel.class);
+        model = new ViewModelProvider(this).get(NewTransactionModel.class);
     }
     @Override
     protected void initProfile() {
@@ -94,12 +86,6 @@ public class NewTransactionActivity extends ProfileThemedActivity implements Tas
         }
         return super.onOptionsItemSelected(item);
     }
-
-    @Override
-    protected void onStart() {
-        super.onStart();
-        // FIXME if (tvDescription.getText().toString().isEmpty()) tvDescription.requestFocus();
-    }
     public void onTransactionSave(LedgerTransaction tr) {
         navController.navigate(R.id.action_newTransactionFragment_to_newTransactionSavingFragment);
         try {
@@ -131,8 +117,11 @@ public class NewTransactionActivity extends ProfileThemedActivity implements Tas
                 .setVisible(true);
         }
 
-        model.observeSimulateSave(this, state -> menu.findItem(R.id.action_simulate_save)
-                                                     .setChecked(state));
+        model.observeSimulateSave(this, state -> {
+            menu.findItem(R.id.action_simulate_save)
+                .setChecked(state);
+            findViewById(R.id.simulationLabel).setVisibility(state ? View.VISIBLE : View.GONE);
+        });
 
         return true;
     }
@@ -156,11 +145,4 @@ public class NewTransactionActivity extends ProfileThemedActivity implements Tas
         model.toggleSimulateSave();
     }
 
-    private class AsyncCrasher extends AsyncTask<Void, Void, Void> {
-        @Override
-        protected Void doInBackground(Void... voids) {
-            throw new RuntimeException("Simulated crash");
-        }
-    }
-
 }