In this design patterns in java series, I will be documenting the most common design patterns as written by the Gang of Four in their classic book: Design Patterns – Elements of Reusable Object-oriented Software.
I will maintain a pattern (no pun intended) of giving a real-world example then show you the code example. Ready? Let us do this!
Real World Example
Design patterns are everywhere in our lives. For example, a newspaper publishing company releases papers each morning and the papers are delivered to their customers/readers by the good old paper boys! So, the company will keep a list of newspaper subscribers in their database somewhere! The readers are free to subscribe to or unsubscribe from the service if you are tired or when money runs out! Makes sense right?
According to the documentation, a RecyclerView is a flexible view for providing a limited window into a large data set. If you have done any android development before, you definitely know the popular ListView class used to display lists of things. After its release by Google however, most of us have moved on and now use RecyclerViews. In this post, I want to show you how to handle click events like regular touch event and also long click in recyclerviews because you cannot just set OnClickListeners like you would for a ListView.
EventBus is an Android optimized event bus that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality. You see, if you have developed android applications before, you will agree with me when I say that communication between different parts of the project code can be a pain. Using interfaces might work but not all the times. The idea though would be to stick to the best design patterns in Java which include decoupling your code. Eliminate dependencies. Let us get started!
First Things First
To use EventBus, you should add the following to your build.gradle file (app-level file)
Let me start this short post by saying I am sorry for taking what almost felt like an eternity to write new posts. Will you accept my apology? Thank you!! I mean, I have been gone so long that Donald Trump has spewed more insults at people than all my previous blog posts combined. Let me not start talking about all the things that have happened around the world.
You wanna know something? I think it is laziness or whatever you call that situation where you give yourself excuses not to do certain things. Yeah, the struggle is real bro!
Let’s learn how to update android apk outside the playstore in this short post! Perhaps you have a scenario where you don’t want to publish your app in the playstore. The reason behind your decision could be to have more control over who installs the app or even the size of the file itself among other things.
Food Saver app enables anyone to fight hunger now – yes, immediately, by providing you with 15 closest food collection centers based on your GPS coordinates. I will describe the key features later in a video demo below but for now, let me tell you a bit about why this is one of the most important projects I have solely worked on. Here is how the home screen looks like – watch video below this post for a demo:
Let’s learn how to share an image on Facebook in Android using their ever-changing API. If you have used Facebook’s Android SDK, you know it can be a PITA to say the least. I think Mark should give the developers a vacation for heck’s sake!
How To Share An Image On Facebook In Android – Sample Code
Before you can use Facebook’s Android SDK in your Android application (to add features like sharing, liking etc), you have several options of including their SDK in your project. For instance:
3D printing technology is no longer too foreign to most of us. You must have heard about it while running around or even while seated somewhere watching something online – who knows? In this feature post, am going to let my friend Nathan Adams tell us about his brand new company – FYI he also provides hosting services among other things; AllosTech and what he has to offer to the masses as far as 3D printing technology is concerned.
3D Printing Technology – AllosTech Launching
I am pleased to announce the opening of a brand new 3D Printing company – AllosTech
Retrofit library is a Type-safe REST client for android and Java, courtesy of Square Inc. Most modern android apps make HTTP requests to some remote server somewhere in Antarctica or who knows where! Making such requests can sometimes be a pain in the … what did you just say? Using this retrofit library will save you a lot of pain as well as boiler-plate code. In this simple tutorial, I will show you everything you need to get started with it. Let us get started!
Retrofit Library Implementation Steps
Below are the steps we will follow while implementing this retrofit library in our android application.