I was trying to create a class
class TestingModel {
companion object {
const val IMAGE_SLIDER: Int = 0
const val TRENDING_ADS: Int = 1
}
var viewType: Int? = 0
var imageSliderList: List<SlideModel>? = null
var adsList: List<HomeTrendingAdsModel>? = null
var categoryList: List<HomeCategoryModel>? = null
constructor(viewType: Int?, imageSliderList: List<SlideModel>? = null) {
this.viewType = viewType
this.imageSliderList = imageSliderList
}
constructor(viewType: Int?, adsList: List<HomeTrendingAdsModel>?) {
this.viewType = viewType
this.adsList = adsList
}
constructor(viewType: Int?, categoryList: List<HomeCategoryModel>?) {
this.viewType = viewType
this.categoryList = categoryList
}
}
However, I got an error saying
Platform declaration clash: The following declarations have the same JVM signature ( (Ljava/lang/Integer;Ljava/util/List;)V):
public constructor TestingModel(viewType: Int?, imageSliderList: List<SlideModel>? = ...) defined in com.example.theads.Model.TestingModel
public constructor TestingModel(viewType: Int?, categoryList: List<HomeCategoryModel>?) defined in com.example.theads.Model.TestingModel
public constructor TestingModel(viewType: Int?, adsList: List<HomeTrendingAdsModel>?) defined in com.example.theads.Model.TestingModel
I saw in a library doing exactly the same without error.
Edit: That other library is below:
class SlideModel {
var imageUrl: String? = null
var imagePath: Int? = 0
var title: String? = null
var scaleType: ScaleTypes? = null
constructor(imageUrl: String?, title: String? = null, scaleType: ScaleTypes? = null) {
this.imageUrl = imageUrl
this.title = title
this.scaleType = scaleType
}
constructor(imagePath: Int?, title: String? = null, scaleType: ScaleTypes? = null) {
this.imagePath = imagePath
this.title = title
this.scaleType = scaleType
}
constructor(imageUrl: String?, scaleType: ScaleTypes?) {
this.imageUrl = imageUrl
this.scaleType = scaleType
}
constructor(imagePath: Int?, scaleType: ScaleTypes?) {
this.imagePath = imagePath
this.scaleType = scaleType
}
}
I'm creating a recycler view with multiple recyclerviews in it. So this class becomes a model class for that recyclerview and I want it to call viewType and differnet list from other model classes. Thank you