fixup! AppDetails: Fix user review + minor cleanup
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -717,6 +717,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
|
|
||||||
updateAppDescription(app)
|
updateAppDescription(app)
|
||||||
updateAppRatingAndReviews(app)
|
updateAppRatingAndReviews(app)
|
||||||
|
updateUserReview()
|
||||||
updateAppDevInfo(app)
|
updateAppDevInfo(app)
|
||||||
updateAppPermission(app)
|
updateAppPermission(app)
|
||||||
|
|
||||||
@@ -828,26 +829,25 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUserReview(review: Review) {
|
private fun updateUserReview(review: Review? = null) {
|
||||||
binding.layoutDetailsReview.apply {
|
binding.layoutDetailsReview.apply {
|
||||||
layoutUserReview.visibility = View.VISIBLE
|
layoutUserReview.isVisible = !authProvider.isAnonymous
|
||||||
inputTitle.setText(review.title)
|
btnPostReview.setOnClickListener {
|
||||||
inputReview.setText(review.comment)
|
viewModel.postAppReview(
|
||||||
userStars.rating = review.rating.toFloat()
|
app.packageName,
|
||||||
|
Review(
|
||||||
|
title = inputTitle.text.toString(),
|
||||||
|
rating = userStars.rating.toInt(),
|
||||||
|
comment = inputReview.text.toString()
|
||||||
|
),
|
||||||
|
app.testingProgram?.isSubscribed ?: false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (!authProvider.isAnonymous && app.isInstalled) {
|
if (review != null) {
|
||||||
btnPostReview.setOnClickListener {
|
inputTitle.setText(review.title)
|
||||||
addOrUpdateReview(
|
inputReview.setText(review.comment)
|
||||||
app,
|
userStars.rating = review.rating.toFloat()
|
||||||
Review().apply {
|
|
||||||
title = inputTitle.text.toString()
|
|
||||||
rating = userStars.rating.toInt()
|
|
||||||
comment = inputReview.text.toString()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
layoutUserReview.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1025,8 +1025,4 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
private fun addAvgReviews(number: Int, max: Long, rating: Long): RelativeLayout {
|
private fun addAvgReviews(number: Int, max: Long, rating: Long): RelativeLayout {
|
||||||
return RatingView(requireContext(), number, max.toInt(), rating.toInt())
|
return RatingView(requireContext(), number, max.toInt(), rating.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addOrUpdateReview(app: App, review: Review, isBeta: Boolean = false) {
|
|
||||||
viewModel.postAppReview(app.packageName, review, isBeta)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user