From a0c512c9007b75fac1478ccf0174ff5d386f2e66 Mon Sep 17 00:00:00 2001 From: s1ngle0f Date: Sun, 4 Aug 2024 19:58:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A8=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B7=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 11 ++++++-- app/src/main/java/ru/myitschool/work/Book.kt | 3 +++ .../java/ru/myitschool/work/BookAdapter.kt | 26 +++++++++++++++++++ .../java/ru/myitschool/work/MainActivity.kt | 19 ++++++++++++++ app/src/main/res/layout/activity_main.xml | 14 ++++++++++ app/src/main/res/layout/item_book.xml | 22 ++++++++++++++++ 6 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/ru/myitschool/work/Book.kt create mode 100644 app/src/main/java/ru/myitschool/work/BookAdapter.kt create mode 100644 app/src/main/java/ru/myitschool/work/MainActivity.kt create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/item_book.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9ee5c40..4162890 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,14 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.Default" - tools:targetApi="31" /> + android:theme="@style/Theme.Design.Light.NoActionBar" + tools:targetApi="31"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/ru/myitschool/work/Book.kt b/app/src/main/java/ru/myitschool/work/Book.kt new file mode 100644 index 0000000..7ee9310 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/Book.kt @@ -0,0 +1,3 @@ +package ru.myitschool.work + +data class Book(val title: String, val author: String) diff --git a/app/src/main/java/ru/myitschool/work/BookAdapter.kt b/app/src/main/java/ru/myitschool/work/BookAdapter.kt new file mode 100644 index 0000000..815cf4b --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/BookAdapter.kt @@ -0,0 +1,26 @@ +package ru.myitschool.work + +import android.view.Gravity +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import ru.myitschool.work.databinding.ItemBookBinding + +class BookAdapter(private val bookList: List) : RecyclerView.Adapter() { + + //TODO: Реализовать класс BookViewHolder, используя binding + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookViewHolder { + val inflater = LayoutInflater.from(parent.context) + val binding = ItemBookBinding.inflate(inflater, parent, false) + return BookViewHolder(binding) + } + + override fun onBindViewHolder(holder: BookViewHolder, position: Int) { + //TODO: Заполнить элемент списка данными дата класса. Нечетные блоки информации должны быть прижаты вправо + } + + override fun getItemCount() = bookList.size +} diff --git a/app/src/main/java/ru/myitschool/work/MainActivity.kt b/app/src/main/java/ru/myitschool/work/MainActivity.kt new file mode 100644 index 0000000..744796d --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/MainActivity.kt @@ -0,0 +1,19 @@ +package ru.myitschool.work + +import android.os.Bundle +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(R.layout.activity_main) + + //TODO: Создать и заполнить RecyclerView + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..61a3f47 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/app/src/main/res/layout/item_book.xml b/app/src/main/res/layout/item_book.xml new file mode 100644 index 0000000..faef0fd --- /dev/null +++ b/app/src/main/res/layout/item_book.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file