Commit 07e62214 authored by Alutulu's avatar Alutulu

arrondit nbr

parent eb647a7e
...@@ -7,7 +7,6 @@ import android.widget.ImageView ...@@ -7,7 +7,6 @@ import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import com.example.elbuenopeso.R import com.example.elbuenopeso.R
import com.example.elbuenopeso.models.AdModel import com.example.elbuenopeso.models.AdModel
import java.math.RoundingMode
class AdAdapter(private val context: Context, private val adModelArrayList: List<AdModel>) : BaseAdapter() { class AdAdapter(private val context: Context, private val adModelArrayList: List<AdModel>) : BaseAdapter() {
...@@ -19,6 +18,8 @@ class AdAdapter(private val context: Context, private val adModelArrayList: List ...@@ -19,6 +18,8 @@ class AdAdapter(private val context: Context, private val adModelArrayList: List
override fun getItemId(i: Int): Long = i.toLong() override fun getItemId(i: Int): Long = i.toLong()
fun usingJavaStringFormat(input: Double, scale: Int) = String.format("%.${scale}f", input)
override fun getView(i: Int, view: View?, viewGroup: ViewGroup): View { override fun getView(i: Int, view: View?, viewGroup: ViewGroup): View {
var convertView = view var convertView = view
val ad = adModelArrayList[i] val ad = adModelArrayList[i]
...@@ -31,8 +32,7 @@ class AdAdapter(private val context: Context, private val adModelArrayList: List ...@@ -31,8 +32,7 @@ class AdAdapter(private val context: Context, private val adModelArrayList: List
imageIV.setImageResource(ad.image) imageIV.setImageResource(ad.image)
titleTV.text = ad.title titleTV.text = ad.title
addressTV.text = ad.address addressTV.text = ad.address
val prix = (ad.prix.toString()) prixTV.text = "${usingJavaStringFormat(ad.prix, 2)} €"
prixTV.text = "${prix.toBigDecimal().setScale(2, RoundingMode.UP).toDouble()} €"
return convertView return convertView
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment