Commit 29b73ec8 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Apps: Migrate to AppCompactResources.getDrawable() method

Current method has been deprecated

References:
- [1]: https://developer.android.com/reference/android/content/res/Resources#getDrawable(int)

Signed-off-by: Aayush Gupta's avatarAayush Gupta <theimpulson@e.email>
parent 1e49b097
Pipeline #109293 passed with stage
in 3 minutes and 54 seconds
......@@ -27,6 +27,7 @@ import android.widget.Button
import android.widget.ImageView
import android.widget.RatingBar
import android.widget.TextView
import androidx.appcompat.content.res.AppCompatResources
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import foundation.e.apps.R
......@@ -105,7 +106,7 @@ class ApplicationViewHolder(private val activity: Activity, private val view: Vi
if (app.basicData != null) {
this.application?.removeListener(this)
this.application = app
icon.setImageDrawable(view.context.resources.getDrawable(R.drawable.ic_app_default))
icon.setImageDrawable(AppCompatResources.getDrawable(activity, R.drawable.ic_app_default))
application!!.loadIcon(this)
application!!.addListener(this)
title.text = application!!.basicData!!.name
......@@ -124,7 +125,7 @@ class ApplicationViewHolder(private val activity: Activity, private val view: Vi
} else {
this.application?.removeListener(this)
this.application = app
icon.setImageDrawable(view.context.resources.getDrawable(R.drawable.ic_app_default))
icon.setImageDrawable(AppCompatResources.getDrawable(activity, R.drawable.ic_app_default))
application!!.addListener(this)
if (application!!.searchAppsBasicData != null) {
if (application!!.searchAppsBasicData!!.is_pwa) {
......
......@@ -28,6 +28,7 @@ import android.view.animation.Animation
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.content.res.AppCompatResources
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import foundation.e.apps.R
......@@ -88,14 +89,14 @@ class SmallApplicationViewHolder(private val activity: Activity, private val vie
if(app.basicData!=null) {
this.application?.removeListener(this)
this.application = app
icon.setImageDrawable(view.context.resources.getDrawable(R.drawable.ic_app_default))
icon.setImageDrawable(AppCompatResources.getDrawable(activity, R.drawable.ic_app_default))
application!!.loadIcon(this)
application!!.addListener(this)
title.text = application!!.basicData!!.name
}else if(app.pwabasicdata!=null){
this.application?.removeListener(this)
this.application = app
icon.setImageDrawable(view.context.resources.getDrawable(R.drawable.ic_app_default))
icon.setImageDrawable(AppCompatResources.getDrawable(activity, R.drawable.ic_app_default))
application!!.PwaloadIcon(this)
application!!.addListener(this)
title.text = application!!.pwabasicdata!!.name
......
......@@ -63,7 +63,7 @@ class ApplicationsFragment() : Fragment() {
//Add New Category
if (!it.any { Category -> Category.id == "system_apps" })
it.add(Category("system_apps"))
view.categories_list.adapter = CategoriesListAdapter(it, color)
view.categories_list.adapter = context?.let { context -> CategoriesListAdapter(context, it, color) }
view.categories_list.visibility = View.VISIBLE
view.progress_bar.visibility = View.GONE
}
......
......@@ -18,6 +18,7 @@
package foundation.e.apps.categories
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
......@@ -25,13 +26,14 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.appcompat.content.res.AppCompatResources
import androidx.recyclerview.widget.RecyclerView
import foundation.e.apps.R
import foundation.e.apps.categories.category.CategoryActivity
import foundation.e.apps.categories.model.Category
import foundation.e.apps.utils.Constants
class CategoriesListAdapter(private var categories: ArrayList<Category>, color: Int?)
class CategoriesListAdapter(private val context: Context, private var categories: ArrayList<Category>, color: Int?)
: RecyclerView.Adapter<CategoriesListAdapter.CategoryViewHolder>() {
val color = color;
......@@ -62,7 +64,7 @@ class CategoriesListAdapter(private var categories: ArrayList<Category>, color:
override fun onBindViewHolder(holder: CategoryViewHolder, position: Int) {
holder.categoryIcon.setImageDrawable(holder.categoryIcon.resources.getDrawable(categories[position].getIconResource()))
holder.categoryIcon.setImageDrawable(AppCompatResources.getDrawable(context, categories[position].getIconResource()))
//holder.categoryIcon.setColorFilter(Color.parseColor("#0088ED"))
if (color != null) {
holder.categoryIcon.setColorFilter(color)
......
......@@ -59,7 +59,7 @@ class GamesFragment() : Fragment() {
// Bind to the list of games categories
categoriesViewModel.getGamesCategories().observe(viewLifecycleOwner, Observer {
if (it!!.isNotEmpty()) {
view.categories_list.adapter = CategoriesListAdapter(it, color)
view.categories_list.adapter = context?.let { context -> CategoriesListAdapter(context, it, color) }
view.categories_list.visibility = View.VISIBLE
view.progress_bar.visibility = View.GONE
}
......
......@@ -51,7 +51,7 @@ class PwasFragment : Fragment() {
// Bind to the list of pwas categories
categoriesViewModel.getPwasCategories().observe(viewLifecycleOwner, Observer {
if (it!!.isNotEmpty()) {
view.categories_list.adapter = CategoriesListAdapter(it, null)
view.categories_list.adapter = context?.let { context -> CategoriesListAdapter(context, it, null) }
view.categories_list.visibility = View.VISIBLE
view.progress_bar.visibility = View.GONE
}
......
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