Implemented displaying bank's icon in TransferMoneyDialog

This commit is contained in:
dankito 2020-05-25 19:20:55 +02:00
parent fda744be8a
commit bf541bfe80
4 changed files with 58 additions and 4 deletions

View File

@ -1,9 +1,11 @@
package net.dankito.banking.ui.android.adapter
import android.content.Context
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import kotlinx.android.synthetic.main.list_item_bank_account.view.*
import net.dankito.banking.ui.android.R
import net.dankito.banking.ui.model.BankAccount
@ -21,9 +23,21 @@ open class BankAccountsAdapter(bankAccounts: List<BankAccount>) : ListAdapter<Ba
view?.let {
view.txtBankAccountDisplayName.text = item.displayNameIncludingBankName
setIcon(item, view.imgBankIcon)
}
return view
}
protected open fun setIcon(bankAccount: BankAccount, imgBankIcon: ImageView) {
try {
val iconUrl = bankAccount.account.bank.iconUrl
imgBankIcon.visibility = if (iconUrl == null) View.GONE else View.VISIBLE
imgBankIcon.setImageURI(Uri.parse(iconUrl))
} catch (e: Exception) {
imgBankIcon.visibility = View.GONE
}
}
}

View File

@ -1,6 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_bank_account_height"
android:padding="@dimen/list_item_bank_account_padding"
android:gravity="center_vertical"
>
<ImageView
android:id="@+id/imgBankIcon"
android:layout_width="@dimen/list_item_bank_account_icon_size"
android:layout_height="@dimen/list_item_bank_account_icon_size"
android:layout_marginRight="@dimen/list_item_bank_account_icon_margin_right"
android:layout_marginEnd="@dimen/list_item_bank_account_icon_margin_right"
android:layout_gravity="center_vertical"
android:visibility="gone"
/>
<TextView
android:id="@+id/txtBankAccountDisplayName"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -9,5 +27,6 @@
android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="marquee"
android:padding="@dimen/list_item_bank_account_padding"
/>
/>
</LinearLayout>

View File

@ -51,7 +51,10 @@
<dimen name="dialog_transfer_money_instant_payment_margin_bottom">6dp</dimen>
<dimen name="dialog_transfer_money_buttons_width">120dp</dimen>
<dimen name="list_item_bank_account_height">26dp</dimen>
<dimen name="list_item_bank_account_padding">4dp</dimen>
<dimen name="list_item_bank_account_icon_size">16dp</dimen>
<dimen name="list_item_bank_account_icon_margin_right">8dp</dimen>
<dimen name="list_item_bank_account_text_size">13sp</dimen>
<dimen name="list_item_remittee_height">60dp</dimen>

View File

@ -7,6 +7,8 @@ import javafx.beans.property.SimpleStringProperty
import javafx.collections.FXCollections
import javafx.geometry.Insets
import javafx.geometry.Pos
import javafx.scene.control.ContentDisplay
import javafx.scene.image.ImageView
import javafx.scene.layout.Priority
import net.dankito.banking.ui.javafx.dialogs.JavaFxDialogService
import net.dankito.banking.ui.model.BankAccount
@ -33,6 +35,8 @@ open class TransferMoneyDialog @JvmOverloads constructor(
private val FieldHeight = 40.0
private val TextFieldHeight = 32.0
private const val BankIconSize = 24.0
private val ButtonHeight = 40.0
private val ButtonWidth = 150.0
}
@ -96,6 +100,20 @@ open class TransferMoneyDialog @JvmOverloads constructor(
combobox(selectedBankAccount, bankAccountsSupportingTransferringMoney) {
fixedHeight = TextFieldHeight
cellFormat {
text = it.displayNameIncludingBankName
it.account.bank.iconUrl?.let { iconUrl ->
graphic = ImageView(iconUrl)?.apply {
this.fitHeight = BankIconSize
this.fitWidth = BankIconSize
this.isPreserveRatio = true
}
contentDisplay = ContentDisplay.LEFT
}
?: run { contentDisplay = ContentDisplay.TEXT_ONLY }
}
}
vboxConstraints {