I would like to reduce the following lines of code. There is no need to declare a class and then instantiate to run it. It should be possible to write code so that you can define the class and instantiate it as one construct. I still need runOnUiThread to run it, but I'm looking for a concise way to combine class definition and instantiation. I saw how this is done somewhere, but I canโt remember how it was done:
class OnRunnableCompleted implements Runnable { @Override public void run() { } } OnRunnableCompleted onRunnableCompleted = new OnRunnableCompleted(); runOnUiThread(onRunnableCompleted);
source share