N
N
neitoo2022-04-15 21:21:02
Android
neitoo, 2022-04-15 21:21:02

How to correctly describe class constructor for values ​​from Firebase?

The code:

class Houses(_costV: String, _locationV: String, _roomsV: String, _squareV: String, _image: String, _infoV: String, _put: String, _date: String, _time: String) {
    private var costV: String
    private var locationV: String
    private var roomsV: String
    private var squareV: String
    private var image: String
    private var infoV: String
    private var put: String
    private var date: String
    private var time: String
    init {
        costV=_costV
        locationV=_locationV
        roomsV=_roomsV
        squareV=_squareV
        image=_image
        infoV=_infoV
        put=_put
        date=_date
        time=_time
    }




    fun getCostV(): String {
        return costV
    }

    fun setCostV(costV: String) {
        this.costV = costV
    }

    fun getLocationV(): String {
        return locationV
    }

    fun setLocationV(locationV: String) {
        this.locationV = locationV
    }

    fun getRoomsV(): String {
        return roomsV
    }

    fun setRoomsV(roomsV: String) {
        this.roomsV = roomsV
    }

    fun getSquareV(): String {
        return squareV
    }

    fun setSquareV(squareV: String) {
        this.squareV = squareV
    }

    fun getImage(): String {
        return image
    }

    fun setImage(image: String?) {
        this.image = image!!
    }

    fun getInfoV(): String {
        return infoV
    }

    fun setInfoV(infoV: String) {
        this.infoV = infoV
    }

    fun getPut(): String {
        return put
    }

    fun setPut(put: String) {
        this.put = put
    }

    fun getDate(): String {
        return date
    }

    fun setDate(date: String) {
        this.date = date
    }

    fun getTime(): String {
        return time
    }

    fun setTime(date: String) {
        this.time = date
    }
}


The data in this class should be received from Firebase and then sent to the activity, but in the end it crashes the application with this error:
com.google.firebase.database.DatabaseException: Class ru.homebuy.neito.Model.Houses does not define a no-argument constructor. If you are using ProGuard, make sure these constructors are not stripped.


How to correctly describe the constructor so that the data is normally transmitted and received from the server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacen11, 2022-04-16
@neitoo

god, what a mess. Have you looked at the features of Kotlin at least a little?

class Houses(var costV: String, var  locationV: String, var roomsV: String, var squareV: String, var image: String, var infoV: String, var put: String, var date: String, var time: String)

this is the same as what you did
does not define a no-argument constructor
it is written in black and white
when you did this, did any new problems appear?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question