This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dagger.kotlin | |
import java.util.* | |
//Since the function's body contains a single expression, we need not use curly braces here | |
fun createRandomNumber() = Random().nextInt() | |
//This works for properties as well | |
val MY_API_KEY : String = "API_KEY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class StudentKt { | |
@NotNull | |
private static final String MY_API_KEY = "API_KEY"; | |
public static final int createRandomNumber() { | |
return (new Random()).nextInt(); | |
} | |
@NotNull | |
public static final String getMY_API_KEY() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kotlindemo | |
import android.content.Context | |
import android.widget.Toast | |
fun Any.shortToast(ctx: Context) = Toast.makeText(ctx, this.toString(), Toast.LENGTH_SHORT).show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
title: 'Flutter Demo', | |
theme: new ThemeData( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => new _MyHomePageState(); | |
} | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
int _counter = 0; | |
void _incrementCounter() { | |
setState(() { | |
_counter++; | |
}); | |
} | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
.... | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
title: new Text(widget.title), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.google.firebase:firebase-ml-vision:15.0.0' | |
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fab_take_photo.setOnClickListener { | |
// cameraView is a custom View which provides camera preview | |
cameraView.captureImage { cameraKitImage -> | |
// Get the Bitmap from the captured shot and use it to make the API call | |
getLabelsFromDevice(cameraKitImage.bitmap) | |
} | |
} | |
private fun getLabelsFromDevice(bitmap: Bitmap) { | |
val image : FirebaseVisionImage = FirebaseVisionImage.fromBitmap(bitmap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun getLabelsFromDevice(bitmap: Bitmap) { | |
... | |
val detector : FirebaseVisionCloudLabelDetector = FirebaseVision.getInstance().visionCloudLabelDetector | |
detector.detectInImage(image) | |
.addOnSuccessListener { | |
for(firebaseVision : FirebaseVisionCloudLabel in it){ | |
... | |
} | |
} | |
.addOnFailureListener { |