prevent NPE in import list
This commit is contained in:
parent
9700ccd5a0
commit
9881be1309
1 changed files with 7 additions and 6 deletions
|
@ -11,7 +11,6 @@ import app.aaps.core.interfaces.maintenance.PrefsImportDir
|
||||||
import app.aaps.core.interfaces.maintenance.PrefsMetadataKey
|
import app.aaps.core.interfaces.maintenance.PrefsMetadataKey
|
||||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||||
import app.aaps.core.interfaces.rx.bus.RxBus
|
import app.aaps.core.interfaces.rx.bus.RxBus
|
||||||
import app.aaps.core.interfaces.rx.weardata.CwfData
|
|
||||||
import app.aaps.core.interfaces.rx.weardata.CwfFile
|
import app.aaps.core.interfaces.rx.weardata.CwfFile
|
||||||
import app.aaps.core.interfaces.rx.weardata.EventData
|
import app.aaps.core.interfaces.rx.weardata.EventData
|
||||||
import app.aaps.core.interfaces.rx.weardata.ZipWatchfaceFormat
|
import app.aaps.core.interfaces.rx.weardata.ZipWatchfaceFormat
|
||||||
|
@ -30,7 +29,6 @@ import org.joda.time.Hours
|
||||||
import org.joda.time.LocalDateTime
|
import org.joda.time.LocalDateTime
|
||||||
import org.joda.time.format.DateTimeFormat
|
import org.joda.time.format.DateTimeFormat
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.zip.ZipInputStream
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
@ -89,10 +87,13 @@ class PrefFileListProviderImpl @Inject constructor(
|
||||||
|
|
||||||
// we sort only if we have metadata to be used for that
|
// we sort only if we have metadata to be used for that
|
||||||
if (loadMetadata) {
|
if (loadMetadata) {
|
||||||
prefFiles.sortWith(
|
prefFiles
|
||||||
compareByDescending<PrefsFile> { it.metadata[PrefsMetadataKeyImpl.AAPS_FLAVOUR]?.status as PrefsStatusImpl }
|
.filter { it.metadata[PrefsMetadataKeyImpl.AAPS_FLAVOUR]?.status != null }
|
||||||
.thenByDescending { it.metadata[PrefsMetadataKeyImpl.CREATED_AT]?.value }
|
.toMutableList()
|
||||||
)
|
.sortWith(
|
||||||
|
compareByDescending<PrefsFile> { it.metadata[PrefsMetadataKeyImpl.AAPS_FLAVOUR]?.status as PrefsStatusImpl }
|
||||||
|
.thenByDescending { it.metadata[PrefsMetadataKeyImpl.CREATED_AT]?.value }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return prefFiles
|
return prefFiles
|
||||||
|
|
Loading…
Reference in a new issue