Untitled

mail@pastecode.io avatar
unknown
kotlin
2 years ago
5.0 kB
2
Indexable
Never
        grid.onItemClickListener = OnItemClickListener { parent, view, position, id ->
            val selectedItem = parent.getItemAtPosition(position) as GridElement
            lateinit var currentElement: String

            println("$currentCombinationPosition he re ")


                if(falseclickposition == "Before") {
                    if (satisfied < falseclickcount) {
                        if (currentCombinationPosition == 0 && satisfied < falseclickcount) {
                            satisfied++

                            updateBottomSheet(toptext, inputtednum, bottomSheetAdapter)
                            return@OnItemClickListener
                        }
                    }
                }

                if(falseclickposition == "After" && currentCombinationPosition == combination.chunked(5).size){
                    if(satisfied < falseclickcount){
                            satisfied++
                        updateBottomSheet(toptext, inputtednum, bottomSheetAdapter)
                        return@OnItemClickListener
                        }
                }



            currentElement = arrowCombinations[currentCombinationPosition]

            println("Curr el: $currentElement")
            if(currentElement == "ArrLi" || currentElement == "ArrRi" || currentElement == "ArrTi" || currentElement == "ArrBl"
                || currentElement == "ArrTw" || currentElement == "ArrDb") {
                gridElementsArray.forEachIndexed { index, arrayOfGridElements ->
                    arrayOfGridElements.forEachIndexed { sndindex, gridElement ->
                        if(gridElement == selectedItem){
                            if(currentElement == "ArrLi") {
                                val leftElement = gridElementsArray.getOrNull(index)?.getOrNull(sndindex+1)
                                if(leftElement?.img?.key == "LeFtArRoW"){
                                    inputtedElements.add(leftElement)
                                    currentCombinationPosition++
                                } else if(leftElement == null){
                                    println("Adding null!!")
                                    inputtedElements.add(null)
                                }
                            } else if(currentElement == "ArrRi"){
                                val rightArrow = gridElementsArray.getOrNull(index)?.getOrNull(sndindex - 1)
                                if(rightArrow?.img?.key == "RiGhTaRrOw"){
                                    inputtedElements.add(rightArrow)
                                    currentCombinationPosition++
                                }
                            } else if(currentElement == "ArrTi") {
                                val topArrow = gridElementsArray.getOrNull(index+1)?.getOrNull(sndindex)
                                if (topArrow?.img?.key == "ToPaRrOw") {
                                    inputtedElements.add(topArrow)
                                    currentCombinationPosition++
                                }
                            }
                            else if(currentElement == "ArrBl"){
                                val bottomImgArrow = gridElementsArray[index - 1][sndindex + 1]
                                if(bottomImgArrow.img.key == "BoTtOmArRoW"){
                                    inputtedElements.add(bottomImgArrow)
                                    currentCombinationPosition++
                                }
                            }
                            else if(currentElement == "ArrTw"){
                                val TopArrow = gridElementsArray.getOrNull(index + 1)?.getOrNull(sndindex)
                                if(TopArrow?.whiteNumber?.key == "ArRoWuP"){
                                    inputtedElements.add(TopArrow)
                                    currentCombinationPosition++
                                }
                            }

                            else if(currentElement == "ArrDb"){
                                val downArrow = gridElementsArray.getOrNull(index - 1)?.getOrNull(sndindex)
                                if(downArrow?.blackNumber?.key == "ArRoWdOwNbLaCk"){
                                    inputtedElements.add(downArrow)
                                    currentCombinationPosition++
                                }
                            }
                        }
                    }
                }
            } else {
                inputtedElements.add(selectedItem)
                if(falseclickposition == "Before"){
                    if(satisfied >= falseclickcount){

                        currentCombinationPosition++
                    }
                } else {
                    currentCombinationPosition++
                }

            }




            updateBottomSheet(toptext, inputtednum, bottomSheetAdapter)
        }