In modern Android development, constructing network structure is an important factor and we can implement network communication structure using HTTP client tools like OkHttp, Retrofit, or Volley. Also, it is an important factor to design how to handle callback responses from the network. Many people standardize callback responses by creating wrapper classes like
Response and handling success data or error messages depending on the response state like the below.
However, what if we want to handle error cases depending on its HTTP status code (401, 402. 403..) or handle each error response globally for logging/debugging error messages or showing toasts? Or what if we want to get directly typed wrapper classes from every different service without creating new instances of wrappers every time manually? Probably we have to write a bunch of codes and classes for building the response handling. Constructing the structure of the standardized response requires a lot of resources at the initial time. …
Hilt is a dependency injection tool that has been introduced by Google in the last year. Hilt makes our projects cleaner and reduces setup time for constructing our DI environment than Dagger-Android. It has been steadily getting feedback and developing for several months. Now Hilt is more stable than the earliest was. In this post, we will take a look at what is the main difference between the earliest version of Hilt and the newest one.
There is no difference in using
HiltAndroidApp annotation for building the base DI environment. The role of the
HiltAndroidApp is kicking off the code generation of the Hilt components of our project in the compile-time and generates the base classes that need to construct our DI structure. So we don’t need to create a bunch of boilerplates like ActivityModule, ViewModelModule, ViewModelFactory, etc. …
Spinner is one of the most frequently used widgets in Android for selecting a specific item in a dropdown list. The Android SDK provides a default widget called Spinner, but as we know it requires many kinds of boilerplates and difficult to fully customize for our preferred design. And no animations. This requires our valuable time whenever we need to create a different type of spinners based on preferred designs. In this post, we will take a look at how to customize a better Spinner using a library, PowerSpinner.
The components of Android (Activity, Fragment, Service, BroadcastReceiver) are very independent of each other. It means they don’t have any dependencies on each other and it allows us to decide their entry points at any points. And we can decide and change their workflow by the desired anytime.
But the independent characteristics make it difficult to communicate with each other. So the Android SDK supports concepts of the Intent for holding an abstract description of an action to be performed, and the Bundle for passing data based on inter-process communication mechanism. They are one of the most important and basic things in Android development and we must use them for starting components or passing data between them. …
Anew UI toolkit Jetpack Compose is announced by Google. Jetpack Compose is Android’s new modern toolkit for building native UI based declarative component approaches. In contrast to imperative programming, declarative programming is a programming paradigm that expresses the logic of computation or drawing UIs without describing its control flow. The declarative programming approaches in mobile are already used widely like SwiftUI and Flutter. And here is a new one; Jetpack Compose.
Application class is the first entry point of the android application process and it’s for maintaining a global application state. It is always running while our activities and services are running and also it is the first context to be created and the last to be destroyed. So it manages lifecycles of the whole applications using ApplicationContext, we can access the application’s resources, show toast messages, and create instances of Android SDK related classes that use it.
The other role of the Application class is initializing every SDKs and libraries which required ApplicationContext in the application’s whole lifecycle. As the size of the project grows, the size of the application class also grows. That makes poor readability because of every initialization code snippets are just in one class. …
Dagger is one of the most popular and most used libraries for building dependency injection, especially in Android. But the initial cost of learning is high and beginners are difficult to debug and hard to understand what’s going on in the compile time. So here is another powerful DI weapon for beginners and old dagger users: Hilt. In this post, we will look around what’s big differences between dagger-android and Hilt and what’s the benefits bu using Hilt.
The Hilt reached alpha but there is no official documentation and explains. so I’ve looked around documentations in the code to rely on, interpretations might also be wrong. It is an alpha, the main implementation might be also will be changed in future releases. …
Progressbar is one of the most frequently used widgets in Android development. However as we know, the default ProgressBar provided by Android SDK has poor customizable options. There is no way to show the current progress value, no progress animations, no gradient/rounded basic attributes. Every time we should create a different drawable XML file, but it is still limited. This posting is about how to implement a polished and flexible ProgressView, fully customizable with animations and its UX design philosophy.
Generally, progressBar draws only progress. …
Requesting data to remote server and handling responses is always one of the important issues in Android development. When we are building our project even a small-sized demo project, we have to spend time constructing the REST service structure. Using the modern Android development tool like Retrofit2, OkHttp, LiveData, or RxJava we can implement the network interfaces easily and request asynchronously. But designing standardized response models/interfaces and handling success data and errors are also important things.
In the last post, we found out about the motion systems in the new version of the material design. In this part, we’re going to find about the modern Android development tools and architectures.
I published an open-source project DisneyMotions, it is based on MVVM architecture and written in Kotlin. Check the full source code on this repository. 💗