SQLite Triggers (+ Android Room) Jan 17, 2020 Introduction SQLite is one of the most used database. This is because it is used on almost all mobile devices in the world. As SQLite is very similar to SQL everyone already knows the basic concepts like querying, inserting, updating, deleting data; databases and tables; joining tables etc. But SQLite also has some advanced features and this article is about one of such called Trigger. If we try to speculate on the name “Trigger” we might say that probably something will be done when some changes are made to the database. ...
Decoding Handler and Looper in Android Dec 24, 2019 Introduction Handler and Looper are one of the main low-level Android OS things, which almost nobody uses directly (at least nowadays). But they are at the core, so many other high-level solutions are based on them. Therefore one should know what Handler and Looper are, what and how they are doing. In this article we’ll try to understand Handler and Looper in Android. What, how and why we might need them. ...
Operator fusion in RxJava 2 Nov 2, 2019 Introduction RxJava is a very powerful library, though it has some issues as well. Specifically performance and memory issues, which come from problems library tries to solve and how the solution is designed from technical perspective. In order to minimize overhead in RxJava there are a number of optimizations, which are called “operator fusion”. And we’ll talk about them in this article. But first let’s recap how RxJava reactive types work and what issues they have. ...
Random interview coding task retrospective Sep 27, 2019 Introduction It happens often that on interviews you’ve asked to perform some coding task. For unknown reason most of the times you’ve asked to write some code not in the IDE, but on piece of paper. I don’t like such tasks on an interview, because in real life one won’t write any kind of code on a paper. If you need to write something not in IDE you face issues like you can’t quickly change something or write new code in between the lines. ...
SiMMMMpLLLLeDateFormat Jul 21, 2019 Introduction Using SimpleDateFormat to format dates and times is a common thing (as Java 8 Time API is not that available on Android yet). Usually it looks like: val formatter = SimpleDateFormat("dd MMMM yyyy", Locale.ENGLISH) formatter.format(date) We can use different formats and locales with not only providing correct translations, but also some additional locale-specific formatting rules. One tricky thing about SimpleDateFormat formats is why we have M and L when they look identical? ...
3x3x3 Rubik’s cube world (GIF alert) Jul 7, 2019 Introduction I find Rubik’s cube an awesome puzzle. It has simple design, but quite difficult to solve (if you don’t know how to do that). At the same time it is possible to learn how to solve cube — there are a lot of algorithms for solving (for example Fridrich method describes quite a lot of them). These optimized algorithms made popular speedcubing — solving cube on time — with world record of less than 4 seconds. ...
Android Version Code Tricks Jul 4, 2019 Introduction Version code is a special integer value which works as an internal version number. It is not visible to end users. Android system uses this number to protect against application downgrades — it is not possible to install new application with version code lower than in currently installed application. Developers can use version code for example for doing specific tasks on updating to specific version. Version code is placed inside AndroidManifest, but usually it is inside *defaultConfig *in build. ...
Throttling in RxJava 2 Jun 24, 2019 Introduction I don’t know for what reason but I see from time to time same misunderstanding on different throttle operators in RxJava. Usually nobody says about throttle, instead by default everyone says that debounce can be used. Especially using debounce to avoid multiple clicks on buttons is commonly suggested, which I believe is a bad UX (some examples here and here). Let’s finally look at available options in RxJava and find out when it is better to use what. ...
Java-C-Assembly Matryoshka Jun 4, 2019 Source Disclaimers: I’ll use Windows and more particularly Visual C++ with its Inline Assembler. If you use MacOs or Linux you will have significant differences comparing to what is described in the article. Everything below is shown mostly for demonstration purposes Introduction Java is mature self-sufficient language, though as we all know it is possible to “connect” java to C (via Java-Native-Interface or JNI) to speed up some critical pieces of code. ...
RxJava Observable to Single May 27, 2019 Transforming Single to Observable is simple, as Single satisfies Observable’s contract. Just call single.toObservable() and you’re good. But transforming Observable to Single is not that simple: if it happens that Observable emits exactly one value and completes (or terminates with error without emitting values) then it is pretty straightforward, otherwise one need to set up some additional rules. In RxJava there are a number of operators for transforming Observable to Single: ...