4

My Android App is an Open GL ES 2.0 App. For one particular scene, I am overlaying a few textViews on top of my GL Surfaceview along with the some OpenGL textured quads.

I need one of my textViews to 'flash' - I'm targeting Gingerbread, therefore, I can't use animations, so I've created a method which does this:

public void flashText(){        
    if(myText.getVisibility()==View.VISIBLE)
        myText.setVisibility(View.GONE);
    else
        myText.setVisibility(View.VISIBLE);     
}

Then, from my OpenGL thread, I do the following:

void updateLogic(
        if (System.currentTimeMillis()>(flashTimer+250)){

            flashTimer=System.currentTimeMillis();              

              activity.runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                      activity.flashText();
            }
        });
    }
}

The above method (updateLogic) is called 60 times a second. The timer is set to 250ms, so I get a 'flashing' animation 4 times a second, - or 4 times a second, FlashText is called via runOnUiThread.

This does work, however, it affects the animation of my openGL objects enough for it to be a problem.

My question is, is there a better way to do this? (because the method I'm using is clearly not efficient enough).

Zippy
  • 3,826
  • 5
  • 43
  • 96
  • Why do you have to target gingerbread? – Charles Durham Jan 07 '16 at 21:32
  • @CharlesDurham, it was purely a business decision, not a technical one. – Zippy Jan 07 '16 at 21:34
  • This is not necessarily a solution, but does changing gone to invisible have any affect? I think if you toggle between gone and visible it actually is redrawing the view in question. –  Jan 07 '16 at 21:37
  • Hi @TDev, it's a nice idea, but unfortunately, it doesn't make any difference. – Zippy Jan 07 '16 at 21:43
  • @Zippy My only other guess would be to attempt changing the alpha using the .setAlpha(float) method or upgrading it to AlphaAnimation with a really short duration. AlphaAnimation is available for your use. –  Jan 07 '16 at 21:54
  • As per my question I'm targeting Gingerbread, so can't use setAlpha. – Zippy Jan 07 '16 at 22:00
  • Correct, but AlphaAnimation is a level 1 support. –  Jan 07 '16 at 23:37

0 Answers0