Skip to content

Instantly share code, notes, and snippets.

@ChanSek
Last active July 12, 2016 12:26
Show Gist options
  • Save ChanSek/0d9941ac56c04d911164fe6cc13628ef to your computer and use it in GitHub Desktop.
Save ChanSek/0d9941ac56c04d911164fe6cc13628ef to your computer and use it in GitHub Desktop.
FirebaseRecyclerView.onCreateViewHolder()
@Override
public VH onCreateViewHolder(ViewGroup parent, int viewType) {
ViewGroup view = (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(mModelLayout, parent, false);
try {
Constructor<VH> constructor = mViewHolderClass.getConstructor(View.class);
return constructor.newInstance(view);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment