Skip to content

Commit

Permalink
Updated code to retrieve image
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Jan 4, 2024
1 parent a60c0fa commit 53123bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ abstract class AbstractDescriptor<T : BaseNettest>(
* @return Int representing the display icon for the current descriptor.
*/
open fun getDisplayIcon(context: Context): Int {
return context.resources.getIdentifier(icon, "drawable", context.packageName).let {
return context.resources.getIdentifier(
StringUtils.camelToSnake(
icon
), "drawable", context.packageName
).let {
if (it == 0) R.drawable.ooni_empty_state else it
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.openobservatory.ooniprobe.common.AbstractDescriptor
import org.openobservatory.ooniprobe.common.AppDatabase
import org.openobservatory.ooniprobe.common.OONITests
import org.openobservatory.ooniprobe.common.PreferenceManager
import org.openobservatory.ooniprobe.common.StringUtils
import java.io.Serializable
import java.util.Date
import com.raizlabs.android.dbflow.annotation.TypeConverter as TypeConverterAnnotation
Expand Down Expand Up @@ -96,14 +95,6 @@ class InstalledDescriptor(
return R.string.TestResults_NotAvailable
}

override fun getDisplayIcon(context: Context): Int {
return context.resources.getIdentifier(
StringUtils.camelToSnake(
icon
), "drawable", context.packageName
)
}

override fun toRunTestsGroupItem(preferenceManager: PreferenceManager): GroupItem {
return GroupItem(
selected = false,
Expand Down

0 comments on commit 53123bb

Please sign in to comment.