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