I'm trying to do a Parse request but I got this error :
com.parse.ParseObject cannot be cast to com.mysapp.mys.common.model.Lesson
but it doesn't enter inside the subscribe after the return of the request. The answer of the server is good because I have the log of it on real-time.
I believe I have a problem when I receive the answer and when I cast implicitly with the lambda. But I don't know how to achieve it in another way.
fun getLessons(coach: Boolean, lessonType: LessonType?, date: Date?, position: LatLng, distance: Double): Single<List<Lesson>> { val params = hashMapOf<String, Any?>() if (lessonType == null){ params["lessonType"] = "" } else{ } params["lessonType"] = 12 params["date"] = date params["geoPoint"] = ParseGeoPoint(44.557514, -0.86099) params["within"] = 4935.772 Log.e("params : ", "lessonType: " + params.get("lessonType") + "| date : " + params.get("date").toString() + " | geoPoint: " + params.get("geoPoint") + " | within: "+ params.get("within")) return ParseObservable.callFunction<List<Lesson>>("getSessions", params).singleOrError() } how I treat it :
disposables.add(repository.getLessons(false, lesson, dateSelected, position, distance.toDouble()) .observeOn(Schedulers.io()) .subscribe({ lessons -> Log.e("LESSONS", lessons.toString()) removeCanceledLessonsAndEmit(lessons) }, Throwable::printStackTrace) ) I don't know how Parse is working so that's why I have copied on this
request who already exists in the project :
fun getAverageRating(coachId: String): Single<HashMap<String, Int>> { val params = hashMapOf<String, String>() params["coachId"] = coachId return ParseObservable.callFunction<HashMap<String, Int>>("getAverageRating", params).singleOrError() } how it's treated :
disposables.add(repository.getAverageRating(coachId) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ rating -> if (rating > 0) { ratingBar.visibility = View.VISIBLE ratingBar.rating = rating } else ratingBar.visibility = View.GONE }, Throwable::printStackTrace) ) If you need any details feel free to ask me.
ParseObjectto a subclass ofParseObject. Do you have any info on that. I get aClassCastExpectionwhen I try to do that.