Home | History | Annotate | Download | only in databinding
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package android.databinding;
     17 
     18 /**
     19  * Utility class for managing Observable callbacks.
     20  */
     21 public class PropertyChangeRegistry extends
     22         CallbackRegistry<Observable.OnPropertyChangedCallback, Observable, Void> {
     23 
     24     private static final CallbackRegistry.NotifierCallback<Observable.OnPropertyChangedCallback, Observable, Void> NOTIFIER_CALLBACK = new CallbackRegistry.NotifierCallback<Observable.OnPropertyChangedCallback, Observable, Void>() {
     25         @Override
     26         public void onNotifyCallback(Observable.OnPropertyChangedCallback callback, Observable sender,
     27                 int arg, Void notUsed) {
     28             callback.onPropertyChanged(sender, arg);
     29         }
     30     };
     31 
     32     public PropertyChangeRegistry() {
     33         super(NOTIFIER_CALLBACK);
     34     }
     35 
     36     /**
     37      * Notifies registered callbacks that a specific property has changed.
     38      *
     39      * @param observable The Observable that has changed.
     40      * @param propertyId The BR id of the property that has changed or BR._all if the entire
     41      *                   Observable has changed.
     42      */
     43     public void notifyChange(Observable observable, int propertyId) {
     44         notifyCallbacks(observable, propertyId, null);
     45     }
     46 }
     47