1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.launcher3.celllayout 17 18 import android.view.View 19 import com.android.launcher3.celllayout.CellPosMapper.CellPos 20 import com.android.launcher3.model.data.ItemInfo 21 import com.android.launcher3.util.CellAndSpan 22 23 // This class stores info for two purposes: 24 // 1. When dragging items (mDragInfo in Workspace), we store the View, its cellX & cellY, 25 // its spanX, spanY, and the screen it is on 26 // 2. When long clicking on an empty cell in a CellLayout, we save information about the 27 // cellX and cellY coordinates and which page was clicked. We then set this as a tag on 28 // the CellLayout that was long clicked 29 class CellInfo(v: View?, info: ItemInfo, cellPos: CellPos) : 30 CellAndSpan(cellPos.cellX, cellPos.cellY, info.spanX, info.spanY) { 31 @JvmField val cell: View? 32 @JvmField val screenId: Int 33 @JvmField val container: Int 34 35 init { 36 cell = v 37 screenId = cellPos.screenId 38 container = info.container 39 } 40 toStringnull41 override fun toString(): String { 42 return "CellInfo(cell=$cell, screenId=$screenId, container=$container)" 43 } 44 } 45