[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-android] 02/03: Show a different product layout when there
From: |
gnunet |
Subject: |
[taler-wallet-android] 02/03: Show a different product layout when there's only one product |
Date: |
Wed, 11 Mar 2020 13:58:30 +0100 |
This is an automated email from the git hooks/post-receive script.
torsten-grote pushed a commit to branch master
in repository wallet-android.
commit 88decdd5f85c0537059185f164ba3b15e4f1b477
Author: Torsten Grote <address@hidden>
AuthorDate: Wed Mar 11 09:37:24 2020 -0300
Show a different product layout when there's only one product
The image will be shown bigger and centered below the product name.
---
.../net/taler/wallet/payment/ProductAdapter.kt | 9 ++-
.../main/res/layout/list_item_product_single.xml | 76 ++++++++++++++++++++++
2 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
b/app/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
index 8519dcb..e1f9809 100644
--- a/app/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
+++ b/app/src/main/java/net/taler/wallet/payment/ProductAdapter.kt
@@ -37,9 +37,14 @@ internal class ProductAdapter :
RecyclerView.Adapter<ProductViewHolder>() {
override fun getItemCount() = items.size
+ override fun getItemViewType(position: Int): Int {
+ return if (itemCount == 1) 1 else 0
+ }
+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):
ProductViewHolder {
- val view =
-
LayoutInflater.from(parent.context).inflate(R.layout.list_item_product, parent,
false)
+ val res =
+ if (viewType == 1) R.layout.list_item_product_single else
R.layout.list_item_product
+ val view = LayoutInflater.from(parent.context).inflate(res, parent,
false)
return ProductViewHolder(view)
}
diff --git a/app/src/main/res/layout/list_item_product_single.xml
b/app/src/main/res/layout/list_item_product_single.xml
new file mode 100644
index 0000000..a4578b3
--- /dev/null
+++ b/app/src/main/res/layout/list_item_product_single.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under
the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT
ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along
with
+ ~ GNU Taler; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="8dp">
+
+ <TextView
+ android:id="@+id/quantity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintEnd_toStartOf="@+id/name"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintHorizontal_chainStyle="packed"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.0"
+ tools:text="31" />
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/name"
+ tools:ignore="ContentDescription"
+ tools:srcCompat="@tools:sample/avatars"
+ tools:visibility="visible" />
+
+ <TextView
+ android:id="@+id/name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ app:layout_constrainedWidth="true"
+ app:layout_constraintBottom_toTopOf="@+id/image"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/price"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toEndOf="@+id/quantity"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_goneMarginEnd="0dp"
+ tools:text="A product item that can have a very long name that
wraps over two lines" />
+
+ <TextView
+ android:id="@+id/price"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.0"
+ tools:text="23.42" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
--
To stop receiving notification emails like this one, please contact
address@hidden.