mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-12-18 08:41:03 +00:00
fix category display
This commit is contained in:
@ -88,7 +88,7 @@ class CategoryProductsActivity : AppCompatActivity() {
|
|||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
supportActionBar?.apply {
|
supportActionBar?.apply {
|
||||||
setDisplayHomeAsUpEnabled(true)
|
setDisplayHomeAsUpEnabled(true)
|
||||||
// title = category.name
|
title = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
val fullImageUrl = when (val img = category.image) {
|
val fullImageUrl = when (val img = category.image) {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package com.alya.ecommerce_serang.ui.product.category
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.alya.ecommerce_serang.BuildConfig
|
import com.alya.ecommerce_serang.BuildConfig.BASE_URL
|
||||||
import com.alya.ecommerce_serang.R
|
import com.alya.ecommerce_serang.R
|
||||||
import com.alya.ecommerce_serang.data.api.dto.ProductsItem
|
import com.alya.ecommerce_serang.data.api.dto.ProductsItem
|
||||||
import com.alya.ecommerce_serang.databinding.ItemProductGridBinding
|
import com.alya.ecommerce_serang.databinding.ItemProductGridBinding
|
||||||
@ -46,8 +46,15 @@ class ProductsCategoryAdapter(
|
|||||||
val priceValue = product.price.toDoubleOrNull() ?: 0.0
|
val priceValue = product.price.toDoubleOrNull() ?: 0.0
|
||||||
tvProductPrice.text = "Rp ${NumberFormat.getNumberInstance(Locale("id", "ID")).format(priceValue.toInt())}"
|
tvProductPrice.text = "Rp ${NumberFormat.getNumberInstance(Locale("id", "ID")).format(priceValue.toInt())}"
|
||||||
// Load product image
|
// Load product image
|
||||||
|
|
||||||
|
val fullImageUrl = when (val img = product.image) {
|
||||||
|
is String -> {
|
||||||
|
if (img.startsWith("/")) BASE_URL + img.substring(1) else img
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
Glide.with(itemView.context)
|
Glide.with(itemView.context)
|
||||||
.load("${BuildConfig.BASE_URL}${product.image}")
|
.load(fullImageUrl)
|
||||||
.placeholder(R.drawable.placeholder_image)
|
.placeholder(R.drawable.placeholder_image)
|
||||||
.error(R.drawable.placeholder_image)
|
.error(R.drawable.placeholder_image)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
@ -57,15 +64,6 @@ class ProductsCategoryAdapter(
|
|||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
onClick(product)
|
onClick(product)
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Optional: Show stock status
|
|
||||||
// if (product.stock > 0) {
|
|
||||||
// tvStockStatus.text = "Stock: ${product.stock}"
|
|
||||||
// tvStockStatus.setTextColor(ContextCompat.getColor(itemView.context, R.color.green))
|
|
||||||
// } else {
|
|
||||||
// tvStockStatus.text = "Out of Stock"
|
|
||||||
// tvStockStatus.setTextColor(ContextCompat.getColor(itemView.context, R.color.red))
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,10 +28,10 @@
|
|||||||
app:layout_collapseMode="parallax"
|
app:layout_collapseMode="parallax"
|
||||||
android:contentDescription="Category Header Image" />
|
android:contentDescription="Category Header Image" />
|
||||||
|
|
||||||
<View
|
<!-- <View-->
|
||||||
android:layout_width="match_parent"
|
<!-- android:layout_width="match_parent"-->
|
||||||
android:layout_height="match_parent"
|
<!-- android:layout_height="match_parent"-->
|
||||||
android:background="@color/blue_50" />
|
<!-- android:background="@color/blue_50" />-->
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
|
|||||||
Reference in New Issue
Block a user