Skip to content

Instantly share code, notes, and snippets.

@egglang

egglang/3-1.java Secret

Last active January 23, 2018 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egglang/221a0dcb016d80766cabee91fe42d476 to your computer and use it in GitHub Desktop.
Save egglang/221a0dcb016d80766cabee91fe42d476 to your computer and use it in GitHub Desktop.
課題3 ClockViewModel
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