File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
sample/src/main/java/dev/arkbuilders/sample Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 11package dev.arkbuilders.sample
22
33import android.os.Bundle
4+ import android.widget.Toast
45import androidx.appcompat.app.AppCompatActivity
56import androidx.compose.foundation.layout.padding
67import androidx.compose.ui.Modifier
@@ -49,7 +50,6 @@ class ScoreActivity : AppCompatActivity() {
4950 this ,
5051 customRequestKey = PICK_RESOURCE_KEY
5152 ) { resourcePath ->
52- btnPickResource.text = resourcePath.name
5353 rootFolder?.let {
5454 onResourcePicked(root = it, resourcePath)
5555 }
@@ -78,7 +78,19 @@ class ScoreActivity : AppCompatActivity() {
7878 ) = lifecycleScope.launch {
7979 val (index, scoreStorage) = setupIndexAndScoreStorage(root)
8080 val id = index.allPaths().toList()
81- .find { it.second == resourcePath }!! .first
81+ .find { it.second == resourcePath }?.first
82+
83+ id ? : let {
84+ Toast .makeText(
85+ this @ScoreActivity,
86+ " File does not belong to root" ,
87+ Toast .LENGTH_SHORT
88+ ).show()
89+ return @launch
90+ }
91+
92+ findViewById<MaterialButton >(R .id.btn_pick_resource).text = resourcePath.name
93+
8294 val scoreWidgetController = ScoreWidgetController (
8395 lifecycleScope,
8496 getCurrentId = { id },
You can’t perform that action at this time.
0 commit comments