New York Tech Journal
Tech news from the Big Apple

Mar GDG Meetup: #ServiceWorkers, Advanced #TextViews and ng-conf Recap

Posted on March 19th, 2015


03/18/2015 @Google, Chelsea Market, NY, 75 Ninth Ave, NY

Presentations on #TextView and #ServiceWorkers were supplemented by four shorter presentations.

Chiu-Ki Chen spoke about how Android TextView in the UI can be used to create a wide variety of exciting visual effects.

She first concentrated on how the contents of a TextView can create text shadows, glowing text, custom fonts, color gradients fonts and text pattern coloring

She next showed how spannable strings can be used to create strings of characters with variety of adjustments in font height, color, clickability etc. within a single TextView. A single TextView can therefore create the look and feel of tagged segments in an Html document.

As a final touch, Chiu-Ki showed how to create text on a lined page by combining text and graphics on a canvas. She also showed how emoji unicodes can be remapped to images which can be resized and positioned like characters.

20150318_194246[1] 20150318_201541[1]

As a followup to last month’s meetingJeff Posnick spoke about Service Workers. Service Workers are #javaScript code that creates native-app capabilities for web pages. These include local responses to events, off-line capabilities, push notifications in Chrome:

  1. JavaScript runs outside of the main page => no DOM access
  2. Responds to events
  3. Applies to all pages under a scope and persists when tabs are closed
  4. A cache is exposed to the service worker, so pages can be used off-line.
  5. Can modify CSS.
  6. For security reasons, it only runs on https locations

Programming. Service workers are based on Promises (a syntax which is an alternative to callbacks for asynchronous code.) In the code, an asynchronous process is called and returns immediately with a promise that will eventually be fulfilled. Once the promise is fulfilled, the code starts the next process. Debugging can be done in Chrome using the web page: chrome://serviceworker-internals

Implementation: When a web page is first called, the service worker is not invoked, (but this can be overridden). This is done so the page runs on other browsers that may not support Service Workers, In addition, the JavaScript should include code like

if (‘serviceWorker’ in navigator) …

so the Service Worker only runs when the browser can handle it.

Service worker should live at the root of your domain since it only has control over network requests that are within that part of the tree.

Things you can do. If you are offline and the video you requested is not available, it will return the previous video you downloaded. It can write a custom off-line page. It can trigger a push notification so long as Chrome is running, even if the page is not active. It can send notifications to a wearable watch.

In the shorter presentations

  1. Alex Qin – @CoalitionForQueens – talked about their program to teach adults to code. They are looking for instructors.
  2. Elcin Erkin – updated the audience on the latest developments in AngularJS from the ng-conf 2015 in Salt Lake City Utah. The main discussion was about migrating to Angular 2.0. The upgrade will feature
    1. Better performance and design.
    2. New TypeScript created jointly by Microsoft and Angular
    3. Speed up using unidirectional bindings.
    4. Changes in syntax and semantics.
    5. A new router to better serve complex applications.
    6. The Angular team has taken over the Material Design component.
    7. Incorporate web components.
  3. Ray Tsang – In honor of pi day (3/14) he calculated pi to 100B digits in 5 ½ hours on a multicore processor.(I wonder what the distribution of digits looks like)
  4. Dario Laverde– showed how easy it is to create Wearable watch faces using Android Studio. In less than a minute he created a face without writing a single line of code.

posted in:  Android, GDG, Programming    / leave comments:   No comments yet