Back to project page ShoppingList.
The source code is released under:
GNU General Public License
If you think the Android project ShoppingList 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 net.sledzdev.shoppinglist.manager; /* w w w . jav a 2 s. com*/ import android.app.Activity; import android.view.View; import com.google.common.util.concurrent.FutureCallback; /** * Created by Mariusz on 23.01.14. */ public abstract class OnUiThreadFutureCallback<T> implements FutureCallback<T> { Activity activity; View view; protected OnUiThreadFutureCallback(Activity activity) { this.activity = activity; } protected OnUiThreadFutureCallback(View view) { this.view = view; } @Override public void onSuccess(final T t) { post(new Runnable() { @Override public void run() { onSuccessUiThread(t); } }); } protected abstract void onSuccessUiThread(T t); protected void post(Runnable runnable) { if (view != null) { view.post(runnable); } else if (activity != null) { activity.runOnUiThread(runnable); } else { throw new IllegalArgumentException("Activity or View must be set."); } } }