I have three fragments/tabs in viewpager
My first tab loads data from webservice when OnCreateView() is called and populates all the child view in fragment e.g i have spinner and edittexts inm it.
When i open second tab it working find , i'm storing webserice data in siglnton class
when i go to third tab its fine and i update the data on the server
But problem is if i go back from thrid tab to second tab it calls the first fragment onCreateView() and my all data is reload that i don't want.
Related
When dealing with login screens, I am trying to work out the better approach - either execute navigation "action" to go to login fragment on first use (and hide back button to actual app), or start a new login activity (with its own nav graph). For the first approach (just using navigation components), I do not know the way to remove the back button without a hack "hide". I tried using navoptions, setpopupto etc., but it does not work. Code below:
val navOptions = NavOptions.Builder()
.setPopUpTo(R.id.home_fragment, true)
.build()
host?.navController?.navigate(R.id.action_global_signUpFragment_dest, null, navOptions)
Two questions then:
1) How to properly handle login transition with just navigation component?
2) Is starting a new login activity, with separate nav graph, a better idea?
I think the first approach is better.
To hide the 'back' button on your toolbar inside signUpFragment you can use AppBarConfiguration, and customize which destinations are considered top-level destinations.
For example:
val appBarConfiguration = AppBarConfiguration.Builder(setOf(R.id.home_fragment, R.id.signUpFragment_dest)).build()
NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration)
This way home_fragment and signUpFragment_dest will be considered top-level destinations, and won't have back button on toolbar.
Another option for solving the back button problem is how I did it here. Also, rather than show/hide the bottom nav bar, I have two NavHostFragment, one main full screen one, and one contained within the home fragment (above the bottom nav bar).
When I want to navigate to a full screen view I call this extension function,
fun Fragment.findMainNavController(): NavController =
Navigation.findNavController(activity!!, R.id.nav_host_fragment)
then navigate via the main graph.
This makes sense conceptually to me, to have parent and child nav graphs.
I am using Python 2.7, Robot Framework and Selenium2Library on a windows server.
On a page with a button and a data text box, I have a selenium test that clicks the button, this fires off a get request and on return recreates the data text box and updates with the new value. The test then sleeps for 10s to allow this to happen and then reads the value in the data text box.
What I would really like to do is get the element for the data text box, then click the button and keep polling for the original data text reference to become unavailable on the DOM i.e. it has been recreated, and then read the text box to get the value.
I can't for the life of me find out how I would do that using Robot Framework and Selenium2Library as all the calls are self contained and don't pass references back.
Could you offer any other solution?
There are a number of ways to do it with the SeleniumLibrary, all revolving around its Wait Until keywords - documentation link.
Option one - the element is the same, so its locator doesn't change; the check is done with Wait Until Element Contains, and passing the new text:
Click Element ${the_locator_for_the_button}
Wait Until Element Contains ${the_locator_for_the_element} your target text
Option two - if on click the target element changes to a different one, e.g. the locator is different. Then you'd first wait for the initial element to disappear, and the new one to appear:
Click Element ${the_locator_for_the_button}
Wait Until Element Is Not Visible ${the_locator_for_the_initial_element}
Wait Until Element Is Visible ${the_locator_for_the_new_element}
Option three - if you don't want to deal with locators, but to make sure the actual element as Selenium sees it disappears, you can get it with Get Webelement, and then pass that reference to the Wait ... keywords - most (if not all) SeleniumLibrary support both locators or acutal webelements:
Click Element ${the_locator_for_the_button}
${webelement}= Get Webelement ${the_locator_for_the_initial_element}
Wait Until Element Is Not Visible ${webelement}
The good thing about the Wait Until ... keywords is that they constantly poll the DOM for the expected change, and continue at the first detection the condition is met. E.g. it's not a hardcoded sleep that'll pause the execution for the predefined time, but finish as soon as ready.
Have also in mind all these keywords support the argument timeout=Xs, where the X is the time up to which the keyword waits for the condition to be met.
The requirements is like master detail grid, on load the master gets displayed as a table, on every detail row edit button click , need to open the detail edit form in a Modal window. There could be different templates based on detail/productTypes . For example productType1 will display few set of fields(template 1) , so on.
Have WEBAPI with REST support and understand how to build the initial Master table But not sure on how the details part.
Any direction would be helpful.
Does your HTML/CSS Framework provide mechanism for a dialog? If so you would have to create a directive to wrap it around the script to open the dialog.
On the master grid row ng-click will set a flag on the controller. When this flag is set to true, the code in directive will open the dialog. Within that dialog div you can use ng-include that will be bound to the url of the template (controller variable will store that url).
The template is bound to a child object in the controller scope and has the fields for the details. Setting the flag to false will close the dialog and you will have changes your main controller.
Titanium SDK version: 1.7.0.RC1
iPhone SDK version: 4.2
I am developing an iOS app in Appcelerator. I am retrieving tweets from twitter and inserting them into a table. For each row/tweet I am also extracting the containing links for that individual tweet/row and the user can select them from an options dialog which is opened when the row is clicked.
The problem is that if I reload the page and click the row, two dialogs are open upon each other. If I click three times, three dialogs is opened and so on. How can I make sure that the dialog only opens once?
This is my code: http://pastie.org/2004091
Thankful for all help!
I had a similar problem. Especially on the iPhone 3G as this runs slowly and you're more tempted to tap things more than once. The way I got around it is to either remove the event listener from within the event listener itself. Or you set a variable and test for its value in the event listener. So, if you set a variable call 'clicked' to false. When the listener is first check for 'clicked' = false, if it is set it to true so next time the code is not executed.
I am working on a MFC Document View architecture application which has multiple documents and views and a tabbed window interface.
I have been tasked with making an automatic switch to another tab on the press of the OK button in one of the other tabs. When the other tab is clicked on it uses a C++ wrapper over IWebBrowser2 to navigate to a specific web page.
When this is done manually by clicking on the tab everything is fine and the webpage within the view loads successfully.
In my first attempt at doing this the tab successfully switched in response to a call to
AfxGetMainWnd()->SendMessageToDescendants(SOME_MESSAGE, ...);
however by sending this windows message at the wrong point the application would crash once control returned because the chain of events caused the (modeless) dialog (*) that
sent the message, to no longer exist.
I then found the correct place to make the call, but now when the other tab is activated, it no longer displays the webpage as it should.
To debug this problem I added code to check the READYSTATE in both the situation where it works and the situation where it does not. When the page fails to load (despite the call to Navigate2 returning S_OK), the READYSTATE just stays at READYSTATE_LOADING.
Unfortunately now I am to many edits away from when I had it partially working.
I have added TRACE statements to the most obvious events such as OnSetFocus, CView::OnActivateView but all traces come out in the same order despite the behaviour being different
* hosted in the view