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;
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;
Objects.requireNonNull(getSupportActionBar())
.setDisplayHomeAsUpEnabled(true);
- model = ViewModelProviders.of(this)
- .get(NewTransactionModel.class);
+ model = new ViewModelProvider(this).get(NewTransactionModel.class);
}
@Override
protected void initProfile() {
}
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 {
.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;
}
model.toggleSimulateSave();
}
- private class AsyncCrasher extends AsyncTask<Void, Void, Void> {
- @Override
- protected Void doInBackground(Void... voids) {
- throw new RuntimeException("Simulated crash");
- }
- }
-
}