From 6f137277acd5ce8f02f12c55c745ada640d4ead6 Mon Sep 17 00:00:00 2001 From: Norbel AMBANUMBEN Date: Fri, 24 May 2024 17:35:33 +0100 Subject: [PATCH] fix: npe for last run time --- .../ooniprobe/activity/overview/OverviewViewModel.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/activity/overview/OverviewViewModel.kt b/app/src/main/java/org/openobservatory/ooniprobe/activity/overview/OverviewViewModel.kt index bd39742ef..b190b9747 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/activity/overview/OverviewViewModel.kt +++ b/app/src/main/java/org/openobservatory/ooniprobe/activity/overview/OverviewViewModel.kt @@ -5,6 +5,7 @@ import android.view.View import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.MutableLiveData import org.openobservatory.engine.BaseNettest +import org.openobservatory.ooniprobe.R import org.openobservatory.ooniprobe.activity.AbstractActivity import org.openobservatory.ooniprobe.common.AbstractDescriptor import org.openobservatory.ooniprobe.common.Application @@ -124,9 +125,11 @@ class OverviewViewModel @Inject constructor(var application: Application, var pr fun getLastTime(): String? { return descriptor.value?.let { - DateUtils.getRelativeTimeSpanString( - Result.getLastResult(it.name).start_time.time - ).toString() + Result.getLastResult(it.name)?.start_time?.time?.let { time -> + DateUtils.getRelativeTimeSpanString( + time + ).toString() + }?: application.getString(R.string.Dashboard_Overview_LastRun_Never) } }