Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PostValueSampleActivity extends BaseActivity {
- private MutableLiveData<Integer> source;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- source = new MutableLiveData<>();
- source.observe(this, new Observer<Integer>() {
- @Override
- public void onChanged(@Nullable Integer integer) {
- append(integer.toString());
- }
- });
- }
- @Override
- protected void onResume() {
- super.onResume();
- AsyncTask.execute(new Runnable() {
- @Override
- public void run() {
- source.postValue(1);
- source.postValue(2);
- source.postValue(3);
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment