API for PhotoSwipe V4 UI - photoswipe

Is there a single function call when the Phottoswipe UI elements are used by a user? I'd need to update a PHP session last activity time and need to tap into the PhotoSwipe UI. I can update the session when the user clicks on a thumbnail, but once the PhotoSwipe is fired, user might zoom, click on share button, go to full screen, or hit the close button. All of these are user activities that should keep a session alive. Going to next or previous slide also needs to update the session.
From the documentation I don't see any API for this, but is there a place in the code where one can intercept ALL of the UI activities?
By the way, the new version has greatly improved the previous one thanks to Dmitry Semenov rewrite of the code.

There is no API of UI, as UI is built just via public API of PhotoSwipe.
photoSwipeInstance.framework.bind(document, 'pswpTap click', function(e) {
// tap or click
// can trigger twice (if touch device)
});

Related

How iOS handles events that occurs just right before the background?

First of all I'd like to say sorry in case my question is dummy, I'm really new to iOS and what to understand how thing are going on. Imagine such a situation - user taps on home button and the app starts to collapse, but immediately after taping on home button user taped on some UI element. So, I'm wondering how the iOS will handle this? I tried to do some tests using breakpoints, but since it just test I can't be 100% sure. It seems that if the UI interaction event will happen before the system will call willResignActive then the event will be fully processed and if the system will call willResignActive first, then the even will be discarded and won't be handled at all. Is this correct, or I missed something? Thanks
First, why do you want to use this in your app? If a user presses a button exactly in this time, it's okay that the action is not handled.
The only thing you have to keep track of is that whenever the button gets pressed and let's say you store a file without a completion handler it could be that you present an alert which is saying that everything went well but you actually not saved the file because the user left the app in this time.
But since you're never doing critical actions without completion handlers, in my opinion, there's no need to make sure that this doesn't happen.
If I got you wrong, just comment!

How to manage background tasks iOS

Lets say a user starts async request in PageViewController flow then dismisses. If they quickly bring back PageViewController it won't navigate to the correct page because an async request (that determines the next logical page to show) is underway. Is it standard to prevent the user from dismissing controller or asking them not to? If not, how do I manage background tasks, so I know to keep loading screen up and wait to navigate pages until last request completes and changes state/server side data?

Web view did finish delegate method is not called in iOS

I am developing a product in which we have to render a web page. This particular web page can invoke our objective c methods. This is implemented using EasyJSWebview. Once the web page is loaded that has a timer running there. Web page is shown properly till the timer reaches the desintaiton time. Once that timer is reached, that page is reloaded with some event content. There the problem is occurred. The problem is that the page starts to load, activity indicator is shown but it does not close of finishing delegate method is not called. So, Activity Indicator is shown forever. But, Page is not loaded yet. But, If I navigate to the side menu and reload the page manually, That event web page is loaded properly and If I press home button when it reloads with the activity indicator, the app closes and I open it again, that activity indicator is hidden and the page is not loaded yet.
There are lots of hits to server during this event. It occurs only in live. But, If I test it in our development server with many hits with the help of JMeter, our application works properly.
So, It occurs only in live. Our live deployment consists of many replica's of servers. Can it occur due to this too?.
I am not able to find any solution for this. Please let me know if you have any solution for this.
Thanks in advance.
This was just an internet issue. The present code works properly.

Function execution if next view is loaded

I am new to Parse and iOS app development, so please pardon my question if the answer is obvious.
Does a function execution continue if the next view in a view hierarchy (nav controller) is loaded?
I currently have a view where the user takes a picture, which is then displayed on screen. I want to begin the upload and packaging of this image immediately, to save time. So my question really deals with the [saveInBackground] and [getObjectInBackground] functions. If the user taps the button to go to the next view, before the upload is completed, will the functions stop their execution or continue until it completes?
Thanks
Siddharth
As long as you use the function saveInBackground, your photo will be saved even if switching views. If you used saveEventually then the photo would be saved whenever it can (if there is no internet it will upload it when internet becomes available).

How to remove all callbacks of a popped screen in Blackberry java

I have a blackberry application in which i want to show a "please wait" modal screen(which is a FullScreen push as modal screen) while sending a server request and if the user hitting the device back button , pop the modal screen and current active screen.This works fine.
My problem is that : I used a callback for server request in the active screen.But the callback executed even after popped up the screen.
Exactly whats happening while calling popScreen()? How can i remove all callbacks and refresh the screen if the user pressing back button while server request happens?
Thanks in Advance
There are several solutions to this problem of course. I guess the server request is sent asynchronously.
The simplest way I think out is having a flag and when the callback
is triggered check whether the user cancelled the action (pressing
the back button).
Another solution, perhaps not that nice is to check whether the
Loading Screen is still in the display stack.
What I think would be a proper solution is to have a stack of
cancelled http operations, so you can stop requests at any time. Then
if the request to the server has been sent, before calling the
callbacks you can check if the operation has been cancelled.
Otherwise, you just avoid sending the request to the server.
When you call popScreen, the screen which is on top of the display stack (the screen in the foreground) is removed from the stack and the Screen is refreshed (a paint event is triggered) to reflect the changes. Make sure you execute Screen.pop() on the UiThread:
UiApplication.getUiApplication().invokeLater(runnable)
In your scenario, how is the callback handled? Is it a delegate you passed along with the request or is a listener you register?
When I refer to delegate I mean something like the following:
Server.sendRequest(request, objectWithCallbacks)
and callbacks of the objectWithCallbacks (and only objectWithCallbacks) will be called accordingly. On the other hand, a listener would be something like:
Server.addListener(objectWithCallbacks, request)
Server.sendRequest(request);
this way, all the objects listening to "eventName" will get their callbacks triggered accordingly.
As far as I see, your callback will be always executed but in the callback itself you can check if the screen is currently displayed.
if( this.isDisplayed() ) {
// Do the magic
}else{
// Do nothing
}
Good Luck

Resources