[Android] Fix Typecast exception
Nicolas Pomepuy
git at videolan.org
Tue Sep 3 09:40:38 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Sep 3 08:09:06 2019 +0200| [961d5a1afcf7fc09a4007dc45092068d97ed7ca1] | committer: Nicolas Pomepuy
Fix Typecast exception
Fixes #1013
> https://code.videolan.org/videolan/vlc-android/commit/961d5a1afcf7fc09a4007dc45092068d97ed7ca1
---
vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt b/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
index 9a13db22c..583bb4192 100644
--- a/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
+++ b/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
@@ -110,11 +110,11 @@ object ModelsHelper {
return if (item.title.isEmpty() || !Character.isLetter(item.title[0]) || isSpecialItem(item)) "#" else item.title.substring(0, 1).toUpperCase()
}
- fun getHeader(context: Context?, sort: Int, item: MediaLibraryItem, aboveItem: MediaLibraryItem?) = if (context !== null) when (sort) {
+ fun getHeader(context: Context?, sort: Int, item: MediaLibraryItem?, aboveItem: MediaLibraryItem?) = if (context !== null || item == null) when (sort) {
SORT_DEFAULT,
SORT_FILENAME,
SORT_ALPHA -> {
- val letter = if (item.title.isEmpty() || !Character.isLetter(item.title[0]) || ModelsHelper.isSpecialItem(item)) "#" else item.title.substring(0, 1).toUpperCase()
+ val letter = if (item!!.title.isEmpty() || !Character.isLetter(item.title[0]) || ModelsHelper.isSpecialItem(item)) "#" else item.title.substring(0, 1).toUpperCase()
if (aboveItem == null) letter
else {
val previous = if (aboveItem.title.isEmpty() || !Character.isLetter(aboveItem.title[0]) || ModelsHelper.isSpecialItem(aboveItem)) "#" else aboveItem.title.substring(0, 1).toUpperCase()
@@ -122,7 +122,7 @@ object ModelsHelper {
}
}
SORT_DURATION -> {
- val length = getLength(item)
+ val length = getLength(item!!)
val lengthCategory = lengthToCategory(length)
if (aboveItem == null) lengthCategory
else {
@@ -131,7 +131,7 @@ object ModelsHelper {
}
}
SORT_RELEASEDATE -> {
- val year = getYear(item)
+ val year = getYear(item!!)
if (aboveItem == null) year
else {
val previous = getYear(aboveItem)
@@ -141,10 +141,10 @@ object ModelsHelper {
SORT_LASTMODIFICATIONDATE -> {
val timestamp = (item as AbstractMediaWrapper).lastModified
val category = getTimeCategory(timestamp)
- if (aboveItem == null) getTimeCategoryString(context, category)
+ if (aboveItem == null) getTimeCategoryString(context!!, category)
else {
val prevCat = getTimeCategory((aboveItem as AbstractMediaWrapper).lastModified)
- if (prevCat != category) getTimeCategoryString(context, category) else null
+ if (prevCat != category) getTimeCategoryString(context!!, category) else null
}
}
SORT_ARTIST -> {
More information about the Android
mailing list