The goal with the architecture is to end up with something like this:
If you’re familiar with libraries like greenDAO or EventBus, you may have heard of the company that created them: greenrobot. If not, I recommend checking them out. In short, they build high quality open source libraries for app developers.
Recently, they have come out with a new library called ObjectBox. 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.
If you’re familiar with RelativeLayout, then ConstraintLayout 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.
To add ConstraintLayout to your project, place the following in your
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:
At Google I/O this year, Google announced a new set of architecture libraries. One of the new components they included is called LiveData. 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.
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.
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 sunk cost fallacy. 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.
To get started you need to include the following in your
Now you can set up your API interface with RxJava Observables, for example:
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.
Alternatively, I can set up my own deserializer, like so:
Lastly, here is my API creation with a deserializer for the
User added in:
It’s human nature to compare yourself to others. Everybody does it. The problem is that many of us misunderstand what we’re comparing.
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.
Yet, consider this: you and your friend are different people. You live completely different lives. It’s not as if your…
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.
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. …
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.
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…
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.