| 179 | } |
| 180 | |
| 181 | static void UpdateItem(JNIEnv * env, jobject item, storage::NodeAttrs const & attrs) |
| 182 | { |
| 183 | auto const & ciBuilder = CountryItemBuilder::Instance(env); |
| 184 | using SLR = jni::TScopedLocalRef; |
| 185 | |
| 186 | // Localized name |
| 187 | env->SetObjectField(item, ciBuilder.m_Name, SLR(env, jni::ToJavaString(env, attrs.m_nodeLocalName)).get()); |
| 188 | |
| 189 | // Direct parent[s]. Do not specify if there are multiple or none. |
| 190 | if (attrs.m_parentInfo.size() == 1) |
| 191 | { |
| 192 | storage::CountryIdAndName const & info = attrs.m_parentInfo[0]; |
| 193 | env->SetObjectField(item, ciBuilder.m_DirectParentId, SLR(env, jni::ToJavaString(env, info.m_id)).get()); |
| 194 | env->SetObjectField(item, ciBuilder.m_DirectParentName, SLR(env, jni::ToJavaString(env, info.m_localName)).get()); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | env->SetObjectField(item, ciBuilder.m_DirectParentId, nullptr); |
| 199 | env->SetObjectField(item, ciBuilder.m_DirectParentName, nullptr); |
| 200 | } |
| 201 | |
| 202 | // Topmost parent[s]. Do not specify if there are multiple or none. |
| 203 | if (attrs.m_topmostParentInfo.size() == 1) |
| 204 | { |
| 205 | storage::CountryIdAndName const & info = attrs.m_topmostParentInfo[0]; |
| 206 | env->SetObjectField(item, ciBuilder.m_TopmostParentId, SLR(env, jni::ToJavaString(env, info.m_id)).get()); |
| 207 | env->SetObjectField(item, ciBuilder.m_TopmostParentName, SLR(env, jni::ToJavaString(env, info.m_localName)).get()); |
| 208 | } |
| 209 | else |
| 210 | { |
| 211 | env->SetObjectField(item, ciBuilder.m_TopmostParentId, nullptr); |
| 212 | env->SetObjectField(item, ciBuilder.m_TopmostParentName, nullptr); |
| 213 | } |
| 214 | |
| 215 | // Description |
| 216 | env->SetObjectField(item, ciBuilder.m_Description, |
| 217 | SLR(env, jni::ToJavaString(env, attrs.m_nodeLocalDescription)).get()); |
| 218 | |
| 219 | // Sizes |
| 220 | env->SetLongField(item, ciBuilder.m_Size, attrs.m_localMwmSize); |
| 221 | env->SetLongField(item, ciBuilder.m_EnqueuedSize, attrs.m_downloadingMwmSize); |
| 222 | env->SetLongField(item, ciBuilder.m_TotalSize, attrs.m_mwmSize); |
| 223 | |
| 224 | // Child counts |
| 225 | env->SetIntField(item, ciBuilder.m_ChildCount, attrs.m_downloadingMwmCounter); |
| 226 | env->SetIntField(item, ciBuilder.m_TotalChildCount, attrs.m_mwmCounter); |
| 227 | |
| 228 | // Status and error code |
| 229 | UpdateItemShort(env, item, attrs.m_status, attrs.m_error); |
| 230 | |
| 231 | // Presence flag |
| 232 | env->SetBooleanField(item, ciBuilder.m_Present, attrs.m_present); |
| 233 | |
| 234 | // Progress |
| 235 | float percentage = 0; |
| 236 | if (attrs.m_downloadingProgress.m_bytesTotal != 0) |
| 237 | { |
| 238 | auto const & progress = attrs.m_downloadingProgress; |
no test coverage detected