Skip to content

Instantly share code, notes, and snippets.

View the-dagger's full-sized avatar
🚀
To Boldly Go Where No Man Has Gone Before

Harshit Dwivedi the-dagger

🚀
To Boldly Go Where No Man Has Gone Before
View GitHub Profile
@the-dagger
the-dagger / Student.kt
Last active January 26, 2018 13:28
Student.kt
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"
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() {
package kotlindemo
import android.content.Context
import android.widget.Toast
fun Any.shortToast(ctx: Context) = Toast.makeText(ctx, this.toString(), Toast.LENGTH_SHORT).show()
@the-dagger
the-dagger / main.dart
Last active March 1, 2018 20:25
Flutter
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(
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
....
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
class _MyHomePageState extends State<MyHomePage> {
....
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
implementation 'com.google.firebase:firebase-ml-vision:15.0.0'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0'
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)
private fun getLabelsFromDevice(bitmap: Bitmap) {
...
val detector : FirebaseVisionCloudLabelDetector = FirebaseVision.getInstance().visionCloudLabelDetector
detector.detectInImage(image)
.addOnSuccessListener {
for(firebaseVision : FirebaseVisionCloudLabel in it){
...
}
}
.addOnFailureListener {