/*
 * Copyright (C) 2016 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.coordinators;

import android.view.View;

final class Binding implements View.OnAttachStateChangeListener {
  private final Coordinator coordinator;
  private final View view;
  private View attached;

  Binding(Coordinator coordinator, View view) {
    this.coordinator = coordinator;
    this.view = view;
  }

  @Override public void onViewAttachedToWindow(View v) {
    if (!v.equals(attached)) {
      attached = v;
      if (coordinator.isAttached()) {
        throw new IllegalStateException(
            "Coordinator " + coordinator + " is already attached to a View");
      }
      coordinator.setAttached(true);
      coordinator.attach(view);
      view.setTag(R.id.coordinator, coordinator);
    }
  }

  @Override public void onViewDetachedFromWindow(View v) {
    if (v == attached) {
      attached = null;
      coordinator.detach(view);
      coordinator.setAttached(false);
      view.setTag(R.id.coordinator, null);
    }
  }
}

@@ -630,16 +630,59 @@
 ators;%0A%0A
+import android.support.annotation.NonNull;%0A
 import a
@@ -699,16 +699,16 @@
 w.View;%0A
-
 %0Afinal c
@@ -1014,24 +1014,33 @@
 hedToWindow(
+@NonNull 
 View v) %7B%0A  
@@ -1049,18 +1049,13 @@
 if (
-!v.equals(
+v != 
 atta
@@ -1059,17 +1059,16 @@
 ttached)
-)
  %7B%0A     
@@ -1373,24 +1373,24 @@
 %0A    %7D%0A  %7D%0A%0A
-
   @Override 
@@ -1426,16 +1426,25 @@
 mWindow(
+@NonNull 
 View v) 

fix asymmetry in view/attached comparison