Шаблон практики

This commit is contained in:
s1ngle0f 2024-08-04 16:10:29 +03:00
parent 3e6fe310e0
commit bf7de64522
8 changed files with 99 additions and 3 deletions

View File

@ -1,4 +1,5 @@
plugins {
id("org.jetbrains.kotlin.android")
androidApplication
}
@ -17,7 +18,7 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures.viewBinding = true
compileOptions {
@ -27,5 +28,9 @@ android {
}
dependencies {
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.activity:activity:1.9.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
defaultLibrary()
}

View File

@ -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">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,3 @@
package ru.myitschool.work
data class Book(val title: String, val author: String)

View File

@ -0,0 +1,26 @@
package ru.myitschool.work
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
class BookAdapter(private val bookList: List<Book>) : RecyclerView.Adapter<BookAdapter.BookViewHolder>() {
class BookViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val titleTextView: TextView = itemView.findViewById(R.id.bookTitle)
val authorTextView: TextView = itemView.findViewById(R.id.bookAuthor)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookViewHolder {
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.item_book, parent, false)
return BookViewHolder(itemView)
}
override fun onBindViewHolder(holder: BookViewHolder, position: Int) {
//TODO: Заполнить
}
override fun getItemCount() = bookList.size
}

View File

@ -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: Заполнить
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" />
</RelativeLayout>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="@+id/bookTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/bookAuthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
</LinearLayout>

View File

@ -2,4 +2,5 @@
plugins {
androidApplication version Version.gradle apply false
kotlinJvm version Version.Kotlin.language apply false
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
}