Fix crash caused by file_ext being null

This commit is contained in:
EncEx
2022-04-14 00:16:31 +08:00
parent 5c7b903f2f
commit 328db61bed
2 changed files with 10 additions and 3 deletions
+2 -2
View File
@@ -11,8 +11,8 @@ android {
applicationId "com.lsper.view" applicationId "com.lsper.view"
minSdkVersion 25 minSdkVersion 25
targetSdkVersion 32 targetSdkVersion 32
versionCode 1101010 versionCode 11010101
versionName "1.2.4" versionName "1.2.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@@ -50,9 +50,16 @@ class PostAdapter(val context: Context, private var postList: ArrayList<Post>) :
Log.w("position", position.toString()) Log.w("position", position.toString())
Log.w("url", postList[position].sample_url) Log.w("url", postList[position].sample_url)
Log.w("rating", postList[position].rating) Log.w("rating", postList[position].rating)
var file_ext = postList[position].file_ext
if (file_ext == null){
val strarr = postList[position].sample_url.split(".")
file_ext = strarr[strarr.lastIndex]
Log.e("file_ext",file_ext)
}
PicActivity.actionStartActivity(context,postList[position].id,postList[position].sample_url, PicActivity.actionStartActivity(context,postList[position].id,postList[position].sample_url,
postList[position].file_url,postList[position].tags,postList[position].file_ext, postList[position].file_url,postList[position].tags,file_ext,
postList[position].author,postList[position].file_size) postList[position].author,postList[position].file_size)
} }