Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CU-19bjtt] rating color #101

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app/src/main/java/com/checkin/app/checkin/Shop/utility.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.checkin.app.checkin.Shop

import android.widget.TextView
import com.checkin.app.checkin.R
import com.checkin.app.checkin.home.epoxy.NearbyRestaurantModelHolder
import com.checkin.app.checkin.restaurant.activities.PublicRestaurantProfileActivity


fun PublicRestaurantProfileActivity.changetextviewcolor(rating: Float,tvrating: TextView) {
ratingvalue(rating, tvrating)


}

fun NearbyRestaurantModelHolder.changetextviewcolor(rating: Double, tvrating: TextView) {
ratingvalue(rating.toFloat(), tvrating)


}


private fun ratingvalue(rating: Float,tvrating: TextView) {

when(rating){
in 4.0..5.0 -> tvrating.setBackgroundResource(R.color.apple_green)
in 3.0..4.0 -> tvrating.setBackgroundResource(R.color.md_deep_orange_300)
else -> tvrating.setBackgroundResource(R.color.red_500)

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
import com.checkin.app.checkin.R
import com.checkin.app.checkin.Shop.changetextviewcolor
import com.checkin.app.checkin.home.model.NearbyRestaurantModel
import com.checkin.app.checkin.misc.epoxy.BaseEpoxyHolder
import com.checkin.app.checkin.restaurant.activities.openPublicRestaurantProfile
Expand Down Expand Up @@ -65,6 +66,7 @@ abstract class NearbyRestaurantModelHolder : EpoxyModelWithHolder<NearbyRestaura
}

tvRating.text = data.formatRating
changetextviewcolor(data.ratings,tvRating)
tvDistance.text = data.formatDistance

imDistance.setImageResource(if (data.distance > 1.5) R.drawable.ic_distance_vehicle else R.drawable.ic_distance_walking)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import butterknife.BindView
import butterknife.ButterKnife
import butterknife.OnClick
import com.checkin.app.checkin.R
import com.checkin.app.checkin.Shop.changetextviewcolor
import com.checkin.app.checkin.auth.exceptions.InvalidOTPException
import com.checkin.app.checkin.auth.fragments.OtpVerificationDialog
import com.checkin.app.checkin.auth.fragments.PhoneEditDialog
Expand Down Expand Up @@ -408,6 +409,7 @@ class PublicRestaurantProfileActivity : BaseActivity(), AppBarLayout.OnOffsetCha
} else "-"
} ?: "-"
tvRating.text = restaurantModel.formatRating()
changetextviewcolor(restaurantModel.rating, tvRating)
tvDistance.text = restaurantModel.formatDistance
restaurantModel.restaurantOffers?.let {
tvReferrals.visibility = View.VISIBLE
Expand Down