hansschmucker
Android Enthusiast
OK, I must be doing something wrong here, due to my limited experience with Java, but it's hard to describe the problem in few enough words to feed it into Google:
My Renderer is receiving events from the main thread using queueEvent(Runnable) . I know I can declare those inline using new Runnable(){...}, but what I can't do is include any variables available while the Runnable is created. I expected something like this to work:
or maybe
But no such luck. For now I've created a separate class for each event runnable, but frankly this is tiresome and counter-intuitive, no to mention that it clutters up my src directory something fierce: Does any long-time Java expert know how this is supposed to be solved?
My Renderer is receiving events from the main thread using queueEvent(Runnable) . I know I can declare those inline using new Runnable(){...}, but what I can't do is include any variables available while the Runnable is created. I expected something like this to work:
Code:
view.queueEvent(new Runnable(currentRenderer,currentSig){
private int sig;
private GameRenderer rnd;
public Runable(GameRenderer aRnd, int aSig){
sig=aSig;
rnd=aRnd;
}
@Override
public void run() {
rnd.perform(sig);
}
});
or maybe
Code:
view.queueEvent(new Runnable(){
private int sig=currentSig;
private GameRenderer rnd=currentRenderer;
@Override
public void run() {
rnd.perform(sig);
}
});
But no such luck. For now I've created a separate class for each event runnable, but frankly this is tiresome and counter-intuitive, no to mention that it clutters up my src directory something fierce: Does any long-time Java expert know how this is supposed to be solved?
).