andrexpmt's People
andrexpmt's Issues
Drag and drop bug
To run the app just press the play button in intellij.
Im using the android 30 image in the emulator, but the jetpack compose preview feature also exhibits the below behaviour, you just cant run the debugger against that IIUC.
The drag and drop code is from
andrexpmt/comp/src/main/java/com/example/comp/dnd/author
Lines 1 to 4 in f775839
Problem description
Hi folks, I'm doing a homework project in jetpack compose and I have a bug I havent been able to track down after hours of debugging. I only have a basic knowledge of jetpack; the issue is that I'm either getting some stale, or refreshed data in a lambda closure in a composable, I cant tell.
i.e. dataToDrop is wrong in this scope, but everywhere else I've managed to look in the debugger, at any given time the data seems to be correct (except when this code runs):
andrexpmt/comp/src/main/java/com/example/comp/dnd/DragAndDrop.kt
Lines 74 to 79 in f775839
It's passed here:
and I would hope it is a constant reference to the appropriate LetterTileModel object.
I'm trying to drag and drop some tiles onto a game grid, and the drag operation passes a tile model object around, I have a "list" of tiles the user can drag from, and that works fine-ish; when I take a tile out of the list and put it on the grid, the remaining tiles get relabeled just fine, however somehow the stored drop data (the internal identity of the tile) somehow retains the original ordering, and I find this completely incomprehensible.
So if my tiles are [ H Y D P E ] and I take out H and put it on the grid, the remaining tiles show as [ Y D P E ] but their identities are [ H Y D P ], or at least debugging shows that when picking up the remaining tile, the onDrag data will have the labels H Y D P respectively. Placing the Y tile will result in a crash because the "owner" of the H tile is now a TileSocket which doesnt implement move(), and move() is called on the owner.
(This results in various odd behaviors such as the fact that placing every other tile will work (presumably because the incrementing off-by-one issue will not have assigned an already placed identity to the tile yet))
![](https://private-user-images.githubusercontent.com/47436522/295968402-e1f687e0-a674-45ee-a88a-32b276215ed8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2Mjg4MzAsIm5iZiI6MTcxODYyODUzMCwicGF0aCI6Ii80NzQzNjUyMi8yOTU5Njg0MDItZTF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YTM1YWFiMjFkYjdjYTE4MzhlYmU5NTgyMjU4Yzc1MTU2NTMyYzI0ZWQwMzNhMWExODk0M2I0N2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GisIGIRVW3pUOav1b9OPMdcGLA1WaxVKMeztyapY3fo)
The specific issue is that the dataToDrop argument passed through DropTarget to the onDrag callback is the wrong offset list data (but I don't understand how it can end up like that)
The game crashes when placing a tile located after a previously placed tile because the "owner" of the previous tile is now a socket, which doesn't implement move() and throws a TODO() exception, but the actual problem is that the identity of the second tile refers to the first tile's identity, and not that the exception happens
Sidestepping the exception results in placing the identity of the first tile any number of times
(because its not removing the new tile from the playable tile set)
(I don't understand how the displaying list can be correct, but the identities can be offset, when Im not doing any sort of mutation on which tile has which identity, and I don't even have a data structure that manages that as an aggregate, its assigned to tiles individually...I think.)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.