use of uk.ivanc.archimvvm.viewmodel.RepositoryViewModel in project archi by ivacf.
the class RepositoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.repository_activity);
setSupportActionBar(binding.toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
Repository repository = getIntent().getParcelableExtra(EXTRA_REPOSITORY);
repositoryViewModel = new RepositoryViewModel(this, repository);
binding.setViewModel(repositoryViewModel);
// Currently there is no way of setting an activity title using data binding
setTitle(repository.name);
}
use of uk.ivanc.archimvvm.viewmodel.RepositoryViewModel in project archi by ivacf.
the class RepositoryViewModelTest method setUp.
@Before
public void setUp() {
githubService = mock(GithubService.class);
application = (ArchiApplication) RuntimeEnvironment.application;
// Mock the retrofit service so we don't call the API directly
application.setGithubService(githubService);
// Change the default subscribe schedulers so all observables
// will now run on the same thread
application.setDefaultSubscribeScheduler(Schedulers.immediate());
// Default behaviour is to load a mock owner when the view model is instantiated
repository = MockModelFabric.newRepository("Repository");
owner = MockModelFabric.newUser("owner");
when(githubService.userFromUrl(repository.owner.url)).thenReturn(Observable.just(owner));
viewModel = new RepositoryViewModel(application, repository);
}
Aggregations