Skip to content

Instantly share code, notes, and snippets.

enum Books: String {
case computer = "Computer"
case science = "Science"
case langugae = "Language"
}
let error : Error = .fatal(num: 404, message: "not found")
private fun setupAdapter() {
this.forecastListAdapter = ForecastListAdapter(this, WeatherService.threeDayForecast)
forecast_List.adapter = this.forecastListAdapter
forecast_List.layoutManager = LinearLayoutManager(this)
}
yourImageView.load(fromURLString: webUrlString, enableAnimation: true, defaultImage: UIImage(named: "defaultImage")!)
@BoshiLee
BoshiLee / passwordupdateAlert.m
Created June 12, 2019 03:14
passwordupdateAlert
// 網銀密碼升級 Alert 文字
NSDate *fourDigisPasswordExpireDate = [@"2019/9/9" dateFromMMBShortStyleDateString];
NSAttributedString *updatePasswordNotifyString = [MMBLoginModel updatePasswordNotifyWithDate:fourDigisPasswordExpireDate];
if ([MMBLoginModel isFourDigiPasswordExpired:fourDigisPasswordExpireDate]) {
[MMBViewEngine.sharedInstance showAlert:@"網銀密碼升級"
attributedmessage:updatePasswordNotifyString
aligment:NSTextAlignmentJustified
actionTitles:@[@"立即升級"] callBack:^(NSInteger isConfirm)
{
Stream<int> countStream(int max) async* {
for (int i = 0; i < max; i++) {
yield i;
}
}
Future<int> sumStream(Stream<int> stream) async {
int sum = 0;
await for (int value in stream) {
class StartTakePictureScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Camera Example'),
),
body: Center(
child: RaisedButton(
child: Text('Take A Picture'),
void pushToCamera(BuildContext context) async {
final cameras = await availableCameras();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TakePictureScreen(camera: cameras.first),
),
);
}
// A screen that takes in a list of cameras and the Directory to store images.
class TakePictureScreen extends StatefulWidget {
final CameraDescription camera;
const TakePictureScreen({
Key key,
@required this.camera,
}) : super(key: key);
@override
// You must wait until the controller is initialized before displaying the
// camera preview. Use a FutureBuilder to display a loading spinner until the
// controller has finished initializing.
FutureBuilder<void>(
future: _initializeControllerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
// If the Future is complete, display the preview.
return CameraPreview(_controller);
} else {