Skip to content

Commit 7b2180d

Browse files
committed
Removed the usage of deprecated class ViewModelProviders
1 parent dffa07c commit 7b2180d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

app/src/main/java/com/example/android/devbyteviewer/ui/DevByteFragment.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import androidx.annotation.LayoutRes
2727
import androidx.databinding.DataBindingUtil
2828
import androidx.fragment.app.Fragment
2929
import androidx.lifecycle.Observer
30-
import androidx.lifecycle.ViewModelProviders
30+
//import androidx.lifecycle.ViewModelProviders
31+
import androidx.lifecycle.ViewModelProvider
3132
import androidx.recyclerview.widget.LinearLayoutManager
3233
import androidx.recyclerview.widget.RecyclerView
3334
import com.example.android.devbyteviewer.R
@@ -50,8 +51,10 @@ class DevByteFragment : Fragment() {
5051
val activity = requireNotNull(this.activity) {
5152
"You can only access the viewModel after onActivityCreated()"
5253
}
53-
ViewModelProviders.of(this, DevByteViewModel.Factory(activity.application))
54-
.get(DevByteViewModel::class.java)
54+
//The ViewModelProviders (plural) is deprecated.
55+
//ViewModelProviders.of(this, DevByteViewModel.Factory(activity.application)).get(DevByteViewModel::class.java)
56+
ViewModelProvider(this, DevByteViewModel.Factory(activity.application)).get(DevByteViewModel::class.java)
57+
5558
}
5659

5760
/**

0 commit comments

Comments
 (0)