| 6 | namespace bdn::ui::android |
| 7 | { |
| 8 | void ViewCore::init() |
| 9 | { |
| 10 | if (View::debugViewEnabled()) { |
| 11 | int bgColor = 0xFF000000 + (std::rand() % 0x00FFFFFF); |
| 12 | _jView.setBackgroundColor(bgColor); |
| 13 | } |
| 14 | |
| 15 | _uiScaleFactor = 1; |
| 16 | |
| 17 | visible.onChange() += [=](auto &property) { |
| 18 | _jView.setVisibility(property.get() ? bdn::android::wrapper::View::VISIBLE |
| 19 | : bdn::android::wrapper::View::INVISIBLE); |
| 20 | }; |
| 21 | |
| 22 | geometry.onChange() += [=](auto) { updateGeometry(); }; |
| 23 | |
| 24 | backgroundColor.onChange() += [=](auto &property) { |
| 25 | auto color = property.get(); |
| 26 | if (color) { |
| 27 | _jView.setBackgroundColor(*color); |
| 28 | } else { |
| 29 | _jView.setBackgroundColor(Color(0x0)); |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | bdn::android::wrapper::NativeViewCoreLayoutChangeListener layoutChangeListener; |
| 34 | getJView().addOnLayoutChangeListener(layoutChangeListener); |
| 35 | |
| 36 | initTag(); |
| 37 | } |
| 38 | |
| 39 | ViewCore::~ViewCore() |
| 40 | { |