Created
August 6, 2015 10:15
-
-
Save serso/7fa1a293b6754f9bd8e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestProguardActivity extends AppCompatActivity { | |
private final Executor background = Executors.newSingleThreadExecutor(); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
final TextView view = new TextView(this); | |
setContentView(view); | |
TestClass.testMethod(view); | |
view.append("Methods:\n"); | |
AnotherTestClass.printMethods(view); | |
final AnotherTestClass o = new AnotherTestClass(); | |
background.execute(new Runnable() { | |
@Override | |
public void run() { | |
o.waitForNotify(view); | |
} | |
}); | |
view.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
synchronized (o) { | |
o.notify(); | |
} | |
} | |
}, 5000); | |
} | |
} | |
final class TestClass { | |
public static void testMethod(TextView view) { | |
view.append("testMethod called\n\n"); | |
} | |
} | |
final class AnotherTestClass { | |
public static void printMethods(TextView view) { | |
for (Method method : AnotherTestClass.class.getMethods()) { | |
view.append(method.getName()); | |
view.append("\n"); | |
} | |
} | |
public void waitForNotify(final TextView view) { | |
try { | |
final long waiting = System.currentTimeMillis(); | |
synchronized (this) { | |
wait(); | |
} | |
final long running = System.currentTimeMillis(); | |
view.post(new Runnable() { | |
@Override | |
public void run() { | |
view.append("\n\nwaiting at " + waiting); | |
view.append("\nrunning at " + running + " after " + (running - waiting) + "ms"); | |
} | |
}); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment