This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Все обернул здесь в класс ItunesMusic | |
class ItunesMusic { | |
//private val TAG: String = "DEBUG" | |
private val baseUrl = "https://itunes.apple.com" | |
var trackLst: ArrayList<ItunesTrack>? = null | |
// retrofit initialisation will come with class member initialisation | |
private val retrofit = Retrofit.Builder() | |
.baseUrl(baseUrl) | |
.addConverterFactory(GsonConverterFactory.create()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.android10 | |
import android.view.LayoutInflater | |
import android.view.ViewGroup | |
import android.widget.TextView | |
import androidx.recyclerview.widget.RecyclerView | |
import androidx.recyclerview.widget.RecyclerView.Adapter | |
import androidx.recyclerview.widget.RecyclerView.ViewHolder | |
class TextViewHolder : RecyclerView.ViewHolder { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun bind(weather: Weather) { | |
this.txtTemperature?.text = weather.temperature.toString() | |
this.txtDay?.text = weather.date | |
if (weather.date != "oleg") { | |
cardWeather?.setCardBackgroundColor(item.resources.getColor(R.color.purple_200)) | |
cardImg?.setImageResource(R.drawable.ic_human) | |
} else { | |
// не дает просто написать цвет через R - ошибка | |
// Should pass resolved color instead of resource id here: | |
// getResources().getColor(R.color.salmon) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.playlistmaker | |
import android.app.Activity | |
import android.os.Bundle | |
import android.text.Editable | |
import android.text.TextWatcher | |
import android.util.Log | |
import android.view.View | |
import android.view.inputmethod.InputMethodManager | |
import android.widget.EditText |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/purple_700" | |
android:orientation="vertical" | |
android:paddingStart="17dp" | |
android:paddingTop="14dp" | |
android:paddingEnd="15dp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.kotlinv3.Logic | |
import android.content.Context | |
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.graphics.Paint | |
import android.util.AttributeSet | |
import android.util.Log | |
import android.view.SurfaceHolder | |
import android.view.SurfaceView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Lotto {// определите поле, в котром будут храниться добавленные игроки Person | |
val persons: MutableSet<Person> = mutableSetOf() | |
// поле thrownNumbers должно хранить в себе набор выброшенных чисел. | |
val thrownNumbers: MutableSet<Int> = mutableSetOf() // определите подходящую структуру данных | |
fun addPerson(person: Person) { | |
this.persons.add(person) | |
} | |
fun start() { | |
var winGame: Boolean = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class NetworkError(var message: String) { | |
class ServerError(requestId: String, message: String) : NetworkError("Ошибка взаимодействия с сервером для запроса: id = $requestId. Сообщение об ошибке: $message") | |
class NoData(var requestId: String, message: String) : NetworkError("Для запроса: id = $requestId нет данных") | |
class NoInternet(var requestId: String) : NetworkError("Нет подключения к интернету.") | |
} | |
class ErrorHandler { | |
fun handleError(error: NetworkError) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class Week(val localizedName:String) { | |
MONDAY("Понедельник"), | |
TUESDAY("Вторник"), | |
WEDNESDAY("Среда"), | |
THURSDAY("Четврег"), | |
FRIDAY("Пятница"), | |
SATURDAY("Суббота"), | |
SUNDAY("Воскресенье"); | |
fun isWeekend(): String{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object PiggyBank { | |
val pig:ArrayList<Money> = ArrayList() // список монеток/купюр | |
var isSmashed:Boolean = false // свойство, определяющее, разбита ли копилка | |
fun putMoney(money: Money) { | |
if(!isSmashed) { | |
pig.add(money) | |
println("Добавлено в копилку $money") | |
} |