Skip to content

Instantly share code, notes, and snippets.

@plateaukao
plateaukao / isolate_example.dart
Last active May 28, 2019 07:18
isolate_example
Isolate isolate;
void startRealAsyncTask() async {
// need a ReceivePort to receive messages.
ReceivePort receivePort= ReceivePort();
isolate = await Isolate.spawn(heavyTask, receivePort.sendPort);
receivePort.listen((data) {
stdout.write('RECEIVE: ' + data + ', ');
});
}
@plateaukao
plateaukao / image_remove_backgroun.dart
Created April 13, 2019 05:18
image remove background in flutter
Future<Uint8List> _downloadImage() async {
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$_filename');
if (file.existsSync()) {
var image = await file.readAsBytes();
return image;
} else {
var response = await http.get(_url,);
var bytes = response.bodyBytes;
@plateaukao
plateaukao / download_image.dart
Created April 13, 2019 05:06
download image in flutter
Future<dynamic> downloadImage() async {
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$filename');
if (file.existsSync()) {
print('file already exist');
var image = await file.readAsBytes();
return image;
} else {
print('file not found downloading from server');
@plateaukao
plateaukao / image.dart
Created April 13, 2019 05:00
flutter_image_example
import 'dart:io' as Io;
import 'package:image/image.dart';
void main() {
// Read an image from file (webp in this case).
// decodeImage will identify the format of the image and use the appropriate
// decoder.
Image image = decodeImage(new Io.File('test.webp').readAsBytesSync());
// Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
Image thumbnail = copyResize(image, 120);
@plateaukao
plateaukao / CircleImageView.java
Created April 4, 2019 07:09
Show image in circle in Android
package com.linecorp.linesdk.dialog.internal;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
@plateaukao
plateaukao / android_translated_string_extraction_cmd
Created April 3, 2019 06:48
android translated string extraction
python main.py original_string_key new_string_key
@plateaukao
plateaukao / android_activity_lifecycle_in_multiwindow_mode
Created October 19, 2018 11:47
Android Activity LifeCycle in Multi-window mode
1. 進入一個 Activity
onStart
onResume
2. 進入 Multi-window 模式
onPause
onStop
onStart
@plateaukao
plateaukao / Undo_enhance.diff
Created June 13, 2018 16:58
enhance undo feature
export interface IPointGroup {
+ maxWidth: number;
color: string;
points: IBasicPoint[];
}
@@ -230,6 +231,7 @@ export default class SignaturePad {
private _strokeBegin(event: MouseEvent | Touch): void {
const newPointGroup = {
color: this.penColor,
+ maxWidth: this.maxWidth,
export interface IPointGroup {
color: string;
points: IBasicPoint[];
}
@plateaukao
plateaukao / undo.js
Created June 13, 2018 16:39
Signature_Pad Undo feature implementation
document.getElementById('undo').addEventListener('click', function () {
var data = signaturePad.toData();
if (data) {
data.pop(); // remove the last dot or line
signaturePad.fromData(data);
}
});