Skip to content

ДЗ по уроку View-Resources #2 #48

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: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<activity
android:name=".CartActivity"
android:label="Cart"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait"
/>
<activity
android:name=".ContactsActivity"
android:label="Contacts"
Expand All @@ -30,6 +32,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
@@ -1,11 +1,82 @@
package otus.gpb.homework.viewandresources

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.ListView
import android.widget.TextView
import android.widget.Toast
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.button.MaterialButton

class CartActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

//setTheme(R.style.Theme_MyTheme) // это работает

setContentView(R.layout.activity_cart)

findViewById<MaterialButton>(R.id.btnClose).setOnClickListener {
Toast.makeText(this, "btnClose", Toast.LENGTH_SHORT).show()
}

findViewById<MaterialButton>(R.id.buttonPlaceOrder).setOnClickListener {
Toast.makeText(this, "buttonPlaceOrder", Toast.LENGTH_SHORT).show()
}

findViewById<MaterialToolbar>(R.id.topAppBar).setNavigationOnClickListener {
finish()
}


val listView: ListView = findViewById(R.id.listItems)

val items = ArrayList<ItemData?>()
for(i in 1..4) {
items.add(ItemData("Item $i", "Category", "Supporting line text lorem ipsum...", "$i$", R.drawable.ic_shape_outline))
}

val listAdapter = ListAdapter(this, items)
listView.adapter = listAdapter
}
}

class ItemData(
var name: String,
var category: String,
var description: String,
var price: String,
var image: Int
)

class ListAdapter(context: Context, dataArrayList: ArrayList<ItemData?>?) :
ArrayAdapter<ItemData?>(context, R.layout.list_item, dataArrayList!!) {

override fun getView(position: Int, view: View?, parent: ViewGroup): View {
var view = view
val listData = getItem(position)
if (view == null) {
view = LayoutInflater.from(context).inflate(R.layout.layout_list_item, parent, false)
}
val listImage = view!!.findViewById<ImageView>(R.id.imageView)
val listName = view.findViewById<TextView>(R.id.textViewName)
val listCategory = view.findViewById<TextView>(R.id.textViewCategory)
val listDescription = view.findViewById<TextView>(R.id.textViewDescription)
val listPrice = view.findViewById<TextView>(R.id.textViewPrice)

listImage.setImageResource(listData!!.image)
listName.text = listData.name
listCategory.text = listData.category
listDescription.text = listData.description
listPrice.text = listData.price

return view
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,42 @@ package otus.gpb.homework.viewandresources

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import android.widget.Toast
import androidx.appcompat.app.ActionBar
import androidx.core.content.ContentProviderCompat.requireContext
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.textview.MaterialTextView
import com.google.android.material.textfield.MaterialAutoCompleteTextView
import com.google.android.material.textfield.TextInputLayout

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

var textField = findViewById<TextInputLayout>(R.id.dropDownPhoneType)
val items = listOf("Mobile", "Stationary")
val adapter = ArrayAdapter(this, R.layout.list_item, items)
(textField.editText as? AutoCompleteTextView)?.setAdapter(adapter)

var topAppBar: MaterialToolbar = findViewById(R.id.topAppBar)
topAppBar.setNavigationOnClickListener {
finish()
}
topAppBar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.attach -> {
Toast.makeText(this, "Attach", Toast.LENGTH_SHORT).show()
true
}
R.id.more -> {
Toast.makeText(this, "More", Toast.LENGTH_SHORT).show()
true
}
else -> false
}
}
}
}
Binary file added app/src/main/res/drawable/cat.jpeg
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/ic_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/ic_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>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_bookmark_outline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/bookmark_outline.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="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/ic_calendar_badge.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/calendar_badge.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.5 16C17.6 16 16 17.6 16 19.5S17.6 23 19.5 23 23 21.4 23 19.5 21.4 16 19.5 16M14.21 21H5C3.9 21 3 20.11 3 19V5C3 3.89 3.89 3 5 3H6V1H8V3H16V1H18V3H19C20.1 3 21 3.89 21 5V14.21C20.5 14.08 20 14 19.5 14C19.33 14 19.17 14 19 14.03V8H5V19H14.03C14 19.17 14 19.33 14 19.5C14 20 14.08 20.5 14.21 21Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_cellphone_check.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/cellphone_check.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="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>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_close_circle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/close_circle_outline.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,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>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_dots_vertical.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- 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"
android:tint="?attr/colorOnSurface">
<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>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_emoticon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/emoticon.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,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,2M15.5,8A1.5,1.5 0 0,1 17,9.5A1.5,1.5 0 0,1 15.5,11A1.5,1.5 0 0,1 14,9.5A1.5,1.5 0 0,1 15.5,8M8.5,8A1.5,1.5 0 0,1 10,9.5A1.5,1.5 0 0,1 8.5,11A1.5,1.5 0 0,1 7,9.5A1.5,1.5 0 0,1 8.5,8M12,17.5C9.67,17.5 7.69,16.04 6.89,14H17.11C16.3,16.04 14.33,17.5 12,17.5Z" /></vector>
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_eye_outline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/eye_outline.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,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9M12,4.5C17,4.5 21.27,7.61 23,12C21.27,16.39 17,19.5 12,19.5C7,19.5 2.73,16.39 1,12C2.73,7.61 7,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C15.76,17.5 19.17,15.36 20.82,12C19.17,8.64 15.76,6.5 12,6.5C8.24,6.5 4.83,8.64 3.18,12Z" /></vector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_menu_down.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- 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/ic_microphone.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- drawable/microphone.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,2A3,3 0 0,1 15,5V11A3,3 0 0,1 12,14A3,3 0 0,1 9,11V5A3,3 0 0,1 12,2M19,11C19,14.53 16.39,17.44 13,17.93V21H11V17.93C7.61,17.44 5,14.53 5,11H7A5,5 0 0,0 12,16A5,5 0 0,0 17,11H19Z" /></vector>
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_paperclip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- drawable/paperclip.xml -->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorOnSurface"
>
<path
android:fillColor="#000000"
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>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_shape_outline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- drawable/shape_outline.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorOnSurface"
>
<path
android:fillColor="#000000"
android:pathData="M11,13.5V21.5H3V13.5H11M9,15.5H5V19.5H9V15.5M12,2L17.5,11H6.5L12,2M12,5.86L10.08,9H13.92L12,5.86M17.5,13C20,13 22,15 22,17.5C22,20 20,22 17.5,22C15,22 13,20 13,17.5C13,15 15,13 17.5,13M17.5,15A2.5,2.5 0 0,0 15,17.5A2.5,2.5 0 0,0 17.5,20A2.5,2.5 0 0,0 20,17.5A2.5,2.5 0 0,0 17.5,15Z"
/>
</vector>
7 changes: 7 additions & 0 deletions app/src/main/res/font/roboto.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Roboto"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
7 changes: 7 additions & 0 deletions app/src/main/res/font/roboto_light.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Roboto&amp;weight=300"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
Loading