Skip to content

Commit

Permalink
Update AddFragment.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
tsynik committed Apr 12, 2024
1 parent 07a127b commit b99ebf6
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ class AddFragment : TSFragment() {
torrsAdapter.onClick = {
lifecycleScope.launch(Dispatchers.IO) {
try {
val category = if (it.Categories.equals("series", true)) "tv"
else if (it.Categories.equals("tvshow", true)) "tv"
else if (it.Categories.equals("movie", true)) "movie"
else it.Categories.lowercase()
val category = when {
it.Categories.equals("series", true) -> "tv"
it.Categories.equals("tvshow", true) -> "tv"
it.Categories.equals("movie", true) -> "movie"
else -> it.Categories.lowercase()
}
val torrent = addTorrent("", it.Magnet, it.Title, "", category, "", true)
torrent?.let { App.toast("${getString(R.string.stat_string_added)}: ${it.title}") } ?: App.toast(getString(R.string.error_add_torrent))
} catch (e: Exception) {
Expand All @@ -198,10 +200,12 @@ class AddFragment : TSFragment() {
}
torrsAdapter.onLongClick = {
lifecycleScope.launch(Dispatchers.IO) {
val category = if (it.Categories.equals("series", true)) "tv"
else if (it.Categories.equals("tvshow", true)) "tv"
else if (it.Categories.equals("movie", true)) "movie"
else it.Categories.lowercase()
val category = when {
it.Categories.equals("series", true) -> "tv"
it.Categories.equals("tvshow", true) -> "tv"
it.Categories.equals("movie", true) -> "movie"
else -> it.Categories.lowercase()
}
val torrent: Torrent
val torr = addTorrent("", it.Magnet, it.Title, "", category, "", false) ?: let {
return@launch
Expand Down Expand Up @@ -237,10 +241,12 @@ class AddFragment : TSFragment() {
if (itemPosition in torrsAdapter.list.indices) {
torrsAdapter.list[itemPosition].let {
lifecycleScope.launch(Dispatchers.IO) {
val category = if (it.Categories.equals("series", true)) "tv"
else if (it.Categories.equals("tvshow", true)) "tv"
else if (it.Categories.equals("movie", true)) "movie"
else it.Categories.lowercase()
val category = when {
it.Categories.equals("series", true) -> "tv"
it.Categories.equals("tvshow", true) -> "tv"
it.Categories.equals("movie", true) -> "movie"
else -> it.Categories.lowercase()
}
val torrent: Torrent
val torr = addTorrent("", it.Magnet, it.Title, "", category, "", false) ?: let {
return@launch
Expand Down

0 comments on commit b99ebf6

Please sign in to comment.