Skip to content

delete imports #46

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 1 commit 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
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
tools:targetApi="31">
<activity
android:name=".CartActivity"
android:exported="false"
android:label="Cart"
android:exported="false" />
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ContactsActivity"
android:exported="false"
android:label="Contacts"
android:exported="false" />
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait" />
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
package otus.gpb.homework.viewandresources

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import otus.gpb.homework.viewandresources.ItemRepository.Companion.listItem

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

val toolbar = findViewById<androidx.appcompat.widget.Toolbar>(R.id.cart_toolbar)

setSupportActionBar(toolbar)

supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true)
setDisplayShowHomeEnabled(true)
}

val recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
val itemAdapter = ItemAdapter(listItem)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = itemAdapter
recyclerView.addItemDecoration(RecyclerViewItemDecoration(this, R.drawable.divider))

var cartCount = findViewById<TextView>(R.id.cart_count)
cartCount.text = "${itemAdapter.itemCount} items in your cart"
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
val inflate = menuInflater
inflate.inflate(R.menu.menu_cart, menu)
return super.onCreateOptionsMenu(menu)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
package otus.gpb.homework.viewandresources

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import androidx.appcompat.app.AppCompatActivity

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

val autoCompleteTextView: AutoCompleteTextView = findViewById(R.id.autoCompleteTextView)

val phonesType = resources.getStringArray(R.array.phones)
val arrayAdapter = ArrayAdapter(this, R.layout.dropdown_item, phonesType)

autoCompleteTextView.setAdapter(arrayAdapter)

val toolbar = findViewById<androidx.appcompat.widget.Toolbar>(R.id.contacts_toolbar)

setSupportActionBar(toolbar)

supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true)
setDisplayShowHomeEnabled(true)
}


}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
val inflate = menuInflater
inflate.inflate(R.menu.menu_contacts, menu)
return super.onCreateOptionsMenu(menu)
}
}
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 id: Long,
val title: String,
val category: String,
val price: Double,
val description: String,
val photo: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package otus.gpb.homework.viewandresources

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

class ItemAdapter(private val dataItem: List<Item>) : RecyclerView.Adapter<ItemViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.cart_item, parent, false)
return ItemViewHolder(view)
}

override fun getItemCount() = dataItem.size

override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
val item = dataItem[position]
holder.itemTitle.text = item.title
holder.itemDescription.text = item.description
holder.itemCategory.text = item.category
holder.itemPrice.text = "\$${item.price}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package otus.gpb.homework.viewandresources

class ItemRepository {

companion object{
val listItem = listOf(
Item(1, "title", "category",35.0, "description", ""),
Item(2, "title", "category",15.5, "description", ""),
Item(3, "title", "category",20.2, "description", "")
)
}

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

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

class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

val itemTitle: TextView = itemView.findViewById(R.id.cart_item_title)
val itemImage: ImageView = itemView.findViewById(R.id.cart_item_image)
val itemCategory: TextView = itemView.findViewById(R.id.cart_item_category)
val itemDescription: TextView = itemView.findViewById(R.id.cart_item_description)
val itemPrice: TextView = itemView.findViewById(R.id.cart_item_price)

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

import android.content.Context
import android.graphics.Canvas
import android.graphics.drawable.Drawable
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView

class RecyclerViewItemDecoration(
context: Context,
resId: Int
) : RecyclerView.ItemDecoration() {

private var mDivider: Drawable = ContextCompat.getDrawable(context, resId)!!

override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
super.onDraw(c, parent, state)

val dividerLeft = 32

val dividerRight = parent.width - 32

for (i in 0 until parent.childCount) {

val childAt = parent.getChildAt(i)
val params = childAt.layoutParams as RecyclerView.LayoutParams

val dividerTop: Int = childAt.bottom + params.bottomMargin
val dividerBottom: Int = dividerTop + mDivider.intrinsicHeight

mDivider.setBounds(dividerLeft, dividerTop, dividerRight, dividerBottom)
mDivider.draw(c)
}
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/arrow.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="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M3.825,9L9.425,14.6L8,16L0,8L8,0L9.425,1.4L3.825,7H16V9H3.825Z"
android:fillColor="@color/arrow"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/calendar.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="18dp"
android:height="20dp"
android:viewportWidth="18"
android:viewportHeight="20">
<path
android:pathData="M6,14.5C5.3,14.5 4.708,14.258 4.225,13.775C3.742,13.292 3.5,12.7 3.5,12C3.5,11.3 3.742,10.708 4.225,10.225C4.708,9.742 5.3,9.5 6,9.5C6.7,9.5 7.292,9.742 7.775,10.225C8.258,10.708 8.5,11.3 8.5,12C8.5,12.7 8.258,13.292 7.775,13.775C7.292,14.258 6.7,14.5 6,14.5ZM2,20C1.45,20 0.979,19.804 0.587,19.413C0.196,19.021 0,18.55 0,18V4C0,3.45 0.196,2.979 0.587,2.588C0.979,2.196 1.45,2 2,2H3V0H5V2H13V0H15V2H16C16.55,2 17.021,2.196 17.413,2.588C17.804,2.979 18,3.45 18,4V18C18,18.55 17.804,19.021 17.413,19.413C17.021,19.804 16.55,20 16,20H2ZM2,18H16V8H2V18Z"
android:fillColor="#43474E"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/clip.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="11dp"
android:height="20dp"
android:viewportWidth="11"
android:viewportHeight="20">
<path
android:pathData="M5.5,20C3.967,20 2.667,19.467 1.6,18.4C0.533,17.333 0,16.033 0,14.5V4C0,2.9 0.392,1.958 1.175,1.175C1.958,0.392 2.9,0 4,0C5.1,0 6.042,0.392 6.825,1.175C7.608,1.958 8,2.9 8,4V13.5C8,14.2 7.758,14.792 7.275,15.275C6.792,15.758 6.2,16 5.5,16C4.8,16 4.208,15.758 3.725,15.275C3.242,14.792 3,14.2 3,13.5V4H4.5V13.5C4.5,13.783 4.596,14.021 4.787,14.212C4.979,14.404 5.217,14.5 5.5,14.5C5.783,14.5 6.021,14.404 6.213,14.212C6.404,14.021 6.5,13.783 6.5,13.5V4C6.5,3.3 6.258,2.708 5.775,2.225C5.292,1.742 4.7,1.5 4,1.5C3.3,1.5 2.708,1.742 2.225,2.225C1.742,2.708 1.5,3.3 1.5,4V14.5C1.5,15.6 1.892,16.542 2.675,17.325C3.458,18.108 4.4,18.5 5.5,18.5C6.6,18.5 7.542,18.108 8.325,17.325C9.108,16.542 9.5,15.6 9.5,14.5V4H11V14.5C11,16.033 10.467,17.333 9.4,18.4C8.333,19.467 7.033,20 5.5,20Z"
android:fillColor="#43474E"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/divider.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="2dp" />
<solid android:color="@color/outline_variant" />
</shape>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/flag.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="14dp"
android:height="18dp"
android:viewportWidth="14"
android:viewportHeight="18">
<path
android:pathData="M0,18V2C0,1.45 0.196,0.979 0.587,0.587C0.979,0.196 1.45,0 2,0H12C12.55,0 13.021,0.196 13.413,0.587C13.804,0.979 14,1.45 14,2V18L7,15L0,18ZM2,14.95L7,12.8L12,14.95V2H2V14.95Z"
android:fillColor="#43474E"/>
</vector>
Binary file added app/src/main/res/drawable/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/man.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="24"
android:viewportHeight="24">
<path
android:pathData="M12,12C10.9,12 9.958,11.608 9.175,10.825C8.392,10.042 8,9.1 8,8C8,6.9 8.392,5.958 9.175,5.175C9.958,4.392 10.9,4 12,4C13.1,4 14.042,4.392 14.825,5.175C15.608,5.958 16,6.9 16,8C16,9.1 15.608,10.042 14.825,10.825C14.042,11.608 13.1,12 12,12ZM4,20V17.2C4,16.633 4.146,16.112 4.438,15.637C4.729,15.163 5.117,14.8 5.6,14.55C6.633,14.033 7.683,13.646 8.75,13.387C9.817,13.129 10.9,13 12,13C13.1,13 14.183,13.129 15.25,13.387C16.317,13.646 17.367,14.033 18.4,14.55C18.883,14.8 19.271,15.163 19.563,15.637C19.854,16.112 20,16.633 20,17.2V20H4ZM6,18H18V17.2C18,17.017 17.954,16.85 17.862,16.7C17.771,16.55 17.65,16.433 17.5,16.35C16.6,15.9 15.692,15.563 14.775,15.337C13.858,15.113 12.933,15 12,15C11.067,15 10.142,15.113 9.225,15.337C8.308,15.563 7.4,15.9 6.5,16.35C6.35,16.433 6.229,16.55 6.137,16.7C6.046,16.85 6,17.017 6,17.2V18ZM12,10C12.55,10 13.021,9.804 13.413,9.413C13.804,9.021 14,8.55 14,8C14,7.45 13.804,6.979 13.413,6.588C13.021,6.196 12.55,6 12,6C11.45,6 10.979,6.196 10.587,6.588C10.196,6.979 10,7.45 10,8C10,8.55 10.196,9.021 10.587,9.413C10.979,9.804 11.45,10 12,10Z"
android:fillColor="#43474E"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/microphone.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="14dp"
android:height="19dp"
android:viewportWidth="14"
android:viewportHeight="19">
<path
android:pathData="M7,12C6.167,12 5.458,11.708 4.875,11.125C4.292,10.542 4,9.833 4,9V3C4,2.167 4.292,1.458 4.875,0.875C5.458,0.292 6.167,0 7,0C7.833,0 8.542,0.292 9.125,0.875C9.708,1.458 10,2.167 10,3V9C10,9.833 9.708,10.542 9.125,11.125C8.542,11.708 7.833,12 7,12ZM6,19V15.925C4.267,15.692 2.833,14.917 1.7,13.6C0.567,12.283 0,10.75 0,9H2C2,10.383 2.487,11.563 3.463,12.538C4.438,13.512 5.617,14 7,14C8.383,14 9.563,13.512 10.538,12.538C11.512,11.563 12,10.383 12,9H14C14,10.75 13.433,12.283 12.3,13.6C11.167,14.917 9.733,15.692 8,15.925V19H6Z"
android:fillColor="#43474E"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/mood.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="15dp"
android:height="16dp"
android:viewportWidth="15"
android:viewportHeight="16">
<path
android:pathData="M10.125,7.25C10.438,7.25 10.703,7.141 10.922,6.922C11.141,6.703 11.25,6.438 11.25,6.125C11.25,5.813 11.141,5.547 10.922,5.328C10.703,5.109 10.438,5 10.125,5C9.813,5 9.547,5.109 9.328,5.328C9.109,5.547 9,5.813 9,6.125C9,6.438 9.109,6.703 9.328,6.922C9.547,7.141 9.813,7.25 10.125,7.25ZM4.875,7.25C5.188,7.25 5.453,7.141 5.672,6.922C5.891,6.703 6,6.438 6,6.125C6,5.813 5.891,5.547 5.672,5.328C5.453,5.109 5.188,5 4.875,5C4.563,5 4.297,5.109 4.078,5.328C3.859,5.547 3.75,5.813 3.75,6.125C3.75,6.438 3.859,6.703 4.078,6.922C4.297,7.141 4.563,7.25 4.875,7.25ZM7.5,12.125C8.35,12.125 9.122,11.884 9.816,11.403C10.509,10.922 11.012,10.288 11.325,9.5H3.675C3.987,10.288 4.491,10.922 5.184,11.403C5.878,11.884 6.65,12.125 7.5,12.125ZM7.5,15.5C6.463,15.5 5.488,15.303 4.575,14.909C3.662,14.516 2.869,13.981 2.194,13.306C1.519,12.631 0.984,11.837 0.591,10.925C0.197,10.012 0,9.038 0,8C0,6.963 0.197,5.988 0.591,5.075C0.984,4.162 1.519,3.369 2.194,2.694C2.869,2.019 3.662,1.484 4.575,1.091C5.488,0.697 6.463,0.5 7.5,0.5C8.538,0.5 9.512,0.697 10.425,1.091C11.337,1.484 12.131,2.019 12.806,2.694C13.481,3.369 14.016,4.162 14.409,5.075C14.803,5.988 15,6.963 15,8C15,9.038 14.803,10.012 14.409,10.925C14.016,11.837 13.481,12.631 12.806,13.306C12.131,13.981 11.337,14.516 10.425,14.909C9.512,15.303 8.538,15.5 7.5,15.5ZM7.5,14C9.175,14 10.594,13.419 11.756,12.256C12.919,11.094 13.5,9.675 13.5,8C13.5,6.325 12.919,4.906 11.756,3.744C10.594,2.581 9.175,2 7.5,2C5.825,2 4.406,2.581 3.244,3.744C2.081,4.906 1.5,6.325 1.5,8C1.5,9.675 2.081,11.094 3.244,12.256C4.406,13.419 5.825,14 7.5,14Z"
android:fillColor="@color/on_primary"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/phone.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="18dp"
android:height="22dp"
android:viewportWidth="18"
android:viewportHeight="22">
<path
android:pathData="M2,22C1.45,22 0.979,21.804 0.587,21.413C0.196,21.021 0,20.55 0,20V2C0,1.45 0.196,0.979 0.587,0.587C0.979,0.196 1.45,0 2,0H12C12.55,0 13.021,0.196 13.413,0.587C13.804,0.979 14,1.45 14,2V6H12V5H2V17H12V16H14V20C14,20.55 13.804,21.021 13.413,21.413C13.021,21.804 12.55,22 12,22H2ZM2,19V20H12V19H2ZM10.95,15L6.7,10.75L8.1,9.35L10.95,12.2L16.6,6.55L18,7.95L10.95,15ZM2,3H12V2H2V3Z"
android:fillColor="#43474E"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/sun.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="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<path
android:pathData="M11,14C11.833,14 12.542,13.708 13.125,13.125C13.708,12.542 14,11.833 14,11C14,10.167 13.708,9.458 13.125,8.875C12.542,8.292 11.833,8 11,8C10.167,8 9.458,8.292 8.875,8.875C8.292,9.458 8,10.167 8,11C8,11.833 8.292,12.542 8.875,13.125C9.458,13.708 10.167,14 11,14ZM11,16C9.617,16 8.438,15.512 7.463,14.538C6.488,13.563 6,12.383 6,11C6,9.617 6.488,8.438 7.463,7.463C8.438,6.488 9.617,6 11,6C12.383,6 13.563,6.488 14.538,7.463C15.512,8.438 16,9.617 16,11C16,12.383 15.512,13.563 14.538,14.538C13.563,15.512 12.383,16 11,16ZM4,12H0V10H4V12ZM22,12H18V10H22V12ZM10,4V0H12V4H10ZM10,22V18H12V22H10ZM5.4,6.75L2.875,4.325L4.3,2.85L6.7,5.35L5.4,6.75ZM17.7,19.15L15.275,16.625L16.6,15.25L19.125,17.675L17.7,19.15ZM15.25,5.4L17.675,2.875L19.15,4.3L16.65,6.7L15.25,5.4ZM2.85,17.7L5.375,15.275L6.75,16.6L4.325,19.125L2.85,17.7Z"
android:fillColor="#43474E"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/x.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="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M6.4,15L10,11.4L13.6,15L15,13.6L11.4,10L15,6.4L13.6,5L10,8.6L6.4,5L5,6.4L8.6,10L5,13.6L6.4,15ZM10,20C8.617,20 7.317,19.737 6.1,19.212C4.883,18.688 3.825,17.975 2.925,17.075C2.025,16.175 1.313,15.117 0.788,13.9C0.262,12.683 0,11.383 0,10C0,8.617 0.262,7.317 0.788,6.1C1.313,4.883 2.025,3.825 2.925,2.925C3.825,2.025 4.883,1.313 6.1,0.788C7.317,0.262 8.617,0 10,0C11.383,0 12.683,0.262 13.9,0.788C15.117,1.313 16.175,2.025 17.075,2.925C17.975,3.825 18.688,4.883 19.212,6.1C19.737,7.317 20,8.617 20,10C20,11.383 19.737,12.683 19.212,13.9C18.688,15.117 17.975,16.175 17.075,17.075C16.175,17.975 15.117,18.688 13.9,19.212C12.683,19.737 11.383,20 10,20ZM10,18C12.233,18 14.125,17.225 15.675,15.675C17.225,14.125 18,12.233 18,10C18,7.767 17.225,5.875 15.675,4.325C14.125,2.775 12.233,2 10,2C7.767,2 5.875,2.775 4.325,4.325C2.775,5.875 2,7.767 2,10C2,12.233 2.775,14.125 4.325,15.675C5.875,17.225 7.767,18 10,18Z"
android:fillColor="@color/on_surface_variant"/>
</vector>
Binary file added app/src/main/res/font/roboto.ttf
Binary file not shown.
Loading