android.database.DataSetObserver Java Examples

The following examples show how to use android.database.DataSetObserver. 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: PaCursor.java    From PluginLoader with Apache License 2.0 6 votes vote down vote up
/**
 * Unregister an observer that has previously been registered with this
 * cursor via {@link #registerContentObserver}.
 *
 * @param observer
 *            the object to unregister.
 * @see #registerDataSetObserver(DataSetObserver)
 */
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    try {
        if (mCursor != null) {
            mCursor.unregisterDataSetObserver(observer);
        }
    } catch (Exception e) {
        PaLog.d("Cursor exception: " + e);
        if (mCursor != null) {
            try {
                mCursor.close();
            } catch (Exception exception) {
                PaLog.d("Cursor close exception: " + e);
            }
            mCursor = null;
        }
    }
}
 
Example #2
Source File: BaseSuperAbsListview.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Set the adapter to the listview
 * Automativally hide the progressbar
 * Set the refresh to false
 * If adapter is empty, then the emptyview is shown
 *
 * @param adapter
 */
public void setAdapter(ListAdapter adapter) {
    mProgress.setVisibility(View.GONE);
    if (mEmpty != null && mEmptyId != 0)
        mList.setEmptyView(mEmpty);
    mList.setVisibility(View.VISIBLE);
    mPtrLayout.setRefreshing(false);
    adapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            mProgress.setVisibility(View.GONE);
            isLoadingMore = false;
            mPtrLayout.setRefreshing(false);
            if (mList.getAdapter().getCount() == 0 && mEmptyId != 0) {
                mEmpty.setVisibility(View.VISIBLE);
            } else if (mEmptyId != 0) {
                mEmpty.setVisibility(View.GONE);
            }
        }
    });
    if ((adapter == null || adapter.getCount() == 0) && mEmptyId != 0) {
        mEmpty.setVisibility(View.VISIBLE);
    }
}
 
Example #3
Source File: AbstractWheelAdapter.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
protected void notifyDataChangedEvent()
{
    if (a != null)
    {
        for (Iterator iterator = a.iterator(); iterator.hasNext(); ((DataSetObserver)iterator.next()).onChanged()) { }
    }
}
 
Example #4
Source File: AbstractWheelAdapter.java    From myapplication with Apache License 2.0 5 votes vote down vote up
/**
 * Notifies observers about data changing
 */
protected void notifyDataChangedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onChanged();
        }
    }
}
 
Example #5
Source File: AbstractWheelAdapter.java    From Mupdf with Apache License 2.0 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example #6
Source File: GridViewWithHeaderAndFooter.java    From cube-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.registerObserver(observer);
    if (mAdapter != null) {
        mAdapter.registerDataSetObserver(observer);
    }
}
 
Example #7
Source File: AbstractWheelAdapter.java    From CoolClock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example #8
Source File: BaseBindAdapter.java    From Pioneer with Apache License 2.0 5 votes vote down vote up
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    if (observer == null) {
        /*
         * http://stackoverflow.com/questions/7290841/java-lang-illegalargumentexception-the-observer-is-null
         * ListView / GridView #onDetachedFromWindow 方法被重复执行时,
         * SDK在 14-17 之间的系统此处 observer 为 null,若不拦截将产生 IllegalArgumentException,
         * SDK 18 修复了此问题
         */
        return;
    }
    super.unregisterDataSetObserver(observer);
}
 
Example #9
Source File: HeaderGridView.java    From MutiPhotoChoser with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.unregisterObserver(observer);
    if (mAdapter != null) {
        mAdapter.unregisterDataSetObserver(observer);
    }
}
 
Example #10
Source File: HeaderFooterViewListAdapter.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.unregisterObserver(observer);
    if (mAdapter != null) {
        mAdapter.unregisterDataSetObserver(observer);
    }
}
 
Example #11
Source File: AbstractWheelAdapter.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example #12
Source File: ConnectionsDialogFragment.java    From android with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ((CjdnsApplication) getActivity().getApplication()).inject(this);

    Bundle args = getArguments();
    final int peerId = args.getInt(FRAGMENT_BUNDLE_KEY_PEER_ID);

    final Observable<Node.Peer> peerStream = mPeersProducer.createStream()
            .mergeWith(mPeersProducer.updateStream())
            .filter(new Func1<Node.Peer, Boolean>() {
                @Override
                public Boolean call(Node.Peer peer) {
                    return peer.id == peerId;
                }
            });

    mAdapter = new ConnectionAdapter(getActivity(), mBus,
            AppObservable.bindFragment(this, mSettingsProducer.themeStream()),
            AppObservable.bindFragment(this, peerStream));
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            if (mAdapter.hasData() && mAdapter.getCount() <= 0) {
                dismiss();
            }
        }
    });

    return new MaterialDialog.Builder(getActivity())
            .title(R.string.connections_list_title)
            .adapter(mAdapter, null)
            .listSelector(R.drawable.md_transparent)
            .build();
}
 
Example #13
Source File: InMemoryTreeStateManager.java    From satstat with GNU General Public License v3.0 5 votes vote down vote up
private synchronized void internalDataSetChanged() {
    visibleListCache = null;
    unmodifiableVisibleList = null;
    if (observers != null)
    	for (final DataSetObserver observer : observers) {
    		observer.onChanged();
    	}
}
 
Example #14
Source File: AdmobAdapterWrapper.java    From admobadapter with Apache License 2.0 5 votes vote down vote up
public void setAdapter(BaseAdapter adapter) {
    mAdapter = adapter;
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            notifyDataSetChanged();
        }

        @Override
        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
}
 
Example #15
Source File: AbstractWheelAdapter.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * Notifies observers about data changing
 */
protected void notifyDataChangedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onChanged();
        }
    }
}
 
Example #16
Source File: AbstractWheelAdapter.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example #17
Source File: AbstractWheelAdapter.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void unregisterDataSetObserver(DataSetObserver datasetobserver)
{
    if (a != null)
    {
        a.remove(datasetobserver);
    }
}
 
Example #18
Source File: Indicator.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public void setViewPager(ViewPager viewPager) {
    this.viewPager = viewPager;
    viewPager.addOnPageChangeListener(this);
    setPageCount(viewPager.getAdapter().getCount());
    viewPager.getAdapter().registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            setPageCount(Indicator.this.viewPager.getAdapter().getCount());
        }
    });
    setCurrentPageImmediate();
}
 
Example #19
Source File: DragSortListView.java    From DongWeather with Apache License 2.0 5 votes vote down vote up
public AdapterWrapper(ListAdapter adapter) {
    super();
    mAdapter = adapter;
    
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        public void onChanged() {
            notifyDataSetChanged();
        }

        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
}
 
Example #20
Source File: GridViewWithHeaderAndFooter.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.registerObserver(observer);
    if (mAdapter != null) {
        mAdapter.registerDataSetObserver(observer);
    }
}
 
Example #21
Source File: BaseAdapterDecoratorTest.java    From ListViewAnimations with Apache License 2.0 5 votes vote down vote up
public void testUnregisterDataSetObserver() {
    DataSetObserver mock = mock(DataSetObserver.class);
    mBaseAdapterDecorator.registerDataSetObserver(mock);
    mBaseAdapterDecorator.unregisterDataSetObserver(mock);

    verify(mBaseAdapter).unregisterDataSetObserver(mock);
}
 
Example #22
Source File: RefreshContentWrapper.java    From CollapsingRefresh with Apache License 2.0 5 votes vote down vote up
@Override
public void setViewPagerObserver(DataSetObserver observer) {
    super.setViewPagerObserver(observer);
    if (observer == null) {
        wrapperViewPager(mViewPager, this);
    }
}
 
Example #23
Source File: ContentDecoratorAdapter.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    mAdapter.registerDataSetObserver(observer);
}
 
Example #24
Source File: AbstractCursor.java    From sqlite-android with Apache License 2.0 4 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.registerObserver(observer);
}
 
Example #25
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    if (observer != null) {
        super.unregisterDataSetObserver(observer);
    }
}
 
Example #26
Source File: CommonAdapter.java    From TwinklingRefreshLayout with Apache License 2.0 4 votes vote down vote up
public void unregisterDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.unregisterObserver(observer);
}
 
Example #27
Source File: StickyGridHeadersBaseAdapterWrapper.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    super.registerDataSetObserver(observer);
    mDelegate.registerDataSetObserver(observer);
}
 
Example #28
Source File: DecoratorAdapter.java    From SwipeActionAdapter with Apache License 2.0 4 votes vote down vote up
@Override
public void unregisterDataSetObserver(final DataSetObserver observer){
    mBaseAdapter.unregisterDataSetObserver(observer);
}
 
Example #29
Source File: HeaderViewListAdapter.java    From ZrcListView with MIT License 4 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (mAdapter != null) {
        mAdapter.registerDataSetObserver(observer);
    }
}
 
Example #30
Source File: TweetTimelineRecyclerViewAdapter.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
TweetTimelineRecyclerViewAdapter(Context context,
                                 final TimelineDelegate<Tweet> timelineDelegate,
                                 int styleResId) {
    if (context == null) {
        throw new IllegalArgumentException("Context must not be null");
    }
    this.context = context;
    this.timelineDelegate = timelineDelegate;
    this.styleResId = styleResId;

    this.timelineDelegate.refresh(new Callback<TimelineResult<Tweet>>() {
        @Override
        public void success(Result<TimelineResult<Tweet>> result) {
            notifyDataSetChanged();
            previousCount = TweetTimelineRecyclerViewAdapter.this.timelineDelegate.getCount();
        }

        @Override
        public void failure(TwitterException exception) {

        }
    });

    final DataSetObserver dataSetObserver = new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            if (previousCount == 0) {
                notifyDataSetChanged();
            } else {
                notifyItemRangeInserted(previousCount,
                        TweetTimelineRecyclerViewAdapter.this.timelineDelegate.getCount()
                                - previousCount);
            }
            previousCount = TweetTimelineRecyclerViewAdapter.this.timelineDelegate.getCount();
        }

        @Override
        public void onInvalidated() {
            notifyDataSetChanged();
            super.onInvalidated();
        }
    };

    this.timelineDelegate.registerDataSetObserver(dataSetObserver);
}