Remove maxWidth logic from SimpleNavigationView since it's not a sidebar anymore

This commit is contained in:
arkon 2020-04-10 18:11:04 -04:00
parent df27138401
commit 92fa8d683a

View File

@ -20,7 +20,6 @@ import com.google.android.material.internal.ScrimInsetsFrameLayout
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import eu.kanade.tachiyomi.R as TR import eu.kanade.tachiyomi.R as TR
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
import kotlin.math.min
@Suppress("LeakingThis") @Suppress("LeakingThis")
@SuppressLint("PrivateResource", "RestrictedApi") @SuppressLint("PrivateResource", "RestrictedApi")
@ -30,11 +29,6 @@ open class SimpleNavigationView @JvmOverloads constructor(
defStyleAttr: Int = 0 defStyleAttr: Int = 0
) : ScrimInsetsFrameLayout(context, attrs, defStyleAttr) { ) : ScrimInsetsFrameLayout(context, attrs, defStyleAttr) {
/**
* Max width of the navigation view.
*/
private var maxWidth: Int
/** /**
* Recycler view containing all the items. * Recycler view containing all the items.
*/ */
@ -54,28 +48,11 @@ open class SimpleNavigationView @JvmOverloads constructor(
R.styleable.NavigationView_elevation, 0).toFloat()) R.styleable.NavigationView_elevation, 0).toFloat())
} }
maxWidth = a.getDimensionPixelSize(R.styleable.NavigationView_android_maxWidth, 0)
a.recycle() a.recycle()
recycler.layoutManager = LinearLayoutManager(context) recycler.layoutManager = LinearLayoutManager(context)
} }
/**
* Overriden to measure the width of the navigation view.
*/
@SuppressLint("SwitchIntDef")
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
val width = when (MeasureSpec.getMode(widthSpec)) {
MeasureSpec.AT_MOST -> MeasureSpec.makeMeasureSpec(
min(MeasureSpec.getSize(widthSpec), maxWidth), MeasureSpec.EXACTLY)
MeasureSpec.UNSPECIFIED -> MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.EXACTLY)
else -> widthSpec
}
// Let super sort out the height
super.onMeasure(width, heightSpec)
}
/** /**
* Base view holder. * Base view holder.
*/ */