From 7dea0c0d83cb3c31e51621dcd8304fb85c0ceb8b Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 6 Nov 2020 03:13:54 +0100 Subject: [PATCH] Using new convenience methods from AndroidUtils to show / hide views --- .../ui/android/activities/LoginActivity.kt | 5 ++-- .../adapter/AccountTransactionAdapter.kt | 8 ++++--- .../android/adapter/RecipientListAdapter.kt | 3 ++- .../viewholder/CheckableValueViewHolder.kt | 3 ++- .../ui/android/dialogs/AddAccountDialog.kt | 6 +++-- .../ui/android/dialogs/EnterTanDialog.kt | 7 +++--- .../android/dialogs/SendMessageLogDialog.kt | 6 +++-- .../ui/android/dialogs/TransferMoneyDialog.kt | 23 ++++++------------ .../settings/ProtectAppSettingsDialog.kt | 15 +++++++----- .../android/extensions/ImageViewExtensions.kt | 9 +++---- .../banking/ui/android/home/HomeFragment.kt | 24 +++++++++---------- .../ui/android/views/CollapsibleTextView.kt | 3 ++- .../ui/android/views/FormLabelledValue.kt | 10 +++----- .../android/views/SecondaryIconDrawerItem.kt | 6 +++-- 14 files changed, 65 insertions(+), 63 deletions(-) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt index a7006269..2a67a43a 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/activities/LoginActivity.kt @@ -12,6 +12,7 @@ import net.dankito.banking.ui.android.authentication.AuthenticationService import net.dankito.banking.ui.android.authentication.AuthenticationType import net.dankito.banking.ui.android.di.BankingComponent import net.dankito.banking.ui.android.extensions.addEnterPressedListener +import net.dankito.utils.android.extensions.hide import javax.inject.Inject @@ -37,7 +38,7 @@ open class LoginActivity : BaseActivity() { setContentView(R.layout.activity_login) if (authenticationService.authenticationType == AuthenticationType.Password) { - lytBiometricAuthentication.visibility = View.GONE + lytBiometricAuthentication.hide() edtxtLoginPassword.actualEditText.addEnterPressedListener { checkEnteredPasswordAndLogIn() @@ -47,7 +48,7 @@ open class LoginActivity : BaseActivity() { btnLogin.setOnClickListener { checkEnteredPasswordAndLogIn() } } else { - lytPasswordAuthentication.visibility = View.GONE + lytPasswordAuthentication.hide() btnBiometricAuthentication.customButtonClickHandler = { authenticationService.loginUserWithBiometric { result -> diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt index 7379f4d9..e8c61bef 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt @@ -9,6 +9,8 @@ import net.dankito.banking.ui.android.extensions.showAmount import net.dankito.banking.ui.model.IAccountTransaction import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.utils.android.extensions.asActivity +import net.dankito.utils.android.extensions.hide +import net.dankito.utils.android.extensions.show import net.dankito.utils.android.ui.adapter.ListRecyclerAdapter @@ -41,11 +43,11 @@ open class AccountTransactionAdapter(protected val presenter: BankingPresenter) if (presenter.areAllAccountSelected) { viewHolder.imgvwBankIcon.setIcon(item.account.bank) - // TODO: if bank icon isn't set: Show default icon? show at least an empty space to that amount and date don't shift up causing an inconsistent view? - viewHolder.imgvwBankIcon.visibility = View.VISIBLE + viewHolder.imgvwBankIcon.show() } else { - viewHolder.imgvwBankIcon.visibility = View.GONE + // TODO: if bank icon isn't set: Show default icon? show at least an empty space to that amount and date don't shift up causing an inconsistent view? + viewHolder.imgvwBankIcon.hide() } } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/RecipientListAdapter.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/RecipientListAdapter.kt index ca38ab0d..e46c03c1 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/RecipientListAdapter.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/RecipientListAdapter.kt @@ -4,6 +4,7 @@ import android.view.View import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.adapter.viewholder.RecipientViewHolder import net.dankito.banking.search.TransactionParty +import net.dankito.utils.android.extensions.isGone import net.dankito.utils.android.ui.adapter.ListRecyclerAdapter @@ -19,7 +20,7 @@ open class RecipientListAdapter(protected val itemClicked: ((TransactionParty) - viewHolder.txtvwRecipientName.text = item.name viewHolder.txtvwRecipientBankName.text = item.bankName - viewHolder.txtvwRecipientBankName.visibility = if (item.bankName.isNullOrBlank()) View.GONE else View.VISIBLE + viewHolder.txtvwRecipientBankName.isGone = item.bankName.isNullOrBlank() viewHolder.txtvwRecipientAccountId.text = item.iban diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/viewholder/CheckableValueViewHolder.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/viewholder/CheckableValueViewHolder.kt index 153950e2..4d364c69 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/viewholder/CheckableValueViewHolder.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/viewholder/CheckableValueViewHolder.kt @@ -6,6 +6,7 @@ import android.widget.TextView import com.mikepenz.fastadapter.FastAdapter import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.adapter.CheckableValueAdapterItem +import net.dankito.utils.android.extensions.setVisibleOrInvisible open class CheckableValueViewHolder(view: View) : FastAdapter.ViewHolder(view) { @@ -16,7 +17,7 @@ open class CheckableValueViewHolder(view: View) : FastAdapter.ViewHolder) { - imgCheckmark.visibility = if (item.isChecked) View.VISIBLE else View.INVISIBLE + imgCheckmark.setVisibleOrInvisible(item.isChecked) txtValue.text = item.text } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt index c87e2061..fee8e1aa 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt @@ -25,6 +25,8 @@ import net.dankito.banking.ui.model.responses.AddAccountResponse import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.android.extensions.asActivity +import net.dankito.utils.android.extensions.hide +import net.dankito.utils.android.extensions.show import net.dankito.utils.android.extensions.showKeyboardDelayed import javax.inject.Inject @@ -118,12 +120,12 @@ open class AddAccountDialog : DialogFragment() { val password = bankCredentialsPassword.password btnAddAccount.isEnabled = false - pgrbrAddAccount.visibility = View.VISIBLE + pgrbrAddAccount.show() presenter.addAccountAsync(selectedBank, userName, password) { response -> context?.asActivity()?.runOnUiThread { btnAddAccount.isEnabled = true - pgrbrAddAccount.visibility = View.GONE + pgrbrAddAccount.hide() handleAccountCheckResponseOnUiThread(response) } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt index a40d352d..9685bc36 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt @@ -26,6 +26,7 @@ import net.dankito.banking.ui.model.responses.BankingClientResponse import net.dankito.banking.ui.model.tan.* import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.utils.android.extensions.getSpannedFromHtml +import net.dankito.utils.android.extensions.show import javax.inject.Inject @@ -118,7 +119,7 @@ open class EnterTanDialog : DialogFragment() { val tanMediaForTanMethod = presenter.getTanMediaForTanMethod(bank, tanChallenge.tanMethod) if (tanMediaForTanMethod.size > 1) { - rootView.lytTanMedium.visibility = View.VISIBLE + rootView.lytTanMedium.show() tanMediumAdapter.setItems(bank.tanMediaSorted) @@ -172,7 +173,7 @@ open class EnterTanDialog : DialogFragment() { protected open fun setupFlickerCodeTanView(rootView: View) { val flickerCodeView = rootView.flickerCodeView - flickerCodeView.visibility = View.VISIBLE + flickerCodeView.show() val flickerCode = (tanChallenge as FlickerCodeTanChallenge).flickerCode if (flickerCode.decodingSuccessful) { @@ -184,7 +185,7 @@ open class EnterTanDialog : DialogFragment() { } protected open fun setupImageTanView(rootView: View) { - rootView.tanImageView.visibility = View.VISIBLE + rootView.tanImageView.show() val decodedImage = (tanChallenge as ImageTanChallenge).image if (decodedImage.decodingSuccessful) { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/SendMessageLogDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/SendMessageLogDialog.kt index a747e19c..b5556125 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/SendMessageLogDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/SendMessageLogDialog.kt @@ -13,6 +13,8 @@ import kotlinx.android.synthetic.main.dialog_send_message_log.view.* import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.di.BankingComponent import net.dankito.banking.ui.presenter.BankingPresenter +import net.dankito.utils.android.extensions.hide +import net.dankito.utils.android.extensions.show import javax.inject.Inject @@ -54,8 +56,8 @@ open class SendMessageLogDialog : DialogFragment() { val messageLog = presenter.getMessageLogForAccounts(presenter.allBanksSortedByDisplayIndex).joinToString("\r\n\r\n") if (messageLog.isBlank()) { - rootView.txtvwInfoNoMessageLogEntriesYet.visibility = View.VISIBLE - rootView.lytMessageLog.visibility = View.GONE + rootView.txtvwInfoNoMessageLogEntriesYet.show() + rootView.lytMessageLog.hide() } else { rootView.edtxtMessageLog.setText(context?.getString(R.string.dialog_send_message_courteously_add_error_description, messageLog)) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt index 15fbeff3..9e2a4553 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt @@ -35,11 +35,8 @@ import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.ui.android.extensions.isEllipsized import net.dankito.banking.ui.android.views.InfoPopupWindow import net.dankito.banking.util.ValidationResult +import net.dankito.utils.android.extensions.* import net.dankito.utils.multiplatform.toBigDecimal -import net.dankito.utils.android.extensions.asActivity -import net.dankito.utils.android.extensions.getDimension -import net.dankito.utils.android.extensions.getResourceIdentifier -import net.dankito.utils.android.extensions.setVisibility import java.math.BigDecimal import java.text.DecimalFormatSymbols import java.util.* @@ -114,7 +111,7 @@ open class TransferMoneyDialog : DialogFragment() { account = preselectedValues?.account ?: accountsSupportingTransferringMoney.first() if (accountsSupportingTransferringMoney.size > 1) { - rootView.lytSelectBankAccount.visibility = View.VISIBLE + rootView.lytSelectBankAccount.show() val adapter = IconedBankAccountsAdapter(accountsSupportingTransferringMoney) rootView.spnBankAccounts.adapter = adapter @@ -185,13 +182,7 @@ open class TransferMoneyDialog : DialogFragment() { } protected open fun setRealTimeTransferControlsVisibility(rootView: View) { - rootView.lytRealTimeTransfer.visibility = - if (account.supportsRealTimeTransfer) { - View.VISIBLE - } - else { - View.GONE - } + rootView.lytRealTimeTransfer.setVisibility(account.supportsRealTimeTransfer) } protected open fun showRealTimeTransferInfo(btnShowRealTimeTransferInfo: ImageButton) { @@ -353,16 +344,16 @@ open class TransferMoneyDialog : DialogFragment() { if (foundBank != null) { txtRecipientBankInfo.text = getString(R.string.dialog_transfer_money_bic_detected_from_iban, foundBank.bic, foundBank.name) - txtRecipientBankInfo.visibility = View.VISIBLE + txtRecipientBankInfo.show() setIbanValidationErrorVisibility() } else if (enteredIban.length >= InputValidator.MinimumLengthToDetermineBicFromIban) { txtRecipientBankInfo.text = getString(R.string.dialog_transfer_money_could_not_determine_bic_from_iban, enteredIban.substring(4, InputValidator.MinimumLengthToDetermineBicFromIban)) - txtRecipientBankInfo.visibility = View.VISIBLE + txtRecipientBankInfo.show() setIbanValidationErrorVisibility() } else { - txtRecipientBankInfo.visibility = View.GONE + txtRecipientBankInfo.hide() } checkIfRequiredDataEnteredOnUiThread() @@ -371,7 +362,7 @@ open class TransferMoneyDialog : DialogFragment() { protected open fun setIbanValidationErrorVisibility() { getIbanTextInputErrorView()?.let { textInputError -> val displaysErrorOrHint = lytRecipientIban.error != null || lytRecipientIban.helperText != null - (textInputError.parent?.parent as? ViewGroup)?.visibility = if (displaysErrorOrHint) View.VISIBLE else View.GONE + (textInputError.parent?.parent as? ViewGroup)?.setVisibility(displaysErrorOrHint) } } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt index fa82b24a..404152d3 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt @@ -15,6 +15,9 @@ import net.dankito.banking.ui.android.di.BankingComponent import net.dankito.banking.ui.android.extensions.addEnterPressedListener import net.dankito.banking.ui.android.util.StandardTextWatcher import net.dankito.utils.android.extensions.hideKeyboardDelayed +import net.dankito.utils.android.extensions.hide +import net.dankito.utils.android.extensions.setVisibility +import net.dankito.utils.android.extensions.show import org.slf4j.LoggerFactory import javax.inject.Inject @@ -62,7 +65,7 @@ open class ProtectAppSettingsDialog : SettingsDialogBase() { val isBiometricAuthenticationSupported = authenticationService.isBiometricAuthenticationSupported val showAuthenticationMethods = isBiometricAuthenticationSupported || authenticationType != AuthenticationType.None // hide select authentication method if password is the only option to choose - segmentedGroup.visibility = if (showAuthenticationMethods) View.VISIBLE else View.GONE + segmentedGroup.setVisibility(showAuthenticationMethods) segmentedGroup.doOnNextLayout { val segmentedControlButtonWidth = segmentedGroup.measuredWidth / 3 btnShowBiometricAuthenticationSection.layoutParams.width = segmentedControlButtonWidth @@ -70,7 +73,7 @@ open class ProtectAppSettingsDialog : SettingsDialogBase() { btnShowRemoveAppProtectionSection.layoutParams.width = segmentedControlButtonWidth } - btnShowBiometricAuthenticationSection.visibility = if (isBiometricAuthenticationSupported) View.VISIBLE else View.GONE + btnShowBiometricAuthenticationSection.setVisibility(isBiometricAuthenticationSupported) btnShowBiometricAuthenticationSection.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { showAuthenticationLayout(rootView, lytBiometricAuthentication) @@ -114,11 +117,11 @@ open class ProtectAppSettingsDialog : SettingsDialogBase() { } protected open fun showAuthenticationLayout(rootView: View, authenticationLayoutToShow: ViewGroup) { - lytBiometricAuthentication.visibility = View.GONE - lytPasswordAuthentication.visibility = View.GONE - lytRemoveAppProtection.visibility = View.GONE + lytBiometricAuthentication.hide() + lytPasswordAuthentication.hide() + lytRemoveAppProtection.hide() - authenticationLayoutToShow.visibility = View.VISIBLE + authenticationLayoutToShow.show() if (authenticationLayoutToShow == lytRemoveAppProtection) { btnSetAuthenticationMethod.setText(R.string.dialog_protect_app_settings_button_remove_app_protection_title) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/ImageViewExtensions.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/ImageViewExtensions.kt index 24bbf9a0..2dd1b018 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/ImageViewExtensions.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/ImageViewExtensions.kt @@ -1,8 +1,9 @@ package net.dankito.banking.ui.android.extensions -import android.view.View import android.widget.ImageView import net.dankito.banking.ui.model.IBankData +import net.dankito.utils.android.extensions.hide +import net.dankito.utils.android.extensions.show fun ImageView.setIcon(bank: IBankData<*, *>) { @@ -10,15 +11,15 @@ fun ImageView.setIcon(bank: IBankData<*, *>) { val iconData = bank.iconData if (iconData != null) { - this.visibility = View.VISIBLE + this.show() this.setImageFromBytes(iconData) } else { - this.visibility = View.GONE + this.hide() this.setImageURI(null) } } catch (e: Exception) { - this.visibility = View.GONE + this.hide() } } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt index 5171b094..6f1b9761 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt @@ -26,6 +26,9 @@ import net.dankito.banking.ui.model.parameters.TransferMoneyData import net.dankito.banking.ui.model.responses.GetTransactionsResponse import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.utils.android.extensions.asActivity +import net.dankito.utils.android.extensions.hide +import net.dankito.utils.android.extensions.isGone +import net.dankito.utils.android.extensions.setVisibility import net.dankito.utils.multiplatform.sum import javax.inject.Inject @@ -246,7 +249,7 @@ class HomeFragment : Fragment() { mnitmBalance.title = presenter.formatAmount(presenter.balanceOfSelectedAccounts) mnitmBalance.isVisible = presenter.doSelectedAccountsSupportRetrievingBalance - lytTransactionsSummary.visibility = if (presenter.doSelectedAccountsSupportRetrievingBalance) View.VISIBLE else View.GONE + lytTransactionsSummary.setVisibility(presenter.doSelectedAccountsSupportRetrievingBalance) txtCountTransactions.text = context?.getString(R.string.fragment_home_count_transactions, transactionAdapter.items.size) @@ -264,11 +267,11 @@ class HomeFragment : Fragment() { val haveTransactionsBeenRetrieved = transactionsRetrievalState == TransactionsRetrievalState.RetrievedTransactions val noAccountsAddedYet = presenter.allBanks.isEmpty() - lytTransactionsTopBar.visibility = if (haveTransactionsBeenRetrieved) View.VISIBLE else View.GONE - rcyvwAccountTransactions.visibility = if (haveTransactionsBeenRetrieved) View.VISIBLE else View.GONE - lytNoTransactionsFetched.visibility = if (haveTransactionsBeenRetrieved || noAccountsAddedYet) View.GONE else View.VISIBLE - btnRetrieveTransactions.visibility = if (TransactionsCannotBeRetrievedStates.contains(transactionsRetrievalState)) View.GONE else View.VISIBLE - btnAddAccount.visibility = if (noAccountsAddedYet) View.VISIBLE else View.GONE + lytTransactionsTopBar.setVisibility(haveTransactionsBeenRetrieved) + rcyvwAccountTransactions.setVisibility(haveTransactionsBeenRetrieved) + lytNoTransactionsFetched.isGone = haveTransactionsBeenRetrieved || noAccountsAddedYet + btnRetrieveTransactions.isGone = TransactionsCannotBeRetrievedStates.contains(transactionsRetrievalState) + btnAddAccount.setVisibility(noAccountsAddedYet) val messageArgs = mutableListOf() val transactionsRetrievalStateMessageId = when (transactionsRetrievalState) { @@ -291,19 +294,14 @@ class HomeFragment : Fragment() { showTopFetchAllTransactionsView = presenter.showStrikingFetchAllTransactionsViewForSelectedAccounts val showFetchAllTransactionsView = presenter.showFetchAllTransactionsViewForSelectedAccounts - if (showFetchAllTransactionsView && showTopFetchAllTransactionsView) { - lytTopFetchAllTransactions.visibility = View.VISIBLE - } - else { - lytTopFetchAllTransactions.visibility = View.GONE - } + lytTopFetchAllTransactions.setVisibility(showFetchAllTransactionsView && showTopFetchAllTransactionsView) if (showFetchAllTransactionsView && showTopFetchAllTransactionsView == false) { // TODO: implement CoordinatorLayout to show lytBottomFetchAllTransactions below rcyvwAccountTransactions // lytBottomFetchAllTransactions.visibility = View.VISIBLE } else { - lytBottomFetchAllTransactions.visibility = View.GONE + lytBottomFetchAllTransactions.hide() } } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/CollapsibleTextView.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/CollapsibleTextView.kt index 0f5f4565..47f988cb 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/CollapsibleTextView.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/CollapsibleTextView.kt @@ -9,6 +9,7 @@ import kotlinx.android.synthetic.main.view_collapsible_text.view.* import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.util.StandardTextWatcher import net.dankito.utils.android.extensions.asActivity +import net.dankito.utils.android.extensions.setVisibility import java.util.* import kotlin.concurrent.schedule @@ -64,7 +65,7 @@ open class CollapsibleTextView @JvmOverloads constructor( Timer().schedule(500) { // wait some time till txtvwCollapsibleText is layout and lineCount is set context.asActivity()?.runOnUiThread { val showExpandButton = isCollapsed == false || txtvwCollapsibleText.lineCount > CountDisplayedLinesWhenCollapsed - btnExpandCollapseTextView.visibility = if (showExpandButton) View.VISIBLE else View.GONE + btnExpandCollapseTextView.setVisibility(showExpandButton) } } } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt index 5efbca51..4ca2543f 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt @@ -8,6 +8,7 @@ import android.widget.LinearLayout import android.widget.TextView import kotlinx.android.synthetic.main.view_form_labelled_value.view.* import net.dankito.banking.ui.android.R +import net.dankito.utils.android.extensions.setVisibility open class FormLabelledValue @JvmOverloads constructor( @@ -60,13 +61,8 @@ open class FormLabelledValue @JvmOverloads constructor( } open fun setValueAndVisibilityIfValueIsSet(value: CharSequence?) { - if (value != null) { - this.value = value - this.visibility = View.VISIBLE - } - else { - this.visibility = View.GONE - } + this.setVisibility(value != null) + this.value = value ?: "" } } \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/SecondaryIconDrawerItem.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/SecondaryIconDrawerItem.kt index 490a0c07..c2e5197b 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/SecondaryIconDrawerItem.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/SecondaryIconDrawerItem.kt @@ -16,6 +16,8 @@ import com.mikepenz.materialdrawer.model.BaseDescribeableDrawerItem import com.mikepenz.materialdrawer.model.BaseViewHolder import net.dankito.banking.ui.android.R import net.dankito.utils.android.extensions.createColorStateList +import net.dankito.utils.android.extensions.hide +import net.dankito.utils.android.extensions.show open class SecondaryIconDrawerItem> : BaseDescribeableDrawerItem() { @@ -41,7 +43,7 @@ open class SecondaryIconDrawerItem> : BaseD bindViewHelper(holder) if (secondaryIcon == null) { - holder.btnSecondaryIcon.visibility = View.GONE + holder.btnSecondaryIcon.hide() } else { val context = holder.itemView.context @@ -52,7 +54,7 @@ open class SecondaryIconDrawerItem> : BaseD holder.btnSecondaryIcon.setOnClickListener { onSecondaryIconClicked?.invoke() } - holder.btnSecondaryIcon.visibility = View.VISIBLE + holder.btnSecondaryIcon.show() } //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)