Guest User

Untitled

a guest
Sep 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class PostValueSampleActivity extends BaseActivity {
  2.  
  3. private MutableLiveData<Integer> source;
  4.  
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8.  
  9. source = new MutableLiveData<>();
  10. source.observe(this, new Observer<Integer>() {
  11. @Override
  12. public void onChanged(@Nullable Integer integer) {
  13. append(integer.toString());
  14. }
  15. });
  16. }
  17.  
  18. @Override
  19. protected void onResume() {
  20. super.onResume();
  21.  
  22.  
  23. AsyncTask.execute(new Runnable() {
  24. @Override
  25. public void run() {
  26. source.postValue(1);
  27. source.postValue(2);
  28. source.postValue(3);
  29. }
  30. });
  31. }
  32. }
Add Comment
Please, Sign In to add comment