Code example for AtomicBoolean

Methods: get, set

0
	public void onRestoreInstanceState(Parcelable pState) {
		if (pState instanceof Bundle) {
			Bundle bundle = (Bundle) pState;
			pState = bundle.getParcelable(SUPER_STATE); // if we receive a superstate, we should restore it
 
			mIsLoading.set(bundle.getBoolean(IS_LOADING));
			if (mIsLoading.get()) { // if the refresh view was displayed before config change, it should be displayed again
				showRefreshView(); 
			} 
		} 
 
		super.onRestoreInstanceState(pState); // restore the super state
	} 
 
	/** {@inheritDoc} */ 
	public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
		// The user must provide an OnListEnds object AND the list should not be empty 
		if (mOnListEnds != null && getAdapter() != null && !getAdapter().isEmpty()) {
 
			if (!mIsLoading.get() && mOnListEnds.isEnd(firstVisibleItem, visibleItemCount, totalItemCount)) {
				// show the refresh view IF it's not the case AND the end is near 
				showRefreshView(); 
 
				// start the user action 
				mOnListEnds.onStartRefresh();
			} 
		} 
 
		// if a scrollListener is provided, use it! 
		if (mScrollListener != null) {
			mScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
		} 
 
	} 
 
	/** 
	 * show the refresh view and start the animation of the icon 
	 */ 
	private void showRefreshView() { 
		mIsLoading.set(true);
 
		addFooterView(mRefreshView);
		mRefreshView.setVisibility(View.VISIBLE);
		mRefreshIcon.clearAnimation();
		mRefreshIcon.startAnimation(mFlipAnimation);