enpassio / Databinding

Various examples on databinding which can help not only understand how to get started with it but it also shows how this can be used in complex and real use cases
Apache License 2.0
26 stars 14 forks source link

Databinding sample using NewsApi in Kotlin #28

Open rajtheinnovator opened 5 years ago

rajtheinnovator commented 5 years ago

@GretaGri I think you were working on this branch: https://github.com/enpassio/Databinding/tree/dev-databinding-newsapi-kotlin Have you done it? If so, can you make a PR in the respective branch? Or is it that, this is already implemented by you @OyaCanli on your side?

OyaCanli commented 5 years ago

@rajtheinnovator It was Greta who was going to do kotlin version of NewsApi. But I don't know where she is regarding that. If you are too busy @GretaGri, I can make that as well. I learned kotlin in the meanwhile.

rajtheinnovator commented 5 years ago

@OyaCanli for now let's go with the article and when Greta gets time, she can do the sample. But just in case, it she'd not be free by that time, one of me or you can do that Kotlin version.

OyaCanli commented 5 years ago

@rajtheinnovator Sorry I forgot to inform you. I have talked to Greta, she was still in hospital then. (Hopefully they returned home now) She said she'll be busy for a while and that I can do it if I am willing and if I want it to be done sooner. So I'll be doing that one as well. No big deal, kotlin practice for me ;) And I copy paste resources from java version. It''s not gonna take much time.

rajtheinnovator commented 5 years ago

Sure thing, @OyaCanli :+1: Please continue with it and let me know if any help is needed from my side.

OyaCanli commented 5 years ago

@rajtheinnovator Already made it up and running :) But I need to polish kotlin code. I found that there is an extension function URL("yourUrl").readText() in Kotlin, which replaces quite a large chunk of code in our NetworkUtils. But it is not advised for large data streams. I'm not sure if ours count as a large api request. Do you have any idea about this? (I tried and it works fine, by the way) Another question: shall we use coroutines instead of asynctask?

rajtheinnovator commented 5 years ago

@OyaCanli as the api we're using is returning 20 items in a single call, so I think it's safe to use the method readText(). However, if the api is not paginated and can return lot more result set, then in that case, it'd be preferred not to use it. To conclude, we can use this method in our sample and to make it clear further, we can leave a comment there regarding the issue/risk it involves.

For the part of coroutines, I think it's a special topic in itself and not many developers are still used to it, specially the ones trying Kotlin first time. So maybe we should leave it for other separate repository.

OyaCanli commented 5 years ago

We are returning only 10 items in fact. Ok, cool. Thanks!