<?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[Stories by Pierce Zaifman on Medium]]></title>
        <description><![CDATA[Stories by Pierce Zaifman on Medium]]></description>
        <link>https://medium.com/@PierceZaifman?source=rss-1736df87918------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BH7LSoU-2xS8DvYlhCGfqw.jpeg</url>
            <title>Stories by Pierce Zaifman on Medium</title>
            <link>https://medium.com/@PierceZaifman?source=rss-1736df87918------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 09:03:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@PierceZaifman/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Applying Google’s Android architecture with ObjectBox database]]></title>
            <link>https://proandroiddev.com/applying-googles-android-architecture-with-objectbox-database-5153ce8ffac1?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/5153ce8ffac1</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Wed, 04 Oct 2017 20:31:15 GMT</pubDate>
            <atom:updated>2017-10-04T20:50:41.657Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ik3qiwUmvfCDISgvE-yQg.jpeg" /></figure><p>If you haven’t seen Google’s architecture, you can learn more about it <a href="https://developer.android.com/topic/libraries/architecture/index.html">here</a>. Also, if you’re not familiar with ObjectBox, check out <a href="http://piercezaifman.com/objectbox-android-database/">this post</a>.</p><h3>Introduction</h3><p>The goal with the architecture is to end up with something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*EjGlVGGBrlrmvmcy.png" /></figure><p>The main difference is that I’ll be using ObjectBox instead of Room. The architecture doesn’t enforce any specific implementations though. You can always swap out the implementation details. I found ObjectBox to be one of the simplest databases, and it allows for reactive queries without depending on RxJava (though you can use RxJava if you want to).</p><p>To see the full example, you can find the GitHub repository <a href="https://github.com/PierceZ/GoogleArchitectureExample">here</a>.</p><h3>Getting started</h3><p>To start, I added two models to my project: Zoo and Animal. A Zoo has a one-to-many relation with Animals. You can see their implementations below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99b4d54f3e720a2ea6adf08395fc9055/href">https://medium.com/media/99b4d54f3e720a2ea6adf08395fc9055/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2269cf0354582f1f49abab0e9b9e23d2/href">https://medium.com/media/2269cf0354582f1f49abab0e9b9e23d2/href</a></iframe><p>Then I created a simple MainActivity (the View layer), with a RecyclerView to display a list of Zoos, and a FloatingActionButton (FAB) to add new Zoos. I also added in some mock data for this example, so the app would have some data to display. The activity’s code is below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39195db7aad98c0cf78c17e19d5d76c2/href">https://medium.com/media/39195db7aad98c0cf78c17e19d5d76c2/href</a></iframe><p>I create the ViewModel for the MainActivity which is responsible for loading a list of Zoos. The activity observes this data, and when it, changes it lets the ZooAdapter know about it. I’ve left out the adapter’s and layouts’ details as they are just regular implementations. You can view the adapter <a href="https://github.com/PierceZ/GoogleArchitectureExample/blob/master/app/src/main/java/com/piercezaifman/googlearchitectureexample/view/ZooAdapter.java">here</a> if you would like to see it.</p><p>You can see the result below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*APbmA86nMj_5G0V4.png" /></figure><h3>ViewModel</h3><p>The ViewModel is essentially just responsible for communicating between the repository and view. It sends requests from the view to the repository, and returns results to the view as well. I try to make one ViewModel per view, but you could use more it if makes sense to do so. All of my ViewModels extend from a BaseViewModel class which manages the ObjectBox subscriptions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/100e4106a2978118a3ed462d81192813/href">https://medium.com/media/100e4106a2978118a3ed462d81192813/href</a></iframe><p>To really follow this type of architecture properly, I shouldn’t be exposing ObjectBox to the ViewModel layer. I left it this way to keep the example simpler, but you could abstract it out with something like <a href="https://github.com/JakeWharton/RxRelay">RxRelay</a>.</p><p>The ViewModel which manages my MainActivity looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe66dbae5cb99138e35a99a1326246d7/href">https://medium.com/media/fe66dbae5cb99138e35a99a1326246d7/href</a></iframe><p>It initializes itself with MutableLiveData to observe List, and an ObjectBox DataSubscription. This subscription monitors changes in the database, it will set the MutableLiveData whenever the data changes. Which will then notify its own observers of the change. One nice thing with LiveData is that its observers are lifecycle aware, so background data updates will only be sent when the view is active.</p><p>It also exposes a method to refresh the Zoos. This would trigger the repository to refresh the data from the source. Typically a remote server, so it would send a network request to get the latest data. As a result, the ObjectBox database gets updated and relevant subscriptions will be notified. Resulting in the LiveData in my ViewModel getting updated, passing on the result to its observers, and notifying the view layer.</p><h3>Repository</h3><p>The repository is responsible for passing requests from the ViewModel to the database and the network, and returning the response. I broke these layers down into API classes (to access remote APIs) and <a href="https://en.wikipedia.org/wiki/Data_access_object">DAO</a> classes (to access the database). You can see my implementation here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c486ac204bc3adc6238a6c8de00489d1/href">https://medium.com/media/c486ac204bc3adc6238a6c8de00489d1/href</a></iframe><p>I keep most of the logic in the repository layer. The DAO and API layers only have one responsibility. For the DAO it’s interacting with the database, and for the API it’s interacting with the remote API. They are either passing data on, or returning it, they don’t manipulate it themselves. So when the repository gets a response from the API, it’s responsible for parsing that response and subsequently sending it to the DAO to update the database.</p><p>If the repository is given an Observer or LiveData, it sets its value on completion to pass the response back to the ViewModel. These response objects can contain extra information like status codes (success, failure, etc.) and error messages. Since the data models won’t contain this type of information. The implementation of these response objects really depend on what kind of information the ViewModel needs.</p><h3>Parsing</h3><p>To prevent the repository from becoming bloated, I split the response parsing logic into its own set of classes. These parsing classes just take a response String (likely JSON), and convert it into the appropriate model(s). For parsing Zoo responses my class looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/790000ef5693d14591eeb1cc41a61463/href">https://medium.com/media/790000ef5693d14591eeb1cc41a61463/href</a></iframe><p>You may notice I included a list of Animals in the parser — this is because it’s possible that a response for a Zoo could contain Animals as well. Although I didn’t actually implement any such responses in this example. The idea here is that a Parser class isn’t directly mapping JSON objects to my data models. It parses the entire response, which may include multiple data models or specific keys that don’t belong to models (like page count).</p><h3>DAO</h3><p>This layer is responsible for interacting with the database. I would create DAO classes for each model, like my ZooDAO:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37adeb4f7a739e5ca12204f059437151/href">https://medium.com/media/37adeb4f7a739e5ca12204f059437151/href</a></iframe><p>Here you can see ObjectBox being accessed directly. It performs any required database operations, and builds query subscriptions. These queries can be observed in the ViewModel, which notifies the LiveData of any data updates.</p><h3>API</h3><p>The API layer is used to make requests to the network and pass those responses back to the repository. The implementation in this example is mocked out, you can see the source <a href="https://github.com/PierceZ/GoogleArchitectureExample/blob/master/app/src/main/java/com/piercezaifman/googlearchitectureexample/repository/api/ZooAPI.java">here</a>. This could use any type of network requests, you could use <a href="https://github.com/square/retrofit">Retrofit</a> for example.</p><p>The repository observes the response from the API and handles them. Every API request will create a Response object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34abcc54b90b157d379868f806c49aa0/href">https://medium.com/media/34abcc54b90b157d379868f806c49aa0/href</a></iframe><p>This is the relevant information that the repository needs — the response payload and status. More statuses could be added, for example for specific error statuses like authentication failure.</p><h3>Bringing it all together</h3><p>In this example, I have my MainActivity observing the Zoos LiveData. It will be notified whenever this value is set. For example, if I add a new Zoo, it will automatically refresh the view. This is because I have set up a DataSubscription with ObjectBox to observe changes. You can see this in action here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/0*1WKTELtApf0PEhJ5.gif" /></figure><p>You can find the source code for this DialogFragment <a href="https://github.com/PierceZ/GoogleArchitectureExample/blob/master/app/src/main/java/com/piercezaifman/googlearchitectureexample/view/ZooFragment.java">here</a>. The important piece of this class is that it’s observing the response here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cbf5fbb458e7d5335c5e4c85ac528ce/href">https://medium.com/media/9cbf5fbb458e7d5335c5e4c85ac528ce/href</a></iframe><p>When the save action is triggered in the ViewModel, it sets the LiveData’s response with the loading status. Then when it succeeds or fails, it sets that result back as well. Once it returns back to MainActivity, you can see the new Zoo was added without having to explicitly trigger a refresh.</p><h3>Wrap up</h3><p>To see the full example, you can find the GitHub repository <a href="https://github.com/PierceZ/GoogleArchitectureExample">here</a>. But, you can apply what I have explained here to any new views/models/repositories.</p><p>I believe this architecture is a bit easier to understand and apply than the fully <a href="https://github.com/android10/Android-CleanArchitecture">Clean Architecture</a>. But, the same principles apply — like isolating unique layers and giving them a single responsibility. I do not consider what I have presented here to be complete, it is meant to be a starting point. You can use it as is, but you should be thinking about how you can build and improve on it. Moving towards something like <a href="https://github.com/bufferapp/android-clean-architecture-boilerplate">Buffer’s Clean Architecture Boilerplate</a> is the goal. But, it can be overwhelming to grasp all of these concepts without a solid base to stand on.</p><p>Also, in an effort to make it easier to grasp, I tried to keep dependencies to a minimum. I did not include things like Retrofit, OkHttp, Butterknife, RxJava, Dagger, etc. You can add whatever libraries you like to use, you can swap out ObjectBox too. Though I think it works well with this approach.</p><p>Let me know what you think of this approach. Also if you have any comments, questions, or suggestions please post them.</p><h3>If You Want To Read More Like This, Follow Me On <a href="https://medium.com/@piercezaifman">Medium</a>. Thanks!</h3><p><em>Originally published at </em><a href="https://piercezaifman.com/applying-googles-android-architecture-with-objectbox-database/"><em>piercezaifman.com</em></a><em> on October 4, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5153ce8ffac1" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/applying-googles-android-architecture-with-objectbox-database-5153ce8ffac1">Applying Google’s Android architecture with ObjectBox database</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ObjectBox, a modern and easy to use Android database]]></title>
            <link>https://proandroiddev.com/objectbox-a-modern-and-easy-to-use-android-database-1172b7605645?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/1172b7605645</guid>
            <category><![CDATA[android-libraries]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Sat, 02 Sep 2017 16:59:47 GMT</pubDate>
            <atom:updated>2017-11-19T21:39:43.338Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KV-kUG0bWuBXftslP0kQ_g.jpeg" /></figure><p>If you’re familiar with libraries like <a href="http://greenrobot.org/greendao/">greenDAO</a> or <a href="http://greenrobot.org/eventbus/">EventBus</a>, you may have heard of the company that created them: <a href="http://greenrobot.org/">greenrobot</a>. If not, I recommend checking them out. In short, they build high quality open source libraries for app developers.</p><p>Recently, they have come out with a new library called <a href="http://objectbox.io/">ObjectBox</a>. It is used to help manage your app’s local data storage. Their older library greenDAO serves the same purpose, but ObjectBox is their next step in local storage solutions. The biggest difference is that ObjectBox does not use SQL at all.</p><h4>Getting Started</h4><p>To get started using it, you can check out their <a href="http://objectbox.io/documentation/introduction">gradle setup</a>. Once you have gradle setup, the library is easy to use. Simply create your data model classes as normal, and add the annotation @Entity. See an example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a78476b857dd553d7276c26a181ea42/href">https://medium.com/media/8a78476b857dd553d7276c26a181ea42/href</a></iframe><p>ObjectBox needs access to the properties of your class, so you’ll need to make the appropriate setter and getter methods. Alternatively, you can remove the private modifier and ObjectBox’s generated classes will access them directly instead.</p><p>Now that you have your data models setup, you need to initialise the database. I prefer to do this in my Application class, but you could setup your own singleton or inject it with <a href="https://google.github.io/dagger/">Dagger</a> if you prefer. My application class looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41467509f9eb29fdb61ae13021ea92fe/href">https://medium.com/media/41467509f9eb29fdb61ae13021ea92fe/href</a></iframe><h4>CRUD</h4><p>Now that I have my database setup, I can access it using the <a href="http://objectbox.io/files/objectbox-java/current/io/objectbox/BoxStore.html">BoxStore</a> class. Instead of the typical SQL tables, they have boxes. Here are some example usages of a box:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/781f38194d5879bcf473a37ea7a5a0b4/href">https://medium.com/media/781f38194d5879bcf473a37ea7a5a0b4/href</a></iframe><p>These are simple examples of the basic <a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> operations. You can do more complex queries too, and without having to write confusing SQL statements. ObjectBox creates queries with a fluent API, so chaining conditions is easy and understandable. To learn more about writing queries, check <a href="http://objectbox.io/documentation/queries/">their documentation</a>.</p><h4>Relations</h4><p>Like most other databases, ObjectBox has support for <a href="http://objectbox.io/documentation/relations/">relations</a>. It has support for one-to-one, one-to-many relations and many-to-many relations. Here’s an example of what a one-to-many relation looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55a38b6391af9ecd50b261093f5b88ec/href">https://medium.com/media/55a38b6391af9ecd50b261093f5b88ec/href</a></iframe><p>This defines a relation between a Zoo, which has many Animals, and the Animal, which belongs to one Zoo. Currently you must make relations at least package private for ObjectBox.</p><p>To modify these relations or access them, it looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb503d5a891d5c057500e2c993dfca47/href">https://medium.com/media/cb503d5a891d5c057500e2c993dfca47/href</a></iframe><h4>Migrations</h4><p>Unlike other database libraries (including their own greenDAO), migrations are almost entirely automatic. So you don’t need to worry about managing each schema version.</p><p>For example, if you add a new property or delete a property, there’s no migration code required. There are only two cases you need to be concerned with in terms of migration. Renaming a property or class, and changing a property type. They include documentation on how to handle these cases <a href="http://objectbox.io/documentation/objectbox-entity-property-migration/">here</a>. In most cases though, there will be no work required for migrations.</p><h4>Wrap Up</h4><p>ObjectBox has many more features like <a href="http://objectbox.io/documentation/transactions/">transactions</a>, <a href="http://objectbox.io/documentation/entity-annotations/#Property_indexes">database indexes</a>, <a href="http://objectbox.io/documentation/kotlin/">Kotlin support</a>, <a href="http://objectbox.io/documentation/data-observers-reactive-extensions/">reactive extensions</a> and the <a href="http://objectbox.io/features/">list</a> goes on. But, this post should give you a good idea of the approach greenrobot has taken with this library.</p><p>At the time of writing this, ObjectBox has just come out of beta with version 1.0. While they are still working on some issues and new features, I think it’s a great library and highly recommend giving it a shot. To learn more about it, you can check out their website here: <a href="http://objectbox.io/">http://objectbox.io</a>.</p><h3><strong>If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/objectbox-android-database/"><em>piercezaifman.com</em></a><em> on September 2, 2017.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Ff20c9a%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Ff20c9a%2F&amp;image=https%3A%2F%2Fe.enpose.co%2F%3Fkey%3DdRXnS9Gplk%26w%3D700%26h%3D425%26url%3Dhttps%253A%252F%252Fupscri.be%252Ff20c9a%252F%253Fenpose&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/87c27c6bd6c8dea21c9726d9564b27d6/href">https://medium.com/media/87c27c6bd6c8dea21c9726d9564b27d6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1172b7605645" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/objectbox-a-modern-and-easy-to-use-android-database-1172b7605645">ObjectBox, a modern and easy to use Android database</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use ConstraintLayout]]></title>
            <link>https://medium.com/android-news/how-to-use-constraintlayout-736a78e2971c?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/736a78e2971c</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Thu, 24 Aug 2017 15:56:39 GMT</pubDate>
            <atom:updated>2017-08-24T18:59:30.428Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jf8LFBhLY1tnbl-o9SDhnw.jpeg" /></figure><p>If you’re familiar with RelativeLayout, then <a href="https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html">ConstraintLayout</a> should feel similar to you. ConstraintLayout has much more flexibility though, and performs better than the RelativeLayout. In general, you should always use ConstraintLayout over RelativeLayout.</p><p>To add ConstraintLayout to your project, place the following in your build.gradle files:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95bb38f86a43cb02521f6d1574118ad2/href">https://medium.com/media/95bb38f86a43cb02521f6d1574118ad2/href</a></iframe><p>Before we look at an example of ConstraintLayout, let’s look at an example using RelativeLayout. I want to have a layout that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/0*eMXq1Qtcg5AwuTpl.png" /></figure><p>To accomplish this, here is my RelativeLayout:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2507b1b742bbbb521a5c403ddd7af02/href">https://medium.com/media/b2507b1b742bbbb521a5c403ddd7af02/href</a></iframe><p>Now to do the same with ConstraintLayout, I added the same kind of constraints my RelativeLayout had:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fd2dcaf576c86319db82793174c1f4b/href">https://medium.com/media/6fd2dcaf576c86319db82793174c1f4b/href</a></iframe><p>But, the result looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/0*mK9eHsoCIgIUXrvP.png" /></figure><p>This is because my TextView’s width is set to wrap_content, so it only takes as much space as it needs. As opposed to in the RelativeLayout, where the view gets stretched to make it align properly. If you want the view to fill up this space, you can simply set the width to 0dp.</p><p>As you can see already, ConstraintLayout can do the same things as RelativeLayout, and more. Another nice addition from ConstraintLayout is the <a href="https://developer.android.com/reference/android/support/constraint/Guideline.html">Guideline</a>. This can be used in your ConstraintLayout to help set the position and size of your views. For example, if I wanted TextView1 from my previous example to take up 25% of the width, I could do it like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0c378dd2462c6579c9425d2c720cb85/href">https://medium.com/media/e0c378dd2462c6579c9425d2c720cb85/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/0*zH5eE7Q019XXhvTB.png" /></figure><p>One other big improvement over RelativeLayout is the design tab support. While you can write the xml yourself like I did above, there are some nice visual tools available too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*15PfRWGKXBxCWH-b.gif" /></figure><h3>Further reading</h3><p>To learn more about ConstraintLayout, check out the official Android documentation: <br> <a href="https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html">https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html</a></p><h3><strong>If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/how-to-use-constraintlayout/"><em>piercezaifman.com</em></a><em> on August 24, 2017.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=736a78e2971c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/how-to-use-constraintlayout-736a78e2971c">How to use ConstraintLayout</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make an Event Bus with Google’s LiveData]]></title>
            <link>https://medium.com/android-news/how-to-make-an-event-bus-with-googles-livedata-5efcc50d818f?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/5efcc50d818f</guid>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Sat, 22 Jul 2017 12:30:01 GMT</pubDate>
            <atom:updated>2017-07-24T14:54:21.825Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ROpjLHSbUor03kd7fVs1w.png" /></figure><p>At Google I/O this year, Google announced a new set of <a href="https://developer.android.com/topic/libraries/architecture/index.html">architecture libraries</a>. One of the new components they included is called <a href="https://developer.android.com/topic/libraries/architecture/livedata.html">LiveData</a>. It can be used to help manage propagating data to your views, while respecting the Activity and Fragment lifecycles. Until now, you typically had to manage all of this on your own. Or more commonly, many developers neglected to handle these scenarios at all. This resulted in memory leaks, among other issues.</p><p>In the past, I wrote about <a href="https://piercezaifman.com/how-to-make-an-event-bus-with-rxjava-and-rxandroid">how to make an event bus with RxJava</a>. I also wrote about how you could <a href="http://piercezaifman.com/moving-away-from-the-event-bus-with-rxjava-and-dagger-2/">send events without the event bus using RxJava and Dagger</a>. I had mentioned that if you’re not careful about managing these subscriptions, it can easily lead to memory leaks. If you have other developers using your code, you don’t want to rely on them knowing exactly how your code works. It should be as foolproof as possible.</p><p>LiveData can be used to resolve these issues, in conjunction with the <a href="https://developer.android.com/reference/android/arch/lifecycle/LifecycleRegistryOwner.html">LifecycleRegistryOwner</a>. To add these components to your project, you can follow <a href="https://developer.android.com/topic/libraries/architecture/adding-components.html">Google’s instructions</a>.</p><p>To set up the event bus, we need to implement LifecycleRegistryOwner on our Activities and Fragments. To simplify this, I have a BaseActivity class, and a BaseFragment class which can be extended from. These classes will implement the LifecycleRegistryOwner interface, so all of my Activities and Fragments don’t have to. You can see these implementations below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83a1b37e90be7c1f3f056b89b5f9d6a8/href">https://medium.com/media/83a1b37e90be7c1f3f056b89b5f9d6a8/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93c183c328f6a96668e8c5cdbc285690/href">https://medium.com/media/93c183c328f6a96668e8c5cdbc285690/href</a></iframe><p>The other piece is my LiveData class. I want to be able to send any type of data through my event bus, so I will use the Object class for my LiveData. I named my implementation EventLiveData:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb79ea57e0dad60b9dd2b4c15073ed58/href">https://medium.com/media/bb79ea57e0dad60b9dd2b4c15073ed58/href</a></iframe><p>My event bus uses integer constants to define different subjects. These subjects are what define the type of event you are observing. When your LifecycleRegistryOwner is destroyed, its Observers <a href="https://developer.android.com/reference/android/arch/lifecycle/LiveData.html">will be removed</a>. I override the removeObserver method so that the EventLiveData can remove itself from the event bus.</p><p>The reason I remove the EventLiveData from the event bus, is because it will send out whatever its current value is to new observers. This behaviour is fine if you’re loading data, but I’m also using it to send events like tapping on a button. I don’t want those events to get repeated.</p><p>With these components included, my new event bus class looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b37b6cfc2df4aba127e1ed8d35170d5c/href">https://medium.com/media/b37b6cfc2df4aba127e1ed8d35170d5c/href</a></iframe><p>To use the LiveDataBus, you subscribe to a subject with a LifecycleRegistryOwner (typically a Fragment or Activity). Then, implement the <a href="https://developer.android.com/reference/android/arch/lifecycle/Observer.html">Observer</a> callback to do whatever you want with the data. Since the bus uses Objects, you need to cast it to whatever type of data you’re receiving. Here is an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8ac2d4e0fd79348b4c2ee7fcad489fd/href">https://medium.com/media/e8ac2d4e0fd79348b4c2ee7fcad489fd/href</a></iframe><h3>Wrap up</h3><p>The way that I am using LiveData is not how it was intended to be used. But, it does exactly what I need — it takes care of the lifecycle issues for me. Now I don’t have to worry about my event bus causing memory leaks, or any other lifecycle problems. Especially if someone other than me is using this code. Now, it’s foolproof!</p><h3><strong>If You Enjoyed Reading, Please Click That Little Heart. If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/how-to-make-an-event-bus-with-googles-livedata/"><em>piercezaifman.com</em></a><em> on July 22, 2017.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5efcc50d818f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/how-to-make-an-event-bus-with-googles-livedata-5efcc50d818f">How to make an Event Bus with Google’s LiveData</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[If you build it, they won’t come]]></title>
            <link>https://medium.com/slight-improvement/if-you-build-it-they-wont-come-2e84e7e87139?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e84e7e87139</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[indie-game]]></category>
            <category><![CDATA[ideas]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Sat, 24 Jun 2017 13:19:05 GMT</pubDate>
            <atom:updated>2017-06-24T13:36:09.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDhPHqgreXNORQiC--bTbw.jpeg" /></figure><p>Do you have an idea for a new website, app, game, etc.? There are a few things you should consider before dedicating the next few years of your life to it.</p><p>If you spend a significant amount of time on anything, you may start to feel like it has some inherent value because of that time. Well, it doesn’t. This is known as the <a href="https://en.wikipedia.org/wiki/Sunk_cost">sunk cost fallacy</a>. You can’t get your time back, so you feel the need to justify its value. Whether you spent one year or one day on it, the end result is all that matters.</p><p>Nobody owes you anything for your hard work. In fact, nobody cares about your effort in the slightest. All they care about is the end product. Do they want it, or not. It’s your responsibility to make a product that people want to buy. If it sells poorly, the only person you can blame is yourself.</p><p>In general, there are 3 reasons your product didn’t sell.</p><h4>There isn’t a market for what you’re trying to sell.</h4><p>You need to do some market research. Find the answer to these questions:</p><ul><li>Are there similar products to what you’re making?</li><li>Is there room for you in the market?</li><li>How well do similar products typically sell?</li><li>How much money and/or time do you need to spend to make your product?</li><li>Will you be able to make that money back?</li></ul><h4>The people who would want your product were not aware of it.</h4><p>You know there’s a market, but how do you reach that market? You need a marketing campaign. Get a demo you can show as soon as possible, and try to build a following. You need to keep promoting your product to get attention. You also need to keep in mind that, only a small percentage of interested people will actually buy it. A like or retweet is not the same as a sale.</p><p>How many people will convert to buyers? If you don’t think it will be enough, it may be time to move on to your next idea. Why invest more money and time into something you know will not be successful? You’re setting yourself up for disappointment.</p><h4>There is a market, and they were aware of your product, but it wasn’t very good.</h4><p>While marketing is important, it’s not everything. You still need to actually make something great. If you trick people into buying garbage, they won’t be happy. Especially on the internet, where many communities tend to have a witch hunt mob mentality. To prevent such issues, you can do beta tests with focus groups. Find out what the issues are and fix them.</p><p>You need to make sure you solve these issues <em>before</em> you take your product to market. If you don’t, you’re gambling with your success. And the odds are overwhelmingly against you.</p><p>In the end, you can do whatever you want with your time. But, if you expect to earn money, hoping for the best isn’t good enough.</p><h3><strong>If You Enjoyed Reading, Please Click That Little Heart. If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/if-you-build-it-they-wont-come/"><em>piercezaifman.com</em></a><em> on June 24, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e84e7e87139" width="1" height="1" alt=""><hr><p><a href="https://medium.com/slight-improvement/if-you-build-it-they-wont-come-2e84e7e87139">If you build it, they won’t come</a> was originally published in <a href="https://medium.com/slight-improvement">Slight Improvement</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Retrofit with RxJava and Gson]]></title>
            <link>https://medium.com/android-news/retrofit-with-rxjava-and-gson-49d7dad1c56e?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/49d7dad1c56e</guid>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Sat, 10 Jun 2017 13:33:01 GMT</pubDate>
            <atom:updated>2017-06-10T16:01:32.041Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXmliZJExVImRubvUWIvpw.jpeg" /></figure><p>To get started you need to include the following in your build.gradle file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab81b584824560cf2b1242696d12bc96/href">https://medium.com/media/ab81b584824560cf2b1242696d12bc96/href</a></iframe><p>Now you can set up your API interface with RxJava Observables, for example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/860e41e2fd6f0e28e00c30b31d902da4/href">https://medium.com/media/860e41e2fd6f0e28e00c30b31d902da4/href</a></iframe><p>As you can see above, I can use my own data model and the JSON response will be converted automatically. I can also simply get a JsonObject if I just want to use the JSON myself.</p><p>Alternatively, I can set up my own deserializer, like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/996a696b69c3eba2f1140b25de7a2d0c/href">https://medium.com/media/996a696b69c3eba2f1140b25de7a2d0c/href</a></iframe><p>Lastly, here is my API creation with a deserializer for the User added in:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7536c6220a755c5572ec15d7fae2729/href">https://medium.com/media/c7536c6220a755c5572ec15d7fae2729/href</a></iframe><p>There are many different ways you can use <a href="http://square.github.io/retrofit/">Retrofit</a>, <a href="https://github.com/ReactiveX/RxJava">RxJava</a>, and <a href="https://sites.google.com/site/gson/gson-user-guide">Gson</a>. This example can be used as a starting point, but there is much more you can do with each of these libraries if you need to.</p><h3><strong>If You Enjoyed Reading, Please Click That Little Heart. If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/retrofit-rxjava-gson/"><em>piercezaifman.com</em></a><em> on June 10, 2017.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49d7dad1c56e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/retrofit-with-rxjava-and-gson-49d7dad1c56e">Retrofit with RxJava and Gson</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t let others influence your goals]]></title>
            <link>https://medium.com/slight-improvement/dont-let-others-influence-your-goals-ae81ecd04508?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae81ecd04508</guid>
            <category><![CDATA[goals]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[self-awareness]]></category>
            <category><![CDATA[lifestyle]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Sun, 04 Jun 2017 13:45:38 GMT</pubDate>
            <atom:updated>2017-06-04T16:14:21.225Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xEZqCX3EprIvNuRb_ya4ew.jpeg" /></figure><p>It’s human nature to compare yourself to others. Everybody does it. The problem is that many of us misunderstand what we’re comparing.</p><p>For example, you’re looking at Facebook and see that your friend got a new high paying job. This person is the same age as you, but you know they are making significantly more money than you. Why aren’t you doing that well? You may feel like you’ve fallen behind, or that something has gone wrong in your life.</p><p>Yet, consider this: you and your friend are different people. You live completely different lives. It’s not as if your friend is a copy of you with a better job. Maybe you’re more athletic than them, or you have more free time to enjoy each day. Think about what you have, not what you don’t have.</p><p>It’s easy to get tunnel vision and focus on the negatives. Thoughts like: “I’m not making enough money”, “I need to start exercising more”, “I need to travel more”, or “I don’t have enough friends”. While it’s good to have goals, there’s only so much time in a day, in your life. You can’t do everything, but nobody can. It’s not something you should feel bad about.</p><p>We sometimes look at the best parts of other people’s lives and compare ourselves. We can’t measure up to that. That’s a combination of people, nobody has the best of everything. You have to decide what’s most important to you.</p><p>People do change though. Once in awhile you should think about how you are spending your time. Are you making progress towards your goals? Have your goals changed? If you decide you want to start working out, then you need to take time away from something else.</p><p>Figure out what you want and spend your time accordingly.</p><h3><strong>If You Enjoyed Reading, Please Click That Little Heart. If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/dont-let-others-influence-your-goals/"><em>piercezaifman.com</em></a><em> on June 4, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae81ecd04508" width="1" height="1" alt=""><hr><p><a href="https://medium.com/slight-improvement/dont-let-others-influence-your-goals-ae81ecd04508">Don’t let others influence your goals</a> was originally published in <a href="https://medium.com/slight-improvement">Slight Improvement</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s new for Android from Google IO 2017]]></title>
            <link>https://medium.com/android-news/whats-new-for-android-from-google-io-2017-27b28c510117?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/27b28c510117</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-apps]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Mon, 22 May 2017 13:49:12 GMT</pubDate>
            <atom:updated>2017-05-24T18:59:27.168Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JpSmkJ8Yj-vtM1uUJwKypw.jpeg" /></figure><p>Another year, another Google IO conference. As usual, there were some interesting announcements regarding Android. As I was watching the conference, I made a list of things I wanted to try out or learn more about.</p><h3>Kotlin</h3><p>Having hung out in various Android communities, Kotlin has been something I’ve seen come up more and more frequently lately. I’ve been mostly avoiding it, because it seemed like a fad. Now that I know it’s not going anywhere, and is supported by Google, I feel like I need to give it a shot. Google promised that support for Java is still going strong, but I wouldn’t be surprised if they started to focus more on Kotlin going forward.</p><p>At this point, Kotlin is something you can’t afford to ignore as an Android developer. Not only that, but from what I’ve seen and read, Kotlin will make your life easier. I tried out a new library this year called <a href="https://github.com/orfjackal/retrolambda">Retrolambda</a>, and now I can’t live without it. I can only imagine that Kotlin is full of nice stuff like lambdas that I probably don’t want to miss out on.</p><h3>Architecture</h3><p>Google showed off a slick new set of libraries under the umbrella of <a href="https://developer.android.com/topic/libraries/architecture/index.html">architecture</a>. For now there are two main components in here. The first is lifecycle management, and the second is an ORM called Room. I didn’t find Room to be very compelling in comparison to other ORMs.</p><p>However, their set of lifecycle management tools will change how I write my apps forever. I haven’t had a chance to try it out yet, but this was my favourite thing to come out of the conference. Having to manage the lifecycle, prevent UI events from being triggered in the background, it’s all taken care of for you. Every question I had, they answered. I highly recommend checking this out.</p><h3>Other stuff</h3><ul><li><a href="https://developer.android.com/preview/features/autosizing-textview.html">Autosizing textviews</a>. You can now have your text shrink down to fit the available space, instead of always truncating.</li><li><a href="https://developer.android.com/preview/features/adaptive-icons.html">Adaptive icons</a>. They are changing launcher icons again. You can now include two layers. One is the icon itself, the other is a background. They will allow OEMs to mask the background layer, so they can keep all app icons consistent.</li><li><a href="https://developer.android.com/preview/features/downloadable-fonts.html">Custom fonts</a> are actually supported now. You don’t have to do weird hacks to get it working. In the next version of Play Services they will also support over 800 fonts that you do not need to include in your app. They will all be bundled with Play Services, so you can just grab them from the system.</li><li><a href="https://developer.android.com/preview/features/notification-channels.html">Notification channels</a>. These are categories for your notifications, so users can have more control over the types of notifications they see from your app. Previously they could only enable/disable all notifications. Once your app targets Android O, you will be required to use notification channels.</li><li><a href="https://developer.android.com/reference/android/appwidget/AppWidgetManager.html#requestPinAppWidget(android.content.ComponentName,%20android.os.Bundle,%20android.app.PendingIntent)">Widget requests</a>. If you’ve made a widget, you know that they are difficult for users to find. With this new feature in Android O, you can actually request users to pin your widget.</li><li>The Play Store will be included in the new Android O emulator. So now you can actually test apps that require an up to date version of Play Services.</li></ul><p>That’s it for my list. What was your favourite announcement from Google IO?</p><h3><strong>If You Enjoyed Reading, Please Click That Little Heart. If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/whats-new-for-android-google-io-2017/"><em>piercezaifman.com</em></a><em> on May 22, 2017.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27b28c510117" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/whats-new-for-android-from-google-io-2017-27b28c510117">What’s new for Android from Google IO 2017</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Living with no regrets]]></title>
            <link>https://medium.com/the-ascent/living-with-no-regrets-9fb33db01247?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fb33db01247</guid>
            <category><![CDATA[positive-thinking]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[regret]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[the-ascent]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Sat, 20 May 2017 17:31:51 GMT</pubDate>
            <atom:updated>2017-05-20T19:46:15.225Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KjOhEqbRenMl_U92YPjg-w.jpeg" /></figure><p>Your life is made up of a series of choices. For many of us, having a choice means that there are right and wrong answers. But I don’t think that’s true.</p><p>When I was in university, at the end of my third year of a four year program, I had the option to take an extra year to do an internship. I had the choice to either take the extra year or finish my degree earlier. There are benefits and negatives to each option that I considered, and I chose to do an internship. I’ll never know what would have happened if I finished earlier. But the truth is that I don’t care.</p><p>I don’t wonder what would have happened if I did one thing or another. There’s no limit to the different choices I could have made, but didn’t. If I spent all my time thinking about what didn’t happen, I’d miss out on what is happening now.</p><p>You may think, “well, if you had graduated a year earlier and gotten the same job, you’d save a year of time”. From a career perspective, that may be true. But, had I done that there’s no guarantee I’d have the same job. Even if I had gotten the same job, I can’t replace the experiences I had that year, the people I met, the places I went to, and so on.</p><p>Everything I have done makes me who I am, if I changed what I did in the past, I wouldn’t be me. I would be someone else.</p><h3><strong>If You Enjoyed Reading, Please Click That Little Heart. If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/living-with-no-regrets/"><em>piercezaifman.com</em></a><em> on May 20, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fb33db01247" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-ascent/living-with-no-regrets-9fb33db01247">Living with no regrets</a> was originally published in <a href="https://medium.com/the-ascent">Ascent Publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to convert an AsyncTask to RxJava]]></title>
            <link>https://medium.com/android-news/how-to-convert-an-asynctask-to-rxjava-80e5d777a40?source=rss-1736df87918------2</link>
            <guid isPermaLink="false">https://medium.com/p/80e5d777a40</guid>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Pierce Zaifman]]></dc:creator>
            <pubDate>Sun, 14 May 2017 13:38:36 GMT</pubDate>
            <atom:updated>2017-05-14T14:31:14.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajiSyTszcLpkduuy5yBaKw.jpeg" /></figure><p>Let’s take a look at a sample <a href="https://developer.android.com/reference/android/os/AsyncTask.html">AsyncTask</a>. It will make a network request to a URL and then return whether or not it was successful. For this example I’m using <a href="http://square.github.io/okhttp/">OkHttp</a>, but that part isn’t important.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbe021536cecf6fffc9bd8fac1d52e1b/href">https://medium.com/media/fbe021536cecf6fffc9bd8fac1d52e1b/href</a></iframe><p>If you’ve used an AsyncTask before this code should look familiar. Inside the doInBackground method I make a network request to some given URL, and return the result as a Boolean. Then in onPostExecute I could do something with that result.</p><p>Now if I want to remove the AsyncTask and replace it with <a href="https://github.com/ReactiveX/RxJava">RxJava</a> (and <a href="https://github.com/orfjackal/retrolambda">Retrolambda</a>), one solution would look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68aa01f7854d8db04d61dc9009572689/href">https://medium.com/media/68aa01f7854d8db04d61dc9009572689/href</a></iframe><p>There are many ways you could approach this in RxJava. But essentially all I’m doing is creating an <a href="http://reactivex.io/documentation/observable.html">Observable</a> which reports on the result of the network request. I observe the result on the main thread (with <a href="https://github.com/ReactiveX/RxAndroid">RxAndroid</a>) so I could make any UI changes. This is effectively the same as the AsyncTask I created. The main difference is that with an Observable I have much more flexibility in how results are processed.</p><h3><strong>If You Enjoyed Reading, Please Click That Little Heart. If You Want To Read More Like This, Follow Me On </strong><a href="https://medium.com/@piercezaifman"><strong>Medium</strong></a><strong>. Thanks!</strong></h3><p><em>Originally published at </em><a href="https://piercezaifman.com/converting-an-asynctask-to-rxjava/"><em>piercezaifman.com</em></a><em> on May 14, 2017.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80e5d777a40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/how-to-convert-an-asynctask-to-rxjava-80e5d777a40">How to convert an AsyncTask to RxJava</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>