Do ktlint format
This commit is contained in:
1 parent
5d8acd9577
commit
a85f3cbe0b
7 files changed
+56
-54
No files matched your search
@@ -24,15 +24,12 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
private var drawerLayout: DrawerLayout? = null
|
||||
private var mAboveSnackViewList: MutableList<View>? = null
|
||||
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(
|
||||
context!!, attrs
|
||||
) {
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs) {
|
||||
helper = FullDraggableHelper(context, this)
|
||||
}
|
||||
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(
|
||||
context!!, attrs, defStyle
|
||||
) {
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) :
|
||||
super(context!!, attrs, defStyle) {
|
||||
helper = FullDraggableHelper(context, this)
|
||||
}
|
||||
|
||||
@@ -65,8 +62,8 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
}
|
||||
|
||||
override fun hasEnabledDrawer(gravity: Int): Boolean {
|
||||
return (drawerLayout!!.getDrawerLockMode(gravity) == DrawerLayout.LOCK_MODE_UNLOCKED
|
||||
&& findDrawerWithGravity(gravity) != null)
|
||||
return drawerLayout!!.getDrawerLockMode(gravity) == DrawerLayout.LOCK_MODE_UNLOCKED &&
|
||||
findDrawerWithGravity(gravity) != null
|
||||
}
|
||||
|
||||
override fun offsetDrawer(gravity: Int, offset: Float) {
|
||||
@@ -110,7 +107,7 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
val method = DrawerLayout::class.java.getDeclaredMethod(
|
||||
"moveDrawerToOffset",
|
||||
View::class.java,
|
||||
Float::class.javaPrimitiveType
|
||||
Float::class.javaPrimitiveType,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(drawerLayout, drawerView, slideOffsetPercent)
|
||||
@@ -124,9 +121,8 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
// Copied from DrawerLayout
|
||||
private fun findDrawerWithGravity(gravity: Int): View? {
|
||||
val absHorizontalGravity = GravityCompat.getAbsoluteGravity(
|
||||
gravity, ViewCompat.getLayoutDirection(
|
||||
drawerLayout!!
|
||||
)
|
||||
gravity,
|
||||
ViewCompat.getLayoutDirection(drawerLayout!!),
|
||||
) and Gravity.HORIZONTAL_GRAVITY_MASK
|
||||
val childCount = drawerLayout!!.childCount
|
||||
for (i in 0 until childCount) {
|
||||
@@ -144,7 +140,7 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
val gravity = (drawerView.layoutParams as DrawerLayout.LayoutParams).gravity
|
||||
return GravityCompat.getAbsoluteGravity(
|
||||
gravity,
|
||||
ViewCompat.getLayoutDirection(drawerLayout!!)
|
||||
ViewCompat.getLayoutDirection(drawerLayout!!),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -181,7 +177,7 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
override fun layoutDependsOn(
|
||||
parent: CoordinatorLayout,
|
||||
child: AboveSnackerLayout,
|
||||
dependency: View
|
||||
dependency: View,
|
||||
): Boolean {
|
||||
return dependency is SnackbarLayout
|
||||
}
|
||||
@@ -189,7 +185,7 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
override fun onDependentViewChanged(
|
||||
parent: CoordinatorLayout,
|
||||
child: AboveSnackerLayout,
|
||||
dependency: View
|
||||
dependency: View,
|
||||
): Boolean {
|
||||
for (i in 0 until child.aboveSnackViewCount) {
|
||||
val view = child.getAboveSnackViewAt(i)
|
||||
@@ -207,7 +203,7 @@ class AboveSnackerLayout : FrameLayout, AttachedBehavior, FullDraggableHelper.Ca
|
||||
override fun onDependentViewRemoved(
|
||||
parent: CoordinatorLayout,
|
||||
child: AboveSnackerLayout,
|
||||
dependency: View
|
||||
dependency: View,
|
||||
) {
|
||||
for (i in 0 until child.aboveSnackViewCount) {
|
||||
val view = child.getAboveSnackViewAt(i)
|
||||
|
||||
@@ -96,7 +96,7 @@ open class EasyRecyclerView : RecyclerView {
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyle
|
||||
defStyle,
|
||||
) {
|
||||
init(context)
|
||||
}
|
||||
@@ -143,7 +143,9 @@ open class EasyRecyclerView : RecyclerView {
|
||||
fun isItemChecked(position: Int): Boolean {
|
||||
return if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null) {
|
||||
mCheckStates!![position]
|
||||
} else false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
val checkedItemPositions: SparseBooleanArray?
|
||||
@@ -158,7 +160,9 @@ open class EasyRecyclerView : RecyclerView {
|
||||
*/
|
||||
get() = if (mChoiceMode != CHOICE_MODE_NONE) {
|
||||
mCheckStates
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
fun intoCustomChoiceMode() {
|
||||
if (mChoiceMode == CHOICE_MODE_MULTIPLE_CUSTOM && !isInCustomChoice) {
|
||||
@@ -217,13 +221,10 @@ open class EasyRecyclerView : RecyclerView {
|
||||
|
||||
// Start selection mode if needed. We don't need to if we're unchecking something.
|
||||
if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode == null) {
|
||||
check(
|
||||
!(mMultiChoiceModeCallback == null ||
|
||||
!mMultiChoiceModeCallback!!.hasWrappedCallback())
|
||||
) {
|
||||
check(mMultiChoiceModeCallback != null && mMultiChoiceModeCallback!!.hasWrappedCallback()) {
|
||||
"EasyRecyclerView: attempted to start selection mode " +
|
||||
"for CHOICE_MODE_MULTIPLE_MODAL but no choice mode callback was " +
|
||||
"supplied. Call setMultiChoiceModeListener to set a callback."
|
||||
"for CHOICE_MODE_MULTIPLE_MODAL but no choice mode callback was " +
|
||||
"supplied. Call setMultiChoiceModeListener to set a callback."
|
||||
}
|
||||
mChoiceActionMode = startActionMode(mMultiChoiceModeCallback)
|
||||
}
|
||||
@@ -242,7 +243,7 @@ open class EasyRecyclerView : RecyclerView {
|
||||
mChoiceActionMode!!,
|
||||
i,
|
||||
id,
|
||||
true
|
||||
true,
|
||||
)
|
||||
}
|
||||
if (mChoiceMode == CHOICE_MODE_MULTIPLE_CUSTOM) {
|
||||
@@ -277,13 +278,10 @@ open class EasyRecyclerView : RecyclerView {
|
||||
|
||||
// Start selection mode if needed. We don't need to if we're unchecking something.
|
||||
if (value && mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode == null) {
|
||||
check(
|
||||
!(mMultiChoiceModeCallback == null ||
|
||||
!mMultiChoiceModeCallback!!.hasWrappedCallback())
|
||||
) {
|
||||
check(mMultiChoiceModeCallback != null && mMultiChoiceModeCallback!!.hasWrappedCallback()) {
|
||||
"EasyRecyclerView: attempted to start selection mode " +
|
||||
"for CHOICE_MODE_MULTIPLE_MODAL but no choice mode callback was " +
|
||||
"supplied. Call setMultiChoiceModeListener to set a callback."
|
||||
"for CHOICE_MODE_MULTIPLE_MODAL but no choice mode callback was " +
|
||||
"supplied. Call setMultiChoiceModeListener to set a callback."
|
||||
}
|
||||
mChoiceActionMode = startActionMode(mMultiChoiceModeCallback)
|
||||
}
|
||||
@@ -306,10 +304,8 @@ open class EasyRecyclerView : RecyclerView {
|
||||
}
|
||||
if (mChoiceActionMode != null) {
|
||||
val id = mAdapter!!.getItemId(position)
|
||||
mMultiChoiceModeCallback!!.onItemCheckedStateChanged(
|
||||
mChoiceActionMode!!,
|
||||
position, id, value
|
||||
)
|
||||
mMultiChoiceModeCallback!!
|
||||
.onItemCheckedStateChanged(mChoiceActionMode!!, position, id, value)
|
||||
}
|
||||
if (mChoiceMode == CHOICE_MODE_MULTIPLE_CUSTOM) {
|
||||
val id = mAdapter!!.getItemId(position)
|
||||
@@ -448,7 +444,9 @@ open class EasyRecyclerView : RecyclerView {
|
||||
*/
|
||||
fun onItemCheckedStateChanged(
|
||||
mode: ActionMode,
|
||||
position: Int, id: Long, checked: Boolean
|
||||
position: Int,
|
||||
id: Long,
|
||||
checked: Boolean,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -462,7 +460,7 @@ open class EasyRecyclerView : RecyclerView {
|
||||
view: EasyRecyclerView,
|
||||
position: Int,
|
||||
id: Long,
|
||||
checked: Boolean
|
||||
checked: Boolean,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -591,7 +589,9 @@ open class EasyRecyclerView : RecyclerView {
|
||||
|
||||
override fun onItemCheckedStateChanged(
|
||||
mode: ActionMode,
|
||||
position: Int, id: Long, checked: Boolean
|
||||
position: Int,
|
||||
id: Long,
|
||||
checked: Boolean,
|
||||
) {
|
||||
mWrapped!!.onItemCheckedStateChanged(mode, position, id, checked)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class FastScroller : View {
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
defStyleAttr,
|
||||
) {
|
||||
init(context, attrs, defStyleAttr)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class FastScroller : View {
|
||||
}
|
||||
check(mRecyclerView == null) {
|
||||
"The FastScroller is already attached to a RecyclerView, " +
|
||||
"call detachedFromRecyclerView first"
|
||||
"call detachedFromRecyclerView first"
|
||||
}
|
||||
mRecyclerView = recyclerView
|
||||
mOnScrollChangeListener = object : RecyclerView.OnScrollListener() {
|
||||
|
||||
@@ -33,7 +33,7 @@ object LayoutManagerUtils {
|
||||
try {
|
||||
sCsdfp = StaggeredGridLayoutManager::class.java.getDeclaredMethod(
|
||||
"calculateScrollDirectionForPosition",
|
||||
Int::class.javaPrimitiveType
|
||||
Int::class.javaPrimitiveType,
|
||||
).apply { isAccessible = true }
|
||||
} catch (e: NoSuchMethodException) {
|
||||
// Ignore
|
||||
@@ -42,7 +42,9 @@ object LayoutManagerUtils {
|
||||
}
|
||||
|
||||
fun scrollToPositionWithOffset(
|
||||
layoutManager: RecyclerView.LayoutManager, position: Int, offset: Int
|
||||
layoutManager: RecyclerView.LayoutManager,
|
||||
position: Int,
|
||||
offset: Int,
|
||||
) {
|
||||
when (layoutManager) {
|
||||
is LinearLayoutManager -> layoutManager.scrollToPositionWithOffset(position, offset)
|
||||
@@ -56,8 +58,10 @@ object LayoutManagerUtils {
|
||||
|
||||
@JvmOverloads
|
||||
fun smoothScrollToPosition(
|
||||
layoutManager: RecyclerView.LayoutManager, context: Context?, position: Int,
|
||||
millisecondsPerInch: Int = -1
|
||||
layoutManager: RecyclerView.LayoutManager,
|
||||
context: Context?,
|
||||
position: Int,
|
||||
millisecondsPerInch: Int = -1,
|
||||
) {
|
||||
val smoothScroller: SimpleSmoothScroller
|
||||
when (layoutManager) {
|
||||
@@ -102,7 +106,9 @@ object LayoutManagerUtils {
|
||||
|
||||
fun scrollToPositionProperly(
|
||||
layoutManager: RecyclerView.LayoutManager,
|
||||
context: Context?, position: Int, listener: OnScrollToPositionListener?
|
||||
context: Context?,
|
||||
position: Int,
|
||||
listener: OnScrollToPositionListener?,
|
||||
) {
|
||||
SimpleHandler.postDelayed({
|
||||
val first = getFirstVisibleItemPosition(layoutManager)
|
||||
@@ -111,8 +117,10 @@ object LayoutManagerUtils {
|
||||
val max = last - first
|
||||
if (offset < max && max > 0) {
|
||||
smoothScrollToPosition(
|
||||
layoutManager, context, position,
|
||||
MathUtils.lerp(100F, 25F, (offset / max).toFloat()).toInt()
|
||||
layoutManager,
|
||||
context,
|
||||
position,
|
||||
MathUtils.lerp(100F, 25F, (offset / max).toFloat()).toInt(),
|
||||
)
|
||||
} else {
|
||||
scrollToPositionWithOffset(layoutManager, position, 0)
|
||||
|
||||
@@ -52,7 +52,7 @@ class RadioGridGroup : SimpleGridLayout {
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyle
|
||||
defStyle,
|
||||
) {
|
||||
init(context, attrs)
|
||||
}
|
||||
@@ -221,9 +221,7 @@ class RadioGridGroup : SimpleGridLayout {
|
||||
id = generateViewId()
|
||||
child.setId(id)
|
||||
}
|
||||
child.setOnCheckedChangeListener(
|
||||
mChildOnCheckedChangeListener
|
||||
)
|
||||
child.setOnCheckedChangeListener(mChildOnCheckedChangeListener)
|
||||
}
|
||||
mOnHierarchyChangeListener?.onChildViewAdded(parent, child)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ open class SimpleGridLayout : ViewGroup {
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyle
|
||||
defStyle,
|
||||
) {
|
||||
init(context, attrs)
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ class DownloadsScene :
|
||||
val items = arrayOf(
|
||||
getString(R.string.let_me_select),
|
||||
getString(R.string.default_download_label_name),
|
||||
*list
|
||||
*list,
|
||||
)
|
||||
BaseDialogBuilder(requireContext())
|
||||
.setTitle(R.string.default_download_label)
|
||||
|
||||
Reference in new issue
Block a user