I am currently developing a rss-reader-app and got stuck on a problem:
In a special activity i need to
swipe left/right to switch to the previous/next article
scroll up/down to scroll through the current article
build some custom gestures (For example swipe a "S" to share this article)
Is there any way to get those 3 requirements build in?
The problem is when I listen for the custom gestures either the swipe or the scroll stops working depending on the orientation of the GestureOverlayView.
I hope you understand what I mean!
Regards
Manu
Context: I tried to implement a flingable VelocityViewPager. The flinging motion works properly. I like that the page "snaps" to center after the flinging motion. Despite this, I've had a few issues with it so far. One issue is that the page doesn't snap to center when you drag it passed a certain amount. I've solved this issue using this code so this is just for context. Another issue is below...
Problem: After beginFakeDrag() -> FlingRunnable (flinging motion) -> endFakeDrag(), endFakeDrag()'s internal code "snaps" the page to center. When I try to fling again during the snap motion, it waits until after the animation completes--putting the flinging motion on queue.
How can I cancel the snap motion on touch down so that it doesn't delay the flinging motion?
Attempt 1: On touch down, I tried to beginFakeDrag() but it doesn't cancel the endFakeDrag() snap motion.
Attempt 2: Instead of calling endFakeDrag(), I tried to mimic the snap motion during fake drag so that I can implement the cancellation myself and only call endFakeDrag() when the page is already centered. I tried this via SnapRunnable using Scroller's startScroll().
This might be my best option, but I can't figure out how much distanceX to scroll to in order to center the page. I tried to look into the original ViewPager.class but the algorithms confused me and it seems to depend on more internal code that the VelocityViewPager.class can't access.
So I've recently been abusing Google for an answer, however just can't find one, and my head's starting to ache. I've recently released my second game on the Google Play Store, and only now have I been getting feedback that the people aren't too crazy about the button pressing mechanics (same mechanics as the first game). My game can be found here if you want to give it a go, unfortunately I don't have an HTML version hosted elsewhere.
Making the game, I used LibGDX, and for the UI, I've used Scene2D that comes with LibGDX. My game requires that you press the green "bug" button to get a point (the "bug" buttons cycle around at random), you are forced to play against a timer, so you would obviously want to go faster for a higher score (think Piano Tiles).
Now, to the problem at hand, one of the game modes in my new game is called "Zen", two buttons, one gives you 1 point, the other 2 points. The problem I'm experiencing is that if you hold both "bug" (bottom right and bottom left) buttons down, and release one of the buttons, the released one triggers a score increase, and the other button resets as if it was never pressed on in the first place (even if your finger is still on it). Here's the code for my Scene2D buttons (working off memory, don't have my code near me at the moment):
// All is initialized correctly, no crashes, here's the part about the listener.
leftBugButton.addListener(new ChangeListener()
{
#Override
public void changed(ChangeEvent event, Actor actor)
{
// Run code here when button has been released.
}
}
// And the right hand button's code. Initialization is perfect, no problems.
rightBugButton.addListener(new ChangeListener()
{
#Override
public void changed(ChangeEvent event, Actor actor)
{
// Run code here when button has been released.
}
}
Getting to my question, what I want to go for is that if a button press has been completed (pressing and then releasing), I don't want the other buttons to reset to an unpressed state.
Any tips, or perhaps a different Listener I should use, or even dumping Scene2D for these buttons (using sprites with InputListener for example)? Any help would be greatly appreciated.
Thanks in advance,
TV
Don't use ChangeListener for that, use a ClickListener (button.addClickListener(new ClickListener...)) and handle your process on touchUp event, ChangeListener gonna process if ANYTHING on the button change and it's not a good approach to handle a button release event.
Found my problem, I kept rebuilding the Stack after every button press, resulting in the odd behavior, opted instead for a .setStyle() on my buttons which is working a lot better.
I am trying to develop an application in which I want to know when the camera button(if the phone has one),has been pressed for feature phones like Series60 using J2ME.I dont want to take a snapshot or take a video.I just want to know when the hardware button has been pressed.
I have been unable to find a proper way for this.Your help is greatly appreciated.
Create a canvas, listen for keypresses and output all events to the screen. If no event occurs when you press the camera key then you can't do it.
I have 4 buttons 1)left 2)video 3)technical insight 4)right..as seen in the below image.Now I want to provide functionlity to this image.The functionality is
If i click on the left arrow the video technical insight have to scroll to the left and similarly if I click on the right arrow the the two buttons have to scroll to the right and show two more video names..in Blackberry Simulator
Can anyone please help me in writing the code.I would be happy If I can get the code to provide this functionality in Blackberry..
I have some ideas regarding this.Do tell me if this can be done or not..
I created left button ,videos button,technicalinsight button and right button in a manager called hfm
When i click on the left button the entire things in hfm will get deleted using hfm.deleteAll() and then repaint it with the hfm which we get after scroll.
Is this idea good or any better approach for this??
you can Override the paint() method and use graphics.drawBitmap to redraw the screen.