void JUIView::RestoreParameters()

in NearbyConnectionsCpp/app/src/main/cpp/jui_helper/JavaUI.cpp [248:307]


void JUIView::RestoreParameters(std::unordered_map<std::string, int32_t> &map) {
  // Restore Layout Rule
  for (int32_t i = 0; i < LAYOUT_PARAMETER_COUNT; ++i) {
    if (array_current_rules_[i] != LAYOUT_PARAMETER_UNKNOWN) {
      AddRule(i, array_current_rules_[i]);
    }
  }

  auto it = map_attribute_parameters.begin();
  auto itEnd = map_attribute_parameters.end();
  while (it != itEnd) {
    AttributeParameterStore &p = map_attribute_parameters[it->first];
    switch (p.type) {
      case ATTRIBUTE_PARAMETER_INT:
        JUIBase::SetAttribute(map, it->first.c_str(), (int32_t)p.i);
        break;
      case ATTRIBUTE_PARAMETER_FLOAT:
        JUIBase::SetAttribute(map, it->first.c_str(), p.f);
        break;
      case ATTRIBUTE_PARAMETER_BOOLEAN:
        JUIBase::SetAttribute(map, it->first.c_str(), p.f);
        break;
      case ATTRIBUTE_PARAMETER_STRING:
        JUIBase::SetAttribute(map, it->first.c_str(), p.str->c_str());
        break;
      case ATTRIBUTE_PARAMETER_IF:
        JUIBase::SetAttribute(map, it->first.c_str(), p.param_if.i1,
                              p.param_if.f2);
        break;
      case ATTRIBUTE_PARAMETER_FF:
        JUIBase::SetAttribute(map, it->first.c_str(), p.param_ff.f1,
                              p.param_ff.f2);
        break;
      case ATTRIBUTE_PARAMETER_IIII:
        JUIBase::SetAttribute(map, it->first.c_str(), p.param_iiii.i1,
                              p.param_iiii.i2, p.param_iiii.i3,
                              p.param_iiii.i4);
        break;
      case ATTRIBUTE_PARAMETER_FFFI:
        JUIBase::SetAttribute(map, it->first.c_str(), p.param_fffi.f1,
                              p.param_fffi.f2, p.param_fffi.f3, p.param_fffi.i);
        break;
      default:
        break;
    }
    it++;
  }

  if (layoutWidth_ != ATTRIBUTE_SIZE_WRAP_CONTENT ||
      layoutHeight_ != ATTRIBUTE_SIZE_WRAP_CONTENT || layoutWeight_ != 0.f) {
    if (layoutWeight_ != 0.f)
      SetLayoutParams(layoutWidth_, layoutHeight_, layoutWeight_);
    else
      SetLayoutParams(layoutWidth_, layoutHeight_);
  }

  if (marginLeft_ || marginRight_ || marginTop_ || marginBottom_) {
    SetMargins(marginLeft_, marginTop_, marginRight_, marginBottom_);
  }
}