共有ビューモデル実装

This commit is contained in:
ろむねこ 2024-01-29 11:30:40 +09:00
parent b756eea9bb
commit 6d17811ada
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -0,0 +1,19 @@
package one.nem.lacerta.component.viewer;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class SharedViewModel extends ViewModel {
private final MutableLiveData<Integer> currentFragmentPosition = new MutableLiveData<>();
public void setCurrentFragmentPosition(int position) {
currentFragmentPosition.setValue(position);
}
public int getCurrentFragmentPosition() {
assert currentFragmentPosition.getValue() != null;
return currentFragmentPosition.getValue();
}
}