android.databinding.ObservableArrayList Java Examples

The following examples show how to use android.databinding.ObservableArrayList. 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: LayerListAdapter.java    From spline with Apache License 2.0 7 votes vote down vote up
public ObservableList<Layer> getTwirledDownLayersForGroup(LayerGroup root) {
    ObservableList<Layer> twirledDownLayers = new ObservableArrayList<>();

    for (Layer l : root.getLayers()) {
        twirledDownLayers.add(l);
        if (l instanceof LayerGroup) {
            LayerGroup group = (LayerGroup) l;
            if (group.isTwirledDown()) {
                int i = twirledDownLayers.indexOf(l);
                List<Layer> childLayers = getTwirledDownLayersForGroup(group);
                twirledDownLayers.addAll(i + 1, childLayers);
            }
        }
    }

    return twirledDownLayers;
}
 
Example #2
Source File: BaseExpandableAdapter.java    From ExpandableRecyclerview-Databinding with Apache License 2.0 6 votes vote down vote up
/**
 * expand item
 *
 * @param parentIndex                       will be expand item index
 * @param baseExpandableObservable          the item Observable
 * @param expansionTriggeredByListItemClick
 */
public void expandItem(int parentIndex, BaseExpandableObservable baseExpandableObservable, boolean expansionTriggeredByListItemClick) {
    if (parentIndex >= 0 && parentIndex < mDataList.size() && !baseExpandableObservable.isExpand.get()) {

        ObservableArrayList<Object> childList = baseExpandableObservable.getChildList();
        final int childSize = childList.size();
        for (int i = 0; i < childSize; i++) {
            Object o = childList.get(i);
            int newIndex = parentIndex + i + 1;
            mDataList.add(newIndex, o);
        }
        notifyItemRangeInserted(parentIndex + 1, childSize);
        int positionStart = parentIndex + childSize;
        if (parentIndex != mDataList.size() - 1)
            notifyItemRangeChanged(positionStart, mDataList.size() - positionStart);
        baseExpandableObservable.setIsExpand(true);
        if (!mRecyclerViews.isEmpty()) {
            BindingViewHolder viewHolderForAdapterPosition = (BindingViewHolder) mRecyclerViews.get(0).findViewHolderForAdapterPosition(parentIndex);
            baseExpandableObservable.onExpansionToggled(viewHolderForAdapterPosition, parentIndex, true);
        }
        if (expansionTriggeredByListItemClick && mExpandCollapseListener != null) {
            mExpandCollapseListener.onListItemExpanded(parentIndex);
        }
    }
}
 
Example #3
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    ObservableArrayList users = new ObservableArrayList();
    users.add(new User("George", "Mount"));
    binding.setUsers(users);
    binding.setHandler(new ButtonHandler(users));
}
 
Example #4
Source File: MeiziFragment.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
private void initData() {
    sex = SexUtil.getSex(getActivity());
    data = new ObservableArrayList<>();
    if (sex == 0) {
        data.addAll(boys);
    } else if (sex == 1) {
        data.addAll(girls);
    }
}
 
Example #5
Source File: CurrencyListViewModel.java    From exchange-rates-mvvm with Apache License 2.0 5 votes vote down vote up
public CurrencyListViewModel(Navigator navigator, GetCurrenciesUseCase currenciesUseCase, GetCurrenciesRatesDate getCurrenciesRatesDate) {
    mCurrencies = new ObservableArrayList<>();
    mCurrenciesUseCase = checkNotNull(currenciesUseCase);
    mGetCurrenciesRatesDate = checkNotNull(getCurrenciesRatesDate);
    mNavigator = checkNotNull(navigator);
    setReadDate(new Date());
}
 
Example #6
Source File: BaseExpandableAdapter.java    From ExpandableRecyclerview-Databinding with Apache License 2.0 5 votes vote down vote up
/**
 * @param baseExpandableObservable         {@link BaseExpandableObservable}
 * @param parentIndex                      item index
 * @param collapseTriggeredByListItemClick
 */

private void collapseListItem(int parentIndex, BaseExpandableObservable baseExpandableObservable, boolean collapseTriggeredByListItemClick) {
    if (baseExpandableObservable.isExpand.get()) {
        ObservableArrayList<Object> childItemList = baseExpandableObservable.getChildList();
        if (childItemList != null && !childItemList.isEmpty()) {
            int childListItemCount = childItemList.size();
            for (int i = childListItemCount - 1; i >= 0; i--) {
                int index = parentIndex + i + 1;
                Object o = mDataList.get(index);
                if (o instanceof BaseExpandableObservable) {
                    BaseExpandableObservable parentListItem;
                    try {
                        parentListItem = (BaseExpandableObservable) o;
                        collapseListItem(index, parentListItem, false);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
                mDataList.remove(index);
            }

            notifyItemRangeRemoved(parentIndex + 1, childListItemCount);
            baseExpandableObservable.setIsExpand(false);
            if (!mRecyclerViews.isEmpty()) {
                BindingViewHolder viewHolderForAdapterPosition = (BindingViewHolder) mRecyclerViews.get(0).findViewHolderForAdapterPosition(parentIndex);
                baseExpandableObservable.onExpansionToggled(viewHolderForAdapterPosition, parentIndex, false);
            }
            notifyItemRangeChanged(parentIndex + 1, mDataList.size() - parentIndex - 1);
        }

        if (collapseTriggeredByListItemClick && mExpandCollapseListener != null) {
            int expandedCountBeforePosition = getExpandedItemCount(parentIndex);
            mExpandCollapseListener.onListItemCollapsed(parentIndex - expandedCountBeforePosition);
        }
    }
}
 
Example #7
Source File: BaseExpandableAdapter.java    From ExpandableRecyclerview-Databinding with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(BindingViewHolder holder, int position) {
    Object o = mDataList.get(position);
    ViewDataBinding binding = holder.getBinding();
    binding.setVariable(getVariable(o, position), o);
    binding.executePendingBindings();
    if (o instanceof BaseExpandableObservable) {
        BaseExpandableObservable baseExpandableObservable = (BaseExpandableObservable) o;
        ObservableArrayList<Object> childList = baseExpandableObservable.getChildList();
        if (childList != null && !childList.isEmpty())
            baseExpandableObservable.setItemListExpandCollapseListener(this);
    }
}
 
Example #8
Source File: HomeListAdapter.java    From demo4Fish with MIT License 5 votes vote down vote up
public ViewHolder(ItemHomeListBinding binding) {
    super(binding.getRoot());
    mBinding = binding;

    mList = new ObservableArrayList<>();
    mAdapter = new HomePhotoListAdapter(mContext, mList);
    LinearLayoutManager manager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
    mBinding.list.setLayoutManager(manager);
    mBinding.list.setAdapter(mAdapter);

    mList.addOnListChangedCallback(new RecyclerViewAdapterChangedCallback(mAdapter));
}
 
Example #9
Source File: ExplorerViewModel.java    From SimpleFTP with MIT License 5 votes vote down vote up
/**
 * Default constructor.
 * @param context The context of the current activity.
 */
public ExplorerViewModel(Context context) {
    this.context = context;
    this.isLoading = new ObservableBoolean(false);
    this.isRefreshing = new ObservableBoolean(false);
    this.files = new ObservableArrayList<FileViewModel>();
    this.isSelectionMode = new ObservableBoolean(false);
    this.numberSelectedItems = new ObservableInt(0);
    this.changeDirectory("/");
}
 
Example #10
Source File: HomeViewModel.java    From demo4Fish with MIT License 5 votes vote down vote up
private void initFunctionEntities() {
    mFunctionList = new ObservableArrayList<>();
    String iconUrl = UriUtil.getUriForResourceId(R.mipmap.ic_launcher).toString();
    for (int i = 0; i < 6; i++) {
        FunctionItemEntity entity = new FunctionItemEntity();
        entity.setIconUrl(iconUrl);
        entity.setTitle("测试标题" + i);
        entity.setDesc("测试描述" + i);
        mFunctionList.add(entity);
    }
}
 
Example #11
Source File: HomeViewModel.java    From demo4Fish with MIT License 5 votes vote down vote up
private void initData() {
    mEntity = new HomeEntity();
    mBannerList = new ObservableArrayList<>();
    mHomeList = new ObservableArrayList<>();
    mFreshList = new ArrayList<>();
    mNearList = new ArrayList<>();

    mEntity.setRefreshMoreStatus(LoadMoreView.STATUS_DEFAULT);
    mEntity.setNearMoreStatus(LoadMoreView.STATUS_DEFAULT);
    initFunctionEntities();
}
 
Example #12
Source File: ContentListFragmentViewModel.java    From Anago with Apache License 2.0 5 votes vote down vote up
@Inject
public ContentListFragmentViewModel(BaseFragment fragment, GetFilesUseCase getFilesUseCase) {
    super(fragment);
    this.getFilesUseCase = getFilesUseCase;

    this.contents = new ObservableArrayList<>();
}
 
Example #13
Source File: StarredRepoListFragmentViewModel.java    From Anago with Apache License 2.0 5 votes vote down vote up
@Inject
public StarredRepoListFragmentViewModel(BaseFragment fragment, GetStarredReposUseCase getStarredReposUseCase,
                                        EventBus eventBus) {
    super(fragment);

    this.getStarredReposUseCase = getStarredReposUseCase;
    this.eventBus = eventBus;

    repos = new ObservableArrayList<>();
    isConnecting = new ObservableBoolean(true);
    isRefreshing = new ObservableBoolean(false);
}
 
Example #14
Source File: StargazerListActivityViewModel.java    From Anago with Apache License 2.0 5 votes vote down vote up
@Inject
public StargazerListActivityViewModel(BaseActivity activity, GetStargazersUseCase getStargazersUseCase) {
    super(activity);
    this.getStargazersUseCase = getStargazersUseCase;

    this.users = new ObservableArrayList<>();
}
 
Example #15
Source File: MyRepoListFragmentViewModel.java    From Anago with Apache License 2.0 5 votes vote down vote up
@Inject
public MyRepoListFragmentViewModel(BaseFragment fragment, GetUserReposUseCase getUserReposUseCase, EventBus eventBus) {
    super(fragment);

    this.getUserReposUseCase = getUserReposUseCase;
    this.eventBus = eventBus;

    repos = new ObservableArrayList<>();
    isConnecting = new ObservableBoolean(true);
    isRefreshing = new ObservableBoolean(false);
}
 
Example #16
Source File: IssueListFragmentViewModel.java    From Anago with Apache License 2.0 5 votes vote down vote up
@Inject
public IssueListFragmentViewModel(BaseFragment fragment, GetIssuesUseCase getIssuesUseCase,
                                  EventBus eventBus) {
    super(fragment);
    this.getIssuesUseCase = getIssuesUseCase;
    this.eventBus = eventBus;

    this.issues = new ObservableArrayList<>();
}
 
Example #17
Source File: BindingRecyclerViewAdapter.java    From android-data-binding-recyclerview with Apache License 2.0 5 votes vote down vote up
public void setItems(@Nullable Collection<T> items)
{
    if (this.items == items)
    {
        return;
    }

    if (this.items != null)
    {
        this.items.removeOnListChangedCallback(onListChangedCallback);
        notifyItemRangeRemoved(0, this.items.size());
    }

    if (items instanceof ObservableList)
    {
        this.items = (ObservableList<T>) items;
        notifyItemRangeInserted(0, this.items.size());
        this.items.addOnListChangedCallback(onListChangedCallback);
    }
    else if (items != null)
    {
        this.items = new ObservableArrayList<>();
        this.items.addOnListChangedCallback(onListChangedCallback);
        this.items.addAll(items);
    }
    else
    {
        this.items = null;
    }
}
 
Example #18
Source File: ListServerViewModel.java    From SimpleFTP with MIT License 5 votes vote down vote up
/**
 * Default constructor.
 * @param context The context of the current activity.
 */
public ListServerViewModel(Activity context) {
    this.context = context;
    this.servers = new ObservableArrayList<FtpServerViewModel>();
    this.selectedServer = new ObservableField<FtpServerViewModel>();
    this.selectedServerVisible = new ObservableBoolean();
}
 
Example #19
Source File: BindingRecyclerViewAdapter.java    From SimpleFTP with MIT License 5 votes vote down vote up
/**
 * Sets the list of items to display.
 * @param items The list of items.
 */
public void setItems(@Nullable Collection<T> items)
{
    if (this.items == items)
    {
        return;
    }

    if (this.items != null)
    {
        this.items.removeOnListChangedCallback(onListChangedCallback);
        notifyItemRangeRemoved(0, this.items.size());
    }

    if (items instanceof ObservableList)
    {
        this.items = (ObservableList<T>) items;
        notifyItemRangeInserted(0, this.items.size());
        this.items.addOnListChangedCallback(onListChangedCallback);
    }
    else if (items != null)
    {
        this.items = new ObservableArrayList<>();
        this.items.addOnListChangedCallback(onListChangedCallback);
        this.items.addAll(items);
    }
    else
    {
        this.items = null;
    }
}
 
Example #20
Source File: MainActivity.java    From android-ui-toolkit-demos with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    ObservableArrayList users = new ObservableArrayList();
    users.add(new User("George", "Mount"));
    binding.setUsers(users);
    binding.setHandler(new ButtonHandler(users));
}
 
Example #21
Source File: BusinessQuestion.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 5 votes vote down vote up
public BusinessQuestion(Question item) {
    for (int i = 0; i < 4; i++) isChecked.add(false);
    id = item._id.$id;
    question = item.question;
    choice = Boolean.valueOf(item.choice);
    multiAnswer = Boolean.valueOf(item.multi_answer);
    options = new ObservableArrayList<>();
    options.addAll(item.options);
    while (options.size() < 4) {
        options.add(ChaoliApplication.getAppContext().getString(R.string.useless_option));
    }
}
 
Example #22
Source File: AndroidInfoAdapter.java    From androidexamples with Apache License 2.0 4 votes vote down vote up
public AndroidInfoAdapter(ObservableArrayList<AndroidInfo> l) {
    list = l;
}
 
Example #23
Source File: AndroidInfoAdapter.java    From androidexamples with Apache License 2.0 4 votes vote down vote up
public AndroidInfoAdapter(ObservableArrayList<AndroidInfo> l) {
    list = l;
}
 
Example #24
Source File: ListBinder.java    From androidexamples with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("bind:items")
public static void bindList(RecyclerView view, ObservableArrayList<AndroidInfo> list) {
    LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext());
    view.setLayoutManager(layoutManager);
    view.setAdapter(new AndroidInfoAdapter(list));
}
 
Example #25
Source File: BaseExpandableObservable.java    From ExpandableRecyclerview-Databinding with Apache License 2.0 4 votes vote down vote up
public BaseExpandableObservable() {
    mChildList = new ObservableArrayList<>();
    isExpand = new ObservableBoolean(false);
}
 
Example #26
Source File: BaseExpandableObservable.java    From ExpandableRecyclerview-Databinding with Apache License 2.0 4 votes vote down vote up
public ObservableArrayList<Object> getChildList() {
    return mChildList;
}
 
Example #27
Source File: PullRequestListFragmentViewModel.java    From Anago with Apache License 2.0 4 votes vote down vote up
@Inject
public PullRequestListFragmentViewModel(BaseFragment fragment, GetPullRequestsUseCase getPullRequestsUseCase) {
    super(fragment);
    this.getPullRequestsUseCase = getPullRequestsUseCase;
    this.pullRequests = new ObservableArrayList<>();
}
 
Example #28
Source File: UsersViewModel.java    From android-data-binding-recyclerview with Apache License 2.0 4 votes vote down vote up
public UsersViewModel()
{
    this.users = new ObservableArrayList<>();
}
 
Example #29
Source File: MrSharedState.java    From mr-mantou-android with GNU General Public License v3.0 4 votes vote down vote up
public ObservableArrayList<Image> getImages() {
    return images;
}
 
Example #30
Source File: NoteListModel.java    From mv2m with Apache License 2.0 4 votes vote down vote up
public ObservableArrayList<Note> getItems() {
    return items;
}