avoid deprecated usage of viewModelProviders
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 22 Dec 2019 07:05:37 +0000 (09:05 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 22 Dec 2019 07:05:37 +0000 (09:05 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionFragment.java

index d506ac3..24f7f89 100644 (file)
@@ -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() {
index 10f246d..5cbbab7 100644 (file)
@@ -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);