Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Clean up ViewController and remove final to attach() and detach() met…
Browse files Browse the repository at this point in the history
…hods
  • Loading branch information
Alan Chiu committed Mar 31, 2016
1 parent af89633 commit 9c1850c
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions scoop/src/main/java/com/lyft/scoop/ViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,10 @@ public abstract class ViewController {
private Scoop scoop;
private View view;

final void attach(View view) {
this.attached = true;
this.view = view;
onAttach();
}
protected abstract int layoutId();

public void onAttach() {}

protected final boolean attached() {
return this.attached;
}

final void detach(View view) {
onDetach();
this.view = null;
this.attached = false;
}

public void onDetach() {}

public View getView() {
Expand All @@ -35,20 +21,33 @@ public View getView() {
return this.view;
}

protected abstract int layoutId();
protected final boolean attached() {
return this.attached;
}

protected Scoop getScoop() {
return scoop;
}

void attach(View view) {
this.attached = true;
this.view = view;
onAttach();
}

void detach() {
onDetach();
this.view = null;
this.attached = false;
}

void setScoop(Scoop scoop) {
this.scoop = scoop;
}

static ViewController fromView(View view) {
if (view != null) {
ViewController viewController = (ViewController) view.getTag(ViewControllerInflater.VIEW_CONTROLLER_TAG);
return viewController;
return (ViewController) view.getTag(ViewControllerInflater.VIEW_CONTROLLER_TAG);
}

return null;
Expand Down

0 comments on commit 9c1850c

Please sign in to comment.