Java Code Examples for android.widget.ListAdapter#unregisterDataSetObserver()

The following examples show how to use android.widget.ListAdapter#unregisterDataSetObserver() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PinnedSectionListView.java    From AndroidWeekly with Apache License 2.0 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {

    // assert adapter in debug mode
    if (BuildConfig.DEBUG && adapter != null) {
        if (!(adapter instanceof PinnedSectionListAdapter))
            throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
        if (adapter.getViewTypeCount() < 2)
            throw new IllegalArgumentException("Does your adapter handle at least two types" +
                    " of views in getViewTypeCount() method: items and sections?");
    }

    // unregister observer at old adapter and register on new one
    ListAdapter oldAdapter = getAdapter();
    if (oldAdapter != null) oldAdapter.unregisterDataSetObserver(mDataSetObserver);
    if (adapter != null) adapter.registerDataSetObserver(mDataSetObserver);

    // destroy pinned shadow, if new adapter is not same as old one
    if (oldAdapter != adapter) destroyPinnedShadow();

    super.setAdapter(adapter);
}
 
Example 2
Source File: PinnedSectionListView.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {

    // assert adapter in debug mode
    if (BuildConfig.DEBUG && adapter != null) {
        if (!(adapter instanceof PinnedSectionListAdapter))
            throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
        if (adapter.getViewTypeCount() < 2)
            throw new IllegalArgumentException("Does your adapter handle at least two types" +
                    " of views in getViewTypeCount() method: items and sections?");
    }

    // unregister observer at old adapter and register on new one
    ListAdapter oldAdapter = getAdapter();
    if (oldAdapter != null) oldAdapter.unregisterDataSetObserver(mDataSetObserver);
    if (adapter != null) adapter.registerDataSetObserver(mDataSetObserver);

    // destroy pinned shadow, if new adapter is not same as old one
    if (oldAdapter != adapter) destroyPinnedShadow();

    super.setAdapter(adapter);
}
 
Example 3
Source File: PinnedSectionListView.java    From KUAS-AP-Material with MIT License 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {
	// unregister observer at old adapter and register on new one
	ListAdapter oldAdapter = getAdapter();
	if (oldAdapter != null) {
		oldAdapter.unregisterDataSetObserver(mDataSetObserver);
	}
	if (adapter != null) {
		adapter.registerDataSetObserver(mDataSetObserver);
	}

	// destroy pinned shadow, if new adapter is not same as old one
	if (oldAdapter != adapter) {
		destroyPinnedShadow();
	}

	super.setAdapter(adapter);
}
 
Example 4
Source File: PinnedSectionListView.java    From KUAS-AP-Material with MIT License 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {
	// unregister observer at old adapter and register on new one
	ListAdapter oldAdapter = getAdapter();
	if (oldAdapter != null) {
		oldAdapter.unregisterDataSetObserver(mDataSetObserver);
	}
	if (adapter != null) {
		adapter.registerDataSetObserver(mDataSetObserver);
	}

	// destroy pinned shadow, if new adapter is not same as old one
	if (oldAdapter != adapter) {
		destroyPinnedShadow();
	}

	super.setAdapter(adapter);
}
 
Example 5
Source File: PinnedSectionListView.java    From Contacts with MIT License 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {

    // assert adapter in debug mode
	if (BuildConfig.DEBUG && adapter != null) {
		if (!(adapter instanceof PinnedSectionListAdapter))
			throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
		if (adapter.getViewTypeCount() < 2)
			throw new IllegalArgumentException("Does your adapter handle at least two types" +
					" of views in getViewTypeCount() method: items and sections?");
	}

	// unregister observer at old adapter and register on new one
	ListAdapter oldAdapter = getAdapter();
	if (oldAdapter != null) oldAdapter.unregisterDataSetObserver(mDataSetObserver);
	if (adapter != null) adapter.registerDataSetObserver(mDataSetObserver);

	// destroy pinned shadow, if new adapter is not same as old one
	if (oldAdapter != adapter) destroyPinnedShadow();

	super.setAdapter(adapter);
}
 
Example 6
Source File: PinnedSectionListView.java    From PullToRefresh-PinnedSection-ListView with MIT License 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {

    // assert adapter in debug mode
	if (BuildConfig.DEBUG && adapter != null) {
		if (!(adapter instanceof PinnedSectionListAdapter))
			throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
		if (adapter.getViewTypeCount() < 2)
			throw new IllegalArgumentException("Does your adapter handle at least two types" +
					" of views in getViewTypeCount() method: items and sections?");
	}

	// unregister observer at old adapter and register on new one
	ListAdapter oldAdapter = getAdapter();
	if (oldAdapter != null) oldAdapter.unregisterDataSetObserver(mDataSetObserver);
	if (adapter != null) adapter.registerDataSetObserver(mDataSetObserver);

	// destroy pinned shadow, if new adapter is not same as old one
	if (oldAdapter != adapter) destroyPinnedShadow();

	super.setAdapter(adapter);
}
 
Example 7
Source File: PinnedSectionListView.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {

    // assert adapter in debug mode
	if (BuildConfig.DEBUG && adapter != null) {
		if (!(adapter instanceof PinnedSectionListAdapter))
			throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
		if (adapter.getViewTypeCount() < 2)
			throw new IllegalArgumentException("Does your adapter handle at least two types" +
					" of views in getViewTypeCount() method: items and sections?");
	}

	// unregister observer at old adapter and register on new one
	ListAdapter oldAdapter = getAdapter();
	if (oldAdapter != null) oldAdapter.unregisterDataSetObserver(mDataSetObserver);
	if (adapter != null) adapter.registerDataSetObserver(mDataSetObserver);

	// destroy pinned shadow, if new adapter is not same as old one
	if (oldAdapter != adapter) destroyPinnedShadow();

	super.setAdapter(adapter);
}
 
Example 8
Source File: PinnedSectionListView.java    From Kernel-Tuner with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {

    // assert adapter in debug mode
	if (BuildConfig.DEBUG && adapter != null) {
		if (!(adapter instanceof PinnedSectionListAdapter))
			throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
		if (adapter.getViewTypeCount() < 2)
			throw new IllegalArgumentException("Does your adapter handle at least two types" +
					" of views in getViewTypeCount() method: items and sections?");
	}

	// unregister observer at old adapter and register on new one
	ListAdapter oldAdapter = getAdapter();
	if (oldAdapter != null) oldAdapter.unregisterDataSetObserver(mDataSetObserver);
	if (adapter != null) adapter.registerDataSetObserver(mDataSetObserver);

	// destroy pinned shadow, if new adapter is not same as old one
	if (oldAdapter != adapter) destroyPinnedShadow();

	super.setAdapter(adapter);
}
 
Example 9
Source File: PinnedSectionListView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@Override
public void setAdapter(ListAdapter adapter) {

    // assert adapter in debug mode
    if (adapter != null) {
        if (!(adapter instanceof PinnedSectionListAdapter))
            throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
        if (adapter.getViewTypeCount() < 2)
            throw new IllegalArgumentException("Does your adapter handle at least two types" +
                    " of views in getViewTypeCount() method: items and sections?");
    }

    // unregister observer at old adapter and register on new one
    ListAdapter oldAdapter = getAdapter();
    if (oldAdapter != null) oldAdapter.unregisterDataSetObserver(mDataSetObserver);
    if (adapter != null) adapter.registerDataSetObserver(mDataSetObserver);

    // destroy pinned shadow, if new adapter is not same as old one
    if (oldAdapter != adapter) destroyPinnedShadow();

    Log.e("APP", "mLvFooterLoadingFrame:" + mLvFooterLoadingFrame + " mAddedLvFooter:" + mAddedLvFooter);

    if (null != mLvFooterLoadingFrame && !mAddedLvFooter) {
        addFooterView(mLvFooterLoadingFrame, null, false);
        mAddedLvFooter = true;
    }

    super.setAdapter(adapter);
}
 
Example 10
Source File: InnerListView.java    From MagicHeaderViewPager with Apache License 2.0 5 votes vote down vote up
/**
 * @param adapter
 */
private void unRegisterPreDataSetObserver(ListAdapter adapter) {
    if(adapter != null && mPreDataSetObserverRegistered) {
        adapter.unregisterDataSetObserver(mPreDataSetObserver);
        mPreDataSetObserverRegistered = false;
    }
}