diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/RestaurantActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/RestaurantActivity.kt index 3e95ea3e..1f4bd47a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/RestaurantActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/RestaurantActivity.kt @@ -2,14 +2,12 @@ package es.verdnatura.presentation.view.feature.restaurant import android.view.View import android.widget.Button -import com.google.gson.Gson import com.google.zxing.BarcodeFormat import com.journeyapps.barcodescanner.BarcodeEncoder import es.verdnatura.R import es.verdnatura.databinding.ActivityRestaurantViewBinding import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseActivity -import es.verdnatura.presentation.view.feature.restaurant.model.UserMenu class RestaurantActivity : BaseActivity() { @@ -33,16 +31,27 @@ class RestaurantActivity : BaseActivity() { binding.imageQr.visibility = View.VISIBLE binding.txtOption.visibility = View.VISIBLE binding.txtOption.text = (view as Button).text.toString() - val userMenu = UserMenu( - user = mobileApplication.userId!!, - menu_id = view.tag.toString().toInt(), - menu = view.text.toString(), - name = mobileApplication.userName!! - ) + /* val userMenu = UserMenu( + user = mobileApplication.userId!!, + menu_id = view.tag.toString().toInt(), + menu = view.text.toString(), + name = mobileApplication.userName!! + )*/ + + val userMenuJson = StringBuilder() + .append("{") + .append("\"user\":").append(mobileApplication.userId).append(",") // Sin comillas + .append("\"menu_id\":").append(view.tag.toString().toInt()).append(",") // Sin comillas + .append("\"menu\":\"").append(view.text).append("\",") // Con comillas porque es texto + .append("\"name\":\"").append(mobileApplication.userName) + .append("\"") // Con comillas porque es texto + .append("}") + .toString() + try { val barcodeEncoder = BarcodeEncoder() val bitmap = barcodeEncoder.encodeBitmap( - Gson().toJson(userMenu), + userMenuJson, BarcodeFormat.QR_CODE, 400, 400 diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/model/UserMenu.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/model/UserMenu.kt index 42157440..631babb9 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/model/UserMenu.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/restaurant/model/UserMenu.kt @@ -1,8 +1,10 @@ package es.verdnatura.presentation.view.feature.restaurant.model +import com.google.gson.annotations.SerializedName + data class UserMenu( - val user: Int, - val menu_id: Int, - val menu: String, - val name: String + @SerializedName("user") val user: Int, + @SerializedName("menu_id") val menu_id: Int, + @SerializedName("menu") val menu: String, + @SerializedName("name") val name: String ) \ No newline at end of file