-
App Crash by `@NonNull` and Android Room
@NonNull @NonNull is a handy annotation to help avoid passing a wrong value in fields and parameters. When Android Studio detects, it highlights those potential problem points. This annotation is totally optional. However, I believe that having it is one of the good practices and bringing much bigger value in terms of a bug prevention. This annotation this won’t be...
-
No Gradle Daemon for CI Agents
Gradle runs on the JVM with several supporting libraries that require an initialization time. If you run Gradle tasks frequently, it would be better to minimize duplicate initialization time. Gradle Daemon is the solution for that. It is a long-lived background process that executes tasks quickly if possible. It avoids expensive bootstrapping process and leverages caching. So, there is no...
-
Is 'TextUtils.isEmpty' Evil?
While you are developing an application, we want to avoid duplicate logic as much as possible. For that, we usually make utility classes or apply existing third-party libraries.TextUtils is a utility class provided in the Android package. If it provides what you want, you don’t need to make your own utility class or use other libraries. You can just use...
-
Bash: Alias vs Function
When you use a command line interface a lot, there would be some commands you use every day. Some commands are short but the others could be a bit longer. One reason is that one command runs with several parameters. Another reason is that one command can consist of multiple commands with some operators (e.g. |, :, &&). In any...
-
Your Presenter Might Know View Too Early
When MVP(Model-View-Presenter) is applied in Android, the code is commonly written like below. Contract.Presenter is created in onCreate() and pass the Activity or Fragment implementing the Contract.View. public interface Contract { interface View { showLoading(); showData(List<Data> list); } interface Presenter { } } public class SearchActivity extends AppCompatActivity implements Contract.View { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(); mPresenter =...
-
Realtime Stopwatch
Stopwatch is an application which users allow to measure the elapsed time between the start and the stop. Here are general requirements for that. Have buttons to start, stop. When it is started, ticking time should be displayed. Ticking time should be shonw in the millisecond precision. When it is stopped, elapsed time should be displayed. Requirements looks not difficult....