Skip to content

Instantly share code, notes, and snippets.

@Zhuinden
Last active August 11, 2016 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zhuinden/d4ae72d35357a2397ca52ebab9cc8dcb to your computer and use it in GitHub Desktop.
Save Zhuinden/d4ae72d35357a2397ca52ebab9cc8dcb to your computer and use it in GitHub Desktop.
Realm auto-update adapter example
adapter = new RealmRecyclerViewAdapter<Dog, DogViewHolder>(getContext(),
realm.where(Dog.class).contains(currentName).findAllAsync(), true) { // query definition + true == automatic updates
@Override
public DogViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new DogViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.view_dog_item, parent, false));
}
@Override
public void onBindViewHolder(DogViewHolder holder, int position) {
Dog dog = getItem(position);
holder.bind(dog);
}
};
recyclerView.setAdapter(adapter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment