Skip to content

Instantly share code, notes, and snippets.

View bapspatil's full-sized avatar

Bapusaheb Patil bapspatil

View GitHub Profile
val result = recognizer.processImage(image)
.addOnSuccessListener { result ->
// Task completed successfully
// Text recognition results
val resultText = result.text
// `FirebaseVisionText` is made of `TextBlock`s...
for (block in result.textBlocks) {
// ...and each `TextBlock` has
// text, confidence level, list of recognized languages and corner points and frame in which the text was detected...
val blockText = block.text
recognizer.process(visionImage) { result, error in
guard error == nil, let result = result else {
// ...
return
}
// Text recognition results
let resultText = result.text
// `VisionText` is made of `VisionTextBlock`s...
for block in resultText.blocks {
@bapspatil
bapspatil / main.dart
Last active March 21, 2019 08:52
Main Dart file for Kut In
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'package:http/http.dart' as http;
import 'about_screen.dart';
import 'quote.dart';
void main() => runApp(KutInApp());
@bapspatil
bapspatil / api_call.dart
Last active March 21, 2019 08:53
API call to get quotes for Kut In.
Future<void> getQuote() async {
String baseUrl = 'http://api.kanye.rest/';
try {
http.Response response = await http.get(baseUrl);
var myQuote = Quote.fromJson(jsonDecode(response.body));
setState(() {
_quote = myQuote.quote;
_gradientColors.shuffle(_random);
_colorOne = _gradientColors[0];
_colorTwo = _gradientColors[1];
@bapspatil
bapspatil / gradient_colors.dart
Created March 16, 2019 07:45
List of gradient colors for Kut In
List<Color> _gradientColors = [
const Color(0xfff44336),
const Color(0xffba000d),
const Color(0xff9c27b0),
const Color(0xff6a0080),
const Color(0xff2196f3),
const Color(0xff0069c0),
const Color(0xfffdd835),
const Color(0xffc6a700)
];
@bapspatil
bapspatil / quote.dart
Created March 16, 2019 07:41
The quote data class for the Kut In app.
class Quote {
final String quote;
final String id;
Quote.fromJson(Map<String, dynamic> json)
: quote = json['quote'],
id = json['id'];
}
@bapspatil
bapspatil / colors.xml
Created January 6, 2019 14:15
All Material Design colors.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
<color name="md_red_300">#E57373</color>
<color name="md_red_400">#EF5350</color>
<color name="md_red_500">#F44336</color>
@bapspatil
bapspatil / MySliceProvider.kt
Created October 9, 2018 06:04
MySliceProvider: Creating a SliceAction
private fun createActivityAction(): SliceAction? {
// (1) Create a SliceAction as follows.
return SliceAction.create(
/* (2)
** Pass in a PendingIntent,
** icon to display on the slice,
** size of the icon, and
** and the title of the action,
** to handle the on-click action for a Slice.
*/
@bapspatil
bapspatil / MySliceProvider.kt
Last active October 9, 2018 05:59
MySliceProvider: Implementing the onBindSlice method
override fun onBindSlice(sliceUri: Uri): Slice? {
// (1) Create a Context variable.
val context = context ?: return null
// (2) Create the SliceAction to handle clicks on the Slice.
val activityAction = createActivityAction() ?: return null
// (3) Handle the Uris for returning the Slices here.
return if (sliceUri.path == "/hello") {
// Uri's path is recognized as "hello".
// Note: ANR and StrictMode are enforced here so don't do any heavy operations.
@bapspatil
bapspatil / AndroidManifest.xml
Created October 9, 2018 05:51
AndroidManifest.xml after creating a SliceProvider
<provider
android:name=".MySliceProvider"
android:authorities="com.bapspatil.slicesplayground"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.app.slice.category.SLICE" />
<data
android:host="bapspatil.com"
android:pathPrefix="/hello"