How to prevent preloading of fragments in viewpager? - android-fragments

I have 2 fragments in my viewpager.I want to prevent loading of second fragment since in my 2nd frag i am sending request to the server.I tried setOffscreenPageLimit this function but no luck..Please help me with this.
Thanks in advance

When you use ViewPager in Android there is no way to disable the pre-loading of tabs by atleast 1. That means the min for setOffScreenPageLimit is 1. This is to enable the smooth scrolling with ViewPager.
If your server request is asynchronous then you shouldn't worry about calling the server as it is done in the background thread.

Related

How to reload a page in DukeScript

DukeScript is quite clever in the way it handle changes to the Model so that code is hot-swapped at runtime, see for example here.
One thing it doesn't seem to handle at Runtime though is changes to the HTML layout. Given it runs in a WebView, a kind of a browse, it would nice just to be able to reload the page without having to stop and restart the app.
So, I've tried adding a "reload" button, but I can't find an easy way to do that after the initialization:
BrowserBuilder
.newBrowser()
.loadPage("pages/index.html")
.loadClass(Main.class).
invoke("onPageLoad", args).
showAndWait();
showAndWait() does what it's supposed to do, it doesn't return until the browser is closed. There doesn't seem any way to act on the underlying instance of a WebView and its thread.
Ha ha, simple but effective solution:
Reload
Note: Toni Epple says NetBeans would just detect the change, no reload needed.

MBProgressHUD with ASIHTTPRequest

I am trying to use MBProgressHUD to display a progress of download of multiple images which are downloaded via ASINetworkQueue.
I have set the hud as networkQueue's progress delegate and I have also set the mode of the hud to MBProgressHUDModeDeterminate.
I can make the hud display and hide, but I cannot change the progress. The hud just doesn't redraw itself until the networkQueue is complete.
I can see that MBProgressHUD's drawRect is never called but I don't know why.
I would be very grateful if anyone could provide a sample or pseudo code of how to achieve this.
Thanks,
Andrius
There are perhaps two likely issues:
The main thread of your application has been blocked; are you calling 'waitUntilAllOperationsAreFinished' on the main thread or similar?
ASIHTTPRequest can't report much in the way of progress if the server isn't sending Content-Length: headers, so this could also be the issue.

Wrapping AVCam demo from WWDC 2010

I have three camera-based apps (that take still pictures) in the app-store and have got feedback that the UIImagePickerController interface is very slow - and I can't deny that. So, to improve the performance of the app, I started to experiment with the AVCam Demo source code from the WWDC 2010.
Since the AVFoundation framework does not interact with the UI Kit, I have been successful at wrapping a view around the demo. I am able to transition between the view controllers successfully. The only thing that I've modified is replaced the Record button with the Exit button (to exit to the wrapping view controller)
The modified app works fine during the first session (wrapper -> demo) If I exit the demo to the wrapper, and come back to the demo second time , the video frame in the preview layer freezes a second or two after. The app itself does not freeze - just the video is frozen. At this point, all UI buttons are active. But, when I tap "Still" button to capture the image, I get the following error in an alert:
The operation cannot be completed (AVFoundationErrorDomain error - 11800.)
This cannot be duplicated in the original demo code - because you can't close and reopen the session. So, I am wondering if it has anything to do with the way I "exit" from the session in my test. Here's the "exit" action that I added in the demo code:
- (IBAction)exit:(id)sender
{
[[self captureManager] stopRecording];
[self dismissModalViewControllerAnimated:YES];
}
Is this sufficient - or did I miss something?
Regards, Sam.
There's a little problem of cleaning up a capture session in an orderly fashion, as there's some asynchroneous calls with no alerts of when they're done.
Try stopping and releasing as suggested in this question:
How to properly release an AVCaptureSession
(take the solution with most up votes)
If that doesn't help you may need to post some more code here. Are you sure that's all you changed?
Good luck!
Oded.

Pseudo Multithreading in Flex

I know Flex or Actionscript doesnt support multithreading.. but one of my project requires multithreading.. is there a way to mimic multithreading in Actionscript..
I'm guessing you have a large amount of processing to do but would like the UI to refresh during this process? I had the same problem trying to parse a massive chunk of XML - it would take about a minute and lock the browser, before eventually throwing a timeout exception.
There's a great example here on a pseudo-multi-threaded solution for editing a bitmap image. It's for Flex 4, but the static UIUtilities class is what you're interested in, and it works fine in Flex 3. Simply break your task up into chunks and call pausingFor() and fiddle with the arguments. Very simple and effective once you've got it going.
HTH!
this is an interesting article on the topic green threads
The Flex RPC components are working asynchronous. So if your application is working with a service back-end you could make it threadable by delegating the work to the server.
As flex et al are event driven, can't you use a timer task which does chunks of the work and be triggered every couple 100 of ms?

Flex: navigateToURL() takes about 3-5+ seconds?

My flex app has a call in it to:
navigateToURL(new URLRequest(_rURL),'_self');
But it takes about 3-5 or even more seconds before it will leave the current page.
If I omit the '_self' the new window opens immediately and the page loads immediate...but only when I set it to _self I get a few seconds of a delay before it loads...I have no idea why but it is annoying.. I am wondering if anyone might have any idea why this is happening or anything I can do?
Thanks!
Some browsers process the request before redirecting to the new page. For example, if the URL is a file to be downloaded it will not redirect. You can use the name or ID of the window or frame to get the same effect, "top", "window", "parent", "self" (not _self) etc. More info here, http://www.howtocreate.co.uk/tutorials/javascript/browserinspecific

Resources