fun draw(canvas: Canvas, text: Spanned, layout: Layout) { // ideally the calculations here should be cached since // they are not cheap. However, proper // invalidation of the cache is required whenever // anything related to text has changed. val spans = text.getSpans(0, text.length, Annotation::class.java) spans.forEach { span -> if (span.value.equals("rounded")) { val spanStart = text.getSpanStart(span) val spanEnd = text.getSpanEnd(span) val startLine = layout.getLineForOffset(spanStart) val endLine = layout.getLineForOffset(spanEnd) // start can be on the left or on the right depending // on the language direction. val startOffset = (layout.getPrimaryHorizontal(spanStart) + -1 * layout.getParagraphDirection(startLine) * horizontalPadding).toInt() // end can be on the left or on the right depending // on the language direction. val endOffset = (layout.getPrimaryHorizontal(spanEnd) + layout.getParagraphDirection(endLine) * horizontalPadding).toInt() val renderer = if (startLine == endLine) singleLineRenderer else multiLineRenderer renderer.draw(canvas, layout, startLine, endLine, startOffset, endOffset) } }}
abstract fun draw( canvas: Canvas, layout: Layout, startLine: Int, endLine: Int, startOffset: Int, endOffset: Int )
build.serial
$ npm install -g firebase-tools@latest $ firebase --version 4.0.0
$ npm install firebase-functions@latest
"engines": { "node": "8" }
firebase deploy
i functions: updating Node.js 8 function onMessageCreate(us-central1)... i functions: updating Node.js 8 function onMessageDelete(us-central1)...
compilerOptions
target
lib
"compilerOptions": { "target": "es2017", "lib": ["es2017"], "module": "commonjs", ... }
region
runWith
const functions = require('firebase-functions'); exports.myHttpFunction = functions // Choose a region other than the default us-central1 .region('europe-west1') // Increased memory, decreased timeout (compared to defaults) .runWith({ memory: '1GB', timeoutSeconds: 120 }) .https .onRequest((req, res) = > { // time and memory intensive tasks res.send('Hello world'); });