Work Flashcards
Vital Connect: Disconnect patch problem
- disconnecting a patch worked on Kit Kat and crashed on Lollipop.
- observed a lot of disconnect crashes
- problem occurred on devices running Lollipop but not Kit Kat.
- disconnect call was performed via an AsyncTask.
- fix was to use a Thread instead of an AsyncTask.
- unable to determine the cause of the problem, but there are problems with AsyncTask
- AsyncTask uses an internal work queue with a size limit of 10, so it can overflow
- AsyncTask won’t survive its Activity getting destroyed and recreated. If the Activity restarts, the AsyncTask will have a stale reference to it.
- if AsyncTask’s Activity dies, the AsyncTask won’t, so you need to cancel it yourself. Note that you also need to check that it actually has been cancelled.
It’s probably better to use something other than AsyncTask.
Ooyala: Jumpy scrubber bar problem
On the video player, the scrubber jumped around during seeks.
- if the user played a video and dragged the scrubber, it would jump back to its old position.
- problem occurred because the drag causes the progress bar to be re-rendered with the changing playhead position.
- progress bar also gets re-rendered when the playhead position changes during normal playback.
- resulting behavior is that the drag will move the playhead then the normal playback will move the playhead to the previous, pre-dragging position, causing a jump.
- problem was fixed by creating a variable to cache the playhead position. It is initially set to -1.
- when componentWillReceiveProps (a React Native function called before a component receives new props) is called, the previous and the new playhead positions are compared. If the positions are different, it’s assumed that a seek has occurred, the updated playhead position should not be used, and the cache variable is set to -1.
- when the progress bar is rendered, the playhead position is set to either the cached position if that value is not -1 or the current position. This ensures that dragging the scrubber will only update its position when the drag is complete.
- in handleTouchEnd (a React Native function) which is called at the end of the scrubber drag, the cache variable is set to the current playhead position and saved in the state. This value is used in the next progress bar render.
Ooyala: Customized accent bar color for video player
- added ability to customize the accent bar color for buttons and switches by adding the accentColor parameter to the skin-schema.json
- added the supporting code in the React Native skin layer to use the accent color instead of the default color.
- worked closely with Playback Web team because accent color was already supported in Web, and we needed to support it in Apps.
- worked with documentation team and learned how to generate the HTML documentation for the skin schema.
Ooyala: Fixed error message handling in video player
- Fixed error message handling.
- customer was receiving an iOS error message on an Android app.
- problem was caused by the iOS and Android error message enums being out of sync.
- synched enums in the iOS and Android SDKs and added integer error codes (error messages previously were retrieved based upon their ordinal position).
- modified code in the React Native layer to map the error code received to the error message to be displayed.
- modified code so that the error messages are localized.
- made TODO notes regarding new messages that need to be added to the JSON language files (the mapper either returns the message retrieved from the language file or, if not found, it returns a hard-coded string).
Ooyala product info
- Ooyala is a video publishing and advertising platform aimed at medium to large publishers that want to host and monetize online video.
- the Ooyala platform includes an HTML5/Flash player, a variety of monetization solutions, and detailed video analytics for publishers.
Ooyala Player
- Ooyala Player itself is a broadly compatible HTML5-first video player that supports formats such as DASH and HLS.
- player is responsive and works well on desktop and mobile, with a highly customizable, intuitive user interface.
- analytics side of Ooyala is Ooyala IQ — a multi-dimensional analysis tool that lets you find your most effective video syndication partners and view geographic, device, traffic source and engagement data on a granular basis for all of your hosted videos.
- next-generation video player that provides an engaging, personalized, responsive, content aware, and robust video playback experience that is consistent across devices and platforms.
- implements a new skin that can be applied to three products:
- Ooyala Player V4 for HTML5 is a new Web-based player that runs in popular browsers across desktop and mobile devices.
- Ooyala Player Skin for iOS enhances the Ooyala (video player) Mobile SDK for iOS by integrating the Player V4 skin in iOS native apps.
- Ooyala Player Skin for Android enhances the Ooyala (video player) Mobile SDK for Android by integrating the Player V4 skin in Android native apps.
- high-quality, consistent performance across devices (robust video streaming support with performance enhancements)
- robust, modular, flexible player skin template that follows unified Google Material UX Guidelines and can be customized for a branded playback experience
- easy integration with advertising and analytics services
Ooyala SDK
SDK has two parts:
- content management functions:
- loading a video and its associated metadata from embedded code (content identifiers)
- querying for more videos.
- controlling video playback on a predefined player skin
- functions are essential for playback
- user interface layout controls include the provided skins, and positioning of the video surface within the application.
- controls can be replaced entirely, either from scratch or with the provided controls as a starting point.
-to use the Ooyala Skin SDK in an app:
Since Facebook no longer distributes the latest versions of the React Native AAR files with maven repositories, the React Native file is now distributed with OoyalaSkinSDK.jar.
- to integrate React Native with the OoyalaSkinSDK:
- download and unzip OoyalaSkinSD-Android.zip.
- copy the OoyalaSkinSDK.jar file into the app’s libs/ directory.
- copy the react-native-0.33.0.aar file into the app’s libs/ directory.
- modify your app gradle build file configuration to include OoyalaSkinSDK and React support, as shown in the following gradle build file snippet:
React Native
- created at Facebook
- built on top of React.JS
- framework for building native apps using React
- runs on JS VM of mobile devices
- lets you build mobile apps using only JavaScript
- uses JSX, XML-esque markup
- React Native “bridge” between JS and host platform. Invokes native rendering APIs in Objective-C for iOS or Java for Android
-React component returns markup:
React uses the markup on the DOM
React Native translates the markup to the host
platform. E.g. <view> -> Android TextView
- apps render using real native components, not webviews</view>
React Native pros and cons
pros:
- rapid development
- platform agnosticism
- smaller codebase
cons:
- requires substantial time and energy to integrate into existing mobile codebase
- developers still need to write native code (network stack, internationalization, deep links, navigation, advanced map features)
- “landmines” - interactions in code that can be extremely hard to track down and reproduce
- React Native development cycle is slow (every four weeks), so getting a patch can take time
Vital Connect
- wearable biosensor that monitors vital signs
- allows remote monitoring
- connects via Bluetooth to smartphone
- an app can display steps taken, heart rate, breathing and skin temperature
Patents
Workflow-enabled provider
A workflow-enabled provider includes a service provider and a workflow manager interface unit. The workflow manager interface unit couples the service provider to a workflow manager to provide the automatic discovering, distributed processing and dynamic user interface generating functionality. An advertisement monitor listens for broadcasts from the workflow manager regarding new clients. A request module and a response module handle the transfer of data and control signals between the workflow manager and the service provider. A process control module performs a plurality of processing functions including aggregating requests from clients, selecting requests it can service, presenting user interfaces, processing input via the service provider and controlling the service provider. The user interface module is coupled to the process control module and dynamically generates user interfaces for display by the service provider.
Workflow-enabled client
A workflow-enabled client comprises a client and a workflow manager interface unit. The workflow manager interface unit couples the client to a workflow manager to provide the automatic discovering, distributed processing and dynamic user interface generating functionality of the present invention. A communication manager of the workflow-enabled client has a registration unit that registers, and unregisters, the client with the workflow manager such as by providing a name, a data and other commands. A polling module uses a received location from the workflow manager to retrieve data. The process control module performs a plurality of processing functions such a processing polled data, storing it or providing it to other clients. The process control module can also initiate other clients. The present invention also includes a number of novel methods including a method for registering a client, a method for polling data, and a method for initiating other clients.
Workflow manager for a distributed system
A workflow manager handles the communication between a workflow-enabled provider and a workflow-enabled client. The workflow manager maintains a directory of clients, translates a transaction from a provider into multiple transactions suitable for the client, and handles security. In one embodiment, the workflow manager connects with the workflow-enabled client by registration and with the workflow-enabled provider by advertising and activation. Subsequent communications between the workflow manager and the workflow-enabled provider and the workflow-enabled client are with a request/response protocol. The workflow manager also comprises data storage for storing data for transmission to the workflow-enabled client or the workflow-enabled provider, and workflow storage for storing information related to registered clients. The present invention also includes a number of novel methods including a method for a method for registering a client and a method for activating a provider.
Vital Connect: VC Relay
The Relay SDK
- connects to nearby VCI patches via Bluetooth LE
- collects and stores data
- data is pushed to the VCI Cloud
- client apps can access patch data and perform relay commands
- generates events for select activities that can be received by clients.
- some events will provide additional information to clients as payloads which are in key/value format.
- clients can register to and unregister from events.
- clients can query for data and mark data as “uploaded”.
- clients can delete data.
- clients can configure upload parameters (destination URL, upload frequency, max payload size).
VC Relay
- manages VCRelaySDK API command
- takes input from the calling program
- calls VCI component methods to fulfill the commands
- returns results to the calling program.
VC Patch
- core functionality
- discovers patches
- manages patch connections
- manages data from patches
VC Bluetooth
- device discovery
- device handling
VC Database
- core functionality to interface with a relational database
- connectivity
- database instance management
- table management
- data CRUD operations
VC Network
- core functionality to transfer data between Relay and local/remote service providers via networking protocols.
- uploads data
- downloads assets to/from specified destinations
VCCore
- event handling
- error handling-
- state machine
- log manager
Whatizit files
ViewController.swift checkNetwork(): initAndStart() initTitleAndView(title : String) timeout() getImage() checkCameraPermission() cameraAccessNeededAlert() showCellularAlert() stopProgressAndTimer() showStartAlert() pickImageSourceAlert() showGuessAlert() showTimeoutAlert() showSettingsAlert() showNoNetworkAlert() showResultAlert() playAgainAlert() showFinalScoreAlert() noCameraAlert() usePhotoLibrary()
UImageView.swift
String.swift
NetworkManager.swift
RestKit.framework
SVProgressHUD.framework
VisualRecognitionV3.framework
Whatizit: image recognition
The IBM Watson Visual Recognition service uses deep learning algorithms to analyze images (.jpg or .png) for scenes, objects, faces, text, and other content, and return keywords that provide information about that content.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
// Check for network connection NetworkManager.isUnreachable { _ in self.showSettingsAlert() }
// Display progress spinner SVProgressHUD.show()
// Set timer timer = Timer.scheduledTimer(timeInterval: timeoutSeconds, target: self, selector: #selector(timeout), userInfo: nil, repeats: false)
// Do image recognition if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { imageView.image = image imageView.roundCornersForAspectFit(radius: 15) imagePicker.dismiss(animated: true, completion: nil)
self.navigationItem.title = String.THINKING
let visualRecognition = VisualRecognition(version: version, apiKey: apiKey) let imageData = image.jpegData(compressionQuality: 0.01) let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let fileURL = documentsURL.appendingPathComponent("tempImage.jpg") try? imageData?.write(to: fileURL, options: []) let failure = { (error: Error) in print(error) } visualRecognition.classify(image: image, failure: failure) { classifiedImages in let classes = classifiedImages.images.first!.classifiers.first!.classes
self.classificationResults = [] for index in 0..
Whatizit: NetworkManager
Code is from: https://blog.pusher.com/handling-internet-connection-reachability-swift/
import Foundation
import Reachability
class NetworkManager: NSObject {
var reachability: Reachability!
// Create a singleton instance static let sharedInstance: NetworkManager = { return NetworkManager() }()
override init() { super.init()
// Initialise reachability reachability = Reachability()!
// Register an observer for the network status NotificationCenter.default.addObserver( self, selector: #selector(networkStatusChanged(_:)), name: .reachabilityChanged, object: reachability )
do { // Start the network status notifier try reachability.startNotifier() } catch { print("Unable to start notifier") } }
@objc func networkStatusChanged(_ notification: Notification) { // Do something globally here! }
static func stopNotifier() -> Void { do { // Stop the network status notifier try (NetworkManager.sharedInstance.reachability).startNotifier() } catch { print("Error stopping notifier") } }
// Network is reachable static func isReachable(completed: @escaping (NetworkManager) -> Void) { if (NetworkManager.sharedInstance.reachability).connection != .none { completed(NetworkManager.sharedInstance) } }
// Network is unreachable static func isUnreachable(completed: @escaping (NetworkManager) -> Void) { if (NetworkManager.sharedInstance.reachability).connection == .none { completed(NetworkManager.sharedInstance) } }
// Network is reachable via WWAN/Cellular static func isReachableViaWWAN(completed: @escaping (NetworkManager) -> Void) { if (NetworkManager.sharedInstance.reachability).connection == .cellular { completed(NetworkManager.sharedInstance) } }
// Network is reachable via WiFi static func isReachableViaWiFi(completed: @escaping (NetworkManager) -> Void) { if (NetworkManager.sharedInstance.reachability).connection == .wifi { completed(NetworkManager.sharedInstance) } } }