Skip to content

Instantly share code, notes, and snippets.

@renaudcerrato
Last active October 22, 2018 16:21
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 renaudcerrato/a94e34dce323f8b150633764d542c85d to your computer and use it in GitHub Desktop.
Save renaudcerrato/a94e34dce323f8b150633764d542c85d to your computer and use it in GitHub Desktop.
public class NastyCustomView extends View implements InteractiveViewHelper.Callback {
private final InteractiveViewHelper mInteractiveViewHelper =
new InteractiveViewHelper(this, this);
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mInteractiveViewHelper.onAttachedToWindow();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mInteractiveViewHelper.onDetachedFromWindow();
}
@Override
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
mInteractiveViewHelper.onVisibilityChanged(changedView, visibility);
}
@Override
protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
mInteractiveViewHelper.onWindowVisibilityChanged(visibility);
}
@Override
public void onInteractivityChanged(boolean isInteractive) {
enableNastyThings(isInteractive); // be greener!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment