Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.fancywork.fancyLib

import android.graphics.Bitmap

class FancyPicture(pair: Pair<Bitmap, Array<Array<String?>>>, title: String, id: String) {

// todo id generator

var image: Bitmap = pair.first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data class FancyPicture(
    val id: String,
    val title: String,
    val image: Bitmap,
    val colors: List<List<String>>
)

Этот класс хранит данные, попробуй сделать дата классом, Array заменить на List. String? заменить на String, Избегайте nullable по возможности.

init {
    width = colors.size
    length = colors[0].size
}

А если массив пустой? тут init отвалится с outofboundexeption. лучше вычислять length rows/columns там где это необходимо, сделав проверку на наличие чего-либо в этом списке.

var colors: Array<Array<String?>> = pair.second

var title: String = title
var id: String = id

var width: Int
var length: Int

init {
width = colors.size
length = colors[0].size
}
}