Notes

Android Bootcamp Vietnam

Daniel Weibel
Created 14 Feb 2017
Last updated 6 Apr 2017

These are notes of an eight-week CoderSchool Android development bootcamp that I attended from February to April 2017 in Ho Chi Minh City (a.k.a. Saigon), Vietnam.

The main focus of these notes is on the new concepts that I learned every week, and on the things that proved to be challenging.

Organisation

  • 8 weeks
  • Every week:
    • Theoretical lecture of 2 hours
    • Practical labe of 2 hours
    • Assignment to complete at home
  • Final group project
  • First Lecture: 14 Februrary 2017
  • Last Lecture: 6 April 2017

Week 0

Learned Concepts

  • Cupboard (SQLite database wrapper)
  • Contextual Action Mode (multi-selection in ListView)
  • Publish an app on Google Play

Difficulties

  • Swipe ListView items left and right: requires AndroidSwipeLayout or without a 3rd party library here and here
  • RecyclerView: learn how to use it from the ground up

Things to Check Out

Week 1

Learned Concepts

  • Retrofit 2: full-blown client for accessing RESTful HTTP APIs
  • Gson: convert between JSON objects and Java objects (used by Retrofit)
  • OkHttp 3: HTTP client for Androd and Java (used by Retrofit)
  • ViewHolder pattern: reduce findViewById() in getView() of an adapter for a ListView
  • Data Binding Library: eliminate findViewById() altogether

Difficulties

  • Cannot have a ListView inside a ScrollView, but possible to work around with using a LinearLayout and adding child views programmatically with addView()
  • YouTubePlayerFragments dynamically added to a LinearLayout: cannot have multiple fragments with the same ID in an activity
  • YouTubePlayerViews dynamically added to a LinearLayout: videos don’t load correctly (only last YouTubePlayerView gets its video loaded)

Week 2

  • Lecture: User Interaction and Navigation Flows (Intents)
  • Lab: Book List (Open Library API)
  • Assignment: News Explore

Learned Concepts

  • Stetho: Chrome-based debugging tool for Android
    • Use Stetho for monitoring HTTP requests made by Retrofit and Glide: add a StethoInterceptor to the OkHttp client used by Retrofit, set up Glide to use OkHttp by a GlideModule and also add a StethoInterceptor to this OkHttp client
  • RecyclerView: how to use it (including patches for “onItemClick” and endless scrolling)
  • ProgressDialog/ProgressBar for displaying e.g. a “loading” state
  • Incorporate a ShareActionProvider into the app bar for sharing content
  • Automatic generation of Java model classes for Retrofit from a JSON string with jsonschema2pojo
  • Retrolambda: enable lambda expressions and method references for Java < 8 (lambda expressions and method references are a feature of Java 8, which currently can be used for Android with the new Jack toolchain; however the Jack toolchain is experimental and has some issues, for example, it cannot be used together witht he Data Binding Library)

Difficulties

  • Finetuning of endless scrolling in RecyclerView: hard to achieve a fluent experience with a “staggered grid layout”
  • Many NYTimes Article Search API calls fail for different reasons: not sure if it’s an API or network connection issue or a general one
  • Finetuning of Glide: more images than necessary are fetched from the server rather than from the cache
  • Architecture: how to best organise complex UI code like for the filter dialog?

Week 3

Learned Concepts

  • OAuth: users authorise an app to access their information on a service (e.g. Twitter) without giving their username and password of this service to the app: the users authenticate directly with the service, and the service authorises the app to access the users’ information. This works only with services that provide an OAuth API (see a list here).
  • DBFlow: an ORM (object-relational mapper), alternative to ActiveAndroid, Cupboard, ORMLite, etc.
  • Firebase: a collection of backend services (real-time database, authentication, cloud messaging, storage, test lab, notifications, remote config, AdMob, and more). Use it whenever your app needs an independently running “server”.
  • Use the Data Binding Library to load Java objects into XML layouts (including the definition of new XML attributes with the @BindingAdapter annotation). This is especially useful for ListViews/RecyclerViews by passing the current data object directly into the “item XML layout” in the adapter.

Difficulties

  • Next time when working with an OAuth API, use ScribeJava directly (instead of the Codepath OAuth Handler which wraps around ScribeJava)
  • Legal matters with publishing an app on Google Play: app store listing (including screenshots) must not contain:
    • Image of movie, music album, etc.
    • Title of a movie, music album, etc.
    • Image of a popular person
    • Logo of a company, organisation, etc.
    • App name must not contain name of a company/organisation that makes the app look like having an official relationship with this company/organisation (e.g. NYT Explore is not allowed as an app name)
  • Create an abstract RecyclerView adapter for data binding that can be reused (see a guide here).

Things to Check Out

  • Realm: mobile database (non-SQL and non-ORM)

Week 4

Learned Concepts

  • Listener pattern: passing information from an inner object (e.g. fragment) to an outer parent (e.g. activity) without hard-wiring the innner object to the outer parent or the application in general (keep the inner object stand-alone).
  • EventBus: simplify communication between activities, fragments, etc.
  • Use of managers to pull out business logic from the low-level implementation

Difficulties

  • How to handle the attachment of fragments to activities in a robust way
  • How to best organise complex code in general

Things to Check Out

Week 5

  • Lecture: Content Providers
  • Lab: Google Maps API
  • Interview Prep: Strings and Arrays
  • Project: Deals Sprint 1

Learned Concepts

  • Deep link: a URL that opens a specific activity in an Android app (e.g. clicking on a Wikipedia article link in the Chrome web browser opens the article in the Wikipedia app)
  • Git branching model by Vincent Driessen
  • Milestones and issues on GitHub
  • Square’s Java code style: can be installed in Android Studio and then selected in Preferences > Code Style
  • EditorConfig: enforce coding styles on compatible IDEs by a simple external .editorconfig file (supported by Android Studio out-of-the-box)
  • Exercism: small programming exercises in different languages to prepare for interview exercises

Project

Week 6

  • Lecture: Drawables, Styles, and Themes
  • Lab: Theme Switcher
  • Interview Prep: Big-O Notation and Hashtables
  • Project: Deals Sprint 2

Learned Concepts

  • Different types of Android Drawables: shape drawable, state-list drawable, layer-list drawable
  • Style: collection of view attributes that can be applied to individual views
  • Theme: collection of styles that are automatically applied to all views of an app or activity that support them
  • Implementation of the hashtable data structure: keys mapped to hash value mapped to array indices, and values stored in array

Difficulties

  • How to use the attrs.xml file and ?attr and ?android:attr attributes for defining and using themes
  • How to use the Firebase Real-Time Databa

Things to Check Out

  • git-flow: a command line tool to simplify the usage of the Git branching model by Vincent Driessen
    • See usage overview here
  • InterviewBit: theory and exercises about important topics for interviews
  • InterviewCake: programming interview questions
  • HackerRank: large collection of programming exercises to be solved online
  • Java Features and Promises to prevent callback hell
  • RxJava to prevent callback hell

Project

Learned

  • Firebase data retrieval model: a “query” is a set of listeners that listens on objects in the database matching certain constraints (like WHERE, ORDER BY in SQL). However, unlike a SQL query, a Firebase query does not retrieve this data just a single time (as a snapshot of the data at a specific point in time), but persistently “listens” on this data and triggers the listener callbacks whenever the data matched by the query changes (e.g. an object “entering” or “leaving” the query due to updating the properties of an object, insertion of a new object or deletion of an existing object from the database, etc.).
  • Firebase authentication by email/password, Google (OAuth), and anonymously

Difficulties

  • How to organise Firebase database code (e.g. queried data is returned in a listener callback, at which point we can query more data which is in turn returned in another listener callback, and so on) $\longrightarrow$ Callback Hell (pyramid of anonymous class and callback definitions)
  • How to best handle static data in the Firebase Database, i.e. data which needs to be queried only once and does not need to be updated in real time (e.g. user information). Does it make sense to store it in the Fireabase Real-Time Database, or is it better to store it in a non-real-time database?

Week 7

Learned Concepts

  • Tween animations: animations with a starting and ending point (different from animations used in games)
  • Any view can be animated with ObjectAnimator and AnimatorSet
  • Animations can be defined in XML under res/animator
  • A special type of animations are activity transitions: every activity has an enter and exit transition

Things to Check Out

  • Amazon DynamoDB: cloud-based NoSQL database for document and key-value data (use it for storing independent data that can be retrieved with a key, like in a hashtable)
  • Google Megastore: cloud-based NoSQL database, similar to Amazon DnyamoDB
  • AWS Lambda (Amazon): computing-as-a-service platform to run arbitrary code

Week 8

  • Lecture: Dependency Injection and ReactiveX
  • Project: Internal Demo Day on Thursday, 6 April

Learned Concepts

  • Dependency injection: passing of concrete service objects implementing certain interfaces to clients by an injector
    • 4 components:
      1. Client: any object that is in need of other objects (dependencies)
      2. Service objects: the objects on which a client depends on (dependencies)
      3. Injector: the module that creates service objects and passes them to the clients
      4. Interfaces: defining the functionality of the service objects passed from the injector to the client
    • Goal: move the decision of which objects (configurations) to use from the low-level code to a centralised high-level module. This facilitates managing and changing configurations, as everything can be managed in one place rather than in many (probably deeply nested) spread-out objects.
      • Eliminate object creations in client objects (e.g. by new)
    • The service objects can be injected to the client through the client constructor, setter methods, or fields (done in Android by Dagger)
  • Reactive Programming: programming paradigm centered around transforming one or more data input streams to a data output stream (think of a logic gate in computer architecture). The output stream is adapted constantly according to the input streams.
    • ReactiveX: reactive programming specification based on the observer pattern with implementations for many programming languages and platforms (e.g. RxJava for Java, RxAndroid for Android)

Things to Check out

  • Guice: dependency injection framework for Java
  • Dagger: dependency injection framework for Android
  • RxJava: ReactiveX framework for Java
  • RxAndroid: ReactiveX framework for Android