Re: [android-developers] Re: Scrolling large image - working good but slow
To render to a SurfaceView you need to get the SurfaceHolder, lock it and then draw to the Canvas and finally unlock it. Have you considered an ImageView and just calling invalidate and doing your drawing in onDraw? Lee On Fri, Nov 13, 2009 at 9:32 AM, Genc gmt...@gmail.com wrote: Hi Scott. Thanks for great tips. I've changed my code and not using Gestures any more, just onTouch method and handling ACTION_MOVE motion. It's good up to this point. However, can you give a little sample code about blting a bitmap to surface? How can I do this? Thanks On Nov 12, 8:18 pm, SoftwareForMe.com SoftwareForMe.com softwareforme@gmail.com wrote: * Skip the gesture detector, just handle the touch events yourself * Do not create a new bitmap. Load it once and blt from it to the surface * Background thread should wait on some object to be notified by UI thread when new x/y scroll is available, then draw We use this approach in PhoneMyPC and have very responsive scrolling of quite large images. Scott SoftwareForMe.com On Thu, Nov 12, 2009 at 7:58 AM, Genc gmt...@gmail.com wrote: Hi all, For a project, I'm displaying an image with sizes 800 x 600 and I've implemented my custom scrolling (horizontal and vertical) - which is works fine. However, my problem is that it's not fast enough. If you continuously move your finger on screen for instance, scrolling is not responding fast enough. There is a lag and you need to wait (say 400-500ms) for new scrolled image to be loaded. Now below I described how I implemented scrolling and my question is that - How can I make it faster, if possible - Is there any other better way to implement this. Thanks in advance!! My custom scrolling solution: * I have a Main activity, SurfaceView and a thread * In main activity, I'm using GestureDetector and override onScroll method. * In onScroll method of activity, I'm passing values to SurfaceView's handleScrolling method. * In handleScrolling method, I'm calculating proper values and using newImage = Bitmap.createBitmap(myImage, starX, stopY, SCREEN_WIDTH, SCREEN_HEIGHT); to create a new, scrolled image. * Then in thread loop, I'm drawing this newImage to canvas. Hope this much info helps. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Warm regards, The PhoneMyPC Team -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Trap in TabHost when AsyncTask delays setContentView at activity startup
I'll give this a go and let you know how it works. Thanks for the tip. Lee On Wed, Nov 4, 2009 at 8:27 PM, Jeff Sharkey jshar...@android.com wrote: Instead of delaying the setContentView() call, can you inflate that layout and set its visibility to View.GONE temporarily until the actual content arrives? j On Tue, Nov 3, 2009 at 8:52 PM, Lee Laborczfalvi labor...@gmail.com wrote: I've got a tab host activity started from a home screen shortcut. When my application starts it downloads information from a server using an AsyncTask. In the onPostExecute method of the AsyncTask I call setContentView to display the TabHost. When I start the homescreen shortcut by tapping on the shortcut using my finger everything works as expected, I download the information from the server and display the TabHost with the information in the tabs. However starting the application by navigating to the shortcut with the mouse wheel and then clicking on the shortcut with the mouse wheel leads to a trap in the framework code as soon as my application starts. The stack trace is below: 11-04 15:45:40.113: ERROR/AndroidRuntime(3360): Uncaught handler: thread main exiting due to uncaught exception 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): java.lang.NullPointerException 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.widget.TabHost.onTouchModeChanged(TabHost.java:179) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewTreeObserver.dispatchOnTouchModeChanged(ViewTreeObserver.java:591) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1877) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.performTraversals(ViewRoot.java:715) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.os.Handler.dispatchMessage(Handler.java:99) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.os.Looper.loop(Looper.java:123) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.app.ActivityThread.main(ActivityThread.java:4203) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at java.lang.reflect.Method.invokeNative(Native Method) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at java.lang.reflect.Method.invoke(Method.java:521) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at dalvik.system.NativeStart.main(Native Method) Looking at the code for the TabHost class I see the following code at the point where the trap occurs public void onTouchModeChanged(boolean isInTouchMode) { if (!isInTouchMode) { // leaving touch mode.. if nothing has focus, let's give it to // the indicator of the current tab TRAP ON THIS LINE if (!mCurrentView.hasFocus() || mCurrentView.isFocused()) { mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus(); } } } This looks like a simple fix since mCurrentView is null at the time that this method is called - can this issue be addressed? Does anyone know of any workarounds? Thanks Lee -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Jeff Sharkey jshar...@android.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Trap in TabHost when AsyncTask delays setContentView at activity startup
Thanks for the tip on this. That fixes my issue. What I've done is inflate the layout, call setContentView with that view, add my tabs and set the visibility of the entire view to View.GONE. In my onPostExecute I call setContentView(View.VISIBLE) to display the TabHost. Thanks again, Lee On Wed, Nov 4, 2009 at 8:58 PM, Lee Laborczfalvi labor...@gmail.com wrote: I'll give this a go and let you know how it works. Thanks for the tip. Lee On Wed, Nov 4, 2009 at 8:27 PM, Jeff Sharkey jshar...@android.com wrote: Instead of delaying the setContentView() call, can you inflate that layout and set its visibility to View.GONE temporarily until the actual content arrives? j On Tue, Nov 3, 2009 at 8:52 PM, Lee Laborczfalvi labor...@gmail.com wrote: I've got a tab host activity started from a home screen shortcut. When my application starts it downloads information from a server using an AsyncTask. In the onPostExecute method of the AsyncTask I call setContentView to display the TabHost. When I start the homescreen shortcut by tapping on the shortcut using my finger everything works as expected, I download the information from the server and display the TabHost with the information in the tabs. However starting the application by navigating to the shortcut with the mouse wheel and then clicking on the shortcut with the mouse wheel leads to a trap in the framework code as soon as my application starts. The stack trace is below: 11-04 15:45:40.113: ERROR/AndroidRuntime(3360): Uncaught handler: thread main exiting due to uncaught exception 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): java.lang.NullPointerException 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.widget.TabHost.onTouchModeChanged(TabHost.java:179) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewTreeObserver.dispatchOnTouchModeChanged(ViewTreeObserver.java:591) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1877) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.performTraversals(ViewRoot.java:715) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.os.Handler.dispatchMessage(Handler.java:99) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.os.Looper.loop(Looper.java:123) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.app.ActivityThread.main(ActivityThread.java:4203) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at java.lang.reflect.Method.invokeNative(Native Method) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at java.lang.reflect.Method.invoke(Method.java:521) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at dalvik.system.NativeStart.main(Native Method) Looking at the code for the TabHost class I see the following code at the point where the trap occurs public void onTouchModeChanged(boolean isInTouchMode) { if (!isInTouchMode) { // leaving touch mode.. if nothing has focus, let's give it to // the indicator of the current tab TRAP ON THIS LINE if (!mCurrentView.hasFocus() || mCurrentView.isFocused()) { mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus(); } } } This looks like a simple fix since mCurrentView is null at the time that this method is called - can this issue be addressed? Does anyone know of any workarounds? Thanks Lee -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Jeff Sharkey jshar...@android.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android
[android-developers] Unable to start activity from WebView using URI (but can start from non-webview email application)
I am having issues starting my application using a URI displayed in a WebView control. My application defines two activities that can be started using specific URIs. I've defined my intent filters as follows: intent-filter action android:name=android.intent.action.VIEW / category android:name=android.intent.category.BROWSABLE/ category android:name=android.intent.category.DEFAULT / data android:scheme=myapplication android:host=doAction1/ /intent-filter intent-filter action android:name=android.intent.action.VIEW / category android:name=android.intent.category.BROWSABLE/ category android:name=android.intent.category.DEFAULT / data android:scheme=myapplication android:host=doAction2/ /intent-filterIn the G1 built-in email application if the user clicks on a URI of the format myapplication://doaction1?parameters then the activity corresponding to doAction1 is invoked. Similarly, when the URI is of the format myapplication://doaction2?parameters is clicked on then the activity corresponding to doAction2 is invoked. However when I am running the HTC Magic mail application this does not work. HierarchyViewer shows that the renderer for the HTC app is a WebView control. What is even more puzzling is that when that same email application is used with a GMail account then the activity is started correctly. It seems that the WebView may be intercepting the URI and choosing not to start the activity in the Exchange case - however I want to make sure that I'm not doing something wrong. Any pointers are much appreciated. Thanks Lee -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Trap in TabHost when AsyncTask delays setContentView at activity startup
I've got a tab host activity started from a home screen shortcut. When my application starts it downloads information from a server using an AsyncTask. In the onPostExecute method of the AsyncTask I call setContentView to display the TabHost. When I start the homescreen shortcut by tapping on the shortcut using my finger everything works as expected, I download the information from the server and display the TabHost with the information in the tabs. However starting the application by navigating to the shortcut with the mouse wheel and then clicking on the shortcut with the mouse wheel leads to a trap in the framework code as soon as my application starts. The stack trace is below: 11-04 15:45:40.113: ERROR/AndroidRuntime(3360): Uncaught handler: thread main exiting due to uncaught exception 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): java.lang.NullPointerException 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.widget.TabHost.onTouchModeChanged(TabHost.java:179) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewTreeObserver.dispatchOnTouchModeChanged(ViewTreeObserver.java:591) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1877) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.performTraversals(ViewRoot.java:715) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.os.Handler.dispatchMessage(Handler.java:99) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.os.Looper.loop(Looper.java:123) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at android.app.ActivityThread.main(ActivityThread.java:4203) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at java.lang.reflect.Method.invokeNative(Native Method) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at java.lang.reflect.Method.invoke(Method.java:521) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at dalvik.system.NativeStart.main(Native Method) Looking at the code for the TabHost class I see the following code at the point where the trap occurs public void onTouchModeChanged(boolean isInTouchMode) { if (!isInTouchMode) { // leaving touch mode.. if nothing has focus, let's give it to // the indicator of the current tab TRAP ON THIS LINE if (!mCurrentView.hasFocus() || mCurrentView.isFocused()) { mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus(); } } } This looks like a simple fix since mCurrentView is null at the time that this method is called - can this issue be addressed? Does anyone know of any workarounds? Thanks Lee -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en