Skip to content

Commit 06f05e6

Browse files
Provide context manually
1 parent 503f0c9 commit 06f05e6

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

app/src/main/java/org/stepik/android/view/banner/extension/ItemBannerBindingExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fun ItemBannerBinding.bind(banner: Banner, bannerResourcesMapper: BannerResource
2626

2727
val imageRes = bannerResourcesMapper.mapBannerTypeToImageResource(banner.type)
2828
val backgroundColorRes = bannerResourcesMapper.mapBannerTypeToBackgroundColor(banner.type)
29-
val descriptionTextColorRes = bannerResourcesMapper.mapBannerTypeToDescriptionTextColor(banner.type)
29+
val descriptionTextColorRes = bannerResourcesMapper.mapBannerTypeToDescriptionTextColor(root.context, banner.type)
3030

3131
bannerImage.setImageResource(imageRes)
3232
ViewCompat.setBackgroundTintList(root.bannerRoot, AppCompatResources.getColorStateList(root.context, backgroundColorRes))

app/src/main/java/org/stepik/android/view/banner/mapper/BannerResourcesMapper.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import android.content.Context
44
import androidx.annotation.ColorInt
55
import androidx.annotation.ColorRes
66
import androidx.annotation.DrawableRes
7+
import androidx.core.content.ContextCompat
78
import org.stepic.droid.R
8-
import org.stepic.droid.util.resolveColorAttribute
99
import org.stepik.android.domain.banner.model.Banner
1010
import javax.inject.Inject
1111

1212
class BannerResourcesMapper
1313
@Inject
14-
constructor(private val context: Context) {
14+
constructor() {
1515
@DrawableRes
1616
fun mapBannerTypeToImageResource(bannerType: Banner.ColorType?): Int =
1717
when (bannerType) {
@@ -39,12 +39,12 @@ constructor(private val context: Context) {
3939
}
4040

4141
@ColorInt
42-
fun mapBannerTypeToDescriptionTextColor(bannerType: Banner.ColorType?): Int =
42+
fun mapBannerTypeToDescriptionTextColor(context: Context, bannerType: Banner.ColorType?): Int =
4343
when (bannerType) {
4444
Banner.ColorType.BLUE, Banner.ColorType.VIOLET ->
45-
context.resolveColorAttribute(R.attr.colorOnSecondary)
45+
ContextCompat.getColor(context, R.color.white)
4646
Banner.ColorType.GREEN ->
47-
context.resolveColorAttribute(R.attr.colorPrimary)
47+
ContextCompat.getColor(context, R.color.color_primary)
4848
else ->
4949
-1
5050
}

app/src/main/res/layout/item_banner.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
android:maxLines="2"
4141
android:paddingHorizontal="16dp"
4242
android:paddingBottom="16dp"
43-
android:textColor="@color/color_control_normal"
4443
app:fontFamily="@font/stories_medium"
4544
app:layout_constraintBottom_toBottomOf="parent"
4645
app:layout_constraintLeft_toLeftOf="parent"

0 commit comments

Comments
 (0)