Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
jtp5120
Posts: 298
Registered: 05-02-2010
My Carrier: Verizon
Accepted Solution

Design requirement evolved, saving where the user has scrolled to.

Continuing this thread: http://supportforums.blackberry.com/t5/Java-Development/Confirming-a-design-where-I-need-to-save-whe...

 

The requirements have evolved.

 

I now need to save the position on the Screen where the user has scrolled to once the screen has been redrawn.

 

Specific Screens are relayed out and repainted based on a TimerTask. Once the Screen is redisplayed, I need to automatically reposition/scroll to the position the user was on the screen.

 

For example:

 

  1. A user may leave a Screen open for ten seconds.
  2. A user scrolls down 3/4 of the way down.
  3. After that time has passed, a TimerTask is executed and redraws the Screen with new data.
  4. If the user has scrolled down in a VerticalFieldManager 3/4 of the way down, once the Screen is redrawn the user should be back at the same position - 3/4 of the way down in the VerticalFieldManager.

 

Ideally, I'd like to save the XYPoint and then reposition the Screen to the saved XYPoint - a little prototype needs to be done on my part, granted.

However, is there a better design or has anyone implemented this feature before on OS 5.0.0?

 

Thanks.

--Todd

Windows 7 Enterprise 64-bit (6.1 Build 7600) | Java SE Runtime Environment (build 1.6.0_24-b07) | Eclipse Version: 3.6.2 [M20110210-1200] | BlackBerry Eclipse Plug-in: 1.3.0.201102031007-19 | Java Compiler level: 1.3 | Targeting devices running OS 5 | Simulators: JDE 5.0 packaged 9700, 9630, 9300
Please use plain text.
Developer
peter_strange
Posts: 14,611
Registered: 07-14-2008

Re: Design requirement evolved, saving where the user has scrolled to.

getVerticalScroll should help.

 

You might have to do this recursively depending on the number of Managers and their nesting, but that is how I would start.

 

The other option is to try to find the 'extent' of all the Fields, and it is possible to find out exactly where they are in the Display.  From there you find out the one closest t the top, and then setFocus on that Field once you have relayed out.

 

Sounds like a bit of challenge.  Good luck. 

Please use plain text.
Developer
Developer
CMY
Posts: 961
Registered: 02-10-2009
My Carrier: Verizon

Re: Design requirement evolved, saving where the user has scrolled to.

I have done this with a custom manager(s) using the vertical scroll offset recursively through the manager stack as suggested by Peter, but be mindful that you need not only the y scroll but the y position within the screen/manager to track the actual screen position versus the percieved one. Here is the code I use in my manager with my custom functions:

 

 

public final int getAbsoluteY(){
   int absY = (getY()+drawY);
   while( getManager() instanceof CustomLayoutManager ){
      return absY + ((CustomLayoutManager)getManager()).getAbsoluteY();
   }
   return absY;
}

 

 

Please use plain text.