Ktlint: do code format
This commit is contained in:
1 parent
04c99a5a36
commit
661bf3ecc2
159 files changed
+1631
-1273
No files matched your search
@@ -85,7 +85,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
binding.refreshLayout.setProgressViewOffset(
|
||||
true,
|
||||
0,
|
||||
fitPaddingTop + LayoutUtils.dp2pix(context, 32f)
|
||||
fitPaddingTop + LayoutUtils.dp2pix(context, 32f),
|
||||
) // TODO
|
||||
}
|
||||
|
||||
@@ -95,25 +95,25 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
binding.recyclerView.paddingLeft,
|
||||
binding.recyclerView.paddingTop,
|
||||
binding.recyclerView.paddingRight,
|
||||
mRecyclerViewOriginBottom + fitPaddingBottom
|
||||
mRecyclerViewOriginBottom + fitPaddingBottom,
|
||||
)
|
||||
binding.tip.setPadding(
|
||||
binding.tip.paddingLeft,
|
||||
binding.tip.paddingTop,
|
||||
binding.tip.paddingRight,
|
||||
fitPaddingBottom
|
||||
fitPaddingBottom,
|
||||
)
|
||||
binding.progress.setPadding(
|
||||
binding.progress.paddingLeft,
|
||||
binding.progress.paddingTop,
|
||||
binding.progress.paddingRight,
|
||||
fitPaddingBottom
|
||||
fitPaddingBottom,
|
||||
)
|
||||
binding.fastScroller.setPadding(
|
||||
binding.fastScroller.paddingLeft,
|
||||
binding.fastScroller.paddingTop,
|
||||
binding.fastScroller.paddingRight,
|
||||
mFastScrollerOriginBottom + fitPaddingBottom
|
||||
mFastScrollerOriginBottom + fitPaddingBottom,
|
||||
)
|
||||
if (fitPaddingBottom > LayoutUtils.dp2pix(context, 16f)) {
|
||||
binding.bottomProgress.setPadding(0, 0, 0, fitPaddingBottom)
|
||||
@@ -206,7 +206,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
mNextPage,
|
||||
null,
|
||||
null,
|
||||
emptyList()
|
||||
emptyList(),
|
||||
)
|
||||
}
|
||||
mCurrentTaskId = mIdGenerator.nextId()
|
||||
@@ -217,7 +217,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
mCurrentTaskType,
|
||||
mCurrentTaskPage,
|
||||
mNext,
|
||||
true
|
||||
true,
|
||||
)
|
||||
} else if (mStartPage > 0 && mEndPage == pages) {
|
||||
binding.bottomProgress.show()
|
||||
@@ -230,7 +230,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
mCurrentTaskType,
|
||||
mCurrentTaskPage,
|
||||
null,
|
||||
true
|
||||
true,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
type: Int,
|
||||
page: Int,
|
||||
index: String?,
|
||||
isNext: Boolean
|
||||
isNext: Boolean,
|
||||
)
|
||||
|
||||
protected abstract val context: Context
|
||||
@@ -327,7 +327,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
nextPage: Int,
|
||||
prev: String?,
|
||||
next: String?,
|
||||
data: List<E>
|
||||
data: List<E>,
|
||||
) {
|
||||
if (mCurrentTaskId == taskId) {
|
||||
val dataSize: Int
|
||||
@@ -410,8 +410,10 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
if (mCurrentTaskType == TYPE_PRE_PAGE_KEEP_POS) {
|
||||
binding.recyclerView.stopScroll()
|
||||
LayoutManagerUtils.scrollToPositionProperly(
|
||||
binding.recyclerView.layoutManager, context,
|
||||
dataSize - 1, mOnScrollToPositionListener
|
||||
binding.recyclerView.layoutManager,
|
||||
context,
|
||||
dataSize - 1,
|
||||
mOnScrollToPositionListener,
|
||||
)
|
||||
} else {
|
||||
scrollToPosition(0)
|
||||
@@ -505,7 +507,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
Log.e(
|
||||
TAG,
|
||||
"TYPE_REFRESH_PAGE, but mCurrentTaskPage = " + mCurrentTaskPage +
|
||||
", mStartPage = " + mStartPage + ", mEndPage = " + mEndPage
|
||||
", mStartPage = " + mStartPage + ", mEndPage = " + mEndPage,
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -522,7 +524,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
removeDuplicateData(
|
||||
data,
|
||||
oldIndexStart - CHECK_DUPLICATE_RANGE,
|
||||
oldIndexStart + CHECK_DUPLICATE_RANGE
|
||||
oldIndexStart + CHECK_DUPLICATE_RANGE,
|
||||
)
|
||||
val newIndexEnd = oldIndexStart + data.size
|
||||
mData.addAll(oldIndexStart, data)
|
||||
@@ -575,7 +577,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
LayoutManagerUtils.scrollToPositionWithOffset(
|
||||
binding.recyclerView.layoutManager,
|
||||
position,
|
||||
0
|
||||
0,
|
||||
)
|
||||
onScrollToPosition(position)
|
||||
}
|
||||
@@ -815,4 +817,4 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
private const val KEY_NEXT = "next"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,9 @@ import com.hippo.yorozuya.AnimationUtils
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener
|
||||
|
||||
class FabLayout @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
) : ViewGroup(context, attrs, defStyleAttr), View.OnClickListener {
|
||||
private var mFabSize = 0
|
||||
private var mFabMiniSize = 0
|
||||
@@ -92,7 +94,9 @@ class FabLayout @JvmOverloads constructor(
|
||||
private fun getSecondaryFabAt(index: Int): FloatingActionButton? {
|
||||
return if (index < 0 || index >= secondaryFabCount) {
|
||||
null
|
||||
} else getChildAt(index) as FloatingActionButton
|
||||
} else {
|
||||
getChildAt(index) as FloatingActionButton
|
||||
}
|
||||
}
|
||||
|
||||
fun setSecondaryFabVisibilityAt(index: Int, visible: Boolean) {
|
||||
@@ -152,7 +156,7 @@ class FabLayout @JvmOverloads constructor(
|
||||
maxWidth = maxWidth.coerceAtLeast(suggestedMinimumWidth)
|
||||
setMeasuredDimension(
|
||||
resolveSizeAndState(maxWidth, widthMeasureSpec, 0),
|
||||
resolveSizeAndState(maxHeight, heightMeasureSpec, 0)
|
||||
resolveSizeAndState(maxHeight, heightMeasureSpec, 0),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -185,7 +189,7 @@ class FabLayout @JvmOverloads constructor(
|
||||
layoutRight - childWidth,
|
||||
layoutBottom - childHeight,
|
||||
layoutRight,
|
||||
layoutBottom
|
||||
layoutBottom,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -378,12 +382,14 @@ class FabLayout @JvmOverloads constructor(
|
||||
override fun onClick(v: View) {
|
||||
if (this === v) {
|
||||
isExpanded = false
|
||||
} else mOnClickFabListener?.let {
|
||||
val position = indexOfChild(v)
|
||||
if (position == childCount - 1) {
|
||||
it.onClickPrimaryFab(this, v as FloatingActionButton)
|
||||
} else if (position >= 0 && mExpanded) {
|
||||
it.onClickSecondaryFab(this, v as FloatingActionButton, position)
|
||||
} else {
|
||||
mOnClickFabListener?.let {
|
||||
val position = indexOfChild(v)
|
||||
if (position == childCount - 1) {
|
||||
it.onClickPrimaryFab(this, v as FloatingActionButton)
|
||||
} else if (position >= 0 && mExpanded) {
|
||||
it.onClickSecondaryFab(this, v as FloatingActionButton, position)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,4 +429,4 @@ class FabLayout @JvmOverloads constructor(
|
||||
private const val STATE_KEY_AUTO_CANCEL = "auto_cancel"
|
||||
private const val STATE_KEY_EXPANDED = "expanded"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,11 @@ private val application = EhApplication.application
|
||||
private val errorDrawable = AppCompatResources.getDrawable(application, R.drawable.image_failed)
|
||||
|
||||
open class LoadImageView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
) : FixedAspectImageView(context, attrs, defStyleAttr), View.OnClickListener,
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
) : FixedAspectImageView(context, attrs, defStyleAttr),
|
||||
View.OnClickListener,
|
||||
View.OnLongClickListener {
|
||||
private var mOffsetX = Integer.MIN_VALUE
|
||||
private var mOffsetY = Integer.MIN_VALUE
|
||||
@@ -90,7 +93,7 @@ open class LoadImageView @JvmOverloads constructor(
|
||||
super.setImageDrawable(errorDrawable)
|
||||
setRetry(true)
|
||||
},
|
||||
{ _, _ -> setRetry(false) }
|
||||
{ _, _ -> setRetry(false) },
|
||||
)
|
||||
ehUrl(url)
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ class AutoGridLayoutManager(context: Context?, columnSize: Int, private var fake
|
||||
val spanCount = when (mStrategy) {
|
||||
STRATEGY_MIN_SIZE -> getSpanCountForMinSize(
|
||||
totalSpace,
|
||||
mColumnSize
|
||||
mColumnSize,
|
||||
)
|
||||
|
||||
STRATEGY_SUITABLE_SIZE -> getSpanCountForSuitableSize(
|
||||
totalSpace,
|
||||
mColumnSize
|
||||
mColumnSize,
|
||||
)
|
||||
|
||||
else -> getSpanCountForMinSize(totalSpace, mColumnSize)
|
||||
@@ -67,4 +67,4 @@ class AutoGridLayoutManager(context: Context?, columnSize: Int, private var fake
|
||||
}
|
||||
super.onLayoutChildren(recycler, state)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,38 +51,38 @@ class AutoStaggeredGridLayoutManager(columnSize: Int, orientation: Int) :
|
||||
recycler: RecyclerView.Recycler,
|
||||
state: RecyclerView.State,
|
||||
widthSpec: Int,
|
||||
heightSpec: Int
|
||||
heightSpec: Int,
|
||||
) {
|
||||
if (mColumnSizeChanged && mColumnSize > 0) {
|
||||
val totalSpace = if (orientation == VERTICAL) {
|
||||
check(
|
||||
View.MeasureSpec.EXACTLY == View.MeasureSpec.getMode(
|
||||
widthSpec
|
||||
)
|
||||
widthSpec,
|
||||
),
|
||||
) { "RecyclerView need a fixed width for AutoStaggeredGridLayoutManager" }
|
||||
View.MeasureSpec.getSize(widthSpec) - paddingRight - paddingLeft
|
||||
} else {
|
||||
check(
|
||||
View.MeasureSpec.EXACTLY == View.MeasureSpec.getMode(
|
||||
heightSpec
|
||||
)
|
||||
heightSpec,
|
||||
),
|
||||
) { "RecyclerView need a fixed height for AutoStaggeredGridLayoutManager" }
|
||||
View.MeasureSpec.getSize(heightSpec) - paddingTop - paddingBottom
|
||||
}
|
||||
val spanCount = when (mStrategy) {
|
||||
STRATEGY_MIN_SIZE -> getSpanCountForMinSize(
|
||||
totalSpace,
|
||||
mColumnSize
|
||||
mColumnSize,
|
||||
)
|
||||
|
||||
STRATEGY_SUITABLE_SIZE -> getSpanCountForSuitableSize(
|
||||
totalSpace,
|
||||
mColumnSize
|
||||
mColumnSize,
|
||||
)
|
||||
|
||||
else -> getSpanCountForMinSize(
|
||||
totalSpace,
|
||||
mColumnSize
|
||||
mColumnSize,
|
||||
)
|
||||
}
|
||||
setSpanCount(spanCount)
|
||||
@@ -100,4 +100,4 @@ fun getSpanCountForSuitableSize(total: Int, single: Int): Int {
|
||||
|
||||
fun getSpanCountForMinSize(total: Int, single: Int): Int {
|
||||
return (total / single).coerceAtLeast(1)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user