Add max capacity for folders
This commit is contained in:
parent
c83e7a5226
commit
cca2ceaab9
|
@ -33,6 +33,10 @@ data class HomeScreenGridItem(
|
|||
@Ignore var widthCells: Int = 1,
|
||||
@Ignore var heightCells: Int = 1
|
||||
) {
|
||||
companion object {
|
||||
const val FOLDER_MAX_CAPACITY = 16
|
||||
}
|
||||
|
||||
constructor() : this(null, -1, -1, -1, -1, 0, "", "", "", ITEM_TYPE_ICON, "", -1, "", null, false, null, null, null, null, 1, 1)
|
||||
|
||||
fun getWidthInCells() = if (right == -1 || left == -1) {
|
||||
|
|
|
@ -313,7 +313,12 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
if (it == null) {
|
||||
draggingEnteredNewFolderAt = System.currentTimeMillis()
|
||||
} else if (System.currentTimeMillis() - it > PAGE_CHANGE_HOLD_THRESHOLD) {
|
||||
openFolder(coveredFolder)
|
||||
if (coveredFolder.getFolderItems().count() >= HomeScreenGridItem.FOLDER_MAX_CAPACITY && draggedItem?.parentId != coveredFolder.id) {
|
||||
performHapticFeedback()
|
||||
draggingEnteredNewFolderAt = null
|
||||
} else {
|
||||
openFolder(coveredFolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -597,6 +602,18 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
newParentId: Long? = null,
|
||||
toFolderEnd: Boolean = true
|
||||
) {
|
||||
if (newParentId != null && newParentId != draggedHomeGridItem?.parentId) {
|
||||
gridItems.firstOrNull { it.id == newParentId }?.also {
|
||||
if (it.getFolderItems().count() >= HomeScreenGridItem.FOLDER_MAX_CAPACITY) {
|
||||
performHapticFeedback()
|
||||
draggedItem = null
|
||||
draggedItemCurrentCoords = Pair(-1, -1)
|
||||
redrawGrid()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val finalXIndex = if (newParentId != null) {
|
||||
if (toFolderEnd) {
|
||||
gridItems.firstOrNull { it.id == newParentId }?.getFolderItems()?.maxOf { it.left + 1 } ?: 0
|
||||
|
|
Loading…
Reference in New Issue