Stop assuming that everyone is in the USA. This means when you write articles like 'Google Glass is available to everyone today!' - its not, its only available to the USA.
When you do things like 'Its Pi Day!' or 'its Palindrome week!' - again, its not, its only in the USA where the date format is backwards.
When you have a hangout, meeting, or request work online. When somebody asks your time zone, please be specific - 'east coast' is not a timezone, neither is 'Pacific' (I live in the pacific!)
Even saying 'CST' can be anything from -6 to +8 hours since there are multiple time zones using that abbreviation (http://www.timeanddate.com/library/abbreviations/timezones/ )
Annoyed and needing coffee
In addition to the attached image, I've also got an SVG: http://staticfree.info/~steve/complete_android_fragment_lifecycle.svg which is suitable for printing.
If this is missing lifecycle steps or is inaccurate in any way, let me know so I can update it!
The avatars themselves are fetched from the network, which gives us a square - and sometimes rectangular - source image. Our first step is to create a normalized square image based on the target dimensions on the screen. That normalized image preserves the source aspect ratio, upscaling the source if necessary to fill at least one dimension edge-to-edge and filling the second dimension with white pixels (taking care of non-square sources). This is done with Canvas.drawBitmap that takes a source and destination rectangles as the parameters.
The next step is to compute the pixel size of the ring outline and the drop shadow. The ring outline starts at 1dip and is capped at 4dips, while the drop shadow starts at 2dips and is capped at 3dips. The actual size is determined based on the avatar size, setting the cap at 96x96dips (based on our current design metrics). This results in visuals that scale with the avatar size (seen below), while still capping the ring and drop shadow to not be too big for larger avatars.
Now it's time to take a look at the avatar layers. We have the avatar itself cropped to a circular shape, the ring outline and the drop shadow. In our first implementation pass we used Paint.setShadowLayer to combine the last two together into a single Canvas operation. We first painted the white ring, and then the avatar itself (since the drop shadow extends to both sides of the path, and we didn't want the shadow to be visible on top of the "inner" image). However, the runtime performance of shadow layer was not very satisfactory. It took about 2.5ms to draw a single outline, and when we had a few avatars on the screen, the numbers started adding up.
Instead, we're doing three separate layers.
First, we draw the drop shadow as Canvas.drawOval with a single translucent grey color. We use Paint.setStrokeWidth to set the interpolated drop shadow size, and Paint.setColor to set the interpolated drop shadow color (for larger shadows we use more translucency to keep the same overall shadow "weight" across different avatar sizes).
Second, we draw the avatar itself. We create a BitmapShader with the normalized square avatar source and TileMode.CLAMP and set it with Paint.setShader. Using that Paint object on a Canvas.drawRoundRect call results in the circular crop of the source image. There's some extra bookkeeping to make sure that we're scaling down the normalized source to make the white ring outline external to the image, not losing the few top/bottom/left/right pixels. This can be done with a combination Canvas.scale and Canvas.translate operations to keep the scaled-down avatar centered on canvas.
Third, we draw the ring outline as Canvas.drawOval with opaque white color. We use Paint.setStrokeWidth to set the interpolated ring outline size.
There's a bunch of small objects used for the custom drawing operations, usually involving a mix of Paint and Rect ones. It's recommended to create them once at the class level, initializing as much of the state as you can in your constructor. Then, during the actual transformation / draw operations that can happen multiple times during the layout / render passes, only set those fields that are dynamic (size / color). This way you won't be creating transient objects which are discarded after they're used - saving yourself from unexpected GC pauses in the middle of your rendering. Also try to use Canvas operations (transforms, scaling) instead of creating intermediate Bitmap objects. And measure every step to make sure that you're not using operations that are too expensive.
Happy pixel pushing!
- Beuth Hochschule für Technik BerlinBachelor of Science, 2006 - 2009
- Technische Fachhochschule BerlinMedieninformatik, 2006 - 2009
- FH Brandenburg
- Deutsche Post IT SolutionsTrainee (Fachinformatiker für Anwendungsentwicklung, 2001 - 2004
- Immobilien Scout GmbHMobile Developer, 2007 - present
- Jamba GmbHSenrio J2EE Engineer, 2004 - 2007
- Deutsche Post ITSolutionsDeveloper, 2004 - 2004
Ende eines Trends?: Berlin ist nicht mehr die coolste Stadt der Welt - B...
Berlin verliert seinen unfertigen Charme – und fällt im Rating der Trendsetter zurück. Die Berliner Szene ist inzwischen alarmiert und verun
Google kauft WhatsApp-Konkurrenten Threema für fünf Milliarden Dollar
Zürich, Mountain View (dpo) - Der Internet-Konzern Google kauft die Instant-Messenger-Anwendung Threema für insgesamt fünf Milliarden Dollar
Biernominierung: Bereits über 4000 Jugendliche an halbem Liter Bier auf ...
Berlin (dpo) - "Biernominierung", "Social Beer Game", "Neknominate": Das Grauen hat viele Namen, doch egal, wie es sich nennt, es kann nicht
Best Practices to develop for different Android Device Classifications b...
This Session will give a best practices from the Immobilienscout24 Development for the different Android device classifications. During this
Studie: Abschiebung von Nazis würde Staatskasse um Milliarden entlasten
Berlin (dpo) - Eine neue Studie im Auftrag des Wirtschaftsministeriums sorgt derzeit in Berlin für Aufregung. Aus ihr geht hervor, dass die
Leistungsschutzrecht: Springer knickt vor Google ein
Am Donnerstag ist es so weit. Das umstrittene Leistungsschutzrecht tritt in Kraft. Über Sinn und Unsinn des Gesetzes haben viele Menschen ge
TV: Philips Ambilight und Hue leuchten im Duett - Golem.de
Philips hat einen neuen Fernseher vorgestellt, dessen umlaufender Ambilight-Leuchtrahmen zusammen mit den Hue-LED-Lampen von Philips zusamme