I have a layout called a controller in it i have a couple buttons and such
the problem is in my onTouch function i want to show it on one click and hide it on another. Now this works after 2 touches. The first touch is supposed to show the controller while the next is supposed to make it disappear. The first and second touches do nothing but on the third touch it works. Here are the related functions for this
public boolean onTouchEvent(MotionEvent event)
{
int eventx = event.getAction();
switch(eventx)
{
case MotionEvent.ACTION_DOWN:
if(isLifted)
{
if(!isVisible)
{
Log.i("onTouch", "called showPuse menu");
isVisible = true;
isPaused = true;
showPauseMenu();
}
else if(isVisible)
{
hidePauseMenu();
isVisible= false;
}
isLifted = false;
}
break;
case MotionEvent.ACTION_UP:
if(!isLifted)
{
isLifted = true;
//Log.i("onTouchEvent", "Lifted");
}
}
return false;
}
/***************************************************
* Shows All Views needed to be shown
* Also pauses video and audio
*
* *************************************************/
private void showPauseMenu()
{
Log.i("showPauseMenu", "called");
playButton.setVisibility(View.VISIBLE);
Log.i("showPauseMenu", "plaButton visible");
bottomButtons.setVisibility(View.VISIBLE);
Log.i("showPauseMenu", "bottom Menu showed");
playButton.invalidate();
bottomButtons.invalidate();
pauseMedia();
}
/************************************************
* Hides Views that are part of Pause Menu
* Also starts video and audio back again
*/
private void hidePauseMenu() {
playButton.setVisibility(View.GONE);
bottomButtons.setVisibility(View.GONE);
playMedia();
}
Can anyone say what the problem might be? I’ve been looking at this code for a couple of days now and cant see what it might be.
A few pointers about this code:
Without the full class it’s hard to tell, but I’d investigate both these points.