Skip to content

Commit

Permalink
fix: fixed crash caused by updater in SettingsAboutFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Mar 19, 2023
1 parent fb85b16 commit 6ca51d4
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@ package me.timschneeberger.rootlessjamesdsp.fragment.settings

import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.res.ResourcesCompat
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceGroup
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -71,15 +64,17 @@ class SettingsAboutFragment : SettingsBaseFragment() {
if(tls.size == 1)
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/profile/${tls[0].user}")))
else {
MaterialAlertDialogBuilder(requireContext())
.setItems(tls.map { it.name }.toTypedArray()) { dialogInterface, i ->
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/profile/${tls[i].user}")))
dialogInterface.dismiss()
}
.setTitle(title)
.setNegativeButton(getString(android.R.string.cancel)){ _, _ -> }
.create()
.show()
this@SettingsAboutFragment.context?.let { ctx ->
MaterialAlertDialogBuilder(ctx)
.setItems(tls.map { it.name }.toTypedArray()) { dialogInterface, i ->
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/profile/${tls[i].user}")))
dialogInterface.dismiss()
}
.setTitle(title)
.setNegativeButton(getString(android.R.string.cancel)){ _, _ -> }
.create()
.show()
}
}
true
}
Expand All @@ -101,7 +96,7 @@ class SettingsAboutFragment : SettingsBaseFragment() {
if (hasUpdate)
updateManager.installUpdate(requireActivity())
else
requireContext().toast(getString(R.string.self_update_no_updates))
context?.toast(getString(R.string.self_update_no_updates))
}
}
}
Expand Down

0 comments on commit 6ca51d4

Please sign in to comment.