优化
This commit is contained in:
@@ -16,7 +16,6 @@ import android.view.animation.Animation
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.constraintlayout.widget.ConstraintSet
|
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
@@ -523,13 +522,13 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
|
|
||||||
private fun upBrightnessVwPos() {
|
private fun upBrightnessVwPos() {
|
||||||
if (AppConfig.brightnessVwPos) {
|
if (AppConfig.brightnessVwPos) {
|
||||||
binding.root.modify()
|
binding.root.modifyBegin()
|
||||||
.clear(R.id.ll_brightness, ConstraintSet.LEFT)
|
.clear(R.id.ll_brightness, ConstraintModify.Anchor.LEFT)
|
||||||
.rightToRightOf(R.id.ll_brightness, R.id.vw_menu_root)
|
.rightToRightOf(R.id.ll_brightness, R.id.vw_menu_root)
|
||||||
.commit()
|
.commit()
|
||||||
} else {
|
} else {
|
||||||
binding.root.modify()
|
binding.root.modifyBegin()
|
||||||
.clear(R.id.ll_brightness, ConstraintSet.RIGHT)
|
.clear(R.id.ll_brightness, ConstraintModify.Anchor.RIGHT)
|
||||||
.leftToLeftOf(R.id.ll_brightness, R.id.vw_menu_root)
|
.leftToLeftOf(R.id.ll_brightness, R.id.vw_menu_root)
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import androidx.constraintlayout.widget.ConstraintSet
|
|||||||
import androidx.transition.TransitionManager
|
import androidx.transition.TransitionManager
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun ConstraintLayout.modify(withAnim: Boolean = false): ConstraintModify.ConstraintBegin {
|
fun ConstraintLayout.modifyBegin(withAnim: Boolean = false): ConstraintModify.ConstraintBegin {
|
||||||
val begin = ConstraintModify(this).begin
|
val begin = ConstraintModify(this).begin
|
||||||
if (withAnim) {
|
if (withAnim) {
|
||||||
TransitionManager.beginDelayedTransition(this)
|
TransitionManager.beginDelayedTransition(this)
|
||||||
@@ -60,15 +60,12 @@ class ConstraintModify(private val constraintLayout: ConstraintLayout) {
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除关系<br></br>
|
* 清除关系,这里不仅仅会清除关系,还会清除对应控件的宽高为 w:0,h:0
|
||||||
* 注意:这里不仅仅会清除关系,还会清除对应控件的宽高为 w:0,h:0
|
* @param viewId 视图ID
|
||||||
* @param viewIds
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
fun clear(@IdRes vararg viewIds: Int): ConstraintBegin {
|
fun clear(viewId: Int): ConstraintBegin {
|
||||||
for (viewId in viewIds) {
|
applyConstraintSet.clear(viewId)
|
||||||
applyConstraintSet.clear(viewId)
|
|
||||||
}
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +75,8 @@ class ConstraintModify(private val constraintLayout: ConstraintLayout) {
|
|||||||
* @param anchor 要解除的关系
|
* @param anchor 要解除的关系
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
fun clear(viewId: Int, anchor: Int): ConstraintBegin {
|
fun clear(viewId: Int, anchor: Anchor): ConstraintBegin {
|
||||||
applyConstraintSet.clear(viewId, anchor)
|
applyConstraintSet.clear(viewId, anchor.toInt())
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,4 +277,22 @@ class ConstraintModify(private val constraintLayout: ConstraintLayout) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class Anchor {
|
||||||
|
LEFT, RIGHT, TOP, BOTTOM, BASELINE, START, END, CIRCLE_REFERENCE;
|
||||||
|
|
||||||
|
fun toInt(): Int {
|
||||||
|
return when (this) {
|
||||||
|
LEFT -> ConstraintSet.LEFT
|
||||||
|
RIGHT -> ConstraintSet.RIGHT
|
||||||
|
TOP -> ConstraintSet.TOP
|
||||||
|
BOTTOM -> ConstraintSet.BOTTOM
|
||||||
|
BASELINE -> ConstraintSet.BASELINE
|
||||||
|
START -> ConstraintSet.START
|
||||||
|
END -> ConstraintSet.END
|
||||||
|
CIRCLE_REFERENCE -> ConstraintSet.CIRCLE_REFERENCE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user