Commit b3899c50 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Apps: Upstream lifecycle dependencies

- ViewModelProviders.of() which was part of lifecycle-extensions has been deprecated
- Switch to latest version of lifecycle-viewmodel-ktx as dependency and migrate required
  code to use ViewModelProvider()

References:
- [1]: https://developer.android.com/jetpack/androidx/releases/lifecycle#declaring_dependencies
- [2]: https://twitter.com/ianhlake/status/1159159590476382208

Signed-off-by: Aayush Gupta's avatarAayush Gupta <theimpulson@e.email>
parent 41ba24be
......@@ -56,7 +56,6 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// implementation 'com.android.support:design:27.1.1'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
implementation 'org.bouncycastle:bcpg-jdk15on:1.60'
......@@ -71,7 +70,8 @@ dependencies {
implementation "androidx.preference:preference-ktx:1.1.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.0'
// Lifecycle
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
......
......@@ -25,7 +25,7 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import foundation.e.apps.R
import foundation.e.apps.categories.model.Category
......@@ -39,7 +39,7 @@ class ApplicationsFragment() : Fragment() {
var color:Int = 0;
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
categoriesViewModel = ViewModelProviders.of(activity!!).get(CategoriesViewModel::class.java)
categoriesViewModel = ViewModelProvider(this).get(CategoriesViewModel::class.java)
val view = inflater.inflate(R.layout.fragment_application_categories, container, false)
view.categories_list.layoutManager = LinearLayoutManager(context)
......
......@@ -25,7 +25,7 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import foundation.e.apps.R
import foundation.e.apps.categories.viewmodel.CategoriesViewModel
......@@ -38,7 +38,7 @@ class GamesFragment() : Fragment() {
var color:Int = 0;
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
categoriesViewModel = ViewModelProviders.of(activity!!).get(CategoriesViewModel::class.java)
categoriesViewModel = ViewModelProvider(this).get(CategoriesViewModel::class.java)
val view = inflater.inflate(R.layout.fragment_games_categories, container, false)
view.categories_list.layoutManager = LinearLayoutManager(context)
......
......@@ -7,7 +7,7 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import foundation.e.apps.R
import foundation.e.apps.categories.viewmodel.CategoriesViewModel
......@@ -18,7 +18,7 @@ class PwasFragment : Fragment() {
private lateinit var categoriesViewModel: CategoriesViewModel
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
categoriesViewModel = ViewModelProviders.of(activity!!).get(CategoriesViewModel::class.java)
categoriesViewModel = ViewModelProvider(this).get(CategoriesViewModel::class.java)
val view = inflater.inflate(R.layout.fragment_application_categories, container, false)
view.categories_list.layoutManager = LinearLayoutManager(context)
......
......@@ -32,7 +32,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ContextThemeWrapper
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
......@@ -75,7 +75,7 @@ class CategoryActivity : AppCompatActivity(), ApplicationManagerServiceConnectio
category = intent.getSerializableExtra(CATEGORY_KEY) as Category
supportActionBar?.title = category.getTitle()
categoryViewModel = ViewModelProviders.of(this).get(CategoryViewModel::class.java)
categoryViewModel = ViewModelProvider(this).get(CategoryViewModel::class.java)
recyclerView = findViewById(R.id.app_list)
val loadMoreContainer = findViewById<RelativeLayout>(R.id.load_more_container)
progressBar = findViewById(R.id.progress_bar)
......
......@@ -30,7 +30,7 @@ import android.widget.ProgressBar
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
......@@ -70,7 +70,7 @@ class HomeFragment : Fragment() {
view.findViewById<TextView>(R.id.tv_featured).setTextColor(accentColorOS);
}*/
homeViewModel = ViewModelProviders.of(activity!!).get(HomeViewModel::class.java)
homeViewModel = ViewModelProvider(this).get(HomeViewModel::class.java)
imageCarousel = view.findViewById(R.id.image_carousel)
divider = view.findViewById(R.id.divider)
categoryList = view.findViewById(R.id.category_list)
......
......@@ -33,7 +33,7 @@ import androidx.cursoradapter.widget.CursorAdapter
import androidx.cursoradapter.widget.SimpleCursorAdapter
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import foundation.e.apps.R
......@@ -71,7 +71,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On
val view = inflater.inflate(R.layout.fragment_search, container, false)
searchViewModel = ViewModelProviders.of(activity!!).get(SearchViewModel::class.java)
searchViewModel = ViewModelProvider(this).get(SearchViewModel::class.java)
focusView = view.findViewById(R.id.view)
searchView = view.findViewById(R.id.search_view)
recyclerView = view.findViewById(R.id.app_list)
......
......@@ -25,7 +25,7 @@ import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import foundation.e.apps.R
import foundation.e.apps.settings.viewmodel.AppRequestViewModel
import foundation.e.apps.utils.Error
......@@ -43,7 +43,7 @@ class AppRequestActivity : AppCompatActivity(), TextWatcher {
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
viewModel = ViewModelProviders.of(this).get(AppRequestViewModel::class.java)
viewModel = ViewModelProvider(this).get(AppRequestViewModel::class.java)
progress_bar.visibility = View.GONE
app_request_error_text_view.visibility = View.GONE
package_name_edit_text.addTextChangedListener(this)
......
......@@ -31,7 +31,7 @@ import android.widget.ProgressBar
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import foundation.e.apps.R
......@@ -64,7 +64,7 @@ class UpdatesFragment() : Fragment() {
val view = inflater.inflate(R.layout.fragment_updates, container, false)
updatesViewModel = ViewModelProviders.of(activity!!).get(UpdatesViewModel::class.java)
updatesViewModel = ViewModelProvider(this).get(UpdatesViewModel::class.java)
recyclerView = view.findViewById(R.id.app_list)
progressBar2 = view.findViewById<ProgressBar>(R.id.progress_bar2)
val updateAll = view.findViewById<Button>(R.id.update_all)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment