diff --git a/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt b/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt index b6cbf73..5110233 100644 --- a/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt +++ b/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt @@ -1,11 +1,32 @@ package otus.gpb.homework.viewandresources -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView + class CartActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_cart) + + val dataset = arrayOf("List item 1", "List item 2", "List item 3", "List item 4") + val customAdapter = CustomAdapter(dataset) + + val recyclerView: RecyclerView = findViewById(R.id.recycler_view) + recyclerView.layoutManager = LinearLayoutManager(this) + recyclerView.adapter = customAdapter + val divider = DividerItemDecoration( + recyclerView.context, + DividerItemDecoration.VERTICAL + ) + recyclerView.addItemDecoration(divider) + val appBar = findViewById(R.id.topAppBar) + appBar.setNavigationOnClickListener { + this.finish() + } } + } \ No newline at end of file diff --git a/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt b/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt index 25f1ffb..9f56d28 100644 --- a/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt +++ b/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt @@ -7,5 +7,9 @@ class ContactsActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_contacts) + val appBar = findViewById(R.id.topAppBar) + appBar.setNavigationOnClickListener { + this.finish() + } } } \ No newline at end of file diff --git a/app/src/main/java/otus/gpb/homework/viewandresources/CustomAdapter.kt b/app/src/main/java/otus/gpb/homework/viewandresources/CustomAdapter.kt new file mode 100644 index 0000000..03ee2a5 --- /dev/null +++ b/app/src/main/java/otus/gpb/homework/viewandresources/CustomAdapter.kt @@ -0,0 +1,45 @@ +package otus.gpb.homework.viewandresources + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView + +class CustomAdapter(private val dataSet: Array) : + RecyclerView.Adapter() { + + /** + * Provide a reference to the type of views that you are using + * (custom ViewHolder) + */ + class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + val textView: TextView + + init { + // Define click listener for the ViewHolder's View + textView = view.findViewById(R.id.name) + } + } + + // Create new views (invoked by the layout manager) + override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder { + // Create a new view, which defines the UI of the list item + val view = LayoutInflater.from(viewGroup.context) + .inflate(R.layout.text_row_item, viewGroup, false) + + return ViewHolder(view) + } + + // Replace the contents of a view (invoked by the layout manager) + override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) { + + // Get element from your dataset at this position and replace the + // contents of the view with that element + viewHolder.textView.text = dataSet[position] + } + + // Return the size of your dataset (invoked by the layout manager) + override fun getItemCount() = dataSet.size + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/account_outline.xml b/app/src/main/res/drawable/account_outline.xml new file mode 100644 index 0000000..b1fe8e1 --- /dev/null +++ b/app/src/main/res/drawable/account_outline.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/baseline_arrow_back_24.xml b/app/src/main/res/drawable/baseline_arrow_back_24.xml new file mode 100644 index 0000000..075e95d --- /dev/null +++ b/app/src/main/res/drawable/baseline_arrow_back_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/baseline_bookmark_border_24.xml b/app/src/main/res/drawable/baseline_bookmark_border_24.xml new file mode 100644 index 0000000..279bcf5 --- /dev/null +++ b/app/src/main/res/drawable/baseline_bookmark_border_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/baseline_highlight_off_24.xml b/app/src/main/res/drawable/baseline_highlight_off_24.xml new file mode 100644 index 0000000..3d2846b --- /dev/null +++ b/app/src/main/res/drawable/baseline_highlight_off_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/baseline_mic_24.xml b/app/src/main/res/drawable/baseline_mic_24.xml new file mode 100644 index 0000000..c6ba416 --- /dev/null +++ b/app/src/main/res/drawable/baseline_mic_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/baseline_sentiment_satisfied_alt_24.xml b/app/src/main/res/drawable/baseline_sentiment_satisfied_alt_24.xml new file mode 100644 index 0000000..d92c9df --- /dev/null +++ b/app/src/main/res/drawable/baseline_sentiment_satisfied_alt_24.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/baseline_sunny_24.xml b/app/src/main/res/drawable/baseline_sunny_24.xml new file mode 100644 index 0000000..0ebf3d5 --- /dev/null +++ b/app/src/main/res/drawable/baseline_sunny_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/calendar.xml b/app/src/main/res/drawable/calendar.xml new file mode 100644 index 0000000..5c93a21 --- /dev/null +++ b/app/src/main/res/drawable/calendar.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/cellphone_check.xml b/app/src/main/res/drawable/cellphone_check.xml new file mode 100644 index 0000000..e8b4cca --- /dev/null +++ b/app/src/main/res/drawable/cellphone_check.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/dots_vertical.xml b/app/src/main/res/drawable/dots_vertical.xml new file mode 100644 index 0000000..53254a9 --- /dev/null +++ b/app/src/main/res/drawable/dots_vertical.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/paperclip.xml b/app/src/main/res/drawable/paperclip.xml new file mode 100644 index 0000000..c2c6419 --- /dev/null +++ b/app/src/main/res/drawable/paperclip.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/shape.xml b/app/src/main/res/drawable/shape.xml new file mode 100644 index 0000000..539e880 --- /dev/null +++ b/app/src/main/res/drawable/shape.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/shape_bg.xml b/app/src/main/res/drawable/shape_bg.xml new file mode 100644 index 0000000..1820cb9 --- /dev/null +++ b/app/src/main/res/drawable/shape_bg.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_dlg_button.xml b/app/src/main/res/drawable/shape_dlg_button.xml new file mode 100644 index 0000000..e9a3902 --- /dev/null +++ b/app/src/main/res/drawable/shape_dlg_button.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/weather_sunny.xml b/app/src/main/res/drawable/weather_sunny.xml new file mode 100644 index 0000000..0149124 --- /dev/null +++ b/app/src/main/res/drawable/weather_sunny.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_cart.xml b/app/src/main/res/layout/activity_cart.xml index 57dc4d4..e9d9294 100644 --- a/app/src/main/res/layout/activity_cart.xml +++ b/app/src/main/res/layout/activity_cart.xml @@ -6,4 +6,159 @@ android:layout_height="match_parent" tools:context=".CartActivity"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +