I tried to display a timer ( format dd HH mm ss ) to count the time between each actions (button action for exemple ). And need to work even the app is close and rebuild. Currently I load a string date I saved with sharedpreference when I pressed a button who represent the time when I pressed the button. I format all time decimal to compare and display time difference. I think it's not beautifull, not what I search, and I don't succeded to display clock in the format (dd HH mm ss). If someone have a more simple exemple :)
load_records_pulsion() async{
/*var current_time = DateFormat('yyyy-MM-dd HH').format(DateTime.now());*/
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
RegExp regExp = new RegExp( //Here is the regex time pulsion
r"([12]\d{3})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])",
);
last_pulsion = (prefs.getString('last_pulsion'))??0;
var match = regExp.firstMatch("$last_pulsion");
annees = match.group(1); // hh:mm
mois = match.group(2); // hh:mm
jours = match.group(3); // hh:mm
int annees_int = int.tryParse("$annees") ;
int mois_int = int.tryParse("$mois") ;
int jours_int = int.tryParse("$jours") ;
print("$annees_int");
print("$mois_int");
print("$jours_int");
final last_pulsion2 = DateTime(annees_int, mois_int, jours_int);
final date_now = DateTime.now();
difference_pulsion = date_now.difference(last_pulsion2).inDays;
if(difference_pulsion==0){
difference_pulsion ="";
prefix_pulsion ="Aujourd'hui";
}else{
prefix_pulsion ="jours";
}
});
}
Also I tried this code, it's OK the timer is increase when I call the function, but I don't want datenow, I just need to start with zero time
int _start = 0;
void startTimer() {
_start=0;
var now = new DateTime.now();
const oneSec = const Duration(seconds: 1);
_timer = new Timer.periodic(
oneSec,
(Timer timer) => setState(() {
{
chrono = now.add(new Duration(seconds: _start));
_start = _start + 1;
}
}));
}
Edit: I found this solution but have some lifecycle error, and if I close the app, I loose the timer.
Stopwatch stopwatch = new Stopwatch();
void rightButtonPressed() {
setState(() {
if (stopwatch.isRunning) {
stopwatch.reset();
} else {
stopwatch.reset();
stopwatch.start();
}
});
}
#override
Widget build(BuildContext context)
{
...
new Container(height: 80.0,
child: new Center(
child: new TimerText(stopwatch: stopwatch),
)),
...
class TimerText extends StatefulWidget {
TimerText({this.stopwatch});
final Stopwatch stopwatch;
TimerTextState createState() => new TimerTextState(stopwatch: stopwatch);
}
class TimerTextState extends State<TimerText> {
Timer timer;
final Stopwatch stopwatch;
TimerTextState({this.stopwatch}) {
timer = new Timer.periodic(new Duration(milliseconds: 30), callback);
}
void callback(Timer timer) {
if (stopwatch.isRunning) {
setState(() {
});
}
}
#override
Widget build(BuildContext context) {
final TextStyle timerTextStyle = const TextStyle(fontSize: 50.0, fontFamily: "Open Sans");
String formattedTime = TimerTextFormatter.format(stopwatch.elapsedMilliseconds);
return new Text(formattedTime, style: timerTextStyle);
}
}
class TimerTextFormatter {
static String format(int milliseconds) {
int seconds = (milliseconds / 1000).truncate();
int minutes = (seconds / 60).truncate();
int hours = (minutes / 60).truncate();
int days = (hours / 24).truncate();
String minutesStr = (minutes % 60).toString().padLeft(2, '0');
String secondsStr = (seconds % 60).toString().padLeft(2, '0');
String hoursStr = (hours % 60).toString().padLeft(2, '0');
String daysStr = (days % 24).toString().padLeft(2, '0');
return "$daysStr:$hoursStr:$minutesStr:$secondsStr";
}
}
If you want the counter to persist after closing the app, there is no way around saving the value somewhere (like shared preferences).
Using dateTime.toIso8601String() and DateTime.parse() will make the saving and loading less ugly.
To calculate the passed time you can use DateTime.now().difference(lastButtonPressed)
There should be a function to format Duration (https://api.flutter.dev/flutter/intl/DateFormat/formatDurationFrom.html) but it's not implemented yet. I found one here: Formatting a Duration like HH:mm:ss
Here is a little example:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutterfly/SharedPrefs.dart';
class TestWidget extends StatefulWidget {
#override
_TestWidgetState createState() => _TestWidgetState();
}
class _TestWidgetState extends State<TestWidget> {
DateTime _lastButtonPress;
String _pressDuration;
Timer _ticker;
#override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Time since button pressed"),
Text(_pressDuration),
RaisedButton(
child: Text("Press me"),
onPressed: () {
_lastButtonPress = DateTime.now();
_updateTimer();
sharedPreferences.setString("lastButtonPress",_lastButtonPress.toIso8601String());
},
)
],
),
);
}
#override
void initState() {
super.initState();
final lastPressString = sharedPreferences.getString("lastButtonPress");
_lastButtonPress = lastPressString!=null ? DateTime.parse(lastPressString) : DateTime.now();
_updateTimer();
_ticker = Timer.periodic(Duration(seconds:1),(_)=>_updateTimer());
}
#override
void dispose() {
_ticker.cancel();
super.dispose();
}
void _updateTimer() {
final duration = DateTime.now().difference(_lastButtonPress);
final newDuration = _formatDuration(duration);
setState(() {
_pressDuration = newDuration;
});
}
String _formatDuration(Duration duration) {
String twoDigits(int n) {
if (n >= 10) return "$n";
return "0$n";
}
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
return "${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds";
}
}
For simplicity i initialized shared preferences in the main method in global scope.
Related
I have List array which is based on flutter multi_image_picker: ^4.7.14 dependency. How can I convert List Asset Array to List File Array?
This is the code
class _ConvertImageState extends State<ConvertImage> {
List<Asset> images = List<Asset>();
#override
void initState() {
super.initState();
}
Future<void> pickImages() async {
List<Asset> resultList = List<Asset>();
try {
resultList = await MultiImagePicker.pickImages(
maxImages: 20,
enableCamera: true,
selectedAssets: images,
materialOptions: MaterialOptions(
selectCircleStrokeColor: "white",
actionBarTitle: "Select Images",
allViewTitle: "All Images",
actionBarColor: "#3b3b3b",
actionBarTitleColor: "white",
statusBarColor: '#bbbbbb',
selectionLimitReachedText: "You can select minimum 3 and maximum 20 images",
),
);
} on Exception catch (e) {
print(e);
}
setState(() {
images = resultList;
});
}
#override
Widget build(BuildContext context) {......}
}
Can I do it with a loop? Please, anyone can tell me the correct way?
Here I find an answer. This is my working code. I think it is correct.
class _ConvertImageState extends State<ConvertImage> {
List<Asset> images = List<Asset>();
List<File> fileImageArray = [];
#override
void initState() {
super.initState();
}
Future<void> pickImages() async {
List<Asset> resultList = List<Asset>();
try {
resultList = await MultiImagePicker.pickImages(
maxImages: 20,
enableCamera: true,
selectedAssets: images,
materialOptions: MaterialOptions(
selectCircleStrokeColor: "white",
actionBarTitle: "Select Images",
allViewTitle: "All Images",
actionBarColor: "#3b3b3b",
actionBarTitleColor: "white",
statusBarColor: '#bbbbbb',
selectionLimitReachedText: "You can select minimum 3 and maximum 20 images",
),
);
} on Exception catch (e) {
print(e);
}
setState(() {
images = resultList;
putToFileArray();
});
}
void putToFileArray(){
fileImagesArray.clear();
images.forEach((imageAsset) async {
final filePath =
await FlutterAbsolutePath.getAbsolutePath(imageAsset.identifier);
File tempFile = File(filePath);
if (tempFile.existsSync()) {
fileImageArray.add(tempFile);
}
});
}
#override
Widget build(BuildContext context) {......}
}
FlutterAbsolutePathClass (Dependency)
flutter_absolute_path: ^1.0.6
Link: https://pub.dev/packages/flutter_absolute_path
To Print Array
onPressed: () {
print(fileImageArray.toString());
};
I want to connect to my firebase database as now called "realtime database".
My Apps is running smoothly, but I am getting following error if I want to start the method in my app through a button:
======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown building LoadDataFromFireStore(dirty, state: LoadDataFromFireStoreState#20451):
The getter 'keys' was called on null.
Receiver: null
Tried calling: keys
The relevant error-causing widget was:
LoadDataFromFireStore file:///C:/Users/Nutzer/AndroidStudioProjects/tennis_sv_schwaig/lib/widget/kalender.dart:17:13
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 LoadDataFromFireStoreState._showCalendar (package:tennis_sv_schwaig/widget/kalender.dart:58:34)
#2 LoadDataFromFireStoreState.build (package:tennis_sv_schwaig/widget/kalender.dart:49:13)
#3 StatefulElement.build (package:flutter/src/widgets/framework.dart:4744:28)
#4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4627:15)
...
====================================================================================================
I do not know if theres is a collision with a keyForm in an other method before. Could this be possible?
Here is the code from the method:
import 'dart:math';
import 'dart:collection';
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
import 'package:intl/intl.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
void main() => runApp(kalender());
class kalender extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: LoadDataFromFireStore(),
);
}
}
class LoadDataFromFireStore extends StatefulWidget {
#override
LoadDataFromFireStoreState createState() => LoadDataFromFireStoreState();
}
class LoadDataFromFireStoreState extends State<LoadDataFromFireStore> {
DataSnapshot querySnapshot;
dynamic data;
List<Color> _colorCollection;
#override
void initState() {
_initializeEventColor();
getDataFromDatabase().then((results) {
setState(() {
if (results != null) {
querySnapshot = results;
}
});
});
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: _showCalendar(),
);
}
_showCalendar() {
if (querySnapshot != null) {
List<Meeting> collection;
var showData = querySnapshot.value;
Map<dynamic, dynamic> values = showData;
List<dynamic> key = values.keys.toList();
if (values != null) {
for (int i = 0; i < key.length; i++) {
data = values[key[i]];
collection ??= <Meeting>[];
final Random random = new Random();
collection.add(Meeting(
eventName: data['Subject'],
isAllDay: false,
from: DateFormat('dd/MM/yyyy HH:mm:ss').parse(data['StartTime']),
to: DateFormat('dd/MM/yyyy HH:mm:ss').parse(data['EndTime']),
background: _colorCollection[random.nextInt(9)]));
}
} else {
return Center(
child: CircularProgressIndicator(),
);
}
return SafeArea(
child: Column(
children: [
Container(
height: 400,
child: SfCalendar(
view: CalendarView.month,
initialDisplayDate: DateTime(2020, 4, 5, 9, 0, 0),
dataSource: _getCalendarDataSource(collection),
monthViewSettings: MonthViewSettings(showAgenda: true),
),
),
RaisedButton(onPressed: () {
final dbRef = FirebaseDatabase.instance.reference().child("CalendarData");
dbRef.push().set({
"StartTime": '07/04/2020 07:00:00',
"EndTime": '07/04/2020 08:00:00',
"Subject":'NewMeeting',
}).then((_) {
Scaffold.of(context).showSnackBar(
SnackBar(content: Text('Successfully Added')));
}).catchError((onError) {
print(onError);
});
}, child: Text("Add")),
RaisedButton(onPressed: () {
final dbRef = FirebaseDatabase.instance.reference().child("CalendarData");
dbRef.remove();
}, child: Text("Delete")),
],
));
}
}
void _initializeEventColor() {
this._colorCollection = new List<Color>();
_colorCollection.add(const Color(0xFF0F8644));
_colorCollection.add(const Color(0xFF8B1FA9));
_colorCollection.add(const Color(0xFFD20100));
_colorCollection.add(const Color(0xFFFC571D));
_colorCollection.add(const Color(0xFF36B37B));
_colorCollection.add(const Color(0xFF01A1EF));
_colorCollection.add(const Color(0xFF3D4FB5));
_colorCollection.add(const Color(0xFFE47C73));
_colorCollection.add(const Color(0xFF636363));
_colorCollection.add(const Color(0xFF0A8043));
}
}
MeetingDataSource _getCalendarDataSource([List<Meeting> collection]) {
List<Meeting> meetings = collection ?? <Meeting>[];
return MeetingDataSource(meetings);
}
class MeetingDataSource extends CalendarDataSource {
MeetingDataSource(List<Meeting> source) {
appointments = source;
}
#override
DateTime getStartTime(int index) {
return appointments[index].from;
}
#override
DateTime getEndTime(int index) {
return appointments[index].to;
}
#override
bool isAllDay(int index) {
return appointments[index].isAllDay;
}
#override
String getSubject(int index) {
return appointments[index].eventName;
}
#override
Color getColor(int index) {
return appointments[index].background;
}
}
getDataFromDatabase() async {
var value = FirebaseDatabase.instance.reference();
var getValue = await value.child('CalendarData').once();
return getValue;
}
class Meeting {
Meeting({this.eventName, this.from, this.to, this.background, this.isAllDay});
String eventName;
DateTime from;
DateTime to;
Color background;
bool isAllDay;
}
Hope its enough and anybody could help. Thanks a lot!
I am calculating the maximum value of a simple steam and the result is:
(S1,1000,S1, value: 999)
(S1,2000,S1, value: 41)
The last line of data is obviously late: new SensorReading("S1", 999, 100L)
why was it calculated by the first window(0-1000)?
I think that the first window should be fired when SensorReading("S1", 41, 1000L) arrives.
I am very confused about this result.
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
env.setParallelism(TrainingBase.parallelism);
DataStream<SensorReading> input = env.fromElements(
new SensorReading("S1", 35, 500L),
new SensorReading("S1", 42, 999L),
new SensorReading("S1", 41, 1000L),
new SensorReading("S1", 40, 1200L),
new SensorReading("S1", 23, 1400L),
new SensorReading("S1", 999, 100L)
);
input.assignTimestampsAndWatermarks(new AssignerWithPeriodicWatermarks<SensorReading>() {
private long currentMaxTimestamp;
#Nullable
#Override
public Watermark getCurrentWatermark() {
return new Watermark(currentMaxTimestamp);
}
#Override
public long extractTimestamp(SensorReading element, long previousElementTimestamp) {
currentMaxTimestamp = element.ts;
return currentMaxTimestamp;
}
})
.keyBy((KeySelector<SensorReading, String>) value -> value.sensorName)
.window(TumblingEventTimeWindows.of(Time.seconds(1)))
.reduce(new MyReducingMax(), new MyWindowFunction())
.print();
env.execute();
MyReducingMax(), MyWindowFunction()
private static class MyReducingMax implements ReduceFunction<SensorReading> {
public SensorReading reduce(SensorReading r1, SensorReading r2) {
return r1.getValue() > r2.getValue() ? r1 : r2;
}
}
private static class MyWindowFunction extends
ProcessWindowFunction<SensorReading, Tuple3<String, Long, SensorReading>, String, TimeWindow> {
#Override
public void process(
String key,
Context context,
Iterable<SensorReading> maxReading,
Collector<Tuple3<String, Long, SensorReading>> out) {
SensorReading max = maxReading.iterator().next();
out.collect(new Tuple3<>(key, context.window().getEnd(), max));
}
}
public static class SensorReading {
String sensorName;
int value;
Long ts;
public SensorReading() {
}
public SensorReading(String sensorName, int value, Long ts) {
this.sensorName = sensorName;
this.value = value;
this.ts = ts;
}
public Long getTs() {
return ts;
}
public void setTs(Long ts) {
this.ts = ts;
}
public String getSensorName() {
return sensorName;
}
public void setSensorName(String sensorName) {
this.sensorName = sensorName;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public String toString() {
return this.sensorName + "(" + this.ts + ") value: " + this.value;
}
;
}
An AssignerWithPeriodicWatermarks doesn't create a Watermark at every conceivable opportunity. Instead, Flink calls such an assigner periodically to get the latest watermark, and by default this is done every 200 msec (of real time, not event time). This interval is controlled by ExecutionConfig.setAutoWatermarkInterval(...).
This means that all six of your test events have almost certainly been processed before your watermark assigner could be called.
If you care about having more predictable watermarking, you could use an AssignerWithPunctuatedWatermarks instead.
BTW, the way that your watermark assigner is written, all of the out-of-order events are potentially late. It is more typical to use a BoundedOutOfOrdernessTimestampExtractor that allows for some out-of-orderness.
I've an issue while trying to save an image to the Storage in iOS. Image is downloaded but not saved.
The code is:
Form hi = new Form("Toolbar", new BoxLayout(BoxLayout.Y_AXIS));
TreeModel tm = new TreeModel() {
#Override
public Vector getChildren(Object parent) {
String[] files;
if (parent == null) {
files = FileSystemStorage.getInstance().getRoots();
return new Vector<Object>(Arrays.asList(files));
} else {
try {
files = FileSystemStorage.getInstance().listFiles((String) parent);
} catch (IOException err) {
Log.e(err);
files = new String[0];
}
}
String p = (String) parent;
Vector result = new Vector();
for (String s : files) {
result.add(p + s);
}
return result;
}
#Override
public boolean isLeaf(Object node) {
return !FileSystemStorage.getInstance().isDirectory((String) node);
}
};
Command tree = new Command("Show tree") {
#Override
public void actionPerformed(ActionEvent evt) {
Form treeForm = new Form("Tree", new BorderLayout());
Tree t = new Tree(tm) {
#Override
protected String childToDisplayLabel(Object child) {
String n = (String) child;
int pos = n.lastIndexOf("/");
if (pos < 0) {
return n;
}
return n.substring(pos);
}
};
treeForm.add(BorderLayout.CENTER, t);
Command back = new Command("Back") {
#Override
public void actionPerformed(ActionEvent evt) {
hi.showBack();
}
};
Button backButton = new Button(back);
treeForm.add(BorderLayout.SOUTH, backButton);
treeForm.show();
}
};
hi.getToolbar().addCommandToOverflowMenu(tree);
EncodedImage placeholder = EncodedImage.createFromImage(Image.createImage(hi.getWidth(), hi.getWidth() / 5, 0xffff0000), true);
String photoURL = "https://awoiaf.westeros.org/images/thumb/9/93/AGameOfThrones.jpg/400px-AGameOfThrones.jpg";
StringBuilder fsPath = new StringBuilder(FileSystemStorage.getInstance().getAppHomePath());
fsPath.append("400px-AGameOfThrones.jpg");
URLImage background = URLImage.createToStorage(placeholder, fsPath.toString(), photoURL);
background.fetch();
Style stitle = hi.getToolbar().getTitleComponent().getUnselectedStyle();
stitle.setBgImage(background);
stitle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
stitle.setPaddingUnit(Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS);
stitle.setPaddingTop(15);
SpanButton credit = new SpanButton("Link");
credit.addActionListener((e) -> Display.getInstance().execute("https://awoiaf.westeros.org/index.php/A_Game_of_Thrones"));
hi.add(new SpanLabel("A")).
add(new Label("B", "Heading")).
add(credit);
ComponentAnimation title = hi.getToolbar().getTitleComponent().createStyleAnimation("Title", 200);
hi.getAnimationManager().onTitleScrollAnimation(title);
hi.show();
Which was taken from https://www.codenameone.com/javadoc/com/codename1/ui/URLImage.html
The tree is only to see if the image was saved in the Storage.
You are mixing Storage & FileSystemStorage which are very different things see this.
You can use storage which is a flat set of "files" and that's what URLImage.createToStorage does. But then you need to use the Storage API to work with that and it might not be visible in the FileSystemStorage API.
Alternatively you might be looking for URLImage.createToFileSystem().
I would like to display DateTime picker in my App, so I'm write below code to display DateTime Picker, every thing is working fine but in Android device date is not displayed properly.
Form dialogtimeForm = new Form("Set time");
dialogtimeForm.setUIID("workersListForm");
if(!Constants.PLATFORMNAME.equals(Display.getInstance().getPlatformName())){
spinner = new DateTimeSpinner(){
#Override
protected Dimension calcPreferredSize() {
return new Dimension(460, 180);
}
};
} else{
spinner = new DateTimeSpinner();
}
spinner.setShowMeridiem(true);
spinner.setMinuteStep(1);
int hours = 0;
int minutes = 0;
boolean showMeridiem = false;
Date date = null;
timeValue = data;
if(timeValue != null && !"".equals(timeValue)){
hours = Util.getHours(timeValue);
minutes = Util.getMinutes(timeValue);
showMeridiem = Util.getAmPm(timeValue);
date = Util.getDate(DBActuallCallDate);
}
if(hours > 12){
hours = hours -12;
showMeridiem = true;
}
spinner.setCurrentHour(hours);
spinner.setCurrentMinute(minutes);
spinner.setCurrentMeridiem(showMeridiem);
spinner.setCurrentDate(date);
dialogtimeForm.add(spinner);
Dialog dialog = new Dialog();
dialog.setDisposeWhenPointerOutOfBounds(true);
commands[0] = new Command(Constants.SETCOMMAND){
#Override
public void actionPerformed(ActionEvent evt) {
int hour = spinner.getCurrentHour();
int minute = spinner.getCurrentMinute();
boolean meridiem = spinner.isCurrentMeridiem();
String time = Util.timeConversion(hour, minute, meridiem);
String workerTime = Util.getFormatedTimeValue(time, spinner.getCurrentDate());
callInField.setText(time);
roasterDao = new RoasterDao();
if(flag.equals(Constants.ACTUALCALLOUTFLAG))
roasterDao.updateActualCallOutTime(workerTime, serialId);
else
roasterDao.updateActualCallInTime(workerTime, serialId);
dialog.dispose();
if(ApplicationScopeBean.dialogShow){
if(flag.equals(Constants.ACTUALCALLOUTFLAG))
Dialog.show("Alert", workerName+Constants.CHECKOUTSUCCESSFULLY+time,"ok",null);
else
Dialog.show("Alert", workerName+Constants.CHECKINSUCCESSFULLY+time,"ok",null);
} else{
if(flag.equals(Constants.ACTUALCALLOUTFLAG))
Toast.makeText(RoasterApp.getContext(), workerName+Constants.CHECKOUTSUCCESSFULLY+time, Toast.LENGTH_LONG).show();
else
Toast.makeText(RoasterApp.getContext(), workerName+Constants.CHECKINSUCCESSFULLY+time, Toast.LENGTH_LONG).show();
}
Container unScheduledWorkerTableContainer = setUnScheduledWorkerTable();
unScheduledWorkerTableContainer.setUIID("unScheduledWorkerTable");
unScheduledWorkerBoxContainer.removeAll();
unScheduledWorkerBoxContainer.add(unScheduledWorkerTableContainer);
unScheduledWorkersForm.revalidate();
}
};
commands[1] = new Command(Constants.CLEARCOMMAND){
#Override
public void actionPerformed(ActionEvent evt) {
Dialog dialog1 = new Dialog();
dialog1.setUIID("listDialog");
String clearCallOutDialog = Constants.CLEARCALLOUTDIALOG;
String clearCallInDialog = Constants.CLEARCALLINDIALOG;
dialog.dispose();
FlowLayout centerLayout = new FlowLayout();
centerLayout.setAlign(Component.CENTER);
centerLayout.setValign(Component.TOP);
Container flowContainer = new Container(centerLayout);
Container boxXAxisLayout = new Container(new BoxLayout(BoxLayout.X_AXIS));
Button okButton = new Button(Constants.OKCOMMAND);
okButton.setUIID("dialogCloseButton");
okButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent evt) {
roasterDao = new RoasterDao();
if(flag.equals(Constants.ACTUALCALLOUTFLAG))
roasterDao.updateActualCallOutTime("", serialId);
else
roasterDao.updateActualCallInTime("", serialId);
callInField.setText("");
dialog1.dispose();
dialog.dispose();
Container unScheduledWorkerTableContainer = setUnScheduledWorkerTable();
unScheduledWorkerTableContainer.setUIID("unScheduledWorkerTable");
unScheduledWorkerBoxContainer.removeAll();
unScheduledWorkerBoxContainer.add(unScheduledWorkerTableContainer);
unScheduledWorkersForm.revalidate();
}
});
Button close = new Button(Constants.CANCELCOMMAND);
close.setUIID("dialogCloseButton");
close.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent evt) {
dialog1.dispose();
dialog.dispose();
Container unScheduledWorkerTableContainer = setUnScheduledWorkerTable();
unScheduledWorkerTableContainer.setUIID("unScheduledWorkerTable");
unScheduledWorkerBoxContainer.removeAll();
unScheduledWorkerBoxContainer.add(unScheduledWorkerTableContainer);
unScheduledWorkersForm.revalidate();
}
});
boxXAxisLayout.add(okButton);
boxXAxisLayout.add(close);
flowContainer.add(boxXAxisLayout);
dialog1.setLayout(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE));
String dataLabelString = "";
if(flag.equals(Constants.ACTUALCALLOUTFLAG))
dataLabelString = clearCallOutDialog;
else
dataLabelString = clearCallInDialog;
Label dataLabel = new Label(dataLabelString);
dataLabel.setUIID("confirmDialogBody");
dialog1.add(BorderLayout.CENTER, dataLabel);
dialog1.add(BorderLayout.SOUTH, flowContainer);
dialog1.show();
}
};
commands[2] = new Command(Constants.CANCELCOMMAND){
#Override
public void actionPerformed(ActionEvent evt) {
dialog.dispose();
Container unScheduledWorkerTableContainer = setUnScheduledWorkerTable();
unScheduledWorkerTableContainer.setUIID("unScheduledWorkerTable");
unScheduledWorkerBoxContainer.removeAll();
[![enter image description here][1]][1]unScheduledWorkerBoxContainer.add(unScheduledWorkerTableContainer);
unScheduledWorkersForm.revalidate();
}
};
dialog.show("", dialogtimeForm, commands);
please find screenshots.
The Picker API will display native date/time UI on supported platforms. Date, Time, Numbers and Strings are supported on Android but DateTime is only supported on iOS so you are seeing a "fallback" UI.
There is no native equivalent for "DateTime" on Android so you would need