buildTypes {
debug {
buildConfigField "String", "STORAGE_NAME", "\"my_app_storage\""
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "STORAGE_NAME", "\"my_app_storage\""
}
mytest {
buildConfigField "String", "STORAGE_NAME", "\"my_app_test_storage\""
debuggable = true
}
}
productFlavors {
}
testBuildType "mytest"
public class SharedViewModel extends ViewModel {
private final MutableLiveData<Item> selected = new MutableLiveData<Item>();
public void select(Item item) {
selected.setValue(item);
}
public LiveData<Item> getSelected() {
return selected;
}
}
public class MasterFragment extends Fragment {
private SharedViewModel model;
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
model = new ViewModelProvider(requireActivity()).get(SharedViewModel.class);
itemSelector.setOnClickListener(item -> {
model.select(item);
});
}
}
public class DetailFragment extends Fragment {
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SharedViewModel model = new ViewModelProvider(requireActivity()).get(SharedViewModel.class);
model.getSelected().observe(getViewLifecycleOwner(), { item ->
// Update the UI.
});
}
}
Спросил, чтобы понять стоит ли заморачиваться дальше.
Сейчас попробовал память, прошёл до биоса. Пробую дальше, ставлю все остальное.