User Login validation and preloader in Adobe Air - apache-flex

I am trying to figure out ways to authenticate a user and load the application (while showing a preloader) in Adobe Air [desktop application, and not web based flex app].
This is what I have been able to achieve so far:- A window asks for login details, once validated I make the login window invisible and open an instance of the application's main window. There are 2 problems with this:-
I have to open a new window (2 windows in total). It would rather look better if I was able to simply show the login form in one state and the main application view in another state. I tried that too, but the problem is that besides the view component, flash does execute all the actionscript and keeps the other state ready. There is some application view centric actionscript which starts throwing null reference errors etc. On top of that, the whole things takes a while to show up as both views are created, though only 1 of them is shown
I'd like to show a preloader once the user is authenticated, until the main application view is loaded
In a nutshell, this is what I am trying to do:-
Load the login window as fast as possible and stop there (actionscript in other parts of the application should not run)
Post authentication, load the main view of the application. Show a preloader until the loading is done
Load the main view in the same window (rather than opening a new window and making the login one invisible)
Need help and direction as to how this could be executed.
Thanks!
UPDATE 1
Ok, so now I've managed to consolidate the functionality in a single window. however, the transition between states is not a smooth one.
State 1 is the login screen. If the user enters the correct login credentials, State 2 of the view becomes active.
Now for State 2 to load (its a bunch of UI components and a grid with loads of data) it takes time. Until then, the application blanks out and then all of it is shown in a jerk. Can the transition be made much smoother? Just showing 'Loading...' would suffice. Because State 2 won't show up until all of it has been constructed and State 1 dies away as soon as I change the current state to State 2. Is there any way to monitor the progress and changing the state only when the next state has been loaded!
UPDATE 2
Ok, I got the transition animation to work between states. However, there still exists a problem with the transition switch. The problem is that the state I switch to after login has been verified has a lot of components and shows a lot of data.
Is there a way I can attach Listeners (if any), which I can fire when the state loading is complete and view has been generated! The current jerk like effect in the transition is because the state has changed but the view has not completed yet.
State Change to State 2 is not smooth as State 2 loads about 10000 rows of data from database. Is there a way I can change the state visibly for the user, after state 2 has been completely drawn out and has pulled in all data? creationComplete doesn't help much here.
In short, is there a way to start loading a state from an initial state and make it visible only when its complete loaded? i.e. can I fire an event from state 1 to load state 2, but to visibly transition to state 2 only when state 2 is completely loaded..
UPDATE 3
After a week of firefighting, posting a bounty and scavenging through the web I have still not been able to fix this! My application window becomes unresponsive for the time the UI is created and data is loaded. In Windows, it even shows 'Not Responding' at the window title bar for about 5 seconds. So its the UI getting stuck because the data is taking some time to be fetched and loaded - all of this happens in a single thread by default.
How do people who develop based on Adobe Air do this? I've mostly always seen a loading screen before the actual game is loaded - and when its loaded, its fully functional. There has to be a way!

The time consuming problem of loading 10000 rows in a grid can come in any web based language in any web application because web application needs to run in the environment of a web browser which has its own resource limitation.
So what I would suggest is that you don't load all 10000 records at loading the view. Instead load 1000 records first and then keep a link or button with label "Next" or "Show More" like and on that click bring the next bunch of 1000 records from the database. This way you can accomplish your task.
Thanks,
Jigar Oza

Related

When to use wait.until in Appium?

I just started developing a test automation for an iOS app using Appium. I have to click several buttons in the app one after another with different XPath/Accessability ids.
I wondered, when to use the wait.until(ExpectedConditions.visibilityOf Element) expression.
Example:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//XCUIElementTypeApplication[#name=\"app\"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeTabBar/XCUIElementTypeButton[3]")));
Should I check every time before I click a button if this button is actually visible or existing on the current state of the app or is this just unnecessary and time-wasting?
In my opinion, you should use ExpectedConditions in two case:
Screen load takes long, so you not ending up trying to click something that has not loaded yet. If you find your tests flaky (sometimes pass some times fails) then this probably the main reason why it happens
If you have something like ajax on your screen you want to make sure the data is changed on the page. (Example is you created a post on Facebook, and want to make sure content displayed)

Adobe Air: Null pointers when rendering takes time

I am using the a ViewStack controlled with visibility of selected NavigatorContent being dependent on user selection of an option from a drop down menu.
Each View of the ViewStack has its own separate UI elements including 2-3 DataGrid, charts etc - think of it as a simple school application where each view binds to a course and shows performance of students for that course (while listing students in grid)
Sometimes, there is a problem with showing the data though - before the Rendering completes, the data is ready to be populated; this throws a null exception as the UI element where the data needs to be populated has not been created yet.
For this, I made the 'creationPolicy' set to 'all'. All works just fine after this property is set.
But there certainly are tonnes of performance issues:-
Even if the user never ever visits beyond the 1st visible view, the other views do get rendered (UI elements initialized and created).
Performance hit at startup - startup time is large and grows with the number of views I have (right now I have 9 views with creationPolicy set to all)!! Application was quick to load when only the 1st view was visible by default and creationPolicy was set to default/auto
UI kind of hangs/becomes unresponsive while application starts (as it all happens in the same thread)
What could be a possible solution to this.
These are the solutions that I had in mind, and which didn't work for a reason or two:-
For the first time a view is selected via the dropdown controller (i.e. when the rendering cum UI creation is yet to take place), I can show a preloader or sometime. I tried doing this, but the UI still hangs/becomes unresponsive.
CallLater can it help? Not really, as I would still be creating all views even if they are not required.
So, I need an elegant way of displaying the views (and show some sort of progress or loader) when they are created/instantiated.
Update
I get the Null errors when there is a sort of race condition - when the processing (which returns data to be filled into UI components, lets say a grid) completes before the rendering of the UI element completes - I have recognized why it happens. Initially, I had creationPolicy set to default, so whenever I use to select a view, it was created at that time; and in case the data to be populated was returned before the elements of the view were created there were null pointer (as the UI element I use to refer to were still be created and thus were null at that instance).
Now I am being forced to set the creationPolicy to all so that UI is created for all views and I fire the data processing on selection of that view from the dropdown.
What I'd rather like to do is to have a way to create the UI on demand (and not all of the UI even if it is not being used).
Maybe you shouldn't have the data processing push the results, but vice-versa, have the UI pull the data from the model once the UI controls are ready?
For example, have the data reside in ArrayCollections that you bind to DataGrids. That way, it doesn't matter who finishes first. Data generator doesn't even have to know who or where displays it, and the UI will show the data as soon as ArrayCollection signals that the data has changed.
I would suggest you use modules instead of view stack.
When modules are used separate swf files are created, and not loaded when the application is loaded. A module file is loaded only when it is called through moduleloader.load(module) method.

Flex tabbed view gets reloaded every time

I have a very simple Flex application for mobile phones which uses 3 tabs (with the TabbedViewNavigatorApplication).
It seems that everytime I switch tabs, the selected view is reloaded.
I've set a creationComplete command to do something and everytime I click on the tab it executes the function.
Isn't it possible for the views to get loaded 1 time and that's it?
Seems to me that this behaviour is exactly the point on mobile devices since you want to keep memory / cpu usage as low as possible.
This effectively means destroying all non-active views and all related view components / objects.
However you can override this default behaviour by setting the destructionPolicy on every view to destructionPolicy="never".
This blog post will explain the basic understanding you will need to obtain.
Cheers

Issues with using # for deep linking into dynamic apps?

I have a Flex app I built. It uses the BrowserManager class to listen for changes in the # part of the URL. When a change is made to the hash my application updates accordingly so you can link directly to a state of the application. Also inside my programming when a user clicks something, all I do is use the BrowserManager to update the # and then my listener will apply the correct changes once its finished. I believe this is the best practice way to doing this in Flex.
I have some issues though. When using the Back button in FF or IE, it gets "stuck". for example if the hash is like #state4 clicking the back button will take you to #state3 then #state2 but sometimes get stuck where you can be on #state3 click the back button, see it flicker to #state2 real quick then change back to #state3 preventing you from going back any further in your history.
Now in Chrome its even worse. As you make your way through the application the hash # is updated and so the application updates (proving that the app can see changes in the hash since thats the only way it updates). but when you click the back button, the hash # goes back to its previous state, but my application does not as if it is unaware the hash is changing.
I find this very bizarre and don't know what to make of it. I was wondering if anyone else had experienced this or knows what might be the issue.
To see it in action go here and navigate the builder (it will ask you to click jewelry type, metal, etc.) a few times until you see the big red add to cart button, then try to use your back button to get back to this page.
Have you tried the History Manager. Have a look on the http://www.nbilyk.com/blog/1/68/flex-history-manager

Flex PopupManager Issue

I have been working with pop-up manager lately and have an inconsistency issue.
This is created at application level, and then various levels are added to the application
requiring the pop-up to be brought to the front.
roughly 1 in 5 times the grayish haze will appear (which renders the application unusable) as with any pop-ups, but doesn't display my pop-up window.
This is done within the component that i am popping-up and the application is the component that the pop-up is created on.
PopUpManager.addPopUp(this,application,true);
PopUpManager.bringToFront(this);
PopUpManager.centerPopUp(this);
Any clue how i can remove this inconsistency?
You're setting the model property of addPopUp to true. That means that the application should always 'gray out', becoming unusable until the pop up is closed.
If you want the application to be usable while the pop-up is displayed, set the modal property to false:
PopUpManager.addPopUp(this,application,false);

Resources