Is there a shorter way of doing this, maybe with sealed classes? Android Dev |
- Is there a shorter way of doing this, maybe with sealed classes?
- In-App Reviews API on Kids app
- Is there something you can pass into a Room query 'where' clause that returns all results?
- What's the best practice for doing a network operation off the main thread?
- changing name of airplane mode
Is there a shorter way of doing this, maybe with sealed classes? Posted: 30 May 2022 08:09 PM PDT I need an Optional where the 'None' string representation is "", and the 'Something' string representation is its stored value. I also need to be able to get back to that Optional from the string representation (reification if you will.) Tests to demonstrate usage of what I cooked up below. Wondering if there is a way to do this with less code, or with something built into Kotlin. I confess to not really being able to grok sealed classes. ``` abstract class OptionalFilter { abstract val value: String companion object { fun reify(filter:String): OptionalFilter { if (filter == "") { return NoFilter() } else { return Filtered(filter) } } } } data class Filtered(val filter: String) : OptionalFilter() { override val value = filter } // a little awkward that this is not also a data class? class NoFilter : OptionalFilter() { override val value = "" } ``` [link] [comments] |
In-App Reviews API on Kids app Posted: 30 May 2022 05:16 PM PDT Does anyone know if it is okay to use the In-App Reviews API on a "Designed for Families" app, or does it need to be behind some type of parental wall? I have searched high and low for this answer and can't find anything. [link] [comments] |
Is there something you can pass into a Room query 'where' clause that returns all results? Posted: 30 May 2022 04:45 PM PDT If I have a Room Dao query like so: Is there something I can pass in as type or origin where the effect would be that I didn't have that where clause? Something like '*'? Would null do it? [link] [comments] |
What's the best practice for doing a network operation off the main thread? Posted: 30 May 2022 04:33 PM PDT I have a for loop that has a line of code that does a network operation. I need to run this network operation off the main thread. How should I go about this? The rest of the body in the for loop is dependent on the line of code with the network operation so I would also probably need to move the other code in the for loop with the network operation code line. [link] [comments] |
changing name of airplane mode Posted: 30 May 2022 05:18 PM PDT I've got a Google Pixel 5a w/ 5G, with the latest version of Android 12 and dev mode enabled, I'm trying to see if theresa way to change the name of Airplane Mode to something else. A joke with a friend calls it "Shabbat Mode" and I was trying to see if theres a way to change it to that instead of Airplane Mode [link] [comments] |
You are subscribed to email updates from Developing Android Apps. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
No comments:
Post a Comment