fix: network safety
This commit is contained in:
parent
f03af6856a
commit
e32bfa0cfa
7 changed files with 47 additions and 28 deletions
|
@ -12,6 +12,8 @@ import ani.dantotsu.addons.AddonManager
|
||||||
import ani.dantotsu.addons.LoadResult
|
import ani.dantotsu.addons.LoadResult
|
||||||
import ani.dantotsu.addons.AddonInstallReceiver
|
import ani.dantotsu.addons.AddonInstallReceiver
|
||||||
import ani.dantotsu.media.AddonType
|
import ani.dantotsu.media.AddonType
|
||||||
|
import ani.dantotsu.settings.saving.PrefManager
|
||||||
|
import ani.dantotsu.settings.saving.PrefName
|
||||||
import ani.dantotsu.util.Logger
|
import ani.dantotsu.util.Logger
|
||||||
import eu.kanade.tachiyomi.extension.InstallStep
|
import eu.kanade.tachiyomi.extension.InstallStep
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -70,7 +72,7 @@ class TorrentAddonManager(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAvailable(): Boolean {
|
override fun isAvailable(): Boolean {
|
||||||
return extension?.extension != null
|
return extension?.extension != null && PrefManager.getVal(PrefName.TorrentEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getVersion(): String? {
|
override fun getVersion(): String? {
|
||||||
|
|
|
@ -40,7 +40,12 @@ class MangaUpdates {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val res = client.post(apiUrl, json = query).parsed<MangaUpdatesResponse>()
|
val res = try {
|
||||||
|
client.post(apiUrl, json = query).parsed<MangaUpdatesResponse>()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Logger.log(e.toString())
|
||||||
|
return@tryWithSuspend null
|
||||||
|
}
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
res.results?.map {
|
res.results?.map {
|
||||||
async(Dispatchers.IO) {
|
async(Dispatchers.IO) {
|
||||||
|
|
|
@ -271,6 +271,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
if (torrentExtension.isAvailable()) {
|
if (torrentExtension.isAvailable()) {
|
||||||
val activity = currActivity() ?: requireActivity()
|
val activity = currActivity() ?: requireActivity()
|
||||||
launchIO {
|
launchIO {
|
||||||
|
try {
|
||||||
val extension = torrentExtension.extension!!.extension
|
val extension = torrentExtension.extension!!.extension
|
||||||
torrentExtension.torrentHash?.let {
|
torrentExtension.torrentHash?.let {
|
||||||
extension.removeTorrent(it)
|
extension.removeTorrent(it)
|
||||||
|
@ -298,6 +299,12 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
dismiss()
|
dismiss()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Injekt.get<CrashlyticsInterface>().logException(e)
|
||||||
|
Logger.log(e)
|
||||||
|
toast("Error starting video")
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ani.dantotsu.others
|
package ani.dantotsu.others
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.InputType
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
|
|
|
@ -26,7 +26,11 @@ class ImageSearchViewModel : ViewModel() {
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val res = client.post(url, requestBody = requestBody).parsed<SearchResult>()
|
val res = try {
|
||||||
|
client.post(url, requestBody = requestBody).parsed<SearchResult>()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
SearchResult(error = e.message)
|
||||||
|
}
|
||||||
searchResultLiveData.postValue(res)
|
searchResultLiveData.postValue(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
android:inputType="textMultiLine|none"
|
android:inputType="textMultiLine|none"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
|
android:textSize="12sp"
|
||||||
android:focusableInTouchMode="false"
|
android:focusableInTouchMode="false"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:textColor="?attr/colorOnBackground" />
|
android:textColor="?attr/colorOnBackground" />
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:layout_marginStart="2dp"
|
||||||
android:maxLines="5"
|
android:maxLines="5"
|
||||||
android:text="@string/empty"
|
android:text="@string/empty"
|
||||||
app:lineHeight="15sp" />
|
app:lineHeight="15sp" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue