Fixed some crashes
- Import playlist crash - Create new backup crash
This commit is contained in:
parent
ac902d0bf0
commit
5e08b889c1
3 changed files with 11 additions and 5 deletions
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
import java.lang.Exception
|
||||||
|
|
||||||
class ImportPlaylistDialog : DialogFragment() {
|
class ImportPlaylistDialog : DialogFragment() {
|
||||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||||
|
@ -30,7 +31,11 @@ class ImportPlaylistDialog : DialogFragment() {
|
||||||
return materialDialog(R.string.import_playlist)
|
return materialDialog(R.string.import_playlist)
|
||||||
.setMessage(R.string.import_playlist_message)
|
.setMessage(R.string.import_playlist_message)
|
||||||
.setPositiveButton(R.string.import_label) { _, _ ->
|
.setPositiveButton(R.string.import_label) { _, _ ->
|
||||||
|
try {
|
||||||
libraryViewModel.importPlaylists()
|
libraryViewModel.importPlaylists()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.database.Cursor
|
||||||
|
|
||||||
internal fun Cursor.getInt(columnName: String): Int {
|
internal fun Cursor.getInt(columnName: String): Int {
|
||||||
try {
|
try {
|
||||||
return this.getInt(this.getColumnIndex(columnName))
|
return getInt(getColumnIndexOrThrow(columnName))
|
||||||
} catch (ex: Throwable) {
|
} catch (ex: Throwable) {
|
||||||
throw IllegalStateException("invalid column $columnName", ex)
|
throw IllegalStateException("invalid column $columnName", ex)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ internal fun Cursor.getInt(columnName: String): Int {
|
||||||
|
|
||||||
internal fun Cursor.getLong(columnName: String): Long {
|
internal fun Cursor.getLong(columnName: String): Long {
|
||||||
try {
|
try {
|
||||||
return this.getLong(this.getColumnIndex(columnName))
|
return getLong(getColumnIndexOrThrow(columnName))
|
||||||
} catch (ex: Throwable) {
|
} catch (ex: Throwable) {
|
||||||
throw IllegalStateException("invalid column $columnName", ex)
|
throw IllegalStateException("invalid column $columnName", ex)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ internal fun Cursor.getLong(columnName: String): Long {
|
||||||
|
|
||||||
internal fun Cursor.getString(columnName: String): String {
|
internal fun Cursor.getString(columnName: String): String {
|
||||||
try {
|
try {
|
||||||
return this.getString(this.getColumnIndex(columnName))
|
return getString(getColumnIndexOrThrow(columnName))
|
||||||
} catch (ex: Throwable) {
|
} catch (ex: Throwable) {
|
||||||
throw IllegalStateException("invalid column $columnName", ex)
|
throw IllegalStateException("invalid column $columnName", ex)
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ internal fun Cursor.getString(columnName: String): String {
|
||||||
|
|
||||||
internal fun Cursor.getStringOrNull(columnName: String): String? {
|
internal fun Cursor.getStringOrNull(columnName: String): String? {
|
||||||
try {
|
try {
|
||||||
return this.getString(this.getColumnIndex(columnName))
|
return getString(getColumnIndexOrThrow(columnName))
|
||||||
} catch (ex: Throwable) {
|
} catch (ex: Throwable) {
|
||||||
throw IllegalStateException("invalid column $columnName", ex)
|
throw IllegalStateException("invalid column $columnName", ex)
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,5 +99,6 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
_binding = null
|
_binding = null
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(requireActivity().window.decorView, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue