Sorting Algorithms Live Comparison

Standard

I was browsing internet some time ago and saved this gif comparison of major sorting algorithms against each other and it really gives you a good grasp on their speed.

sorting speed comparison

Here are some stats that I picked out from looking at this:

Fastest Slowest
Random Heap Selection
Nearly Sorted Insertion Selection
Reversed Shell Selection
Few Unique Quick3 Selection
Best All Around: Shell
Worst All Around: Selection

I think “Few Unique” is in random order, but I am not sure. Anyways, I thought this was interesting and is definitely easier than memorizing Big(O) notation. Let me know if I made a mistake.

Android: Customizing SmoothScroller for the RecyclerView

Standard

First, this is not a full comprehensive in-depth guide for the SmoothScroller, but I hope this gives you a jumpstart on where you can begin customizing because I could not find any clear tutorials on this topic.

What is a SmoothScroller you ask? A SmoothScroller is exactly as it seems. It’s a Class that helps a View scroll to an item’s position smoothly to create a seamless transition as opposed to snapping to it abruptly. In this example I will be using its child Class LinearSmoothScroller with the RecyclerView.

We all know that to initialize a RecylerView we need to set a LayoutManager like so:

mRecyclerView.setLayoutManager(mLinearLayoutManager);

or else an error will occur during run-time. Well, the LayoutManager is in charge of the smooth scrolling! Therefore, in order to customize the SmoothScroller we need to create our own custom LayoutManager first.
Continue reading

Android Screen Resolutions and Their Smallest Width in DP

Standard

Edit: Here a more accurate list provided by Google:  https://design.google.com/devices/

When I was developing with the Genymotion emulator, I had trouble getting a sense of how big the actual devices actually were when choosing resolution size for debugging. So I did a little test to see what their smallest width was in dp for each resolution.

A dp is a density-independent pixel that corresponds to the physical size of a pixel at 160 dpi.

Resolution and DP

Now if I want to test out a resolution, I can just look at this chart and see it’s physical size.

I’ve also added annotations for which devices are small, not long, and long, because I feel those devices are the gotchas and need their own dimens.xml file to make them look good.