Skip to content
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: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ android {
kotlinOptions {
jvmTarget = '17'
}

buildFeatures{
viewBinding = true
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@ package otus.gpb.homework.viewandresources

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager

class CartActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_cart)

val rv = findViewById<RecyclerView>(R.id.recyclerView)
rv.addItemDecoration(
DividerItemDecoration(this, DividerItemDecoration.VERTICAL)
)
rv.layoutManager = LinearLayoutManager(this)

val itemsList = listOf(
CartItem("Baguette", "Food", R.drawable.baguette, "$0.50"),
CartItem("Wine", "Food", R.drawable.bottle_wine, "$7.30"),
CartItem("Cheese", "Food", R.drawable.cheese, "$10.00"),
CartItem("Metallica CD", "Music", R.drawable.album, "$15.00")
)

rv.adapter = RcViewItem(itemsList)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package otus.gpb.homework.viewandresources

data class CartItem(val title: String, val description: String, val image: Int, val price: String)
34 changes: 34 additions & 0 deletions app/src/main/java/otus/gpb/homework/viewandresources/RcViewItem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package otus.gpb.homework.viewandresources

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

class RcViewItem(private val itemsList: List<CartItem>) : RecyclerView.Adapter<RcViewItem.RecyclerItemHolder>() {

class RecyclerItemHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val imageView: ImageView = itemView.findViewById(R.id.imageView)
val textViewTitle: TextView = itemView.findViewById(R.id.title)
val textView: TextView = itemView.findViewById(R.id.description)
val priceView: TextView = itemView.findViewById(R.id.price)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerItemHolder {
val itemView = LayoutInflater.from(parent.context)
.inflate(R.layout.item_cart, parent, false)
return RecyclerItemHolder(itemView)
}

override fun onBindViewHolder(holder: RecyclerItemHolder, position: Int) {
val currentItem = itemsList[position]
holder.imageView.setImageResource(currentItem.image)
holder.textViewTitle.text = currentItem.title
holder.textView.text = currentItem.description
holder.priceView.text = currentItem.price
}

override fun getItemCount() = itemsList.size
}
2 changes: 2 additions & 0 deletions app/src/main/res/drawable/account.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<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="@color/icon_color" android:pathData="M14 20H4V17C4 14.3 9.3 13 12 13C13.5 13 15.9 13.4 17.7 14.3C16.9 14.6 16.3 15 15.7 15.5C14.6 15.1 13.3 14.9 12 14.9C9 14.9 5.9 16.4 5.9 17V18.1H14.2C14.1 18.5 14 19 14 19.5V20M23 19.5C23 21.4 21.4 23 19.5 23S16 21.4 16 19.5 17.6 16 19.5 16 23 17.6 23 19.5M12 6C13.1 6 14 6.9 14 8S13.1 10 12 10 10 9.1 10 8 10.9 6 12 6M12 4C9.8 4 8 5.8 8 8S9.8 12 12 12 16 10.2 16 8 14.2 4 12 4Z" /></vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/address.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<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="@color/icon_color" android:pathData="M17,18L12,15.82L7,18V5H17M17,3H7A2,2 0 0,0 5,5V21L12,18L19,21V5C19,3.89 18.1,3 17,3Z" />
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/album.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="56dp" android:width="56dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="@color/icon_color" android:pathData="M12,11A1,1 0 0,0 11,12A1,1 0 0,0 12,13A1,1 0 0,0 13,12A1,1 0 0,0 12,11M12,16.5C9.5,16.5 7.5,14.5 7.5,12C7.5,9.5 9.5,7.5 12,7.5C14.5,7.5 16.5,9.5 16.5,12C16.5,14.5 14.5,16.5 12,16.5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /></vector>
2 changes: 2 additions & 0 deletions app/src/main/res/drawable/arrow_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<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="@color/icon_color" android:pathData="M19,13H6.75L12,18.25L11.34,19L4.84,12.5L11.34,6L12,6.75L6.75,12H19V13Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/baguette.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="56dp" android:width="56dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="@color/icon_color" android:pathData="M5 22C3.68 22 3.15 19.64 3.04 18.7A5.56 5.56 0 0 1 3.36 16A2.5 2.5 0 0 1 5.23 14.38C6.4 14.18 7.23 14.88 8.29 15.12A1.21 1.21 0 0 0 9.85 13.75C9.41 12.03 6.28 12 5 12C5 10.14 7.04 9.9 8.5 10.04A10.8 10.8 0 0 1 11.04 10.6C11.54 10.77 12.12 11.2 12.67 11.16C13.5 11.09 13.67 10.23 13.31 9.6C12.44 8.12 9.97 8 8.5 8C8.5 6 10.23 5.62 11.89 5.92A11.58 11.58 0 0 1 14.38 6.71C14.89 6.93 15.5 7.35 16.06 7.16C17.5 6.72 16 5.18 15.36 4.81A6.6 6.6 0 0 0 13.94 4.23C13.4 4.07 12.74 4.13 13.23 3.5A5.13 5.13 0 0 1 15.96 2.26C17.85 1.82 20.46 1.74 20.92 4.12A5.3 5.3 0 0 1 20.07 7.7A38.96 38.96 0 0 1 13.22 16.33A36.6 36.6 0 0 1 8.62 20.32C7.62 21.04 6.3 22 5 22Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/bottle_wine.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="56dp" android:width="56dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="@color/icon_color" android:pathData="M11.5 2C11.22 2 11 2.22 11 2.5V7C10.93 7 10.85 7 10.78 7.03C9.82 7.27 9.21 8 8.76 8.89C8.3 9.76 8 10.84 8 12C8.05 15 8 18.03 8 21C8 21.55 8.45 22 9 22C11 22 13 22 15 22C15.55 22 16 21.55 16 21C16.04 18 16 15 16 12C16 10.84 15.74 9.76 15.28 8.88C14.83 8 14.22 7.27 13.26 7.04C13.18 7 13.05 7 13 7V2.5C13 2.22 12.78 2 12.5 2M12 8.85C12.32 8.85 12.63 8.9 12.78 9C12.85 9.03 13.2 9.26 13.5 9.81C13.78 10.37 14 11.17 14 12V20H10V12C10 11.17 10.22 10.37 10.5 9.81C10.8 9.26 11.15 9.03 11.22 9C11.36 8.9 11.68 8.85 12 8.85Z" /></vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/calendar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<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="@color/icon_color" android:pathData="M7,10H12V15H7M19,19H5V8H19M19,3H18V1H16V3H8V1H6V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3Z" />
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/cheese.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="56dp" android:width="56dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="@color/icon_color" android:pathData="M11 17.5C11 16.67 11.67 16 12.5 16C12.79 16 13.06 16.09 13.29 16.23L20.75 11.93C20.35 11.22 19.9 10.55 19.41 9.9C19.29 9.96 19.15 10 19 10C18.45 10 18 9.55 18 9C18 8.8 18.08 8.62 18.18 8.46C16.45 6.64 14.34 5.2 12 4.25C11.85 5.24 11 6 10 6C8.9 6 8 5.11 8 4C8 3.72 8.06 3.45 8.16 3.21C7.3 3.08 6.41 3 5.5 3C5.33 3 5.17 3 5 3.03V9.05C6.14 9.28 7 10.29 7 11.5S6.14 13.72 5 13.95V21L11 17.54C11 17.53 11 17.5 11 17.5M14 9C15.11 9 16 9.9 16 11S15.11 13 14 13 12 12.11 12 11 12.9 9 14 9M9 16C8.45 16 8 15.55 8 15S8.45 14 9 14 10 14.45 10 15 9.55 16 9 16M9 10C8.45 10 8 9.55 8 9S8.45 8 9 8 10 8.45 10 9 9.55 10 9 10Z" /></vector>
2 changes: 2 additions & 0 deletions app/src/main/res/drawable/close_circle_outline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<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="@color/icon_color" android:pathData="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2C6.47,2 2,6.47 2,12C2,17.53 6.47,22 12,22C17.53,22 22,17.53 22,12C22,6.47 17.53,2 12,2M14.59,8L12,10.59L9.41,8L8,9.41L10.59,12L8,14.59L9.41,16L12,13.41L14.59,16L16,14.59L13.41,12L16,9.41L14.59,8Z" /></vector>
3 changes: 3 additions & 0 deletions app/src/main/res/drawable/dots_vertical.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<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="@color/icon_color" 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>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/phone_check.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="@color/icon_color" android:pathData="M14.54,23H7C5.9,23 5,22.11 5,21V3C5,1.89 5.89,1 7,1H17C18.1,1 19,1.89 19,3V13C18.3,13 17.63,13.13 17,13.35V5H7V19H13C13,20.54 13.58,21.94 14.54,23M17.75,22.16L15,19.16L16.16,18L17.75,19.59L21.34,16L22.5,17.41L17.75,22.16"/>
</vector>
3 changes: 3 additions & 0 deletions app/src/main/res/drawable/sale.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="@color/icon_color" android:pathData="M16.5,6V17.5A4,4 0,0 1,12.5 21.5A4,4 0,0 1,8.5 17.5V5A2.5,2.5 0,0 1,11 2.5A2.5,2.5 0,0 1,13.5 5V15.5A1,1 0,0 1,12.5 16.5A1,1 0,0 1,11.5 15.5V6H10V15.5A2.5,2.5 0,0 0,12.5 18A2.5,2.5 0,0 0,15 15.5V5A4,4 0,0 0,11 1A4,4 0,0 0,7 5V17.5A5.5,5.5 0,0 0,12.5 23A5.5,5.5 0,0 0,18 17.5V6H16.5Z"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/smile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<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="@color/button_order_text" android:pathData="M12,17.5C14.33,17.5 16.3,16.04 17.11,14H6.89C7.69,16.04 9.67,17.5 12,17.5M8.5,11A1.5,1.5 0 0,0 10,9.5A1.5,1.5 0 0,0 8.5,8A1.5,1.5 0 0,0 7,9.5A1.5,1.5 0 0,0 8.5,11M15.5,11A1.5,1.5 0 0,0 17,9.5A1.5,1.5 0 0,0 15.5,8A1.5,1.5 0 0,0 14,9.5A1.5,1.5 0 0,0 15.5,11M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /></vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/sun.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="@color/icon_color" android:pathData="M3.55,19.09L4.96,20.5L6.76,18.71L5.34,17.29M12,6C8.69,6 6,8.69 6,12S8.69,18 12,18 18,15.31 18,12C18,8.68 15.31,6 12,6M20,13H23V11H20M17.24,18.71L19.04,20.5L20.45,19.09L18.66,17.29M20.45,5L19.04,3.6L17.24,5.39L18.66,6.81M13,1H11V4H13M6.76,5.39L4.96,3.6L3.55,5L5.34,6.81L6.76,5.39M1,13H4V11H1M13,20H11V23H13" />
</vector>
160 changes: 160 additions & 0 deletions app/src/main/res/layout/activity_cart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,166 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/toolbar_cart_bk"
tools:context=".CartActivity">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/toolbar_cart_bk"
android:minHeight="56dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/toolbar_cart"
app:navigationIcon="@drawable/arrow_left"
app:title="Cart"
app:titleTextColor="@color/input_color" />

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/item_count"
android:textColor="@color/input_color"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@color/toolbar_cart_bk"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:itemCount="4"
tools:listitem="@layout/item_cart" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/coast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recyclerView">

<TextView
android:id="@+id/textTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/total"
android:textColor="@color/input_color"
android:textSize="22sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textSubtotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:text="@string/subtotal"
android:textColor="@color/input_color"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textTotal" />

<TextView
android:id="@+id/textShipping"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/shipping"
android:textColor="@color/input_color"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textSubtotal" />

<TextView
android:id="@+id/textTax"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/tax"
android:textColor="@color/input_color"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textShipping" />

<TextView
android:id="@+id/textTotalPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/totalprice"
android:textColor="@color/price_text_color"
android:textSize="22sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textSubtotalPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:gravity="end"
android:text="@string/subtotalprice"
android:textColor="@color/price_text_color"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textTotalPrice" />

<TextView
android:id="@+id/textShippingPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:gravity="end"
android:text="@string/shippingprice"
android:textColor="@color/price_text_color"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textSubtotalPrice" />

<TextView
android:id="@+id/textTaxPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:gravity="end"
android:text="@string/taxprice"
android:textColor="@color/price_text_color"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textShippingPrice" />

<Button
style="@style/ButtonOrder"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:drawableLeft="@drawable/smile"
android:text="@string/placeorder"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textTax" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading