GWT load fragments after application start - java

I am creating an app in GWT, and I just recently implemented code splitting there. I reduced the application size from 1.1MB to 570kB which is nice, so the startup time of the application is now faster (we are using special server where 500kB really matters... not important for my question though ...). After the application starts (in other words user can see login page, can login and use basic parts of the app), I would like to download the rest of the fragments.
I know the fragment will be downloaded when the code in the fragment is needed. But one of the fragments is about 300kB. So when I click in the menu of my app on an item, that causes this fragment to be downloaded, there is a very noticeable delay (1 - 2s), before the user gets a response.
Now I understand that this will most likely happen only once and then the fragment will be cached for like a year, so it will load faster next time. But for example when I try it again on another device, I will have to download fragment for the first time again.
I just need to be sure, that when user launches my app on a phone/tablet using wifi, then disconnects from the wifi or gets out of its range, he will still be able to launch the code in the fragments, even if he didn't launch the things that cause downloading them while he was still connected to the server.
Now he would have to open 3 menu items, to download all the fragments which is annoying.
So in short:
I want my initial download to stay 570kB, and download the rest of the app as soon as possible on the background (if possible).
EDIT:
I found http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html#sequence where you can setup initial loading sequence, so I guess it is what I am looking for. Not sure though if they are loaded asynchronously, because the login screen appears after the fragments are downloaded.

You can cause all fragments to be downloaded after the login panel is rendered. Simply call some method inside the rest of the code - it does not need to do something visible.
Also, if you plan to load all code this way, you only need to split one fragment - your entry point with the login panel. Each split point (a) slightly increases the overall size of the application, and (b) increases, sometimes significantly, the size of the leftover fragment which still needs to be loaded for the first fragment to show up. Thus, there is no point in having more than the initial fragment and the rest of the app, given your requirements.

Related

Android autolink links always start browser

I'm working on an Android application with an activity dedicated to a webview. I also have a chat section of the app that autolinks web links in the messages. I've created a onItemClick listener on the chat messages to start the webview activity. This listener works when I click the whole chat bubble, but I noticed that if I only click the highlighted link in the message, the listener isn't called and instead my default browser is loaded up.
I put a log message in front of every instance of an intent with ACTION_VIEW, thinking that some other part of my app may be launching the browser, but it doesn't seem like this is the case.
I'm wondering if android has any default methods that catch autolink urls and starts the browser that I could override. Otherwise, I was thinking that I could turn off autolink and imitate the appearance of links with the blue text and the underline, but this seems like a poor solution.
Thanks ahead for any tips on how Android works!
I encountered this situation too, where I have autolink set up in TextViews to automatically handle URLs in TextViews. However, the default behavior is to open the web page in an external browser, so how do we make it open in a webview activity (for example)?
Beneath the hood, this is handled for TextView by LinkMovementMethod. However, the behavior is difficult to customize. There is a 3rd party enhancement over LinkMovementMethod, known as BetterLinkMovementMethod, described in more detail in this blog post. With just a few lines of code changes, the TextView autolinks can be made to open in your webview activity (and clearly, all kinds of other behaviors can be customized as desired).

Android WebView - JavaScript Memory Leak

I am having an issue with Javascript in WebView (enabled using webview.getSettings().setJavascriptEnabled(true); ) The HTML pages with embedded Javascript loads and displays properly, however, what I am also doing is constantly refreshing the screen every 10 or 30 seconds. When I go into the shell of my test device (MK808 mini-tv) I use "dumpsys meminfo" in order to see the memory of the processes. Displaying the memory of my app's process every 5 seconds I can see that whenever the page refreshes, the app's memory usage jump multiple (4-10) megabytes. This continues for around 30 minutes or so until the app crashes with a Fatal Signal 11 error in the WebViewCoreThread, with no stack trace.
Constant Increasing Memory (started at around 15000kb):
None of these memory issues or errors occur when javascript is NOT enabled.
I clearCache(true) and freeMemory(), as well as every other database and cache clear, every single time before I refresh.
I have also tried destroying the WebView after each refresh and creating a brand new one, to no avail.
I can easily remake this issue by just making a new Application project and making a webview that reloads based on a handler controlling time..This seems like it should be a widespread issue but I can't find anything on the subject. Could it be my device?
Thanks in advance for the help, I'll be glad to add more information as needed!
try to add this also :
//Injects the supplied Java object into this WebView. The object is injected into the
//JavaScript context of the main frame, using the supplied name. This allows the
//Java object's public methods to be accessed from JavaScript.
WebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");

Alternative to clipboard for sharing data between a web based application and legacy desktop application

I've been pondering over this problem most the afternoon and haven't yet found the most ideal solution so thought I would see what others think..
There is a legacy Win16 application that has to be modified (with the least effort) in order to communicate with a web based application.
The idea is such that in the Win16 app, the user will want to look up a specific code, so they'll click a button which will then launch the browser and allow them to navigate a specific set of pages until they find the result they desire, then they have the option of either pressing Select or Cancel.
Pressing Select should pass back a small string back to the app (around 10 characters) and close the browser. Cancel will likewise send a Cancel message back to the app and again close the browser window.
I can't see many choices available in implementation as the Win16 app is not able to call webservices, so I'm looking at using the clipboard, however that is not without problems.
I hope there's some other alternative I haven't thought of,
As always - all advice appreciated.
Thanks,

Android multitasking problem

I have an android application which main view consists of a tab-bar with three tabs in it.
When developing and running the application on the device through adb I get the following behavior:
When clicking the phone button "Home screen" and relaunching the application it seems as the application continues where I was before pressing the button (remembers selected tab etc...) (apparently its still running in the background).
However when I export and sign the application (using Eclipse) it suddenly always seem to start a new instance of the application when returning from home screen.
Why does it behave so different in those cases? And what do I need to do in my application in order to always have the "running in background" behavior.
If you always want your application to have "running in background behavior", then set android:alwaysRetainTaskState="true" in your main activity manifest. This prevents Android from periodically resetting your application back to the root activity.
android:alwaysRetainTaskState
It sounds as though your application is being destroyed between the point that you go to the home screen and start the app back up again. This can be due to not having enough memory available on the device. If you have a lot of background apps running on your device this may be the reason it is happening.
I would recommend debugging and checking out which path is being hit, that is, whether or not your app is going through just the onResume lifecycle method, or if it is also going through the onCreate lifecycle method.

Java Applets vs Back Button

I noticed that if you're playing a song at http://listen.grooveshark.com/ and you hit the back button Flash is smart enough to keep on playing the music while navigating "back" inside the Flash application.
Is it possible to implement this sort of thing using Java Applets, or do Applets alway shut down when you navigate away from the page (even though the resulting page contains the same applet)?
Looks like grooveshark is being tricky with the URL fragment. They store the search after the # fragment delimiter in the URL, e.g. do a search for ween, and you get this URL
http://listen.grooveshark.com/#/search/songs/?query=ween
Then do a search for bungle and the URL changes to
http://listen.grooveshark.com/#/search/songs/?query=bungle
If you click the back button in your browser, the URL changes to the previous "ween" one, but the browser remains on the same page, because everything before the fragment identifier is the same. There's some javascript that's detecting the changed fragment and updating the UI accordingly.
You could probably do something like this with an applet, but it seems better suited to javascript. The good news is, your applet is going to be cached by the browser, so if you do switch to a different page the applet loading will happen quickly.
http://java.sun.com/docs/books/tutorial/deployment/applet/lifeCycle.html
When the user leaves the page, for
example, to go to another page, the
browser stops and destroys the applet.
The state of the applet is not
preserved. When the user returns to
the page, the browser intializes and
starts a new instance of the applet.
That being said, what you could do is save the state to the server when the applet is stopped and then restore the state from the server when it starts again. If you make it a signed applet it should be able to save the state locally.

Categories

Resources