Mercurial > dwindows
comparison android/DWindows.kt @ 2659:3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
This prevents a crash on non-numeric image assets.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 24 Sep 2021 21:50:17 +0000 |
parents | ad6fc7f1a9af |
children | aca4b56f50dd |
comparison
equal
deleted
inserted
replaced
2658:ad6fc7f1a9af | 2659:3a14d7fd4b99 |
---|---|
808 val length = filename.length | 808 val length = filename.length |
809 | 809 |
810 for (ext in DWImageExts) { | 810 for (ext in DWImageExts) { |
811 if (ext.isNotEmpty() && filename.endsWith(ext)) { | 811 if (ext.isNotEmpty() && filename.endsWith(ext)) { |
812 val filebody: String = filename.substring(7, length - ext.length) | 812 val filebody: String = filename.substring(7, length - ext.length) |
813 if (filebody.toInt() > 0) { | 813 try { |
814 return true | 814 if (filebody.toInt() > 0) { |
815 return true | |
816 } | |
817 } catch(e: NumberFormatException) { | |
815 } | 818 } |
816 } | 819 } |
817 } | 820 } |
818 return false | 821 return false |
819 } | 822 } |
820 | 823 |
821 /** | 824 // Extracts assets/ in the APK to the application cache directory |
822 * extracts assets/ in the APK to the application cache directory | |
823 */ | |
824 private fun extractAssets() { | 825 private fun extractAssets() { |
825 var zipFile: ZipFile? = null | 826 var zipFile: ZipFile? = null |
826 val targetDir = cacheDir | 827 val targetDir = cacheDir |
827 | 828 |
828 try { | 829 try { |