Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FancyPicture class #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
}
}