<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Dionysis’ desk - Medium]]></title>
        <description><![CDATA[Android code, life thoughts and more.. - Medium]]></description>
        <link>https://medium.com/dionysis-lorentzos-blog?source=rss----91298ca0b474---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Dionysis’ desk - Medium</title>
            <link>https://medium.com/dionysis-lorentzos-blog?source=rss----91298ca0b474---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:58:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dionysis-lorentzos-blog" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The happiness in rejection]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/the-happiness-in-rejection-7fa4652667c4?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/7fa4652667c4</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[experience]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Wed, 10 Jun 2020 17:01:01 GMT</pubDate>
            <atom:updated>2020-06-18T21:38:50.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgQzab4Yx1-D0OsjmZ8Cwg.png" /><figcaption><a href="https://dribbble.com/shots/9162827-NOPE">NOPE</a> designed &amp; created by <a href="https://dribbble.com/yakuzo">Yakuzo</a> on Dribbble.</figcaption></figure><p>This post is dedicated to and addressing young developers or anyone in general who are just starting their careers. This is not another post to explain you a technology or how to get hired in your first junior position. It’s to remind you that you are not the only one doing these first steps. We have all been where you are.</p><p>I would like to tell you 2 brief stories from my life.</p><p>The first one was back during my University time. I was looking for an internship, just a few years after the (pretty much) global economic crisis of 2008. In Greece..</p><p>Browsing around the scarce advertised positions in (back then, my major of) business administration.</p><p>I found very few job openings. I applied to three of four. Those were all of the ones that I found in the business domain. In fact, I was invited to an interview for one of them.</p><p>It was a very low-skilled data entry position, in a well-known, globally, financial company (with a 2019 revenue of $42 billion). During the interview, I faced 3 interviewers simultaneously, who, now reflecting it, were asking completely unrelated questions for that position, as well as making very hard (without reason) questions to a 3rd-year student. I was rejected.</p><p>Looking back that was actually some good news. Because taking that no, gave me the motivation to look for jobs abroad. It made me search and apply to more, and more, and more. And eventually, I landed on my first job abroad, in Amsterdam.</p><p>Just two months after that “no”, I was living abroad, getting experiences I would have never received on that boring data entry internship.</p><p>The second one comes 3 years later, when now a young developer, having some experience, I was looking for a full-time job.</p><p>This was a very hard time. I had maybe sent more than 40 or 50 applications globally but didn’t give up until I land on my first full-time dev job.</p><p>During those applications, most HR departments never replied to me. Some applications, in particular, wanted the salary expectations in the application form. There I wrote “X EUR&quot;. I thought that X amount was fair.</p><p>One recruiter emailed me back. Not for an interview, but with the feedback that X EUR is awarded to people after Y years. A month later, I eventually landed on a job with 30% less than this X salary. It was okay, but nevertheless I didn’t give up on what I thought was my market worth.</p><p>What’s actually fascinating here, is that in just 6 months after that email, I reached a salary way greater than the X. And definitely not having reached yet that Y qualification bullet that recruiter had pointed.</p><p>I try to imagine if the first company had said yes and had hired me. I try to imagine if I had really taken to heart the opinion of that recruiter, who actually thought he was helping me. What I would have missed…</p><p>Sometimes we take too deep other people’s or the industry’s opinion. May that be friends, family, partners, colleagues. <em>You have Z years, you will get X percentage, you are in the Y category.</em></p><p><strong>We crave the comfort of not getting a “no&quot;. </strong>Trying to blend in and keeping a lower profile.<strong> While we should crave and, partially, feel happy every time we hear a “no&quot;.</strong></p><p>“No&quot; is nothing else but someone not wanting what you can offer. So that be skills, partnership, time, or anything else.</p><blockquote>“No” is not even a failure. It’s simply a reminder that you know what you want and the other person simply does not want to or cannot give it to you.</blockquote><p>It’s up to you if you confront or give up.</p><p>If you are a young developer, yes, it might take more time to find something that you like, but only with perseverance.</p><p>But this post is not for developers starting their career. It’s for everyone. Just a reminder that only through a non-success state (sometimes for a shorter or other times for a longer period), we will succeed.</p><blockquote>“No” is just a reminder that you are still pursuing the right thing you desire.</blockquote><p>And that’s where the self-satisfaction is: when you get that “yes” and you look back at the process and yourself with a smile.</p><p>What about you? When was the last time you felt happy to eventually hear a no? Let me know in the comments!</p><p>Thank you for reading!</p><p><em>Want to learn more about me? I’m Dionysis, an Android dev at </em><a href="https://twitter.com/sharenowTech"><em>ShareNow</em></a><em> + Founder of </em><a href="https://nutech.io/"><em>Nutech</em></a><em>, a jobs app only for Android developers.</em></p><p><em>If you are an Android developer (either junior or senior), you will most likely be interested in </em><a href="https://nutech.io/"><em>Nutech app</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fa4652667c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/the-happiness-in-rejection-7fa4652667c4">The happiness in rejection</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin’s sealed class ordinals with Recyclerview adapter]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/kotlins-sealed-class-ordinals-with-recyclerview-adapter-1c363ef3c4f2?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/1c363ef3c4f2</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Sun, 03 May 2020 10:21:01 GMT</pubDate>
            <atom:updated>2020-05-03T10:21:01.351Z</atom:updated>
            <content:encoded><![CDATA[<h4>Let’s perfect RecyclerView’s adapter item types with sealed classes.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*NuupgGZt1C6xAvOZ1MzhSw.png" /><figcaption><a href="https://nutech.io/app">Nutech’s main list has 7 view holder types</a></figcaption></figure><p>Here’s a small “code bliss” pattern which we use in <a href="https://nutech.io/app">Nutech — Android jobs app</a>’s list adapters.</p><p>With this code pattern, we believe we finally have one, clean way to write adapters.</p><p>Let’s start.</p><p>By now, we assume (and hope) that you already use sealed classes for both Adapters’ items and view holders. So your average case should look pretty much like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0f0af19ac78986c99246b142294af36/href">https://medium.com/media/d0f0af19ac78986c99246b142294af36/href</a></iframe><p>And in this scenario, because we have more than one item type, we have to define the item type in the adapter. The type must be defined with an Int. So we usually do something like:</p><pre>class JobsListAdapter : ListAdapter&lt;JobListItem, JobViewHolder&gt;() {<br><br>    override fun getItemViewType(position: Int): Int {<br>        // several ways to do that. One of them would be:<br>        return when (getItem(position)) {<br>            is Header -&gt; 0    <strong>&lt;-- let&#39;s simplify this</strong><br>            is JobItem -&gt; 1   <strong>&lt;-- let&#39;s simplify this</strong><br>        } <br>    }<br><br>    override fun onCreateViewHolder(...): JobViewHolder {<br>        return when (viewType) {<br>            0 -&gt; HeaderViewHolder(...)   <strong>&lt;-- let&#39;s simplify this</strong><br>            1 -&gt; JobViewHolder(...).     <strong>&lt;-- let&#39;s simplify this</strong><br>            else -&gt; throw IllegalStateException()<br>        }<br>    }<br>}</pre><p><strong>Let’s change the above and automate </strong>the above types (<em>0 and 1 above</em>) <strong>with</strong> <strong>ordinals!</strong> As if a sealed class was an enum. To do that, we need to:</p><ol><li>Return the type in the <em>getItemViewType</em></li><li>Match the type of the <em>onCreateViewHolder</em></li></ol><blockquote>The trick here? Make our sealed class items have ordinals. Like enums do.</blockquote><h3>Calculate the type of the instance</h3><p>The first step to automate this type’s calculation is to calculate the subclass’s ordinal</p><pre>inline fun &lt;reified T : Any&gt; T.ordinal(): Int =<br>    T::class.<em>java</em>.<em>classes</em>.<em>indexOfFirst </em><strong>{ </strong>sub <strong>-&gt; </strong>sub == <em>javaClass </em><strong>}</strong></pre><p>That way you can now get the <strong>type</strong> <strong>of any item in one function in a generic way:</strong></p><pre>class JobsListAdapter : ListAdapter&lt;JobListItem, JobViewHolder&gt;() {<br><br>    override fun getItemViewType(position: Int): Int {<br>        return getItem(position).ordinal()<em><br>    </em>}<br><br>}</pre><p>So i.e. a <strong><em>HeaderViewHolder</em> </strong>item <strong>will return <em>0</em></strong> and <strong><em>JobViewHolder </em></strong>item <strong>will return <em>1</em></strong><em>.</em></p><h3>Calculate the type of the class, statically</h3><p>The second (and final step) is that we wish to use the <strong>.ordinal()</strong> statically like:</p><pre>override fun onCreateViewHolder(...): JobViewHolder {<br>    return when (viewType) {<br>        Header.ordinal() -&gt; HeaderViewHolder(...)<br>        JobItem.ordinal() -&gt; JobViewHolder(...)<br>        else -&gt; throw IllegalStateException()<br>    }<br>}</pre><p>Thus, let&#39;s extend the .ordinal() function for the static usage:</p><pre>inline fun &lt;reified T : Any&gt; T.ordinal(): Int {<br>    // we differenciate if it&#39;s top level sealed class here 👇<br>    if (T::class.isSealed) {<br>        return T::class.<em>java</em>.<em>classes</em>.<em>indexOfFirst </em><strong>{ </strong>sub <strong>-&gt; </strong>sub == <em>javaClass </em><strong>}<br>    </strong>}</pre><pre>    // and we now added this part 👇<br>    val klass = if (T::class.isCompanion) {<br>        <em>javaClass</em>.<em>declaringClass<br>    </em>} else {<br>        <em>javaClass<br>    </em>}<br><br>    return klass.<em>superclass</em>?.<em>classes</em>?.<em>indexOfFirst </em><strong>{ it </strong>== klass <strong>} </strong>?: -1<br>}</pre><p>🔥 Issue, <strong>this will not work for data classes</strong>, only for objects. So in our example, JobItem.ordinal() cannot be called because JobItem is a data class.</p><p>The solution? ✅ An empty companion object in each data class:</p><pre>sealed class JobListItem {<br><br>    val type: Int = <em>type</em>()<br><br>    object Header : JobListItem()<br><br>    data class JobItem(val payload: Payload) : JobListItem(){<br>        companion object  <strong>&lt;-- with this JobItem.ordinal() now works</strong><br>    }<br>}</pre><h3>Final result</h3><p>Getting and resolving the view holder’s type is now just a readability bliss 💯</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa398a5f0d6e863e66de83f49bc68b35/href">https://medium.com/media/fa398a5f0d6e863e66de83f49bc68b35/href</a></iframe><p>⚠️<em> Note: The code ordinal() will work only with 1st level sealed classes. If you need something more sophisticated, make sure to adjust that method accordingly.</em></p><p><em>⚠️Note 2: Like many features using reflection, when using </em><strong><em>R8’s </em></strong><em>or</em><strong><em> Proguard’s </em></strong><em>obfuscation, you can encounter runtime crashes. You need to make sure </em><strong><em>both the classes and the companion objects</em></strong><em> are available during runtime. One way to do it is with the </em><em>@Keep annotation.</em></p><p>Thank you for reading!</p><p><em>Want to learn more about me? I’m Dionysis, an Android dev at </em><a href="https://twitter.com/sharenowTech"><em>ShareNow</em></a><em> + Founder of </em><a href="https://nutech.io/app"><em>Nutech</em></a><em>, a jobs app only for Android developers.</em></p><p><em>If you are an Android developer, you will most likely be interested in </em><a href="https://nutech.io/app"><em>Nutech app</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c363ef3c4f2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/kotlins-sealed-class-ordinals-with-recyclerview-adapter-1c363ef3c4f2">Kotlin’s sealed class ordinals with Recyclerview adapter</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Nutech, a job board app only for Android devs]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/introducing-nutech-a-job-board-app-only-for-android-devs-e6c03d0a68d?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/e6c03d0a68d</guid>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Fri, 20 Mar 2020 11:46:02 GMT</pubDate>
            <atom:updated>2020-05-01T17:02:23.367Z</atom:updated>
            <content:encoded><![CDATA[<p>We are many more than we think. We are often critical, judgemental, with great attention the detail but we also love what we do. We have events, open-source libraries, and an already big community that it’s only growing. We wish to explore present boundaries, try new things but also have a meaningful purpose of why we work. Or feel free with our choices and be able to choose what we do and where we do it. That’s the first side of the coin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*zCE_Uor1yLpV0RA-ylSS2w.gif" /><figcaption><a href="https://nutech.io/app">Snapshot of item details transition of the Nutech app.</a></figcaption></figure><p>We work for companies that are constantly expanding, offering new opportunities, experiences and improving the daily life of people everywhere around us in this small world. We want to find the best people that are out there because we believe in what we do. We want to laugh together, learn together, experiment together and feel proud of each other. This is the other side of the coin.</p><p>Sadly many focus on profit. Try, fast, fail, sloppy, impatience, pressure, timelines. We wish to change that. When was the last time you were impressed by something? Something that surprised you happily? Something that you feel happy just because it exists. Sometimes this feeling is found less often. And we try to reverse this circle.</p><blockquote>We humbly wish to introduce you Nutech. A free Android app dedicated to only Android jobs. Nothing more and nothing less.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hUk1eqqpJ80XisRt0PvV7A.png" /></figure><p>Minimalist, attention to the details, simple, purposeful. We focus on quality and minor UX details that make us happy. It took us a while to reach this level, but we feel it’s worth it. And we are proud of it. We now want to proudly share it with you.</p><p>We want to deliver the best app for you, an Android developer, to find your next company. Or simply browse the global market and see your worth.</p><p>Or you, a hiring manager, to find the best Android developer for your team. You wish to find exactly the quality people you wish for the cause you work for.</p><p>So give it a try. We are pretty sure that you will like the journey with us. We are still young but we trust we will bring value to you. It’s free and it can only get better 👇</p><p><a href="https://play.google.com/store/apps/details?id=io.nutech">NuTech | Android Jobs - Apps on Google Play</a></p><p>Or hiring Android developers? Publish for free an Android job opening: <a href="https://nutech.io/publish">https://nutech.io/publish</a></p><p>Visit <a href="https://nutech.io/">Nutech’s website</a> for more details.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6c03d0a68d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/introducing-nutech-a-job-board-app-only-for-android-devs-e6c03d0a68d">Introducing Nutech, a job board app only for Android devs</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I bet your RxJava is on the wrong thread]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/i-bet-your-rxjava-is-on-the-wrong-thread-ae02e66a3eac?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/ae02e66a3eac</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Sun, 06 Jan 2019 11:47:47 GMT</pubDate>
            <atom:updated>2020-05-01T23:16:14.942Z</atom:updated>
            <content:encoded><![CDATA[<p>4 years later of heavy usage and me naively thinking I know the ins and outs of RxJava, I was wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*jbP-muYyP2lWaYHWOwDjIQ.jpeg" /><figcaption><a href="http://www.commitstrip.com/en/2014/10/15/when-i-thoroughly-follow-the-requirements/">When I thoroughly follow the requirements</a> by <a href="http://www.commitstrip.com/">CommitStrip</a></figcaption></figure><p>You know, it’s this feeling where you think you are doing fine and then you learn something and the whole world collapses bellow you. Pretty much that.</p><p>Today topic is threading and there are high chances you do it wrong as well because <em>you think</em> you know.</p><p>Regardless, let’s see some Rx puzzles and test how well you know subscribeOn and observeOn. You will find all the answers together at the bottom of the page.</p><h3>Puzzle 1: Subject</h3><p>For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5722e4c2995ac1ffa3c2400ab9097e4e/href">https://medium.com/media/5722e4c2995ac1ffa3c2400ab9097e4e/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: main</pre><pre>B. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxComputationScheduler</pre><pre>C. main thread name: main<br>   subscribe onNext: main<br>   subscribe onNext: main</pre><pre>D. None of the above</pre><h3>Puzzle 2: Subject with completable</h3><p>Almost similar to the above. For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0a1999cddae435b0ee54ffea73ae733/href">https://medium.com/media/f0a1999cddae435b0ee54ffea73ae733/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxIoScheduler</pre><pre>B. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: main</pre><pre>C. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxComputationScheduler</pre><pre>D. None of the above</pre><h3>Puzzle 3: Merge</h3><p>For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/209963ca121b7e50027971da31f41a59/href">https://medium.com/media/209963ca121b7e50027971da31f41a59/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxIoScheduler</pre><pre>B. main thread name: main<br>   subscribe onNext: main<br>   subscribe onNext: main</pre><pre>C. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxComputationScheduler</pre><pre>D. main thread name: main<br>   subscribe onNext: RxIoScheduler<br>   subscribe onNext: RxIoScheduler</pre><pre>E. None of the above</pre><h3>Puzzle 4: Merge with subject</h3><p>Based on puzzles 2 &amp; 3. For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0b5f91134a46550d961b77f1a2f0b45/href">https://medium.com/media/b0b5f91134a46550d961b77f1a2f0b45/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxComputationScheduler</pre><pre>B. main thread name: main<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: RxComputationScheduler<br>   subscribe onNext: main</pre><pre>C. None of the above</pre><h3>Puzzle 5: CombineLatest with observeOn</h3><p>For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa1e194fde295edabfa6e146a6b962ec/href">https://medium.com/media/aa1e194fde295edabfa6e146a6b962ec/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext: RxIoScheduler</pre><pre>B. main thread name: main<br>   subscribe onNext: RxComputationScheduler</pre><pre>C. None of the above</pre><h3>Puzzle 6: CombineLatest with subscribeOn</h3><p>For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d28dffdb8732b22e122515ca3e30dfe/href">https://medium.com/media/8d28dffdb8732b22e122515ca3e30dfe/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext: RxIoScheduler</pre><pre>B. main thread name: main<br>   subscribe onNext: RxComputationScheduler</pre><pre>C. Either of the above</pre><pre>D. None of the above</pre><h3>Puzzle 7: Replay/RefCount with subscribeOn</h3><p>For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2858348d7c1bb5db635d5472fcf6db6/href">https://medium.com/media/c2858348d7c1bb5db635d5472fcf6db6/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext 1: RxComputationScheduler<br>   subscribe onNext 2: RxComputationScheduler</pre><pre>B. main thread name: main<br>   subscribe onNext 2: main<br>   subscribe onNext 1: RxComputationScheduler</pre><pre>C. Either of the above</pre><pre>E. None of the above, something else crazy</pre><h3>Puzzle 8: Completely messed up Replay/RefCount</h3><p>For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/543370d6cd80156b80306127fcdc3462/href">https://medium.com/media/543370d6cd80156b80306127fcdc3462/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext 1: RxNewThreadScheduler<br>   subscribe onNext 2: RxNewThreadScheduler<br>   subscribe onNext 3: RxNewThreadScheduler</pre><pre>B. main thread name: main<br>   subscribe onNext 1: RxNewThreadScheduler<br>   subscribe onNext 2: RxNewThreadScheduler<br>   subscribe onNext 3: main</pre><pre>C. main thread name: main<br>   subscribe onNext 1: RxNewThreadScheduler<br>   subscribe onNext 2: RxComputationScheduler<br>   subscribe onNext 3: main</pre><pre>D. All the above</pre><pre>E. None of the above</pre><h3>Puzzle 9: Replay/RefCount with no completion and observeOn</h3><p>For the given snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bff096cba11beed506a27f6994503a7d/href">https://medium.com/media/bff096cba11beed506a27f6994503a7d/href</a></iframe><p>Which do you think is the system output?</p><pre>A. main thread name: main<br>   subscribe onNext 1: main<br>   subscribe onNext 2: main</pre><pre>B. main thread name: main<br>   subscribe onNext 1: RxIoScheduler<br>   subscribe onNext 2: RxIoScheduler</pre><pre>C. main thread name: main<br>   subscribe onNext 1: RxIoScheduler<br>   subscribe onNext 2: main</pre><pre>D. None of the above</pre><h3>Answers</h3><blockquote>If you don’t want spoilers, don’t scroll further.</blockquote><h4>Answer of puzzle 1</h4><p>Correct answer is A because the default value is based on the subscribeOn (computation thread) and .onNext() of the subject is called from the main thread. Therefore the second emission will ignore the subscribeOn, change thread and will be emitted at the main thread.</p><h4>Answer of puzzle 2</h4><p>Correct answer is A. Same as puzzle 1. Default thread is computation but the .onNext() of the subject is now called from the io thread. Therefore the second emission will change thread and will be emitted at the io thread.</p><h4>Answer of puzzle 3</h4><p>Correct answer is A. The merge() by default will change its thread based on which thread was the last emitted value.</p><h4>Answer of puzzle 4</h4><p>Correct answer is B. The merge() by default will subscribe on the computation thread and then change its thread to the main because of the subject as explained in puzzle 2.</p><h4>Answer of puzzle 5</h4><p>Correct answer is B. The combineLatest() will emit a value based on the last emitted value’s thread. Therefore, the io thread, of the first leg, in that case is ignored and the value will be emitted at the computation thread of the second observable.</p><p><em>Note</em>: the combining operation of the combine latest will also happen to the last emitted thread.</p><h4>Answer of puzzle 6</h4><p>Correct answer is C. This time, due to the subject, the emission sequence is not guaranteed. Therefore the emission can be either in io or computation thread.</p><h4>Answer of puzzle 7</h4><p>Correct answer is C. The emission sequence is not always guaranteed here. If both subscribers have subscribed, the emission will be on the computation scheduler affected by the first. If the second subscription subscribed and emitted faster, the first emission will be on main and then on computation.</p><h4>Answer of puzzle 8</h4><p>Correct answer is D. As above this comes to delicate timing issues which depend how fast the threads are. It could either emit all of them to a new thread, some of them to the new thread, or all of them to the initially “expected” threads.</p><h4>Answer of puzzle 9</h4><p>Correct answer is C. Although, you expect all the emissions to be in io thread, the replay will emit only the last value but will not repeat the last known thread. So the subscribing thread in the second case, which is the main, will also be the one where the 2nd value will be emitted.</p><h3>Final thoughts</h3><p>After all, looks like subscribeOn() is not as predictable and powerful. A proper way, to ensure an operation happens on a particular thread, is to fill your Rx pipeline with observeOn() especially on places after using a subject, a merge(), a combineLatest() or a refCount(). Being generous and put an extra “observeOn”s could be proven safer than not define a thread.</p><p>Keep Rx-ing. ✌️</p><p>Thank you for reading!</p><p><em>Want to learn more about me? I’m Dionysis, an Android dev at </em><a href="https://twitter.com/sharenowTech"><em>ShareNow</em></a><em> + Founder of </em><a href="https://nutech.io/app"><em>Nutech</em></a><em>, a jobs app only for Android developers.</em></p><p><em>If you are an Android developer, you will most likely be interested in </em><a href="https://nutech.io/app"><em>Nutech app</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae02e66a3eac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/i-bet-your-rxjava-is-on-the-wrong-thread-ae02e66a3eac">I bet your RxJava is on the wrong thread</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[As if your project was a house…]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/the-programatic-understanding-of-your-code-product-and-entrepreneurial-idea-1c002a3604c1?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/1c002a3604c1</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Wed, 02 May 2018 14:46:01 GMT</pubDate>
            <atom:updated>2018-06-22T20:52:16.765Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Alright, let’s talk about code.</p><p>I am pretty sure every entrepreneur, investor, product manager or whoever interacts with software development should get this.</p><blockquote>Your company’s idea is like an empty house; an empty apartment that you just moved it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUQWx9De3jlzNnULB1SWTQ.jpeg" /><figcaption>“Chalet Grand-PIC” by <a href="http://www.appareilarchitecture.com/fr/architecture/chaletgrandpic/">Appareil architecture</a></figcaption></figure><p>When you move into a new apartment there is infinite potential of what you can do. Of course it depends your savings, your income or simply your money spending style. For example, you can buy a second-hand pair of curtains, or curtains from IKEA, or something more fancy or expensive.</p><p>Now, your empty apartment is basically an “empty canvas”. You could give an industrial style to your apartment, or a modern, or a minimal with no curtains. You can just buy the first curtains you will find available or you can buy the ones you really like. Your money, your choice.</p><p>Also, you, probably as early as possible, need a bed to sleep. And then a wardrobe. Maybe a washing machine too if you have the space. A table, chairs or a sofa and most probably all of them. You might like to hang stuff on the wall or buy few plants. Forks, knives, dishes, a carpet, a coat-hanger, a coffee machine. Whatever, you name it.</p><p>And then you have a full house. Sweet.</p><p>Now let’s get pragmatic with what happens in software development.</p><p>Your company’s <strong>idea</strong> is like this empty apartment.</p><p>Your <strong>design</strong> skills or you design team is similar to your skills to match harmoniously your apartments’ furniture. You can put little effort looking for a piece of furniture e.g. a bed, because you simply need it asap, or you can sleep a month on the floor until you find a perfect one. You can also compromise to buy a table instantly or eat outside until you get delivered the one you want. Or even you can buy a cheap one and then throw it away later on, when you feel like replacing it.</p><p>But what’s important is this:</p><blockquote>If you buy something there are only two options, you either keep it or you throw it away. Because you either want to replace it, it is broken or useless.</blockquote><p>So you better get that sofa and the dining table you want, unless you want to carry them to the garbage (or pay someone do that for you).</p><p>Now, your furnished apartment is simply the materialisation of your idea, your design skills, your effort and your money to buy all these stuff you have now.</p><p>And that’s pretty much a <strong>company</strong> <strong>product</strong>. Every <strong>feature</strong> you have is like a piece of furniture. Some of them you need them asap. Some of them might don’t look good or fit well with others. For some of them you will prefer to wait a bit until you find the one and for others, if you are frivolous, you might waste your money. They might be difficult to replace, nice, ugly, resilient, fast outdated, fragile, extremely useful, not so useful, totally used, seldom used, fancy, modern, old. Anything.</p><blockquote>And that’s exactly your features in your product.</blockquote><p>You could have a nice, big, corner sofa. Difficult to replace but very useful and resilient as material. But for sure:</p><blockquote>Every piece of furniture gets old or worn out. The same as software does.</blockquote><p>You will replace a broken coffee machine with a new better one. But definitely you don’t need 3 coffee machines in your kitchen. Same with your product’s features.</p><p>And the quality and the material of your furniture? Well that’s similar your product’s software. It starts shiny when brand new and then gets old.</p><p>Now you might ask your company’s developers <strong>why have they slowed down to build new features in relation to the past.</strong></p><p>Well, if you have a crowded apartment with furniture, would you find it unreasonable the cleaning lady you have hired to need more time to clean thoroughly your apartment? Similarly the devs need time to “clean” and maintain the code.</p><p>Okay. You got the idea. How do you live a better life? There are some questions to ask yourself:</p><p>Are you a minimalist? Do you enjoy buying stuff the whole time? Do you care your place to be clean or easily be cleaned? Do you like the area, your neighbours? Is it big enough? Do you want to save money to get that expensive new Macbook Pro or simply buy 5 new t-shirts? Are you willing to save money or totally fine to use your credit card or even take a loan? Do you own your apartment or pay rent? Do you like it? Do you even care?</p><p>All the above applies to your company. Be sure to afford the right amount of rent when you move in and of course it’s up to you on what to buy inside there.</p><p>And really, you can’t always live inside your apartment. It’s getting boring... Take some vacation or even relocate if you need more space…</p><p>What’s your “house”?</p><p><em>Did you like this post?</em></p><p>I write my <em>thoughts and coding experiences </em>at <a href="https://lorentzos.com/">lorentzos.com</a> and <em>tweet</em> at <a href="https://twitter.com/diolor">@diolor</a>.</p><p>I also run <a href="https://www.hamburgtech.jobs/">Hamburg Tech Jobs</a> whenever I find free time.</p><p>Feel free to subscribe or follow me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c002a3604c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/the-programatic-understanding-of-your-code-product-and-entrepreneurial-idea-1c002a3604c1">As if your project was a house…</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Hamburg Tech Jobs]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/introducing-hamburg-tech-jobs-c6504d8c0532?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/c6504d8c0532</guid>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[hamburg]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Fri, 27 Apr 2018 18:34:13 GMT</pubDate>
            <atom:updated>2018-04-27T18:34:19.638Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Hamburg 2018, the community has never been larger.</em></p><p>I remember back in 2015 joining one of the first Android meetups here in Hamburg. They were sparse, happening every 1–3 months due to the lack of speakers. I also remember the drive of the organisers to push stuff forward and try organise them every month.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvznW3KOUI0u8TVtbrNXkA.jpeg" /><figcaption>View from Atlantic-Haus, Hamburg</figcaption></figure><p>Fast-forwarding today, not only these meetups are happening pretty often but new one are constantly introduced. New tech languages, like Kotlin or frameworks like Reactjs or even non engineering ones are emerging like UI/UX.</p><p>And the city itself is embracing more and more developers.</p><p>And more and more non tech companies are shifting their models to hire devs because they see the advantage they gain when incorporating tech people. New startups in the area or existing tech wanting to grow fast!</p><p>So we really felt the need that all these people should have an easy way and a place to look when they are either jumpstarting their career or want to join something new and exciting.</p><blockquote>We are introducing <a href="http://hamburgtech.jobs/">http://hamburgtech.jobs/</a>!</blockquote><p>A centralised way for engineers, designers, agile coachers and product people when they look for something new and exiting in their city. Of course also for foreigners, all over the world, simply interested in moving into this beautiful city.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*fPUKECPpWQca40Sl5uMP1g.png" /></figure><p>Feel free to visit it, write us feedback, tell us your opinion, be open on what you miss or what you want to see.</p><p><em>How can we keep you informed about all the jobs in Hamburg that interest you? Maybe one is already out there.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6504d8c0532" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/introducing-hamburg-tech-jobs-c6504d8c0532">Introducing Hamburg Tech Jobs</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making pictures capture in Android simple]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/making-pictures-capture-in-android-simple-74416a19e800?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/74416a19e800</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cameras]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Mon, 26 Jun 2017 19:51:55 GMT</pubDate>
            <atom:updated>2020-06-25T21:18:17.028Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*yvGrbutm2ULZ0al3APxJtg.png" /><figcaption>Fotoapparat’s icon by <a href="http://leanderlenzing.com/">Leander Lenzing</a></figcaption></figure><p>Let’s face it. Camera api in Android is so broken. Ever talked with an iOS colleague about camera? It “just works” and it’s super frustrating for us (Android devs) to have to spend so much time, weeks to be precise, if we want to use a camera inside our app.</p><p><a href="https://github.com/dmitry-zaitsev">Dmitry</a> has used camera extensively to know the pain and we concluded that there should be an easier way: a simple library which just works with camera in Android phones.</p><p>The idea is simple: ask the library what kind of picture you are willing to take (e.g. MPixels, flash, focus), start/stop the preview during your lifecycle and just provide the interface to take the goddamn photo. All in a simple way that lets you stay sane and have proper sleep at nights.</p><p>So here you go. We created <a href="https://github.com/Fotoapparat/Fotoapparat"><strong>Fotoapparat</strong></a>! It does what promises above and we also added some sugar like registering <em>preview frame analyzer</em>, proper <em>logger, </em>readable way to get the <em>camera capabilities </em>and simple parameters updating API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*i9JQjR4eHExaAKgfmydVyA.jpeg" /></figure><h3>Usage</h3><p>What’s more simple than the following code to take a picture?</p><pre>Fotoapparat fotoapparat = Fotoapparat<br>    .with(context)  <br>    .into(cameraView)<br>    .build();<br><br>fotoapparat.start();<br>    <br>fotoapparat<br>    .takePicture()<br>    .saveToFile(someFile);</pre><p>Looks neat? Hope you like it!</p><p>Let’s dive further. How do you initialize the library?</p><p>With a readable builder. Add all the parameters you wish and we will take care of the rest:</p><pre>Fotoapparat fotoapparat = Fotoapparat<br>    .with(context)  <br>    .into(cameraView)<br>    .lensPosition(<em>firstAvailable</em>(<br>        <em>front</em>(), <em>back</em>()<br>    ))<br>    // even more options here<br>    .build();</pre><p>Starting/stoping the preview? Easy.</p><pre>@Override<br>protected void onStart() {<br>   super.onStart();<br><br>   fotoapparat.start();<br>}<br><br>@Override<br>protected void onStop() {<br>   super.onStop();<br><br>   fotoapparat.stop();<br>}</pre><p>Taking pictures? Yes sir! You wish a File, a Bitmap or both?</p><pre>PhotoResult photoResult = fotoapparat.takePicture();</pre><pre>// save to file<br>photoResult.saveToFile(new File(<br>      getExternalFilesDir(&quot;photos&quot;),<br>      &quot;photo.jpg&quot;<br>));</pre><pre>// obtain Bitmap<br>photoResult<br>      .toBitmap()<br>      .whenAvailable(bitmapPhoto -&gt; {<br>           imageView.setImageBitmap(bitmapPhoto.bitmap);<br>      });</pre><p>Blocking, callback, RxJava 1/2 (Single, Observable, Completable)? Your choice:</p><pre>// synchronous<br>BitmapPhoto bitmapPhoto = photoResult<br>        .toBitmap()<br>        .await();</pre><pre>// asynchronous<br>photoResult<br>        .toBitmap()<br>        .whenAvailable(bitmapPhoto -&gt; {<br><br>        });</pre><pre>// RxJava<br>photoResult<br>        .toBitmap()<br>        .adapt(SingleAdapter.&lt;BitmapPhoto&gt;<em>toSingle</em>())<br>        .subscribe(bitmapPhoto -&gt; {<br>            <br>        });</pre><h3>What can Fotoapparat do?</h3><ul><li>Start an Android camera (front, back or external)</li><li>Start/stop a View preview with desired resolution</li><li>Take a photo, with desired resolution, focus and flash</li><li>Obtain the frames of the preview for further processing</li><li>Easily obtain bitmaps or write photos to files</li><li>Work nicely with RxJava 1/2</li><li>Make you happy</li></ul><h3>What are we planning in Fotoapparat?</h3><ul><li>Switch cameras easily</li></ul><h3>What Fotoapparat cannot do?</h3><ul><li>Take videos</li><li>Make you coffee :(</li></ul><h3>Credits</h3><p>We want to say thanks to <a href="https://github.com/commonsguy">Mark Murphy</a> for the awesome job he did with <a href="https://github.com/commonsguy/cwac-camera">CWAC-Camera</a>. We were using his library for a couple of years and now we feel that Fotoapparat is a next step in the right direction.</p><p>We are also extremely thankful to our friend <a href="http://leanderlenzing.com/">Leander Lenzing</a> for his amazing work on designing our logo.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74416a19e800" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/making-pictures-capture-in-android-simple-74416a19e800">Making pictures capture in Android simple</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Life]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/life-32f7ae11fdb3?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/32f7ae11fdb3</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[inspiration]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[psychology]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Mon, 26 Jun 2017 19:51:33 GMT</pubDate>
            <atom:updated>2017-06-27T20:03:13.482Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<blockquote>Life is a book.</blockquote><p>And it doesn’t really matter which title you will give. It’s a book that you write your own story. It’s a book that you know the title only when you finish writing this story.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HYCZrtETmZ7nPwNyqcBMsw.jpeg" /><figcaption>Just an awesome picture from <a href="https://twitter.com/mpopv">Matt Popovich</a> from <a href="https://unsplash.com/@uh">unsplash</a>.</figcaption></figure><p>And what is really your story? What do you want to write in this book? Which chapters do you want to be full of passion and which ones with action. You are the writer and the storyteller. You choose your destiny and the story, the size of the book and effort you put in writing it.</p><p>The obstacles of the characters, the learnings, the foolish things you did and the fun you will always remember. The foolish nights and the nice mornings that you challenged yourself. That you did something new that you were scared. Something that you always had in distance but now it’s a piece of you. That you are not scared anymore of it but you now enjoy it. Pushing your limits and breaking your fears, that in the safety of your family your own have created, setting your own mind’s barriers.</p><p>To the rebels that defied what was ordinary and to the moving ones who calmed down to learn a different side of life. A new learning each day, totally different. To the relationship that was not working and you made the courage to break free from it and to the ones that worth the effort to chase. To the introverts who learn to laugh with strangers, completely naturally.</p><p>Who are you? Are you there? Living the life as a pilot or as a passenger? Are you there to fight for your dreams, your goals, your passions? Are you there to be humiliated, loved and have fun? Are you there to live your life as you want to be “one day” today? Are you feeling your limits? Are you patient enough to break these limits? Are you ready to pass your mind and body over your past experiences and your barriers? To try again and again. To fail, to learn, to be present and enjoy every second?</p><p>This is your life. This is my life. Exposed, with passion, ups and downs and hell lot of fun.</p><p>This is your book, your story. And you write every single page on it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32f7ae11fdb3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/life-32f7ae11fdb3">Life</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 minutes]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/5-minutes-21fbaf1aa3d9?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/21fbaf1aa3d9</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 21:26:14 GMT</pubDate>
            <atom:updated>2017-04-06T21:26:18.662Z</atom:updated>
            <content:encoded><![CDATA[<p>5 minutes of talk.This is what you need when you talk to someone to identify if he does his job because he of love or because of need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*A5O6k5YdFr5VHb7JYvlRZQ.png" /><figcaption><a href="https://dribbble.com/shots/638763-Clock">Clock</a> by <a href="https://dribbble.com/pacoxiao">Paco</a> in Dribbble.</figcaption></figure><p>Being a developer is easy, attractive and prosperous job. You can easily find a job in which ever city you want to choose from Google Maps.</p><p>Deep inside however we know there are these two kind of people.</p><p>In the first one are the ones who love what they do. The problem solvers, the builders, the pioneers in trying, finding excitement in new technologies, testing ideas, being angry when something is not working and happy as kids to find something new, to learn from others. And regardless everyone being headstrong in the tech community and trying to impose his ideas deep inside they stay passionate learners. And kids.</p><p>The second group are the ones who do something because they have to. They choose to be developer not because of passion but because of income. And this income enables do more things in the rest of the time, travel, being artists or simply having fun.</p><p>Sometimes when we are developers by profession, we might get lost. We might forget. Sometimes the possibilities enabled by having a higher income loses your focus from your passion. The greed, the desire of fame takes away your childish experience of simply solving problems; analyzing problems and giving the world a value with what you can do. The happiness deriving from the people using your library is replaced by greed and numbers of stars in Github.</p><p>5 minutes is usually enough to identify if a person you are going to hire in your team or the team that you are going to join has this spark. This inner love. If they do it because of the money or because they love it.</p><p>And these kind of people will never stop doing. And whatever obstacle they find on their way, corporate, legal, physical or else, they will still try to pursuit what they desire.</p><p>Sometimes you need to go back to your roots and be foolish as a kid to understand what’s your passion. Try, experiment, change and find another passion and another. And if you get tired of your passion, don’t be sad. It’s because you are now a master and it’s time for you to grow and fight and experiment with new challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21fbaf1aa3d9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/5-minutes-21fbaf1aa3d9">5 minutes</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVP and RxJava]]></title>
            <link>https://medium.com/dionysis-lorentzos-blog/mvp-and-rxjava-9dfcbe79bf77?source=rss----91298ca0b474---4</link>
            <guid isPermaLink="false">https://medium.com/p/9dfcbe79bf77</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[mvp]]></category>
            <dc:creator><![CDATA[Dionysis Lorentzos]]></dc:creator>
            <pubDate>Sat, 18 Mar 2017 22:20:52 GMT</pubDate>
            <atom:updated>2020-05-01T23:14:37.149Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>RxJava &amp; MVP pattern are probably the 2 biggest topics in Android talks for the last 1–2 years. Maybe you gave a related talk recently too? :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*sqN9ayYHW4Z1mzZCOevHkw.gif" /><figcaption><a href="https://dribbble.com/shots/2496109-A-collection-of-popular-apps">A collection of popular apps</a> by <a href="https://dribbble.com/Jung_Hanna">Hanna Jung</a> in Dribble.</figcaption></figure><p>We use them, we know them, but do we really <strong>benefit effectively </strong>from them in our app development?</p><p>Are our coding patterns and libraries bring enough value to our customers, or our development speed?</p><p>Let’s focus today on harmonising our Reactive code with MVP with two aspects in mind:</p><ul><li>Simplicity of the code</li><li>Fully test our business logic</li></ul><p>Why? Because by focusing on the above, our future code iterations are much faster.</p><h3>The background</h3><p>The first agreement that we need to make is to understand and split the code logic in 3 (or more) layers:</p><ul><li><strong>Data layer</strong>: Responsible to provide data from either disk, network or more. It answers: <em>What to provide?</em> (e.g. user location, server data, etc..)</li><li><strong>Domain layer</strong>: (Usually) reusable business logic between the ui and data layer. It answers: <em>What to do?</em> (e.g. is user allowed to do X action for his location?)</li><li><strong>UI (or Presentation) layer</strong>: Displays stuff and is the layer of interaction with the user. It answers: <em>What to show?</em> (e.g. enabled or disabled button)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YUXFbtuhOfnVyH8doq5f3g.png" /><figcaption>Minimum example of code layering.</figcaption></figure><p>In this architecture, the <strong>data layer</strong> should have a high percentage of unit testable code. We usually exclude from tests few network or storage classes (android native classes).</p><p>The <strong>domain layer </strong>should have a 100% unit testable code.</p><p>Lastly, the challenge is to have as much unit testable code in the <strong>ui layer</strong>. This is sometimes challenging because we can’t unit test classes extending android’s View, Activity or Fragment (without hacks).</p><p>With this basic understanding of how to split the code in the higher level, we need to relate MVP to this architecture. The relation is:</p><blockquote>MVP is a pattern used only in the UI layer.</blockquote><p>The solution to this? Move as much logic from the views to the Presenters which are plain java classes and can be unit tested easier.</p><p>And then, there is RxJava.</p><blockquote>RxJava is a library to have these 3 layers communicate with each other.</blockquote><p>With all these in our knowledge we structure our UI layer using MVP:</p><h3>1. The presenter</h3><p>The first step is to <strong>prepare the State</strong> of the the view to be displayed to the user. We don’t care at all what kind of view it is (activity, view, etc..) since we use interfaces (StateView).</p><ol><li><em>The general MVP framework:</em></li></ol><p>The minimum actions a presenter will do is to start and stop. The StateView can be updated with a state (or also called sometimes as “Model”). The state is the single point of truth that the View will use to determine what display in the ui.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f38421493c44dd4883f944c7e622689/href">https://medium.com/media/2f38421493c44dd4883f944c7e622689/href</a></iframe><p><em>2. The implementation example :</em></p><p>Firstly, we start the presenter. The presenter is going to receive all the needed Rx observables from the domain layer and then updates the view. In our case checks if the user is logged in:</p><pre>accountInteractor.isUserLoggedIn()</pre><p>Then, we convert these data and judge which state to display:</p><pre>accountInteractor.isUserLoggedIn()<br>     .map(isUserLoggedIn -&gt; new FilterButtonState(isUserLoggedIn))</pre><p>Finally, we update view which we have passed in the onStart:</p><pre>void onStart(StateView&lt;FilterButtonState&gt; view){<br>   subscription = accountInteractor.isUserLoggedIn()<br>       .map(isUserLoggedIn -&gt; new FilterButtonState(isUserLoggedIn))<br>       .subscribe(view::updateState)<br>}</pre><p>When we stop the presenter, we unsubscribe to not leak actions or objects.</p><p><em>Full code:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32dc0c669f51057fe31c9998823769fd/href">https://medium.com/media/32dc0c669f51057fe31c9998823769fd/href</a></iframe><p><em>3. The test</em></p><p>It checks the two cases and the expected results. Valid point is to also have tests against Observable’s errors (if they are expected). In this case we assume we don’t expect any, so there are none.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68cf4bbc67f2a7298b66549ecd41fb40/href">https://medium.com/media/68cf4bbc67f2a7298b66549ecd41fb40/href</a></iframe><h3>2. The View</h3><p>Having defined what are the possible states a view can display for a particular use case, we update the relevant ui in the updateState method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b7087c1163552ad103cd577132b7028/href">https://medium.com/media/8b7087c1163552ad103cd577132b7028/href</a></iframe><p>A question appearing at this point is which lifecycle should be used for our presenter’s start/stop actions?</p><p>If we start/stop the presenter in the Activity’s crete/destroy lifecycle, we don’t need to care at all about <em>onSavedInstance</em> or <em>split screen mode</em>. Which is greatly reduces headaches. If we wish to not run operation when the activity is stopped, such as a battery draining task, then Activity’s onStart/onStop can also be an option.</p><h3>Further explanations</h3><ul><li>When planning your MVP, think of the possible ui states first.</li><li>If you want a <strong>full reactive app,</strong> the Data &lt;-&gt; Domain layer should communicate with RxJava the same way Domain &lt;-&gt; UI layers do. It’s easier to “push states” from the data to the ui layer.</li><li>If two or more different presenters need to know about a ui state (e.g. user selected item from a list and you want to update two separate views), then it’s advisable to <strong>“push down” to the data layer</strong> this object selection awareness logic. It can simply be an object only <strong>persisted in the runtime memory</strong>.</li><li>There are cases we need to update Domain or even Data layer based on <strong>a user ui action</strong> (e.g. as above, user clicks list item), simply add method in the presenter. Call them from the view. If you also need to update the data layer, delegate the action further down. <em>E.g: User clicks log out button, view calls presenter, presenter notifies the further business logic layers and clears the persisted account.</em></li><li>Yes, the layers are adding action delegation but the logic remains easily clean and understandable.</li></ul><p>So there you go! You can unit test a great percentage of your app, you split the code logic and you are able to iterate (both features and bugfixes) very fast!</p><p>Thank you for reading!</p><p><em>Want to learn more about me? I’m Dionysis, an Android dev at </em><a href="https://twitter.com/sharenowTech"><em>ShareNow</em></a><em> + Founder of </em><a href="https://nutech.io/app"><em>Nutech</em></a><em>, a jobs app only for Android developers.</em></p><p><em>If you are an Android developer, you will most likely be interested in </em><a href="https://nutech.io/app"><em>Nutech app</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dfcbe79bf77" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dionysis-lorentzos-blog/mvp-and-rxjava-9dfcbe79bf77">MVP and RxJava</a> was originally published in <a href="https://medium.com/dionysis-lorentzos-blog">Dionysis’ desk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>