ViewCollection: fix crash when clicking options while still loading.

pull/146/head
Tom Hacohen 4 years ago
parent eb09c3a0e0
commit 8a9161301e

@ -4,6 +4,7 @@ import android.content.DialogInterface
import android.os.Bundle
import android.view.*
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
@ -108,7 +109,11 @@ class ViewCollectionFragment : Fragment() {
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val cachedCollection = collectionModel.value!!
val cachedCollection = collectionModel.value
if (cachedCollection == null) {
Toast.makeText(context, R.string.loading_error_title, Toast.LENGTH_LONG).show()
return super.onOptionsItemSelected(item)
}
when (item.itemId) {
R.id.on_edit -> {

Loading…
Cancel
Save