|
|
@ -13,7 +13,9 @@ import io.legado.app.utils.readText |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
class FileAssociationViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
class FileAssociationViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
fun dispatchIndent(uri: Uri): Intent? { |
|
|
|
fun dispatchIndent(uri: Uri): Intent? { |
|
|
|
|
|
|
|
try { |
|
|
|
val url: String |
|
|
|
val url: String |
|
|
|
//如果是普通的url,需要根据返回的内容判断是什么 |
|
|
|
//如果是普通的url,需要根据返回的内容判断是什么 |
|
|
|
if (uri.scheme == "file" || uri.scheme == "content") { |
|
|
|
if (uri.scheme == "file" || uri.scheme == "content") { |
|
|
@ -74,5 +76,10 @@ class FileAssociationViewModel(application: Application) : BaseViewModel(applica |
|
|
|
val newIndent = Intent(Intent.ACTION_VIEW) |
|
|
|
val newIndent = Intent(Intent.ACTION_VIEW) |
|
|
|
newIndent.data = data |
|
|
|
newIndent.data = data |
|
|
|
return newIndent |
|
|
|
return newIndent |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
e.printStackTrace() |
|
|
|
|
|
|
|
toast(e.localizedMessage) |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |