Back to project page HistoryCleanerPro.
The source code is released under:
Copyright (c) 2014, John Phillips All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project HistoryCleanerPro listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ayros.historycleaner; /*from w w w. ja va2s.c o m*/ import java.util.concurrent.CountDownLatch; import android.app.Activity; public abstract class UIRunner { private class UIRunnable implements Runnable { @Override public void run() { action(data); if (latch != null) { latch.countDown(); } } } CountDownLatch latch = null; Object data = null; Activity activity; public UIRunner(Activity a, Object data) { this.activity = a; this.data = data; } public void run() { latch = null; activity.runOnUiThread(new UIRunnable()); } public void runAndWait() { latch = new CountDownLatch(1); activity.runOnUiThread(new UIRunnable()); try { latch.await(); } catch (InterruptedException e) { } } public abstract void action(Object data); }