Journal
Dated notes
Sat, Jun 6, 2020 7:30:08 PM
Practicing how to create a ListView
in Android. Using default Android resources such as android.R.drawable.presence_online
because it has its pair android.R.drawable.presence_offline
.
The @android:id/list
is tricky because I am using ListActivity
I traced via println("*")
the optimization benefits of an improved ArrayAdapter
implementation decreasing the expensive operations layout inflation and object creation through some sort of caching technique via View::setTag
and View::getTag
.
There are 20 rows in your list but Android can only display in the ListView
16 rows. When the app is executed, these 16 rows will be inflated. The remaining 4 rows will not be inflated. When you scroll down such that 4 new row appears, there will be an inflation operation for this 4 new rows. It is Android that knows wither new rows appear by calling the getView
method of ArrayAdapter
. You shall check if the param is null or not. As you scroll back and forth, there will be no more inflation and you retrieved the cached view via getTag
call. According to vogella
, the avoidance of findViewById
improves performance by 15%.
I was surprise when I extend Kotlin's ByteArray
to do hex dump when it also became available to ByteBuffer
:
Some float to hex table:
float
4 bytes representation
0.123
3D FB E7 6D
0.456
3E E9 78 D5
0.789
3F 49 FB E7
3.14159
40 49 0F D0
-1.234
BF 9D F3 B6
If error an Android Studio:
Then try build.gradle
edit using:
Also, not sure but gradle minimum version is 4.6
!?!
Mon, Jun 8, 2020 3:19:55 PM
Inside CMakeLists.txt
, a separate if
is better than with chained elseif
to be more discreet.
For example, in an Android build it is both ON_ANDROID
and ON_UNIX
. In a cygwin shell, it is both ON_CYGWIN
and ON_UNIX.
In a Windows git bash shell, it is both ON_WIN32
and ON_MSVC
. On Linux shell, it is only ON_UNIX
.
Sloppy today. I specified:
And combined with circleci
settings:
The artifacts appear as android
in contrast to what I expected as android/stuff.tar.bz2
. And then, the file type was gzip
format I thought it was circleci doing it. Upon review, it was my z
option in my tar
command making it into gzip
format but with .bz2
extension. Better to skip use of optional destination field so that all outputs are explicit and better tracking.
Got thrown off by ?circle-ci=xxxxx
Wed, Jun 10, 2020 3:01:37 PM
Both sliceArray
and copyOfRange
have same starting point but they differ in the ending. The sliceArray
has inclusive ending whereas copyOfRange
means up to but not including end part.
In the above snippet at line 4, the sliceArray
must use 9
otherwise code will crash. Both lines 4 and 5 are doing same thing. Notice also that sliceArray
uses ..
instead of ,
.
So today, I think my Haskell
familiarization study paid off a little. I was browsing through a Kotlin tutorial and found this:
So thanks to my Haskell
tinkering in the past, this looks like the familiar fold
function in the Haskell world. This fold
thing really got me into a limbo I remember because it is such an alien construct. I also remember, it has a variant called fold1
and how these two differs. The Kotlin
reduce
function is the fold1
in Haskell. Change the array by starting with 0
instead of 2
as in the above snippet you will see it will print 0
. The fold1
variant uses the first element as the initial value of the accumulator.
Last updated
Was this helpful?