Skip to content

Commit

Permalink
Merge branch 'master' into try-another-device
Browse files Browse the repository at this point in the history
  • Loading branch information
greenEkatherine committed Feb 10, 2021
2 parents c81d45d + 6da051b commit c2ca1da
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app/src/main/java/com/example/crosswordToLearn/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ class MainActivity : AppCompatActivity() {

private fun addItem(path: File) {
if(!path.exists()) {
Log.e("ERROR", "The path to the image doesn't exist: ${path.absolutePath}")
return
throw Exception("The path to the image doesn't exist: ${path.absolutePath}")
}
val name = path.name.removeSuffix(IMAGE_FORMAT)
val linearLayout = LinearLayout(this)
Expand All @@ -170,8 +169,7 @@ class MainActivity : AppCompatActivity() {
adjustViewBounds = true
setImageDrawable(Drawable.createFromPath(path.absolutePath))
if(drawable == null) {
Log.e("ERROR", "The bad image")
return
throw Exception("The bad image")
}
val layoutParams = LinearLayout.LayoutParams(imageSize, imageSize)
layoutParams.setMargins(MARGIN, 0, MARGIN, 0)
Expand Down Expand Up @@ -223,7 +221,11 @@ class MainActivity : AppCompatActivity() {
"exist: ${pathToCrosswordData.absolutePath}")
continue
}
addItem(file)
try {
addItem(file)
} catch (e:Exception){
Log.e("ERROR", e.message.toString())
}
}
}
}
Expand All @@ -242,7 +244,13 @@ class MainActivity : AppCompatActivity() {
Log.e("ERROR", "The path to the image doesn't exist: ${path.absolutePath}")
return
}
addItem(pathToImage(name))
try {
addItem(pathToImage(name))
}
catch (e:Exception){
Log.e("ERROR", e.message.toString())
return
}
val adapter = tableLayout.adapter as TableAdapter
val tableRow = adapter.dataset[adapter.dataset.lastIndex]
val linearLayout = tableRow[tableRow.lastIndex]
Expand Down

0 comments on commit c2ca1da

Please sign in to comment.