-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample kanban board app implementation #39
Conversation
Codecov Report
@@ Coverage Diff @@
## main #39 +/- ##
==========================================
- Coverage 78.94% 78.59% -0.36%
==========================================
Files 44 44
Lines 1724 1733 +9
Branches 250 250
==========================================
+ Hits 1361 1362 +1
- Misses 224 232 +8
Partials 139 139
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
||
class KanbanActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityKanbanBinding | ||
private val viewModel: KanbanViewModel by lazy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use viewModels
extension here :)
private val itemsListener: (ViewGroup, Pair<String, List<String>>) -> Unit, | ||
private val itemAddListener: (ViewGroup, String, String) -> Unit, | ||
private val cardDeleteListener: (String) -> Unit, | ||
) : RecyclerView.Adapter<KanbanCardAdapter.KanbanCardViewHolder>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are not going to use Compose... we should at least use ListAdapter.
@@ -196,6 +196,13 @@ public class Document private constructor( | |||
return root.toJson() | |||
} | |||
|
|||
public fun getRoot(): JsonObject { | |||
ensureClone() | |||
val clone = requireNotNull(clone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made ensureClone
to return the clone instance, so we can change to val clone = ensureClone()
ensureClone() | ||
val clone = requireNotNull(clone) | ||
val context = ChangeContext(changeID.next(), clone, null) | ||
return JsonObject(context, clone.rootObject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels kinda weird to me :(
we are returning a mutable JsonObject but changes will have no effect...
maybe we should consider creating a immutable read-only Json elements for this use-case. 🤔
} | ||
} catch (e: Exception) { | ||
// TODO(7hong): handle ConcurrentModificationException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modifying a collection should not happen inside a loop.
we should use iterator.. or loop a snapshot of a collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed this issue on #42
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
|
||
data class KanbanColumn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we need new interface to use these (non-crdt) custom classes easily in the document.
since Android SDK doesn't reveal id of the JsonObject to public, I'm not sure how to get particular JsonObject in the document right now... (ex. when adding a new card to the particular column)
data class KanbanColumn( | ||
val title: String, | ||
val cards: List<Card>, | ||
var id: TimeTicket = TimeTicket.InitialTimeTicket, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using mutable properties should be avoided when we are using Compose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. 👍
What this PR does / why we need it?
Sample Kanban board implementation.
result:
2022-11-08.2.45.20.mov
Any background context you want to provide?
I changed
TimeTicket
as public and used it as a key forJsonArray
, but it is just temporary try to sync with other SDKs.we should change the structure later to improve its usability.
What are the relevant tickets?
Fixes #
Checklist