Are there events when an update is deployed through Appflow? - ionic-v1

I am trying to initiate a popup modal when the download is fully finished and extracted (the app is ready to be closed and reopened to enable the update.)
Are there events that can be listened to in order to initiate the popup at the time I’m wanting? Something like:
.run(function($ionicPlatform) {
document.addEventListener("extracted", updateReady, false);
function updateReady() {
// Initiate popup here
}
}

Related

Javafx application is still running in background even after closing

I'm having a problem closing my JavaFX application. The application keeps running in the background even after closing. I think the actual problem is caused due to the alert box which will popup while closing the application for confirmation, if the alert doesn't pop up (on certain conditions) then the application exits normally.
Actually, I want the user to confirm whether to save the file or not before closing the application so I have added an alert box that will show only if the file is not saved manually (using Ctrl+S or File->Save option) before closing the application. When the popup appears, if the user selects to save the file it will save as usual if it chooses to cancel then the application continues to run.
But the problem is that if the alert box appears for confirmation and the user chooses to save or don't save option then the application doesn't close completely (even after completing all the task related to saving if the user chooses to save the file) it only hides the stage and keeps running in the background but if the alert box doesn't appear for confirmation then the application closes normally.
Here is the code for widow.setOnCloseRequest(); event:-
Platform.runLater(() -> {
window = App.getStage();
window.setOnCloseRequest(event -> {
if (!saveIfFileEdited()) {
event.consume();
} else {
scheduledService.shutdown();
// Platform.exit(); //I have tried this also but it dosen't work.
}
});
});
Here it will call the saveIfFileEdited() method which will handle the alert popup for confirmation & and here is its code:-
private boolean saveIfFileEdited() {
if (isEdited.get()) { // this will check if the file was edited but not saved.
Alert fileEditedAlert = new Alert(Alert.AlertType.CONFIRMATION);
fileEditedAlert.setTitle("Notepad");
fileEditedAlert.setHeaderText(null);
fileEditedAlert.setContentText("Do you want to save the changes to " + windowTitle.get() + "?");
ButtonType save = new ButtonType("Save");
ButtonType dontSave = new ButtonType("Don't Save");
fileEditedAlert.getButtonTypes().setAll(save, dontSave, ButtonType.CANCEL);
Optional<ButtonType> result = fileEditedAlert.showAndWait();
if (result.isPresent() && result.get().equals(save)) {
handleSaveFile(null); // this func will save the file, it may open save file dialog if the file is going to be saved for first time.
return true;
} else if (result.isPresent() && result.get().equals(dontSave)) {
return true;
} else if (result.isPresent() && result.get().equals(ButtonType.CANCEL)) {
return false;
} else {
return false;
}
} else {
return true;
}
}
Please help me to resolve this issue.
I cannot close the JVM forcefully using System.exit(0); because there may be some task in another thread which has to be completed even after closing the application.
Thanks.

Handle Toast Notification message on foreground and background of app - windows10

My app receives toast from PHP using WNS server. Now I want to perform some actions when clicking on toast as listed below.
When the app is not active - the user should redirect to a page on the app "ShowPage".
When the app is active - the toast should show two buttons "Show" and "Cancel". When clicking on Show button app should redirect to "ShowPage"
My current toast from PHP is
$toastMessage= '<?xml version="1.0" encoding="utf-8"?>'.
'<toast launch="">'.
'<visual baseUri="">'.
'<binding template="ToastGeneric">'.
'<text>'.$subtitle.'</text>'.
'</binding>'.
'</visual>'.
'<actions />'.
'</toast>';
And I'm calling below function on App.xaml.cs
private async void RegisterEngagementNotification()
{
StoreServicesEngagementManager engagementManager = StoreServicesEngagementManager.GetDefault();
await engagementManager.RegisterNotificationChannelAsync();
}
Please see the documentation for sending a local toast and handling activation. Everything applies there (other than you're sending the toast from your server, but otherwise adding buttons and handling activation remains the same).
I saw that you're using StoreServicesEngagementManager APIs, then I know you're sending toast notification from windows developer dashboard. So, if you want to your toast contains two buttons, you would need to add actions like the following:
Then, in your "App.xaml.cs" file, you would need to add some code to handle this option in OnActivated.
protected override void OnActivated(IActivatedEventArgs args)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
}
base.OnActivated(args);
var toastActivationArgs = args as ToastNotificationActivatedEventArgs;
if (toastActivationArgs.Argument =="ShowPage")
{
rootFrame.Navigate(typeof(ShowPage));
}
}

Dragging event reverts before confirm

I have a calendar with drag functionality where a user can drag events to quickly update them.
After Dragging an event I ask the user if he wants to save it and then call a UpdatEvent function.
However, before the user confirms, (just as the dialog appears) the event automatically reverts back and only return to the updated position if I confirm in the dialog.
Is there a way for the event to stay in the dragged position and then either revert back or stay in the actual one?
My eventDrop looks like this:
eventDrop: function (event, delta, revertFunc) {
if (confirm("Do you wish to save the event?")) {
UpdateEvent(event.id, event.start);
}
else {
revertFunc();
}
}
At the beginning of the Eventdrop and/or Eventresize place the following:
$('#calendar').fullCalendar('updateEvent', event);

Rapid ajax requests to servlet causing performance issues

I'm new to programming with servlets and ajax. I have client side code that I use to track mouse actions over an image. I need to send the coordinates during a drag to the servlet for processing. I use ajax for this. I have the code working but there seems to be a lag in processing the requests in the servlet. Specifically with dragging.
Client Side Code:
$(document).ready(function(){
// detect mousedown
$("#imgslot").mousedown(function(event){
var leftClick = false; // if user clicked the left mouse button
var rightClick = false; // if user clicked the right mouse button
var interaction={type:"",action:"",lClick:"",rClick:"",x:"null",y:""};
//if the client left clicks
if(event.which===1){
leftClick=true;
}
//if the client left clicks
if(event.which===3){
rightClick=true;
}
interaction={type:"interaction",action:"mousedown",lClick:leftClick,rClick:rightClick,x:event.clientX,y:event.clientY};
sendAjax(interaction);
// detect dragging
$(this).on('mousemove',function(event){
interaction={type:"interaction",action:"drag",lClick:leftClick,rClick:rightClick,x:event.clientX,y:event.clientY};
sendAjax(interaction);
// detect mouseup
}).mouseup(function(event){
interaction={type:"interaction",action:"mouseup",lClick:leftClick,rclick:rightClick,x:event.clientX,y:event.clientY};
sendAjax(interaction);
rightClick = false;
leftClick = false;
$(this).off('mousemove');
$(this).off('mouseup');
});
});
});
function sendAjax(message)
{
$.ajax({
url: "myServlet",
type: "POST",
data: message,
success: function (data) {
}
});
}
In Servlet: Simply printing the requests to test the performance
if (request.getParameter("type") != null) {
System.out.println(request.getParameter("action"));
if (request.getParameter("type").equals("interaction")) {
sendMouseActions(request.getParameter("action"), request.getParameter("lClick"), request.getParameter("rClick"), request.getParameter("x"), request.getParameter("y"));
}
}
My biggest issue is that on a drag, because I have to send each coordinate, when I view my output, it continues to print out that I'm dragging even after I stopped the drag operation. This lag continues for sometime. Any advice?
Of course that will have bad performance. You should handle mouse movement stuff in javascript on the client side. For drag and drop send servlet only begin and final end position. Ajax requests are asynchronous, so you'll end up getting the coordinates out of order anyway if you you send a request each time onmousemove is fired. That's probably why its telling you that you are still dragging after you stopped; requests are getting out of order.

jQuery UI dialog increasingly calling the submit callback

I took the JQuery UI dialog form sample from JQuery UI website.
Since I wanted that, once the dialog is opened and the form is displayed, that pressing the key submits the form, I added the following in the onReady() :
$.extend($.ui.dialog.prototype.options, {
open: function() {
var $this = $(this);
// focus first button and bind enter to it
$this.parent().find('.ui-dialog-buttonpane button:first').focus();
$this.keypress(function(e) {
if( e.keyCode == 13 ) {
$this.parent().find('.ui-dialog-buttonpane button:first').click();
return false;
}
});
}
});
This does perfectly the trick (I mean the click() is triggered when it has to), but the following occurs :
When the form is first submited through a press on the key, the submission is performed once.
If I reopen the dialog, and submit it again with a press on the key, the form is submitted twice.
If I reopen the dialog, and submit it again with a press on the key, the form is submitted three times, and so on...
This can be tested with the following fiddle :
http://jsfiddle.net/fWW2E/
Let me add that doing so by clicking on the dedicated "Submit" button works properly, this fails only when pressing the key is involved.
Any ideas ?
Thank you !
Because since you're assigning this on "open" and your buttons are "closing" the dialog.
When this gets called though:
$('something').dialog('close');
doesn't actually remove the element, it just hides it. So the next time you click to open up a "new" dialog, you're really just showing the first one again. However the "open" event is getting fired again every time it's opened, which is adding a new keypress handler onto it.
Here's the fiddle. I actually write out to the console an array of the current handlers on that element. You'll see everytime you open the dialog that there is another keypress handler.
DEMO

Resources