private void populateSelections(boolean notify) { this.selections.clear(); ArrayList<Integer> movieCollections = new ArrayList<Integer>(); IDataService dataService = DataServiceFactory.GetInstance().GetDataService(); dataService.Open(); for (CollectionMovie member : dataService.GetCollectionMovies(null, this.movieId)) { movieCollections.add(member.getCollectionId()); } for (Collection collection : dataService.GetCollections()) { KeyValueSelection selection = new KeyValueSelection(); selection.id = collection.getId(); selection.name = collection.getName(); selection.selected = movieCollections.contains(collection.getId()); this.selections.add(selection); } if (notify) { ListView lv = this.getListView(); lv.clearChoices(); this.selectionsAdapter.notifyDataSetChanged(); for (KeyValueSelection selection : this.selections) { if (selection.selected) lv.setItemChecked(this.selections.indexOf(selection), true); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.movieId = getArguments().getInt(MOVIE_ID); IDataService dataService = DataServiceFactory.GetInstance().GetDataService(); dataService.Open(); this.movie = dataService.GetMovie(this.movieId); dataService.Close(); this.setImage(this.movieId); setHasOptionsMenu(true); }