small fixes

This commit is contained in:
LagradOst 2021-09-01 15:16:49 +02:00
parent 3ab3986e22
commit d4014084cd
4 changed files with 59 additions and 49 deletions

View file

@ -903,6 +903,7 @@ class PlayerFragment : Fragment() {
}
private fun handlePlayerEvent(event: Int) {
if(!this::exoPlayer.isInitialized) return
when (event) {
PlayerEventType.Play.value -> exoPlayer.play()
PlayerEventType.Pause.value -> exoPlayer.pause()

View file

@ -844,12 +844,12 @@ class ResultFragment : Fragment() {
if (d is LoadResponse) {
updateVisStatus(2)
result_vpn.text = when (api.vpnStatus) {
result_vpn?.text = when (api.vpnStatus) {
VPNStatus.MightBeNeeded -> getString(R.string.vpn_might_be_needed)
VPNStatus.Torrent -> getString(R.string.vpn_torrent)
else -> ""
}
result_vpn.visibility = if (api.vpnStatus == VPNStatus.None) GONE else VISIBLE
result_vpn?.visibility = if (api.vpnStatus == VPNStatus.None) GONE else VISIBLE
result_bookmark_button.text = "Watching"
@ -859,7 +859,7 @@ class ResultFragment : Fragment() {
currentPoster = d.posterUrl
currentIsMovie = !d.isEpisodeBased()
result_openinbrower.setOnClickListener {
result_openinbrower?.setOnClickListener {
val i = Intent(ACTION_VIEW)
i.data = Uri.parse(d.url)
try {
@ -869,7 +869,7 @@ class ResultFragment : Fragment() {
}
}
result_share.setOnClickListener {
result_share?.setOnClickListener {
val i = Intent(ACTION_SEND)
i.type = "text/plain"
i.putExtra(EXTRA_SUBJECT, d.name)

View file

@ -169,25 +169,29 @@ class InAppUpdater {
registerReceiver(
object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val downloadId = intent?.getLongExtra(
DownloadManager.EXTRA_DOWNLOAD_ID, id
) ?: id
try {
val downloadId = intent?.getLongExtra(
DownloadManager.EXTRA_DOWNLOAD_ID, id
) ?: id
val query = DownloadManager.Query()
query.setFilterById(downloadId)
val c = downloadManager.query(query)
val query = DownloadManager.Query()
query.setFilterById(downloadId)
val c = downloadManager.query(query)
if (c.moveToFirst()) {
val columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS)
if (DownloadManager.STATUS_SUCCESSFUL == c
.getInt(columnIndex)
) {
c.getColumnIndex(DownloadManager.COLUMN_MEDIAPROVIDER_URI)
val uri = Uri.parse(
c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))
)
openApk(localContext, uri)
if (c.moveToFirst()) {
val columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS)
if (DownloadManager.STATUS_SUCCESSFUL == c
.getInt(columnIndex)
) {
c.getColumnIndex(DownloadManager.COLUMN_MEDIAPROVIDER_URI)
val uri = Uri.parse(
c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))
)
openApk(localContext, uri)
}
}
} catch (e : Exception) {
e.printStackTrace()
}
}
}, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
@ -220,45 +224,49 @@ class InAppUpdater {
val update = getAppUpdate()
if (update.shouldUpdate && update.updateURL != null) {
runOnUiThread {
val currentVersion = packageName?.let {
packageManager.getPackageInfo(
it,
0
)
}
try {
val currentVersion = packageName?.let {
packageManager.getPackageInfo(
it,
0
)
}
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setTitle("New update found!\n${currentVersion?.versionName} -> ${update.updateVersion}")
builder.setMessage("${update.changelog}")
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setTitle("New update found!\n${currentVersion?.versionName} -> ${update.updateVersion}")
builder.setMessage("${update.changelog}")
val context = this
builder.apply {
setPositiveButton("Update") { _, _ ->
showToast(context, "Download started", Toast.LENGTH_LONG)
thread {
val downloadStatus =
normalSafeApiCall { context.downloadUpdate(update.updateURL) } ?: false
if (!downloadStatus) {
runOnUiThread {
showToast(
context,
"Download Failed",
Toast.LENGTH_LONG
)
val context = this
builder.apply {
setPositiveButton("Update") { _, _ ->
showToast(context, "Download started", Toast.LENGTH_LONG)
thread {
val downloadStatus =
normalSafeApiCall { context.downloadUpdate(update.updateURL) } ?: false
if (!downloadStatus) {
runOnUiThread {
showToast(
context,
"Download Failed",
Toast.LENGTH_LONG
)
}
}
}
}
}
setNegativeButton("Cancel") { _, _ -> }
setNegativeButton("Cancel") { _, _ -> }
if (checkAutoUpdate) {
setNeutralButton("Don't show again") { _, _ ->
settingsManager.edit().putBoolean("auto_update", false).apply()
if (checkAutoUpdate) {
setNeutralButton("Don't show again") { _, _ ->
settingsManager.edit().putBoolean("auto_update", false).apply()
}
}
}
builder.show()
} catch (e: Exception) {
e.printStackTrace()
}
builder.show()
}
return true
}

View file

@ -124,6 +124,7 @@ object VideoDownloadManager {
val totalBytes: Long,
val relativePath: String,
val displayName: String,
val extraData : String? = null,
)
data class DownloadedFileInfoResult(