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)
result_plot_header?.text =
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!!
if (syno.length > 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)
}
result_tag.removeAllViews()
result_tag_holder.visibility = GONE
result_tag?.removeAllViews()
result_tag_holder?.visibility = GONE
// result_status.visibility = GONE
val tags = d.tags
if (tags == null) {
result_tag_holder.visibility = GONE
if (tags.isNullOrEmpty()) {
result_tag_holder?.visibility = GONE
} else {
result_tag_holder.visibility = VISIBLE
result_tag_holder?.visibility = VISIBLE
for ((index, tag) in tags.withIndex()) {
val viewBtt = layoutInflater.inflate(R.layout.result_tag, null)
val btt = viewBtt.findViewById<MaterialButton>(R.id.result_tag_card)
btt.text = tag
result_tag.addView(viewBtt, index)
result_tag?.addView(viewBtt, index)
}
}
@ -971,12 +971,12 @@ class ResultFragment : Fragment() {
val hasDownloadSupport = api.hasDownloadSupport
lateFixDownloadButton(true)
result_play_movie.setOnClickListener {
result_play_movie?.setOnClickListener {
val card = currentEpisodes?.firstOrNull() ?: return@setOnClickListener
handleAction(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card))
}
result_play_movie.setOnLongClickListener {
result_play_movie?.setOnLongClickListener {
val card = currentEpisodes?.firstOrNull() ?: return@setOnLongClickListener true
handleAction(EpisodeClickEvent(ACTION_SHOW_OPTIONS, card))
return@setOnLongClickListener true
@ -988,7 +988,7 @@ class ResultFragment : Fragment() {
// 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) {
val localId = d.getId()
val file =

View file

@ -165,8 +165,14 @@ class InAppUpdater {
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(
object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
@ -234,7 +240,12 @@ class InAppUpdater {
}
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}")
val context = this

View file

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

View file

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

View file

@ -211,6 +211,7 @@
<string name="remote_error">Remote error</string>
<string name="render_error">Renderer 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_mirror">Chromecast Mirror</string>