Question:
Convert a non-negative integer to its English words representation. Given input is guaranteed to be less than 2^31 - 1.
[LeetCode] Shortest Word Distance III
Question:
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.
word1 and word2 may be the same, and they represent two individual words in the list.
[LeetCode] Word Shortest Distance II
Question:
Design a class which receives a list of words in the constructor, and implements a method that takes two words word1 and word2 and return the shortest distance between these two words in the list. Your method will be called repeatedly many times with different parameters.
[LeetCode] Shortest Word Distance
Question:
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.
MVC, MVP, and MVVM design patterns on Android
Shelter in place for COVID-19 in San Francisco
就地避難 (Shelter in place)
本來打算趁今天天氣不錯總算出太陽了,打算帶小孩去 Golden Gate Park 散散心避開人潮,畢竟現在 COVID-19 太過嚴重,最好還是不要去人多的地方增加感染的機率! 結果就在我們做好便當 (打算去踏青,順便找個無人的草原野餐) 準備出發的時候,竟然收到這則消息 -
原來就在今天舊金山市長 London Breed宣布整個舊金山在 3/17 凌晨 0:00 am 進入就地避難(Shelter in place) 的狀態,這還是我第一次在美國遇到這種狀況. 就上網查查現在是什麼情況.
Android Coroutines - Suspend, Resume, and Dispatch
In the Introduction section, we already have a big picture of the Coroutines
feature, including what it is, how we can use it, and other basic concepts. In this article, I will introduce another critical keyword suspend
:
Dagger Series: Something amazing about constructor injection
In Dagger, it provides another way to inject/provide resources by using constructor injection.
The typical case is that we use constructor injection
in a class to inject needed resources as class parameters. In this way, we can directly use the required resources without declaring the @Inject
keyword. Another pro tip is that it has very high potentialities to let your injection more robust and more flexible. Let’s see how we can use constructor injection for providing multi-source injection for the different release versions.
Android Coroutines - Introduction
I recently read the source code of Coroutines.
It’s pretty fun, and I’ve learned a lot from the source code. I am going to share some I learned here. I would break the learning into several parts. I hope everyone can find something useful for your projects.
Android Thread Model
Process v.s Thread
Android OS is a kind of Linus system. Every time you launch an application on your device, it invokes a process to host this application and provides the necessary resources for the application. By default, all components that come from the same application would run in the same process and thread (called main thread or UI thread). By default, you would run all components, Activity,
Service,
Receiver,
Provider,
on the same process. But there’s a way for a specific need for developers who want to run these components on different processes. You can add android: process
in the AndroidManifest.xml
file in each component declaration. For example,