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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
namespace = "otus.gpb.homework.viewandresources"
defaultConfig {
applicationId "otus.gpb.homework.viewandresources"
minSdk 23
minSdk 26
targetSdk 35
versionCode 1
versionName "1.0"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package otus.gpb.homework.viewandresources


import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView


class AdapterCart : RecyclerView.Adapter<ViewHolder>() {
private var list = listOf<Item>()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {

val view = LayoutInflater.from(parent.context)
.inflate(R.layout.text_row_item, parent, false)



return ViewHolder(view)
}


override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = list.getOrNull(position)
item?.let {
holder.bind(item)

}

}

override fun getItemCount(): Int = list.size
fun setData(newList: List<Item>) {
list = newList

}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
package otus.gpb.homework.viewandresources

import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class CartActivity : AppCompatActivity() {
private val adapter: AdapterCart by lazy { AdapterCart() }

@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_cart)

val recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
recyclerView.adapter = adapter
adapter.setData(generate())
findViewById<TextView>(R.id.filledTextCounter).text =
buildString {
append(adapter.itemCount.toString())
append(" items in your cart")
}
findViewById<View>(R.id.close).setOnClickListener { finish() }


}

fun generate() = run {
val list = mutableListOf<Item>()
repeat(
4
) {
val item = Item(

title = "Name ${it.inc()}",
price = 35,
category = "Category",
description = "Supporting line text lorem ipsum dolor sit amet, consectetur.",
photo = R.drawable.ic_launcher_background
)
list.add(item)

}
list.toList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ class ContactsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_contacts)


}
}
10 changes: 10 additions & 0 deletions app/src/main/java/otus/gpb/homework/viewandresources/Item.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package otus.gpb.homework.viewandresources


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

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class ViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
private val title: TextView by lazy { view.findViewById(R.id.textViewTitle) }
private val category: TextView by lazy { view.findViewById(R.id.textViewCategory) }
private val description: TextView by lazy { view.findViewById(R.id.textViewDescription) }
private val price: TextView by lazy { view.findViewById(R.id.textViewPrice) }
private val photo: ImageView by lazy { view.findViewById(R.id.photo) }
fun bind(item: Item) {
title.text = item.title
price.text = buildString {
append("$")
append(item.price.toString())
}
category.text = item.category
description.text = item.description
photo.setImageResource(item.photo)
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_arrow_back_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>

</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/clip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorOnSurfaceVariant"
>
<path
android:pathData="M720,630q0,104 -73,177T470,880q-104,0 -177,-73t-73,-177v-370q0,-75 52.5,-127.5T400,80q75,0 127.5,52.5T580,260v350q0,46 -32,78t-78,32q-46,0 -78,-32t-32,-78v-370h80v370q0,13 8.5,21.5T470,640q13,0 21.5,-8.5T500,610v-350q-1,-42 -29.5,-71T400,160q-42,0 -71,29t-29,71v370q-1,71 49,120.5T470,800q70,0 119,-49.5T640,630v-390h80v390Z"
android:fillColor="#000"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_bookmark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M200,840v-640q0,-33 23.5,-56.5T280,120h400q33,0 56.5,23.5T760,200v640L480,720 200,840ZM280,718 L480,632 680,718v-518L280,200v518ZM280,200h400,-400Z"
android:fillColor="#000"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_cancel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorOnSurfaceVariant">
<path
android:pathData="m336,680 l144,-144 144,144 56,-56 -144,-144 144,-144 -56,-56 -144,144 -144,-144 -56,56 144,144 -144,144 56,56ZM480,880q-83,0 -156,-31.5T197,763q-54,-54 -85.5,-127T80,480q0,-83 31.5,-156T197,197q54,-54 127,-85.5T480,80q83,0 156,31.5T763,197q54,54 85.5,127T880,480q0,83 -31.5,156T763,763q-54,54 -127,85.5T480,880ZM480,800q134,0 227,-93t93,-227q0,-134 -93,-227t-227,-93q-134,0 -227,93t-93,227q0,134 93,227t227,93ZM480,480Z"
android:fillColor="#000"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_mic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M480,560q-50,0 -85,-35t-35,-85v-240q0,-50 35,-85t85,-35q50,0 85,35t35,85v240q0,50 -35,85t-85,35ZM480,320ZM440,840v-123q-104,-14 -172,-93t-68,-184h80q0,83 58.5,141.5T480,640q83,0 141.5,-58.5T680,440h80q0,105 -68,184t-172,93v123h-80ZM480,480q17,0 28.5,-11.5T520,440v-240q0,-17 -11.5,-28.5T480,160q-17,0 -28.5,11.5T440,200v240q0,17 11.5,28.5T480,480Z"
android:fillColor="#000"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_mobile_friendly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M240,920q-33,0 -56.5,-23.5T160,840v-720q0,-33 23.5,-56.5T240,40h400q33,0 56.5,23.5T720,120v160h-80v-40L240,240v480h400v-40h80v160q0,33 -23.5,56.5T640,920L240,920ZM240,800v40h400v-40L240,800ZM598,640L428,470l56,-56 114,114 226,-226 56,56 -282,282ZM240,160h400v-40L240,120v40ZM240,160v-40,40ZM240,800v40,-40Z"
android:fillColor="#000"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_no_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>

</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_person.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M480,480q-66,0 -113,-47t-47,-113q0,-66 47,-113t113,-47q66,0 113,47t47,113q0,66 -47,113t-113,47ZM160,800v-112q0,-34 17.5,-62.5T224,582q62,-31 126,-46.5T480,520q66,0 130,15.5T736,582q29,15 46.5,43.5T800,688v112L160,800ZM240,720h480v-32q0,-11 -5.5,-20T700,654q-54,-27 -109,-40.5T480,600q-56,0 -111,13.5T260,654q-9,5 -14.5,14t-5.5,20v32ZM480,400q33,0 56.5,-23.5T560,320q0,-33 -23.5,-56.5T480,240q-33,0 -56.5,23.5T400,320q0,33 23.5,56.5T480,400ZM480,320ZM480,720Z"
android:fillColor="#000"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_smile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M15.5,9.5m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0"/>

<path android:fillColor="@android:color/white" android:pathData="M8.5,9.5m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0"/>

<path android:fillColor="@android:color/white" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM7,14c0.78,2.34 2.72,4 5,4s4.22,-1.66 5,-4L7,14z"/>

</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_sunny.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M11,4V2c0,-0.55 0.45,-1 1,-1s1,0.45 1,1v2c0,0.55 -0.45,1 -1,1S11,4.55 11,4zM18.36,7.05l1.41,-1.42c0.39,-0.39 0.39,-1.02 0,-1.41c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.41,1.42c-0.39,0.39 -0.39,1.02 0,1.41C17.34,7.44 17.97,7.44 18.36,7.05zM22,11h-2c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h2c0.55,0 1,-0.45 1,-1S22.55,11 22,11zM12,19c-0.55,0 -1,0.45 -1,1v2c0,0.55 0.45,1 1,1s1,-0.45 1,-1v-2C13,19.45 12.55,19 12,19zM5.64,7.05L4.22,5.64c-0.39,-0.39 -0.39,-1.03 0,-1.41s1.03,-0.39 1.41,0l1.41,1.41c0.39,0.39 0.39,1.03 0,1.41S6.02,7.44 5.64,7.05zM16.95,16.95c-0.39,0.39 -0.39,1.03 0,1.41l1.41,1.41c0.39,0.39 1.03,0.39 1.41,0c0.39,-0.39 0.39,-1.03 0,-1.41l-1.41,-1.41C17.98,16.56 17.34,16.56 16.95,16.95zM2,13h2c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1H2c-0.55,0 -1,0.45 -1,1S1.45,13 2,13zM5.64,19.78l1.41,-1.41c0.39,-0.39 0.39,-1.03 0,-1.41s-1.03,-0.39 -1.41,0l-1.41,1.41c-0.39,0.39 -0.39,1.03 0,1.41C4.61,20.17 5.25,20.17 5.64,19.78zM12,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6s6,-2.69 6,-6S15.31,6 12,6z"/>

</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_today.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M360,660q-42,0 -71,-29t-29,-71q0,-42 29,-71t71,-29q42,0 71,29t29,71q0,42 -29,71t-71,29ZM200,880q-33,0 -56.5,-23.5T120,800v-560q0,-33 23.5,-56.5T200,160h40v-80h80v80h320v-80h80v80h40q33,0 56.5,23.5T840,240v560q0,33 -23.5,56.5T760,880L200,880ZM200,800h560v-400L200,400v400ZM200,320h560v-80L200,240v80ZM200,320v-80,80Z"
android:fillColor="#000"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/more_3_dots.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorOnSurfaceVariant"
>
<path
android:pathData="M480,800q-33,0 -56.5,-23.5T400,720q0,-33 23.5,-56.5T480,640q33,0 56.5,23.5T560,720q0,33 -23.5,56.5T480,800ZM480,560q-33,0 -56.5,-23.5T400,480q0,-33 23.5,-56.5T480,400q33,0 56.5,23.5T560,480q0,33 -23.5,56.5T480,560ZM480,320q-33,0 -56.5,-23.5T400,240q0,-33 23.5,-56.5T480,160q33,0 56.5,23.5T560,240q0,33 -23.5,56.5T480,320Z"
android:fillColor="#000"/>
</vector>
Binary file added app/src/main/res/font/roboto_medium.ttf
Binary file not shown.
Binary file added app/src/main/res/font/roboto_regular.ttf
Binary file not shown.
Loading