Guest User

Untitled

a guest
Jun 18th, 2018
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1.   /**
  2.    * A simple executor which passes tasks to the main UI thread for execution.
  3.    * Use this if your task needs to interact with the view hierarchy, such as
  4.    * updating displayed values, sending intents, etc.
  5.    *
  6.    * @author mrenouf@google.com (Mark Renouf)
  7.    *
  8.    */
  9.   public class UiThreadExecutor implements Executor {
  10.     private final Handler handler;
  11.  
  12.     public UiThreadExecutor() {
  13.  
  14.       this.handler = new Handler(Looper.getMainLooper());
  15.     }
  16.  
  17.     @Override
  18.     public void execute(Runnable command) {
  19.       handler.post(command);
  20.     }
  21.   }
Add Comment
Please, Sign In to add comment