com.android.databinding.library.baseAdapters.BR Java Examples

The following examples show how to use com.android.databinding.library.baseAdapters.BR. 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: RadioRVAdapter.java    From Flubber with Apache License 2.0 6 votes vote down vote up
public void setSelected(int index) {
    final RadioElementModel checkedModel = checked.get();
    final int oldCheckedIndex = data.indexOf(checkedModel);

    if (oldCheckedIndex == index) {
        checked.notifyPropertyChanged(BR.checked);
    } else {
        if (oldCheckedIndex >= 0) {
            checkedModel.getChecked().set(false);
            notifyItemChanged(oldCheckedIndex);
        }

        checked.set(data.get(index));
        notifyItemChanged(index);
    }
}
 
Example #2
Source File: TimetableAddActivity.java    From Sunshine with Apache License 2.0 5 votes vote down vote up
private void initWeekView() {
    LinearLayoutManager weekLayoutManager = new LinearLayoutManager(this);
    weekLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);

    binding.includeWeek.recyclerView.setLayoutManager(weekLayoutManager);
    final BaseAdapter weekAdapter = new BaseAdapter<>(R.layout.item_ordinal, BR.ordinal, viewModel.getWeeks());
    binding.includeWeek.recyclerView.setAdapter(weekAdapter);
    weekAdapter.setOnItemHandler(
            new BaseAdapter.OnItemHandler() {
                @Override
                public void onItemHandler(ViewDataBinding viewDataBinding, final int position) {
                    final ItemOrdinalBinding itemBinding = (ItemOrdinalBinding) viewDataBinding;
                    if (viewModel.getWeeks().get(position).isSelected()) {
                        Logger.e("被选中的周" + viewModel.getWeeks().get(position).getId());
                        itemBinding.getRoot().setSelected(true);
                    } else {
                        //由于RecyclerView的布局重用机制,这里必须将其他的布局设置为未选中状态
                        itemBinding.getRoot().setSelected(false);
                    }

                    itemBinding.getRoot().setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            viewModel.getWeeks().get(weekPosition).setSelected(false);
                            viewModel.getWeeks().get(position).setSelected(true);
                            weekPosition = position;
                            weekAdapter.notifyDataSetChanged();
                        }
                    });
                }
            }
    );
}
 
Example #3
Source File: TimetableAddActivity.java    From Sunshine with Apache License 2.0 5 votes vote down vote up
private void initTimeView() {
    LinearLayoutManager timeLayoutManager = new LinearLayoutManager(this);
    timeLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    binding.includeTime.recyclerView.setLayoutManager(timeLayoutManager);
    final BaseAdapter timeAdapter = new BaseAdapter<>(R.layout.item_ordinal, BR.ordinal, viewModel.getTime());
    binding.includeTime.recyclerView.setAdapter(timeAdapter);
    timeAdapter.setOnItemHandler(
            new BaseAdapter.OnItemHandler() {
                @Override
                public void onItemHandler(ViewDataBinding viewDataBinding, final int position) {
                    final ItemOrdinalBinding itemBinding = (ItemOrdinalBinding) viewDataBinding;
                    if (viewModel.getTime().get(position).isSelected()) {
                        Logger.e("被选中的课程" + position);
                        itemBinding.getRoot().setSelected(true);
                    } else {
                        //由于RecyclerView的布局重用机制,这里必须将其他的布局设置为未选中状态
                        itemBinding.getRoot().setSelected(false);
                    }

                    itemBinding.getRoot().setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            viewModel.getTime().get(position).setSelected(!viewModel.getTime().get(position).isSelected());
                            timeAdapter.notifyDataSetChanged();
                        }
                    });
                }
            }
    );
}
 
Example #4
Source File: Color.java    From spline with Apache License 2.0 5 votes vote down vote up
public void setHue(float hue) {
    float[] hsv = {hue, this.saturation, this.value};
    this.color = android.graphics.Color.HSVToColor(this.alpha, hsv);
    updateValues(false);
    this.hue = Math.min(Math.max(0f, hue), 359.9f);

    // For each HSV and RGB property, a change in the property changes both the property itself
    // and the resultant color
    notifyPropertyChanged(BR.hue);
    notifyPropertyChanged(BR.color);
}
 
Example #5
Source File: Color.java    From spline with Apache License 2.0 5 votes vote down vote up
public void setSaturation(float saturation) {
    float[] hsv = {this.hue, saturation, this.value};
    this.color = android.graphics.Color.HSVToColor(this.alpha, hsv);
    updateValues(false);
    // Clamp the saturation value
    this.saturation = Math.min(Math.max(0f, saturation), 1.0f);

    notifyPropertyChanged(BR.saturation);
    notifyPropertyChanged(BR.color);
}
 
Example #6
Source File: Color.java    From spline with Apache License 2.0 5 votes vote down vote up
public void setValue(float value) {
    float[] hsv = {this.hue, this.saturation, value};
    this.color = android.graphics.Color.HSVToColor(this.alpha, hsv);
    updateValues(false);
    // Clamp the value
    this.value = Math.min(Math.max(0f, value), 1.0f);

    notifyPropertyChanged(BR.value);
    notifyPropertyChanged(BR.color);
}
 
Example #7
Source File: InfoActivity.java    From Cashew with Apache License 2.0 5 votes vote down vote up
@Override
public void initView(Bundle savedInstanceState) {
    getBinding().setAct(this);
    getBinding().setVm(new InfoViewModel());
    getBinding().getVm().mImageCacheSize = GlideCacheUtil.getInstance().getCacheSize(this);
    getBinding().getVm().notifyPropertyChanged(BR.imageCacheSize);
}
 
Example #8
Source File: InfoActivity.java    From Cashew with Apache License 2.0 5 votes vote down vote up
/**
 * Clear cache click
 */
public void onClearCacheClick() {
    GlideCacheUtil.getInstance().clearImageAllCache(this);
    Toast.makeText(this, "清除了" + getBinding().getVm().mImageCacheSize + "的缓存", Toast.LENGTH_LONG).show();
    getBinding().getVm().mImageCacheSize = GlideCacheUtil.getInstance().getCacheSize(this);
    getBinding().getVm().notifyPropertyChanged(BR.imageCacheSize);
}
 
Example #9
Source File: LayerRowViewModel.java    From spline with Apache License 2.0 4 votes vote down vote up
public void setVisible(boolean visible) {
    if (layer != null && visible != layer.isVisible()) {
        layer.setVisible(visible);
        notifyPropertyChanged(BR.visible);
    }
}
 
Example #10
Source File: Color.java    From spline with Apache License 2.0 4 votes vote down vote up
public void setAlpha(int alpha) {
    this.color = android.graphics.Color.argb(alpha, this.red, this.green, this.blue);
    updateValues();

    notifyPropertyChanged(BR.alpha);
}
 
Example #11
Source File: LoginViewModel.java    From journaldev with MIT License 4 votes vote down vote up
private void setToastMessage(String toastMessage) {

        this.toastMessage = toastMessage;
        notifyPropertyChanged(BR.toastMessage);
    }
 
Example #12
Source File: LoginViewModel.java    From journaldev with MIT License 4 votes vote down vote up
public void setUserEmail(String email) {
    user.setEmail(email);
    notifyPropertyChanged(BR.userEmail);
}
 
Example #13
Source File: LoginViewModel.java    From journaldev with MIT License 4 votes vote down vote up
public void setUserPassword(String password) {
    user.setPassword(password);
    notifyPropertyChanged(BR.userPassword);
}
 
Example #14
Source File: WeatherActivityViewModel.java    From android-viper with Apache License 2.0 4 votes vote down vote up
private void setCurrentWeatherEntity(final CurrentWeatherEntity currentWeatherEntity)
{
	this.mCurrentWeatherEntity = currentWeatherEntity;
	notifyPropertyChanged(BR.currentWeatherEntity);
}