| | |
| | | import android.arch.lifecycle.LiveData; |
| | | import android.arch.lifecycle.MutableLiveData; |
| | | import android.arch.lifecycle.ViewModel; |
| | | import android.util.Log; |
| | | |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import safeluck.drive.evaluation.util.MyLog; |
| | | |
| | | public class MainViewModel extends ViewModel { |
| | | private static final String TAG = "MainViewModel"; |
| | | AtomicInteger atomicInteger = new AtomicInteger(0); |
| | | private MutableLiveData<String> json = new MutableLiveData<>(); |
| | | public LiveData<String> getJson(){ |
| | | //往json字符串写入数据 |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | json.postValue("我爱你JetPack!!"); |
| | | |
| | | Log.i(TAG, "run: "+ atomicInteger.incrementAndGet()); |
| | | json.postValue("我爱你JetPack!!"+atomicInteger.get()); |
| | | } |
| | | }).start(); |
| | | } |