import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
-import androidx.lifecycle.ViewModelProviders;
+import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
"getActivity() returned null within onActivityCreated()");
list = activity.findViewById(R.id.new_transaction_accounts);
- viewModel = ViewModelProviders.of(activity)
- .get(NewTransactionModel.class);
+ viewModel = new ViewModelProvider(activity).get(NewTransactionModel.class);
mProfile = Data.profile.getValue();
listAdapter = new NewTransactionItemsAdapter(viewModel, mProfile);
list.setAdapter(listAdapter);
list.setLayoutManager(new LinearLayoutManager(activity));
- Data.profile.observe(this, profile -> {
+ Data.profile.observe(getViewLifecycleOwner(), profile -> {
mProfile = profile;
listAdapter.setProfile(profile);
});
}).attachToRecyclerView(list);
viewModel.isSubmittable()
- .observe(this, isSubmittable -> {
+ .observe(getViewLifecycleOwner(), isSubmittable -> {
if (isSubmittable) {
if (fab != null) {
fab.show();
if (args != null) {
String error = args.getString("error");
if (error != null) {
- // TODO display error
Logger.debug("new-trans-f", String.format("Got error: %s", error));
Snackbar.make(list, error, Snackbar.LENGTH_LONG)
.show();
LedgerTransactionAccount emptyAmountAccount = null;
float emptyAmountAccountBalance = 0;
for (int i = 0; i < viewModel.getAccountCount(); i++) {
- LedgerTransactionAccount acc = viewModel.getAccount(i);
+ LedgerTransactionAccount acc =
+ new LedgerTransactionAccount(viewModel.getAccount(i));
if (acc.getAccountName()
.trim()
.isEmpty())