1/*
2 * Copyright (C) 2013 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
17package com.android.mail.utils;
18
19import android.database.DataSetObservable;
20import android.database.DataSetObserver;
21
22/**
23 * A Utility class to register observers and return logging and counts for the number of registered
24 * observers.
25 */
26public class MailObservable extends DataSetObservable {
27    protected static final String LOG_TAG = LogTag.getLogTag();
28    private final String mName;
29
30    public MailObservable(String name) {
31        mName = name;
32    }
33
34    @Override
35    public void registerObserver(DataSetObserver observer) {
36        final int count = mObservers.size();
37        super.registerObserver(observer);
38        LogUtils.d(LOG_TAG, "IN register(%s)Observer: %s before=%d after=%d",
39                mName,  observer, count, mObservers.size());
40    }
41
42    @Override
43    public void unregisterObserver(DataSetObserver observer) {
44        final int count = mObservers.size();
45        super.unregisterObserver(observer);
46        LogUtils.d(LOG_TAG, "IN unregister(%s)Observer: %s before=%d after=%d",
47                mName, observer, count, mObservers.size());
48    }
49}
50