Skip to content

Выполнено ДЗ Views & Resources #38

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ plugins {
}

android {
compileSdk 32
compileSdk 34

defaultConfig {
applicationId "otus.gpb.homework.viewandresources"
minSdk 23
minSdk 26
targetSdk 32
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
package otus.gpb.homework.viewandresources

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import otus.gpb.homework.viewandresources.adapter.CartListAdapter
import otus.gpb.homework.viewandresources.model.CartItem

class CartActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_cart)
supportActionBar?.hide()

val cartItems = listOf(
CartItem(
R.drawable.cupcake,
R.string.on_the_top,
R.string.caption,
R.string.us1
),
CartItem(
R.drawable.forever_friends,
R.string.forever_friends,
R.string.caption,
R.string.us2
),
CartItem(
R.drawable.prototyping_kit,
R.string.prototyping_kit,
R.string.caption,
R.string.us3
),
CartItem(
R.drawable.basket_and_coffee,
R.string.basket_and_coffee,
R.string.caption,
R.string.us4
)
)

val recyclerView: RecyclerView = findViewById(R.id.recycler_view)
recyclerView.adapter = CartListAdapter(cartItems)
recyclerView.layoutManager = LinearLayoutManager(this)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ class ContactsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_contacts)
supportActionBar?.hide()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package otus.gpb.homework.viewandresources.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import otus.gpb.homework.viewandresources.R
import otus.gpb.homework.viewandresources.model.CartItem

class CartListAdapter(
private val listItems: List<CartItem>,
) : RecyclerView.Adapter<CartListAdapter.ViewHolder>() {

inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val imageView: ImageView = itemView.findViewById(R.id.mainImage)
val nameTextView: TextView = itemView.findViewById(R.id.mainText)
val descriptionTextView: TextView = itemView.findViewById(R.id.mainDescription)
val priceTextView: TextView = itemView.findViewById(R.id.mainPrice)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder =
ViewHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.cart_item, parent, false)
)

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = listItems[position]

holder.apply {
imageView.setImageResource(item.image)
nameTextView.setText(item.name)
descriptionTextView.setText(item.description)
priceTextView.setText(item.price)
}
}

override fun getItemCount() = listItems.size
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package otus.gpb.homework.viewandresources.model

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes

data class CartItem(
@DrawableRes val image: Int,
@StringRes val name: Int,
@StringRes val description: Int,
@StringRes val price: Int,
)
1 change: 1 addition & 0 deletions app/src/main/res/drawable/account.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/account.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/arrow_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/arrow_left.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z" /></vector>
Binary file added app/src/main/res/drawable/basket_and_coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/res/drawable/calendar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/calendar.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M19,19H5V8H19M16,1V3H8V1H6V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H18V1M17,12H12V17H17V12Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/close.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/close.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" /></vector>
Binary file added app/src/main/res/drawable/cupcake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/res/drawable/dots_vertical.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/dots_vertical.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" /></vector>
Binary file added app/src/main/res/drawable/forever_friends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/res/drawable/magnify.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/magnify.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/map_marker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/map_marker.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/menu_down.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/menu_down.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M7,10L12,15L17,10H7Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/pencil.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/pencil.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/phone.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/phone.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z" /></vector>
Binary file added app/src/main/res/drawable/prototyping_kit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/res/drawable/tag_heart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/tag_heart.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4A2,2 0 0,0 2,4V11C2,11.55 2.22,12.05 2.59,12.42L11.59,21.42C11.95,21.78 12.45,22 13,22C13.55,22 14.05,21.78 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.45 21.77,11.94 21.41,11.58M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M17.27,15.27L13,19.54L8.73,15.27C8.28,14.81 8,14.19 8,13.5A2.5,2.5 0 0,1 10.5,11C11.19,11 11.82,11.28 12.27,11.74L13,12.46L13.73,11.73C14.18,11.28 14.81,11 15.5,11A2.5,2.5 0 0,1 18,13.5C18,14.19 17.72,14.82 17.27,15.27Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/wallet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/wallet.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M21,18V19A2,2 0 0,1 19,21H5C3.89,21 3,20.1 3,19V5A2,2 0 0,1 5,3H19A2,2 0 0,1 21,5V6H12C10.89,6 10,6.9 10,8V16A2,2 0 0,0 12,18M12,16H22V8H12M16,13.5A1.5,1.5 0 0,1 14.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,12A1.5,1.5 0 0,1 16,13.5Z" /></vector>
Loading