mirror of
				https://github.com/lacerta-doc/Lacerta.git
				synced 2025-11-03 16:40:47 +00:00 
			
		
		
		
	共有ビューモデル実装
This commit is contained in:
		
							parent
							
								
									b756eea9bb
								
							
						
					
					
						commit
						6d17811ada
					
				@ -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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user