I have a function named withColor() that is required to be called in class A and class B 's Snackbar class . I don't want to copy paste its code in each of this classes again and again.
 fun Snackbar.withColor(@ColorInt colorInt:Int): Snackbar { this.view.setBackgroundColor(colorInt) return this }
This function is called in Snackbar usage of Class A and class B like this
class A bindinpercentproblemsFragment.radioGroup10Percentage?.setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener{ group, checkedId ->
        val isChecked = bindinpercentproblemsFragment.radioButton37Percentage.isChecked
        if (isChecked) {
            Snackbar.make(requireView(), "Correct", Snackbar.LENGTH_LONG)
                .withColor(Color.rgb(0, 128, 0))
                .show()
        } else {
            Snackbar.make(requireView(), "InCorrect", Snackbar.LENGTH_LONG)
                .withColor(Color.rgb(255, 0, 0))
                .show()
        }
    })
class B
  binding.radioGroup10HCF?.setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener{ group, checkedId ->
        val isChecked = binding.radioButton40HCF.isChecked
        if (isChecked) {
            Snackbar.make(requireView(), "Correct", Snackbar.LENGTH_LONG)
                .withColor(Color.rgb(0, 128, 0))
                .show()
        } else {
            Snackbar.make(requireView(), "InCorrect", Snackbar.LENGTH_LONG)
                .withColor(Color.rgb(255, 0, 0))
                .show()
        }
    })
 
    