Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
tsynik committed May 3, 2024
1 parent e7dc560 commit 9ce1056
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/ru/yourok/torrserve/atv/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ object Utils {
vintent.putExtra("action", "play")
vintent.putExtra("hash", torr.hash)
vintent.putExtra("title", torr.title)
if (torr.poster.isNotBlank()) vintent.putExtra("poster", torr.poster)
torr.poster?.let { if (it.isNotBlank()) vintent.putExtra("poster", it) }
torr.category?.let { if (it.isNotBlank()) vintent.putExtra("category", it) }
torr.data?.let {if (it.isNotBlank()) vintent.putExtra("data", it) }
vintent.putExtra("save", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ru.yourok.torrserve.server.models.torrent

data class Torrent(
var title: String,
var poster: String,
var poster: String?,
var category: String?,
var data: String?,
var timestamp: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object Play {
torr = Api.getTorrent(torr.hash)
} catch (_: Exception) {
}
while (torr.stat == TorrentHelper.TorrentSTPreload) {
while (torr.stat == TorrentHelper.T_STATE_PRELOAD) {
delay(1000)
try {
torr = Api.getTorrent(torr.hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ open class InfoFragment : TSFragment() {
}
}

if (torr.stat < TorrentHelper.TorrentSTWorking) {
if (torr.stat < TorrentHelper.T_STATE_WORKING) {
if (prc > 0 && prc < 100)
(activity as? PlayActivity)?.showProgress(prc.toInt())
else
Expand Down
17 changes: 6 additions & 11 deletions app/src/main/java/ru/yourok/torrserve/utils/TorrentHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import java.io.File
import java.util.Locale

object TorrentHelper {
const val TorrentSTAdded = 0
const val TorrentSTGettingInfo = 1
const val TorrentSTPreload = 2
const val TorrentSTWorking = 3
const val TorrentSTClosed = 4
const val TorrentInDB = 5
const val T_STATE_ADDED = 0
const val T_STATE_GETINFO = 1
const val T_STATE_PRELOAD = 2
const val T_STATE_WORKING = 3
const val T_STATE_CLOSED = 4
const val T_STATE_INDB = 5

fun getPlayableFiles(torr: Torrent): List<FileStat> {
if (torr.file_stats.isNullOrEmpty())
Expand Down Expand Up @@ -53,16 +53,11 @@ object TorrentHelper {
// if (BuildConfig.DEBUG) Log.d("*****", "waitFiles($count) for $hash")
try {
val torr = Api.getTorrent(hash)
// if (torr.file_stats != null) {
if ((torr.file_stats?.size ?: 0) > 0 || count > 59)
return torr
// else
// count++
// }
count++
Thread.sleep(1000)
} catch (e: Exception) {
e.printStackTrace()
count++
if (count > 59)
return null
Expand Down

0 comments on commit 9ce1056

Please sign in to comment.