@@ -4,31 +4,22 @@ import android.content.Context
44import android.os.Build
55import android.support.annotation.DrawableRes
66import android.support.annotation.RequiresApi
7+ import android.support.constraint.ConstraintLayout
78import android.support.design.widget.Snackbar
8- import android.text.Html
99import android.util.AttributeSet
1010import android.view.View
11- import android.widget.LinearLayout
1211import kotlinx.android.synthetic.main.merge_no_favorites_view.view.*
1312import net.squanchy.R
13+ import net.squanchy.support.text.parseHtml
1414
1515class FavoritesSignedInEmptyLayout @JvmOverloads constructor(
1616 context : Context ? ,
1717 attrs : AttributeSet ? = null ,
18- defStyleAttr : Int = 0 ,
19- defStyleRes : Int = 0
20- ) : LinearLayout(context, attrs, defStyleAttr, defStyleRes), FavoritesSignedInEmptyLayoutView {
18+ defStyleAttr : Int = 0
19+ ) : ConstraintLayout(context, attrs, defStyleAttr), FavoritesSignedInEmptyLayoutView {
2120
2221 private var counter = 0
2322
24- init {
25- super .setOrientation(VERTICAL )
26- }
27-
28- override fun setOrientation (orientation : Int ): Nothing {
29- throw UnsupportedOperationException (" Changing orientation is not supported for ${FavoritesSignedInEmptyLayout ::class .java.simpleName} " )
30- }
31-
3223 override fun onFinishInflate () {
3324 super .onFinishInflate()
3425
@@ -41,9 +32,10 @@ class FavoritesSignedInEmptyLayout @JvmOverloads constructor(
4132
4233 override fun setButtonImage (@DrawableRes resId : Int ) = favoriteFab.setImageResource(resId)
4334
44- // TODO do we still need this? Also why is it requiring Nougat?
4535 @RequiresApi(Build .VERSION_CODES .N )
46- override fun showAchievement (message : String ) = Snackbar .make(this , readAsHtml(message), Snackbar .LENGTH_LONG ).show()
36+ override fun showAchievement (message : String ) {
37+ Snackbar .make(this , parseHtml(message), Snackbar .LENGTH_LONG ).show()
38+ }
4739
4840 private val favoriteButtonClickListener = View .OnClickListener {
4941 presentButtonIcon(counter, this , ::favoritesFilledIconId, ::favoritesEmptyIconId)
@@ -57,7 +49,4 @@ class FavoritesSignedInEmptyLayout @JvmOverloads constructor(
5749 private fun initialAchieventMessage () = resources.getString(R .string.favorites_achievement_fast_learner)
5850
5951 private fun perseveranceAchievementMessage () = resources.getString(R .string.favorites_achievement_persevering)
60-
61- @RequiresApi(Build .VERSION_CODES .N )
62- private fun readAsHtml (message : String ): CharSequence = Html .fromHtml(message, Html .FROM_HTML_MODE_LEGACY )
6352}
0 commit comments