crash fix

This commit is contained in:
LagradOst 2021-09-03 00:27:22 +02:00
parent 30de1783ea
commit 98e1848789
5 changed files with 28 additions and 14 deletions

View File

@ -932,7 +932,7 @@ class ResultFragment : Fragment() {
if (d.type == TvType.Torrent) getString(R.string.play_torrent_button) else getString(R.string.play_movie_button) if (d.type == TvType.Torrent) getString(R.string.play_torrent_button) else getString(R.string.play_movie_button)
result_plot_header?.text = result_plot_header?.text =
if (d.type == TvType.Torrent) getString(R.string.torrent_plot) else getString(R.string.result_plot) if (d.type == TvType.Torrent) getString(R.string.torrent_plot) else getString(R.string.result_plot)
if (d.plot != null) { if (!d.plot.isNullOrEmpty()) {
var syno = d.plot!! var syno = d.plot!!
if (syno.length > MAX_SYNO_LENGH) { if (syno.length > MAX_SYNO_LENGH) {
syno = syno.substring(0, MAX_SYNO_LENGH) + "..." syno = syno.substring(0, MAX_SYNO_LENGH) + "..."
@ -948,22 +948,22 @@ class ResultFragment : Fragment() {
if (d.type == TvType.Torrent) getString(R.string.torrent_no_plot) else getString(R.string.normal_no_plot) if (d.type == TvType.Torrent) getString(R.string.torrent_no_plot) else getString(R.string.normal_no_plot)
} }
result_tag.removeAllViews() result_tag?.removeAllViews()
result_tag_holder.visibility = GONE result_tag_holder?.visibility = GONE
// result_status.visibility = GONE // result_status.visibility = GONE
val tags = d.tags val tags = d.tags
if (tags == null) { if (tags.isNullOrEmpty()) {
result_tag_holder.visibility = GONE result_tag_holder?.visibility = GONE
} else { } else {
result_tag_holder.visibility = VISIBLE result_tag_holder?.visibility = VISIBLE
for ((index, tag) in tags.withIndex()) { for ((index, tag) in tags.withIndex()) {
val viewBtt = layoutInflater.inflate(R.layout.result_tag, null) val viewBtt = layoutInflater.inflate(R.layout.result_tag, null)
val btt = viewBtt.findViewById<MaterialButton>(R.id.result_tag_card) val btt = viewBtt.findViewById<MaterialButton>(R.id.result_tag_card)
btt.text = tag btt.text = tag
result_tag.addView(viewBtt, index) result_tag?.addView(viewBtt, index)
} }
} }
@ -971,12 +971,12 @@ class ResultFragment : Fragment() {
val hasDownloadSupport = api.hasDownloadSupport val hasDownloadSupport = api.hasDownloadSupport
lateFixDownloadButton(true) lateFixDownloadButton(true)
result_play_movie.setOnClickListener { result_play_movie?.setOnClickListener {
val card = currentEpisodes?.firstOrNull() ?: return@setOnClickListener val card = currentEpisodes?.firstOrNull() ?: return@setOnClickListener
handleAction(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card)) handleAction(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card))
} }
result_play_movie.setOnLongClickListener { result_play_movie?.setOnLongClickListener {
val card = currentEpisodes?.firstOrNull() ?: return@setOnLongClickListener true val card = currentEpisodes?.firstOrNull() ?: return@setOnLongClickListener true
handleAction(EpisodeClickEvent(ACTION_SHOW_OPTIONS, card)) handleAction(EpisodeClickEvent(ACTION_SHOW_OPTIONS, card))
return@setOnLongClickListener true return@setOnLongClickListener true
@ -988,7 +988,7 @@ class ResultFragment : Fragment() {
// handleAction(EpisodeClickEvent(ACTION_SHOW_OPTIONS, card)) // handleAction(EpisodeClickEvent(ACTION_SHOW_OPTIONS, card))
// } // }
result_download_movie.visibility = if (hasDownloadSupport) VISIBLE else GONE result_download_movie?.visibility = if (hasDownloadSupport) VISIBLE else GONE
if (hasDownloadSupport) { if (hasDownloadSupport) {
val localId = d.getId() val localId = d.getId()
val file = val file =

View File

@ -165,8 +165,14 @@ class InAppUpdater {
val localContext = this val localContext = this
val id = downloadManager.enqueue(request) val id = try {
downloadManager.enqueue(request)
} catch (e: Exception) {
logError(e)
showToast(this, R.string.storage_error, Toast.LENGTH_SHORT)
-1
}
if (id == -1L) return true
registerReceiver( registerReceiver(
object : BroadcastReceiver() { object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) { override fun onReceive(context: Context?, intent: Intent?) {
@ -191,7 +197,7 @@ class InAppUpdater {
openApk(localContext, uri) openApk(localContext, uri)
} }
} }
} catch (e : Exception) { } catch (e: Exception) {
logError(e) logError(e)
} }
} }
@ -234,7 +240,12 @@ class InAppUpdater {
} }
val builder: AlertDialog.Builder = AlertDialog.Builder(this) val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setTitle(getString(R.string.new_update_format).format(currentVersion?.versionName,update.updateVersion)) builder.setTitle(
getString(R.string.new_update_format).format(
currentVersion?.versionName,
update.updateVersion
)
)
builder.setMessage("${update.changelog}") builder.setMessage("${update.changelog}")
val context = this val context = this

View File

@ -174,4 +174,5 @@
<string name="pause">ooh aaaaa</string> <string name="pause">ooh aaaaa</string>
<string name="resume">oouuh haa</string> <string name="resume">oouuh haa</string>
<string name="double_tap_to_seek_setthings_des">oohahaha hahha ooooohaha</string> <string name="double_tap_to_seek_setthings_des">oohahaha hahha ooooohaha</string>
<string name="storage_error">oohahaha hahha ooooohaha haaoou</string>
</resources> </resources>

View File

@ -202,4 +202,5 @@
<string name="pause">Pausa</string> <string name="pause">Pausa</string>
<string name="resume">Återuppta</string> <string name="resume">Återuppta</string>
<string name="storage_error">Ett nerladdningsfel uppstod, kolla om appen har lagringsbehörigheter</string>
</resources> </resources>

View File

@ -211,6 +211,7 @@
<string name="remote_error">Remote error</string> <string name="remote_error">Remote error</string>
<string name="render_error">Renderer error</string> <string name="render_error">Renderer error</string>
<string name="unexpected_error">Unexpected player error</string> <string name="unexpected_error">Unexpected player error</string>
<string name="storage_error">Download error, check storage permissions</string>
<string name="episode_action_chomecast_episode">Chromecast Episode</string> <string name="episode_action_chomecast_episode">Chromecast Episode</string>
<string name="episode_action_chomecast_mirror">Chromecast Mirror</string> <string name="episode_action_chomecast_mirror">Chromecast Mirror</string>