mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-01-27 08:51:18 +01:00
make sure the file exists before trying to read it at the read activity
This commit is contained in:
parent
90a0d6a663
commit
308755c5ba
@ -80,7 +80,13 @@ class ReadTextActivity : SimpleActivity() {
|
||||
|
||||
val text = if (uri.scheme == "file") {
|
||||
filePath = uri.path
|
||||
File(uri.path).readText()
|
||||
val file = File(filePath)
|
||||
if (file.exists()) {
|
||||
file.readText()
|
||||
} else {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
""
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
contentResolver.openInputStream(uri).bufferedReader().use { it.readText() }
|
||||
|
@ -95,7 +95,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||
|
||||
override fun getSelectableItemCount() = fileDirItems.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int) = createViewHolder(R.layout.list_item, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.list_item, parent)
|
||||
|
||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||
val fileDirItem = fileDirItems[position]
|
||||
@ -461,10 +461,10 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder?) {
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isActivityDestroyed()) {
|
||||
Glide.with(activity).clear(holder?.itemView?.item_icon!!)
|
||||
Glide.with(activity).clear(holder.itemView?.item_icon!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ManageFavoritesAdapter(activity: BaseSimpleActivity, var favorites: ArrayL
|
||||
|
||||
override fun getSelectableItemCount() = favorites.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int) = createViewHolder(R.layout.item_manage_favorite, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_manage_favorite, parent)
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val favorite = favorites[position]
|
||||
|
Loading…
x
Reference in New Issue
Block a user