-
-
Save egglang/221a0dcb016d80766cabee91fe42d476 to your computer and use it in GitHub Desktop.
課題3 ClockViewModel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Application; | |
import android.arch.lifecycle.AndroidViewModel; | |
import android.arch.lifecycle.LiveData; | |
import android.arch.lifecycle.MutableLiveData; | |
import android.support.annotation.NonNull; | |
import java.util.Date; | |
public class ClockViewModel extends AndroidViewModel { | |
private MutableLiveData<Date> clock; | |
public ClockViewModel(@NonNull Application application) { | |
super(application); | |
} | |
public LiveData<Date> getClock() { | |
if (clock == null) { | |
clock = new ClockLiveData(getApplication()); | |
} | |
return clock; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment