• Breaking News

    Friday, September 25, 2020

    Android Dev - Weekly "anything goes" thread!

    Android Dev - Weekly "anything goes" thread!


    Weekly "anything goes" thread!

    Posted: 25 Sep 2020 05:40 AM PDT

    Here's your chance to talk about whatever!

    Although if you're thinking about getting feedback on an app, you should wait until tomorrow's App Feedback thread.

    Remember that while you can talk about any topic, being a jerk is still not allowed.

    submitted by /u/AutoModerator
    [link] [comments]

    Rant: Surprised how uncomfortable/bad Room DB is for developers

    Posted: 25 Sep 2020 06:22 AM PDT

    After developing backend applications with Spring Boot for a while, I recently joined a mobile dev team again. They use Room as DB.
    I can see the pros: like being developed by Google, optimised for mobile and so on....

    But i was shocked how complicated such a trivial task as one-to-many relationships are with Room.

    You can't just have a list of items inside an entity. No, you need to manually persist all items in their own table and manually set the foreign keys. But if you let Room generate the ID of the "One" for you, it's pretty complicated to get this generated ID back, because room will only tell you the row number as result of the insert, but not the ID of the inserted item.

    Fortunately Room has at least some sort of support for reading one-to-many relationships. So you can define a class with the relation and room will at least create a join query.

    Maybe i miss something but based on the official documentation and some research i did that's how it needs to be done :(

    Honestly, in 2020 i would have expected way better tooling for RDBMS even on mobile platforms.

    submitted by /u/tobsinger
    [link] [comments]

    Why use Room for offline caching when Retrofit/ OkHttp provide a better alternative?

    Posted: 24 Sep 2020 11:42 PM PDT

    I have been going through multiple tutorials and it seems the common/ accepted practice is to use Room to save data for offline caching.

    The first problem I faced with Room as the single source of truth was that I had to manually delete data from the app that has been removed from the backend. This made the process like this -

    1. Make API call to get data
    2. If API call is a success, delete old entries and add new ones from the API response and then display the data from the DB (Room with LiveData makes this easy)
    3. If API call fails, fetch data from the app's database directly

    Now, this seems unnecessary complex - inserting/ deleting entries from db after every API request.

    I came across this article which explains that we can use an okHttp interceptor to store response for a defined time period and fetch it only if the API fails.

    /** * Interceptor to cache data and maintain it for four weeks. * * If the device is offline, stale (at most four weeks old) * response is fetched from the cache. */ private static class OfflineResponseCacheInterceptor implements Interceptor { @Override public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (!UtilityMethods.isNetworkAvailable()) { request = request.newBuilder() .header("Cache-Control", "public, only-if-cached, max-stale=" + 2419200) .build(); } return chain.proceed(request); } } 

    I found this a better approach and less complex.

    Thoghts?

    submitted by /u/defrndr
    [link] [comments]

    Announcing a painless Kotlin/Multiplatform NoSQL embedded database

    Posted: 25 Sep 2020 05:50 AM PDT

    Jetpack Compose image loading library for requesting and displaying images using Fresco.

    Posted: 25 Sep 2020 03:05 AM PDT

    All developers will get the new Google Play Console on November 2, 2020

    Posted: 24 Sep 2020 11:02 AM PDT

    DataStore: Security - Styling Android

    Posted: 25 Sep 2020 07:04 AM PDT

    TickingTimer: Android Library to Create Customizable Visual Timer

    Posted: 25 Sep 2020 09:19 AM PDT

    Is it a bad practice to read from LiveData inside ViewModel functions?

    Posted: 25 Sep 2020 09:11 AM PDT

    Let's say I have a list of fetched comments: val comments = MutableLiveData<Comment>(). When a comment is clicked a ViewModel function fun onCommentClicked(commentIndex: Int) is invoked, inside which I have to acquire clicked comment in order to do something. I would have to write val comment = comments.value!!.filter { it.id == commentIndex }.

    Generally speaking I found that very often I read from LiveData variables inside ViewModel code. My SignInViewModel has two live datas val username = MutableLiveData<String>(); val password = MutableLiveData<String>() so when sign in button is pressed I would invoke a method like this one:

    fun signIn() { val params = SignInParams(username.value!!, password.value!!) signInUseCase(params) ... } 

    For some reason it seems a bad practice to me that I so often explicitly read from LiveData. Source code seems to be polluted with .value!! statements.

    I thought about keeping some data in additional backing lateinit properties so whenever I fetch list of comments I would have to set two variables, and later in code I could just easily read from _comments variable without a need to get content from livedata and assert it's not null:

    private lateinit var _comments: List<Comments> val comments = MutableLiveData<List<Comments>() fun onCommentsFetched(fetchedComments: List<Comments>) { _comments = fetchedComments comments.value = _comments } fun someFun(){ val comment = _comments.filter { .... } 

    So is it a bad practice to read from LiveData inside ViewModel functions? Should their content be only exposed to view? How to solve this problem?

    submitted by /u/awdre34
    [link] [comments]

    Mobile Developers Cafe - Issue 7 is out - With a lot of Android Dev content.

    Posted: 25 Sep 2020 08:44 AM PDT

    Which topics from the below image are NOT relevant for android development?

    Posted: 25 Sep 2020 08:14 AM PDT

    Hold On ✋��Before Dagger |HILT, try this Simple DI

    Posted: 25 Sep 2020 07:54 AM PDT

    [Feedback] My first (serious) app, a Real-Debrid companion, is kinda ready

    Posted: 25 Sep 2020 01:53 AM PDT

    COVID related apps

    Posted: 25 Sep 2020 05:31 AM PDT

    Was reading an android games website, and it informed that google has a policy regarding COVID related apps (it was about a virus fighting game, but they couldn't add a COVID name in the game, even though the virus is round):

    https://support.google.com/googleplay/android-developer/answer/9889712?hl=en

    During quarantine, I practiced my app developing skills making an app that got COVID-19 related data from an API, and shows in a human comprehensible form, no judgement on data or info on what should be done with it, in local language (brazilian portuguese). So I guess that due to that policy I wouldn't be able to publish that app, is that right?

    submitted by /u/apeinej
    [link] [comments]

    Migrating SharedPreferences to Jetpack DataStore

    Posted: 25 Sep 2020 05:29 AM PDT

    An Android transformation library providing a variety of image transformations for Coil, Glide, Picasso, and Fresco.

    Posted: 25 Sep 2020 02:53 AM PDT

    What is your experience in using in-app review API?

    Posted: 24 Sep 2020 09:57 AM PDT

    Google just provides us in-app review API.

    https://developer.android.com/guide/playcore/in-app-review

    Have you tried it? May I know, what is your experience so far? Do you see any improvement on your app review rating in Play store?

    Thanks.

    submitted by /u/yccheok
    [link] [comments]

    Questions about Android dev from an iOS dev

    Posted: 24 Sep 2020 09:59 AM PDT

    Hello all! I just have a couple questions about android development, I've been an iOS developer for a couple years now and I want to develop android apps for my startup.

    Originally I thought going Native for both iOS and Android would be the way to go. (I'm building Fin-Tech/Banking & Social Media applications). I then started to use React Native but I see some complications with Native UI and performance when my apps get more content heavy (More than one type of cell on the screen like livestream video and images rendering on RecyclerViews/TableViews).

    Can I develop Android apps with Swift?

    Because I know Swift very well, will learning Kotlin be a task to learn? Looking at the Kotlin docs, shows me that the languages are very similar in verbatim.

    What are your thought about learning Android Dev as an iOS developer? Should I go Native for both or cross platform?

    submitted by /u/Red3nzo
    [link] [comments]

    No comments:

    Post a Comment