Fixes deprecation warnings about ViewModelProviders.of(...).
This commit is contained in:
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.majinnaibu.monstercards.R;
|
||||
|
||||
@@ -20,8 +20,7 @@ public class CollectionsFragment extends Fragment {
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
collectionsViewModel =
|
||||
ViewModelProviders.of(this).get(CollectionsViewModel.class);
|
||||
collectionsViewModel = new ViewModelProvider(this).get(CollectionsViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_collections, container, false);
|
||||
final TextView textView = root.findViewById(R.id.text_collections);
|
||||
collectionsViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.majinnaibu.monstercards.R;
|
||||
|
||||
@@ -20,8 +20,7 @@ public class DashboardFragment extends Fragment {
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
dashboardViewModel =
|
||||
ViewModelProviders.of(this).get(DashboardViewModel.class);
|
||||
dashboardViewModel = new ViewModelProvider(this).get(DashboardViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_dashboard, container, false);
|
||||
final TextView textView = root.findViewById(R.id.text_dashboard);
|
||||
dashboardViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.majinnaibu.monstercards.R;
|
||||
|
||||
@@ -20,8 +20,7 @@ public class LibraryFragment extends Fragment {
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
libraryViewModel =
|
||||
ViewModelProviders.of(this).get(LibraryViewModel.class);
|
||||
libraryViewModel = new ViewModelProvider(this).get(LibraryViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_library, container, false);
|
||||
final TextView textView = root.findViewById(R.id.text_library);
|
||||
libraryViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.majinnaibu.monstercards.R;
|
||||
|
||||
@@ -20,8 +20,7 @@ public class MonsterFragment extends Fragment {
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
monsterViewModel =
|
||||
ViewModelProviders.of(this).get(MonsterViewModel.class);
|
||||
monsterViewModel = new ViewModelProvider(this).get(MonsterViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_monster, container, false);
|
||||
final TextView textView = root.findViewById(R.id.text_monster);
|
||||
monsterViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.NavDirections;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
@@ -23,8 +23,7 @@ public class SearchFragment extends Fragment {
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
searchViewModel =
|
||||
ViewModelProviders.of(this).get(SearchViewModel.class);
|
||||
searchViewModel = new ViewModelProvider(this).get(SearchViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_search, container, false);
|
||||
final TextView textView = root.findViewById(R.id.search_query);
|
||||
searchViewModel.getSearchQuery().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
|
||||
Reference in New Issue
Block a user