androidx.databinding.ObservableField Java Examples
The following examples show how to use
androidx.databinding.ObservableField.
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: DataSetRowHeader.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void bind(DataElement dataElement, ObservableField<DataSetTableAdapter.TableScale> currentTableScale, Boolean dataElementDecoration) { binding.setTableScale(currentTableScale); binding.title.setText(!isEmpty(dataElement.displayFormName()) ? dataElement.displayFormName() : dataElement.displayName()); boolean hasDescription = dataElement.displayDescription()!=null && !dataElement.displayDescription().isEmpty(); boolean showDecoration = dataElementDecoration.equals(true); if (showDecoration|| hasDescription) { binding.descriptionLabel.setVisibility(View.VISIBLE); binding.descriptionLabel.setOnClickListener(v -> new CustomDialog( itemView.getContext(), dataElement.displayName(), dataElement.displayDescription() != null ? dataElement.displayDescription() : itemView.getContext().getString(R.string.empty_description), itemView.getContext().getString(R.string.action_accept), null, Constants.DESCRIPTION_DIALOG, null ).show()); } else binding.descriptionLabel.setVisibility(View.GONE); }
Example #2
Source File: FilterManager.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
public ObservableField<Integer> observeField(Filters filter) { switch (filter) { case ORG_UNIT: return ouFiltersApplied; case SYNC_STATE: return stateFiltersApplied; case PERIOD: return periodFiltersApplied; case CAT_OPT_COMB: return catOptCombFiltersApplied; case EVENT_STATUS: return eventStatusFiltersApplied; case ASSIGNED_TO_ME: return assignedToMeApplied; default: return new ObservableField<>(0); } }
Example #3
Source File: FilterManager.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void reset() { ouFilters = new ArrayList<>(); stateFilters = new ArrayList<>(); periodFilters = null; catOptComboFilters = new ArrayList<>(); eventStatusFilters = new ArrayList<>(); assignedFilter = false; ouFiltersApplied = new ObservableField<>(0); stateFiltersApplied = new ObservableField<>(0); periodFiltersApplied = new ObservableField<>(0); catOptCombFiltersApplied = new ObservableField<>(0); eventStatusFiltersApplied = new ObservableField<>(0); assignedToMeApplied = new ObservableField<>(0); filterProcessor = PublishProcessor.create(); ouTreeProcessor = PublishProcessor.create(); periodRequestProcessor = PublishProcessor.create(); }
Example #4
Source File: ImageRow.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
public ImageHolder onCreate(@NonNull ViewGroup parent, int count, ObservableField<String> imageSelector, String sectionRendering) { FormImageBinding binding = DataBindingUtil.inflate(inflater, R.layout.form_image, parent, false); Integer height = null; Integer parentHeight = parent.getHeight(); if (sectionRendering != null && sectionRendering.equals(ProgramStageSectionRenderingType.SEQUENTIAL.name())) { height = parentHeight / (count > 2 ? 3 : count); } else if (sectionRendering != null && sectionRendering.equals(ProgramStageSectionRenderingType.MATRIX.name())) { height = parentHeight / (count / 2 + 1); } View rootView = binding.getRoot(); if (height != null) { ViewGroup.LayoutParams layoutParams = rootView.getLayoutParams(); layoutParams.height = height; rootView.setLayoutParams(layoutParams); } return new ImageHolder(binding, processor, imageSelector); }
Example #5
Source File: FiltersAdapter.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public FiltersAdapter(ProgramType programType) { this.filtersList = new ArrayList<>(); this.programType = programType; filtersList.add(Filters.PERIOD); filtersList.add(Filters.ORG_UNIT); filtersList.add(Filters.SYNC_STATE); openedFilter = new ObservableField<>(); }
Example #6
Source File: FilterHolder.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
FilterHolder(@NonNull ViewDataBinding binding, ObservableField<Filters> openedFilter) { super(binding.getRoot()); this.binding = binding; this.openFilter = openedFilter; this.filterArrow = binding.getRoot().findViewById(R.id.filterArrow); this.filterIcon = binding.getRoot().findViewById(R.id.filterIcon); this.filterTitle = binding.getRoot().findViewById(R.id.filterTitle); this.filterValues = binding.getRoot().findViewById(R.id.filterValues); }
Example #7
Source File: BlogItemViewModel.java From android-mvvm-architecture with Apache License 2.0 | 5 votes |
public BlogItemViewModel(BlogResponse.Blog blog, BlogItemViewModelListener listener) { this.mBlog = blog; this.mListener = listener; imageUrl = new ObservableField<>(mBlog.getCoverImgUrl()); title = new ObservableField<>(mBlog.getTitle()); author = new ObservableField<>(mBlog.getAuthor()); date = new ObservableField<>(mBlog.getDate()); content = new ObservableField<>(mBlog.getDescription()); }
Example #8
Source File: EventCapturePresenterImpl.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public EventCapturePresenterImpl(EventCaptureContract.View view, String eventUid, EventCaptureContract.EventCaptureRepository eventCaptureRepository, RulesUtilsProvider rulesUtils, ValueStore valueStore, SchedulerProvider schedulerProvider) { this.view = view; this.eventUid = eventUid; this.eventCaptureRepository = eventCaptureRepository; this.rulesUtils = rulesUtils; this.valueStore = valueStore; this.schedulerProvider = schedulerProvider; this.currentPosition = 0; this.sectionsToHide = new ArrayList<>(); this.currentSection = new ObservableField<>(""); this.errors = new HashMap<>(); this.emptyMandatoryFields = new HashMap<>(); this.canComplete = true; this.sectionList = new ArrayList<>(); this.compositeDisposable = new CompositeDisposable(); currentSectionPosition = PublishProcessor.create(); sectionProcessor = PublishProcessor.create(); showCalculationProcessor = PublishProcessor.create(); progressProcessor = PublishProcessor.create(); sectionAdjustProcessor = PublishProcessor.create(); formAdjustProcessor = PublishProcessor.create(); notesCounterProcessor = PublishProcessor.create(); formFieldsProcessor = BehaviorSubject.createDefault(new ArrayList<>()); }
Example #9
Source File: BindingViewItem.java From recyclerview-adapters with Apache License 2.0 | 5 votes |
public void bindVisible(final ObservableField<Boolean> visibleChangeField) { if (visibleChangeField.get() != null) setVisible(visibleChangeField.get()); releaseVisibleChangeBinding(); visibleChangeCallback = new Observable.OnPropertyChangedCallback() { @Override public void onPropertyChanged(Observable sender, int propertyId) { setVisible(visibleChangeField.get(), false); } }; visibleChangeField.addOnPropertyChangedCallback(visibleChangeCallback); this.visibleChangeField = visibleChangeField; }
Example #10
Source File: TimeView.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCellLayout(ObservableField<DataSetTableAdapter.TableScale> tableScale){ binding = DataBindingUtil.inflate(inflater, R.layout.custom_cell_view, this, true); ((CustomCellViewBinding)binding).setTableScale(tableScale); editText = findViewById(R.id.inputEditText); editText.setFocusable(false); //Makes editText not editable editText.setClickable(true);// but clickable editText.setOnFocusChangeListener(this::onFocusChanged); editText.setOnClickListener(this); }
Example #11
Source File: TimeTableView.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCellLayout(ObservableField<DataSetTableAdapter.TableScale> tableScale){ binding = DataBindingUtil.inflate(inflater, R.layout.custom_cell_view, this, true); ((CustomCellViewBinding)binding).setTableScale(tableScale); editText = findViewById(R.id.inputEditText); editText.setFocusable(false); //Makes editText not editable editText.setClickable(true);// but clickable editText.setOnFocusChangeListener(this::onFocusChanged); editText.setOnClickListener(this); }
Example #12
Source File: OptionSetView.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCellLayout(ObservableField<DataSetTableAdapter.TableScale> tableScale) { binding = DataBindingUtil.inflate(inflater, R.layout.custom_cell_view, this, true); ((CustomCellViewBinding) binding).setTableScale(tableScale); editText = findViewById(R.id.inputEditText); editText.setFocusable(false); //Makes editText not editable editText.setClickable(true);// but clickable editText.setOnFocusChangeListener((v, hasFocus) -> { if (hasFocus) editText.performClick(); }); }
Example #13
Source File: DateTableView.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCellLayout(ObservableField<DataSetTableAdapter.TableScale> tableScale){ binding = DataBindingUtil.inflate(inflater, R.layout.custom_cell_view, this, true); ((CustomCellViewBinding)binding).setTableScale(tableScale); editText = findViewById(R.id.inputEditText); selectedCalendar = Calendar.getInstance(); editText.setFocusable(false); //Makes editText not editable editText.setClickable(true);// but clickable editText.setOnFocusChangeListener(this::onFocusChanged); editText.setOnClickListener(this); }
Example #14
Source File: DateTimeTableView.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCellLayout(ObservableField<DataSetTableAdapter.TableScale> tableScale) { binding = DataBindingUtil.inflate(inflater, R.layout.custom_cell_view, this, true); binding.setTableScale(tableScale); textView = findViewById(R.id.inputEditText); selectedCalendar = Calendar.getInstance(); textView.setFocusable(false); //Makes editText not editable textView.setClickable(true);// but clickable textView.setOnFocusChangeListener(this); textView.setOnClickListener(this); }
Example #15
Source File: DateView.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCellLayout(ObservableField<DataSetTableAdapter.TableScale> tableScale){ binding = DataBindingUtil.inflate(inflater, R.layout.custom_cell_view, this, true); ((CustomCellViewBinding)binding).setTableScale(tableScale); editText = findViewById(R.id.inputEditText); selectedCalendar = Calendar.getInstance(); editText.setFocusable(false); //Makes editText not editable editText.setClickable(true);// but clickable editText.setOnFocusChangeListener(this::onFocusChanged); editText.setOnClickListener(this); }
Example #16
Source File: SectionRow.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public SectionRow(LayoutInflater layoutInflater, ObservableField<String> selectedSection, FlowableProcessor<String> sectionProcessor) { this.inflater = layoutInflater; this.selectedSection = selectedSection; this.sectionProcessor = sectionProcessor; }
Example #17
Source File: ObservationViewModel.java From ground-android with Apache License 2.0 | 5 votes |
@Inject ObservationViewModel(Application application) { this.application = application; userName = new ObservableField<>(); modifiedDate = new ObservableField<>(); modifiedTime = new ObservableField<>(); selectedObservation = new MutableLiveData<>(); }
Example #18
Source File: DateTimeRow.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DateTimeRow(LayoutInflater layoutInflater, FlowableProcessor<RowAction> processor, int viewType, boolean isBgTransparent, boolean accessDataWrite, ObservableField<DataSetTableAdapter.TableScale> currentTableScale) { this.processor = processor; this.inflater = layoutInflater; this.viewType = viewType; this.isBgTransparent = isBgTransparent; this.accessDataWrite = accessDataWrite; this.tableScale = currentTableScale; }
Example #19
Source File: EditTextRow.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public EditTextRow(@NonNull LayoutInflater layoutInflater, @NonNull FlowableProcessor<RowAction> processor, ObservableBoolean isEditable, TableView tableView, ObservableField<DataSetTableAdapter.TableScale> tableScale) { this.inflater = layoutInflater; this.processor = processor; this.isEditable = isEditable; this.tableView = tableView; this.tableScale = tableScale; }
Example #20
Source File: BindingItemAdapter.java From recyclerview-adapters with Apache License 2.0 | 5 votes |
public void bindVisible(final ObservableField<Boolean> visibleChangeField) { if (visibleChangeField.get() != null) setVisible(visibleChangeField.get()); releaseVisibleChangeBinding(); visibleChangeCallback = new Observable.OnPropertyChangedCallback() { @Override public void onPropertyChanged(Observable sender, int propertyId) { setVisible(visibleChangeField.get(), false); } }; visibleChangeField.addOnPropertyChangedCallback(visibleChangeCallback); this.visibleChangeField = visibleChangeField; }
Example #21
Source File: SpinnerCellRow.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public SpinnerCellRow(LayoutInflater layoutInflater, FlowableProcessor<RowAction> processor, boolean accessDataWrite, FlowableProcessor<Trio<String, String, Integer>> processorOptionSet, ObservableField<DataSetTableAdapter.TableScale> currentTableScale) { this.processor = processor; this.inflater = layoutInflater; this.accessDataWrite = accessDataWrite; this.processorOptionSet = processorOptionSet; this.tableScale = currentTableScale; this.isSearchMode = true; }
Example #22
Source File: SearchViewModel.java From CloudReader with Apache License 2.0 | 5 votes |
@BindingAdapter("android:textSelection") public static void textSelection(AppCompatEditText tv, ObservableField<String> value) { if (!TextUtils.isEmpty(tv.getText())) { // tv.setText(value.get()); // Set the cursor to the end of the text tv.setSelection(tv.getText().length()); } }
Example #23
Source File: AlbumItemViewModel.java From Jockey with Apache License 2.0 | 5 votes |
public void setAlbum(Album album) { mAlbum = album; mArtistImage = new ObservableField<>(); mTitleTextColor = new ObservableInt(); mArtistTextColor = new ObservableInt(); mBackgroundColor = new ObservableInt(); defaultColors(); if (mAlbum.getArtUri() != null) { int imageSize = mContext.getResources().getDimensionPixelSize(R.dimen.grid_width); Glide.with(mContext) .load(new File(mAlbum.getArtUri())) .placeholder(R.drawable.art_default) .error(R.drawable.art_default) .listener(new PaletteListener(mTitleTextColor, mArtistTextColor, mBackgroundColor)) .into(new ObservableTarget(imageSize, mArtistImage)); } else { Drawable fallback = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.art_default, mContext.getTheme()); mArtistImage.set(fallback); } notifyChange(); }
Example #24
Source File: DataEntryAdapter.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DataEntryAdapter(@NonNull LayoutInflater layoutInflater, @NonNull FragmentManager fragmentManager, @NonNull DataEntryArguments dataEntryArguments, @NonNull FlowableProcessor<RowAction> processor, @NonNull FlowableProcessor<String> sectionProcessor, @NonNull FlowableProcessor<Trio<String, String, Integer>> processorOptSet) { super(new DataEntryDiff()); setHasStableIds(true); rows = new ArrayList<>(); viewModels = new ArrayList<>(); this.processor = processor; this.sectionProcessor = sectionProcessor; imageSelector = new ObservableField<>(""); selectedSection = new ObservableField<>(""); this.processorOptionSet = processorOptSet; this.currentFocusUid = new MutableLiveData<>(); rows.add(EDITTEXT, new EditTextRow(layoutInflater, processor, true, dataEntryArguments.renderType(), false, currentFocusUid)); rows.add(BUTTON, new FileRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(CHECKBOX, new RadioButtonRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(SPINNER, new SpinnerRow(layoutInflater, processor, processorOptionSet, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(COORDINATES, new CoordinateRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid, FeatureType.POINT)); rows.add(TIME, new DateTimeRow(layoutInflater, processor, TIME, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(DATE, new DateTimeRow(layoutInflater, processor, DATE, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(DATETIME, new DateTimeRow(layoutInflater, processor, DATETIME, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(AGEVIEW, new AgeRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(YES_NO, new RadioButtonRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(ORG_UNIT, new OrgUnitRow(fragmentManager, layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(IMAGE, new ImageRow(layoutInflater, processor, dataEntryArguments.renderType())); rows.add(UNSUPPORTED, new UnsupportedRow(layoutInflater)); rows.add(LONG_TEXT, new EditTextRow(layoutInflater, processor, true, dataEntryArguments.renderType(), true, currentFocusUid)); rows.add(DISPLAY, new DisplayRow(layoutInflater)); rows.add(PICTURE, new PictureRow(fragmentManager, layoutInflater, processor, true)); rows.add(SCAN_CODE, new ScanTextRow(layoutInflater, processor, true)); rows.add(SECTION, new SectionRow(layoutInflater, selectedSection, sectionProcessor)); rows.add(OPTION_SET_SELECT, new OptionSetRow(layoutInflater, processor, true, rendering, currentFocusUid)); }
Example #25
Source File: DataEntryAdapter.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DataEntryAdapter(@NonNull LayoutInflater layoutInflater, @NonNull FragmentManager fragmentManager, @NonNull DataEntryArguments dataEntryArguments) { super(new DataEntryDiff()); setHasStableIds(true); rows = new ArrayList<>(); viewModels = new ArrayList<>(); processor = PublishProcessor.create(); sectionProcessor = PublishProcessor.create(); imageSelector = new ObservableField<>(""); selectedSection = new ObservableField<>(""); this.processorOptionSet = PublishProcessor.create(); this.currentFocusUid = new MutableLiveData<>(); rows.add(EDITTEXT, new EditTextRow(layoutInflater, processor, true, dataEntryArguments.renderType(), false, currentFocusUid)); rows.add(BUTTON, new FileRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(CHECKBOX, new RadioButtonRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(SPINNER, new SpinnerRow(layoutInflater, processor, processorOptionSet, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(COORDINATES, new CoordinateRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid, FeatureType.POINT)); rows.add(TIME, new DateTimeRow(layoutInflater, processor, TIME, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(DATE, new DateTimeRow(layoutInflater, processor, DATE, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(DATETIME, new DateTimeRow(layoutInflater, processor, DATETIME, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(AGEVIEW, new AgeRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(YES_NO, new RadioButtonRow(layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(ORG_UNIT, new OrgUnitRow(fragmentManager, layoutInflater, processor, true, dataEntryArguments.renderType(), currentFocusUid)); rows.add(IMAGE, new ImageRow(layoutInflater, processor, dataEntryArguments.renderType())); rows.add(UNSUPPORTED, new UnsupportedRow(layoutInflater)); rows.add(LONG_TEXT, new EditTextRow(layoutInflater, processor, true, dataEntryArguments.renderType(), true, currentFocusUid)); rows.add(DISPLAY, new DisplayRow(layoutInflater)); rows.add(PICTURE, new PictureRow(fragmentManager, layoutInflater, processor, true)); rows.add(SCAN_CODE, new ScanTextRow(layoutInflater, processor, true)); rows.add(SECTION, new SectionRow(layoutInflater, selectedSection, sectionProcessor)); rows.add(OPTION_SET_SELECT, new OptionSetRow(layoutInflater, processor, true, rendering, currentFocusUid)); }
Example #26
Source File: FeatureDetailsViewModel.java From ground-android with Apache License 2.0 | 5 votes |
@Inject public FeatureDetailsViewModel() { featureTitle = new ObservableField<>(); featureSubtitle = new ObservableField<>(); featureSubtitleVisibility = new ObservableInt(); selectedFeature = BehaviorProcessor.createDefault(Optional.empty()); }
Example #27
Source File: MainViewModel.java From android-mvvm-architecture with Apache License 2.0 | 4 votes |
public ObservableField<String> getUserEmail() { return userEmail; }
Example #28
Source File: MainViewModel.java From android-mvvm-architecture with Apache License 2.0 | 4 votes |
public ObservableField<String> getUserName() { return userName; }
Example #29
Source File: StatusEventFilterHolder.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 4 votes |
StatusEventFilterHolder(@NonNull ItemFilterStatusBinding binding, ObservableField<Filters> openedFilter, FiltersAdapter.ProgramType programType) { super(binding, openedFilter); filterType = Filters.EVENT_STATUS; this.programType = programType; }
Example #30
Source File: MainViewModel.java From android-mvvm-architecture with Apache License 2.0 | 4 votes |
public ObservableField<String> getUserProfilePicUrl() { return userProfilePicUrl; }