Java Code Examples for android.databinding.ObservableList#OnListChangedCallback

The following examples show how to use android.databinding.ObservableList#OnListChangedCallback . 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: ListFragment.java    From spline with Apache License 2.0 5 votes vote down vote up
public FileAdapter() {
    mOnListChangedCallback = new ObservableList
            .OnListChangedCallback<ObservableList<Layer>>() {
        @Override
        public void onChanged(ObservableList<Layer> layers) {

        }

        @Override
        public void onItemRangeChanged(ObservableList<Layer> layers, int i, int i1) {

        }

        @Override
        public void onItemRangeInserted(ObservableList<Layer> layers, int start, int
                count) {
            notifyItemRangeInserted(start, count);
        }

        @Override
        public void onItemRangeMoved(ObservableList<Layer> sender, int fromPosition, int
                toPosition, int itemCount) {

        }

        @Override
        public void onItemRangeRemoved(ObservableList<Layer> sender, int positionStart,
                                       int itemCount) {

        }
    };
}
 
Example 2
Source File: HomeViewModel.java    From demo4Fish with MIT License 4 votes vote down vote up
@Override
public void addBannerListChangedCallback(ObservableList.OnListChangedCallback callback) {
    addObservableListBinding(mBannerList, callback);
}
 
Example 3
Source File: HomeViewModel.java    From demo4Fish with MIT License 4 votes vote down vote up
@Override
public void addFunctionListChangedCallback(ObservableList.OnListChangedCallback callback) {
    addObservableListBinding(mFunctionList, callback);
}
 
Example 4
Source File: HomeViewModel.java    From demo4Fish with MIT License 4 votes vote down vote up
@Override
public void addHomeListChangedCallback(ObservableList.OnListChangedCallback callback) {
    addObservableListBinding(mHomeList, callback);
}
 
Example 5
Source File: MainViewModel.java    From demo4Fish with MIT License 4 votes vote down vote up
@Override
public void addDrawerItemsChangedCallback(ObservableList.OnListChangedCallback callback) {
    addObservableListBinding(mDrawerItems, callback);
}
 
Example 6
Source File: ListBinding.java    From demo4Fish with MIT License 4 votes vote down vote up
public ListBinding(ObservableList list, ObservableList.OnListChangedCallback callback) {
    mList = list;
    mCallback = callback;
}
 
Example 7
Source File: ObservableBindingUtil.java    From demo4Fish with MIT License 4 votes vote down vote up
public static IBinding bind(ObservableList observableList, ObservableList.OnListChangedCallback callback) {
    IBinding binding = new ListBinding(observableList, callback);
    binding.bind();

    return binding;
}
 
Example 8
Source File: ViewModel.java    From demo4Fish with MIT License 4 votes vote down vote up
protected void addObservableListBinding(ObservableList observableList, ObservableList.OnListChangedCallback callback) {
    IBinding binding = ObservableBindingUtil.bind(observableList, callback);
    mObservableBindingList.add(binding);
}
 
Example 9
Source File: DocumentView.java    From spline with Apache License 2.0 4 votes vote down vote up
public void init(Context context) {
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    mDensity = metrics.density;

    ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mLongPressTimeout = vc.getLongPressTimeout();

    mScroller = new OverScroller(context);

    mTouchRadius = TOUCH_RADIUS_DP * mDensity;
    mEditCtrlStrokeWidth = EDIT_CTRL_STROKE_DP * mDensity;
    mEditColor = getResources().getColor(R.color.colorAccent, context.getTheme());

    mOnListChangedCallback = new ObservableList
            .OnListChangedCallback<ObservableList<Layer>>() {
        @Override
        public void onChanged(ObservableList<Layer> layers) {
            invalidate();
        }

        @Override
        public void onItemRangeChanged(ObservableList<Layer> layers, int i, int i1) {
            invalidate();
        }

        @Override
        public void onItemRangeInserted(ObservableList<Layer> layers, int start, int count) {
            invalidate();
            addPropertyChangedCallbacks(layers, start, start + count);
        }

        @Override
        public void onItemRangeMoved(ObservableList<Layer> layers, int i, int i1, int i2) {
            invalidate();
        }

        @Override
        public void onItemRangeRemoved(ObservableList<Layer> layers, int i, int i1) {
            invalidate();
        }
    };

    mOnPropertyChangedCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            invalidate();
        }
    };
}
 
Example 10
Source File: LayerListAdapter.java    From spline with Apache License 2.0 4 votes vote down vote up
public LayerListAdapter() {

        mOnListChangedCallback = new ObservableList
                .OnListChangedCallback<ObservableList<Layer>>() {
            @Override
            public void onChanged(ObservableList<Layer> layers) {

            }

            @Override
            public void onItemRangeChanged(ObservableList<Layer> layers, int i, int i1) {

            }

            @Override
            public void onItemRangeInserted(ObservableList<Layer> layers, int start, int count) {
                addListChangedCallbacks(layers, start, start + count);

                for (int i = start; i < start + count; i++) {
                    addLayer(layers.get(i));
                }
            }

            @Override
            public void onItemRangeMoved(ObservableList<Layer> layers, int i, int i1, int i2) {

            }

            @Override
            public void onItemRangeRemoved(ObservableList<Layer> layers, int start, int count) {
                // Because we don't know which item(s) were removed, we have to
                // reconstruct it ourselves
                Set<Layer> currentTwirled = new HashSet<Layer>(getTwirledDownLayersForGroup(mRoot));
                Set<Layer> oldTwirled = new HashSet<Layer>(mTwirledDownLayers);
                oldTwirled.removeAll(currentTwirled);
                for (Layer l : oldTwirled) {
                    removeLayer(l);
                }
            }
        };
    }
 
Example 11
Source File: IHomeViewModel.java    From demo4Fish with MIT License 2 votes vote down vote up
/**
 * 为BannerList添加监听器
 *
 * @param callback
 */
void addBannerListChangedCallback(ObservableList.OnListChangedCallback callback);
 
Example 12
Source File: IHomeViewModel.java    From demo4Fish with MIT License 2 votes vote down vote up
/**
 * 监听功能列表数据
 *
 * @param callback
 */
void addFunctionListChangedCallback(ObservableList.OnListChangedCallback callback);
 
Example 13
Source File: IHomeViewModel.java    From demo4Fish with MIT License 2 votes vote down vote up
/**
 * 对首页列表数据监听
 *
 * @param callback
 */
void addHomeListChangedCallback(ObservableList.OnListChangedCallback callback);
 
Example 14
Source File: IMainViewModel.java    From demo4Fish with MIT License votes vote down vote up
void addDrawerItemsChangedCallback(ObservableList.OnListChangedCallback callback);