-
RxJava: Fail Early and Track Errors
In RxJava, Publisher emits events and you can subscribe to those events with Consumer. While subscribing, emitted events can be used to update the view or to do something else. Below example shows a simple example: getUser() // Publisher. Events could be from the network or database. .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(user -> { // Consumer userTextView.setText(user.getName()); } }); This code work...
-
Use the <merge> Tag for Optimizing View Tree
In Android, a view is one of the basic blocks for user interface components. It is a tree structure and you can nest views to display what you want to show. If the tree height gets longer, it can lead to some performance issue. The reason is that the Android framework does a top-down traversal of the view tree two...
-
How to Set Default Values in Room Database
When you initialize your application, you often need a default value to determine how it works. For example, most values of Settings require a default value. When you use a database, you read a value from there. Thus, it is better to put a default value in there instead of in the code. How can you do it? Room database...
-
Android: Analyze Stack Trace from Plain Text Log
A stack track is a report that shows the stack frames at a certain point. When you debug your application, this is useful to know how to this method is called. This is even useful when a crash happens. At that time, you need to know what happened. A stack track can show how to end up having a crash....
-
OkHttp: How to Refresh Access Token Efficiently
When you use the token-based authentication including OAuth, there are two tokens: access token and refresh token. Whenever you need to access a protected resource, An access token should be used to approve the access right. A refresh Token is a kind of special token. It can be used to get a renewed access token because an access Token has...
-
Android: How to Track All Methods in a Class
When your application gets bigger, it would be hard to know who calls a method and when it is called. If you want to know it, you can print logs using Log class. As described in the previous post, breakpoints can be used for logging without changing your code. However, if there are many methods, both ways are kind of...