Advertisement
AzisMM

Zakat

Oct 25th, 2021
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.33 KB | None | 0 0
  1. private fun initView() {
  2.         binding.btnZakat.setOnClickListener {
  3.             if (TextUtils.isEmpty(binding.etAmountZakat.text)) {
  4.                 Toast.makeText(this, "Masukan Total Harta",
  5.                     Toast.LENGTH_SHORT).show()
  6.             } else if (binding.etAmountZakat.getNumericValue()?.toInt()!! >= 85000000) {
  7.                 val formatAmount = NumberFormat.getNumberInstance(
  8.                     Locale("id", "ID"))
  9.                     .format(binding.etAmountZakat.getNumericValue())
  10.                 binding.tvHartaAmount.text = "Rp $formatAmount"
  11.  
  12.                 val zakat = binding.etAmountZakat.getNumericValue()!!.toInt() * (2.5/100)
  13.                 val formatZakat = NumberFormat.getNumberInstance(
  14.                     Locale("id", "ID")).format(zakat)
  15.                 binding.tvAmountZakat.text = "Rp $formatZakat"
  16.             } else {
  17.                 Toast.makeText(this,
  18.                     "Total Harta masih belum mencapai nisab", Toast.LENGTH_LONG)
  19.                     .show()
  20.                 binding.tvAmountZakat.text = "Rp. 0"
  21.             }
  22.         }
  23.     }
  24.  
  25.     override fun onOptionsItemSelected(item: MenuItem): Boolean {
  26.         when (item.itemId) {
  27.             android.R.id.home -> {
  28.                 finish()
  29.             }
  30.         }
  31.         return super.onOptionsItemSelected(item)
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement