From bd79894e6d9c996cebd017d7d5e226aae9568821 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 22 Dec 2019 09:05:37 +0200 Subject: [PATCH] avoid deprecated usage of viewModelProviders --- .../mobileledger/ui/activity/NewTransactionActivity.java | 5 ++--- .../mobileledger/ui/activity/NewTransactionFragment.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java index d506ac35..24f7f895 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java @@ -24,7 +24,7 @@ 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; @@ -65,8 +65,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() { diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java index 10f246d7..5cbbab71 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java @@ -30,7 +30,7 @@ import androidx.annotation.NonNull; 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; @@ -93,8 +93,7 @@ public class NewTransactionFragment extends Fragment { "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); -- 2.39.5