Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #3891 - handle requiredResourceCountIsIndeterminate -> requ…
Browse files Browse the repository at this point in the history
…iredResourceCountIsPrecise rename
  • Loading branch information
zugaldia committed Feb 25, 2016
1 parent 73ffed3 commit 4e5a0cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ public class OfflineRegionStatus {

/**
* The number of resources that are known to be required for this region. See the
* documentation for `requiredResourceCountIsIndeterminate` for an important caveat
* documentation for `requiredResourceCountIsPrecise` for an important caveat
* about this number.
*/
private long requiredResourceCount = 0;

/**
* This property is true during early phases of an offline download, when the total
* required resource count is unknown and requiredResourceCount is merely a lower
* This property is true when the value of requiredResourceCount is a precise
* count of the number of required resources, and false when it is merely a lower
* bound.
*
* Specifically, it is true before until the style and tile sources have been
* downloaded, and false thereafter.
* Specifically, it is false during early phases of an offline download. Once
* style and tile sources have been downloaded, it is possible to calculate the
* precise number of required resources, at which point it is set to true.
*/
private boolean requiredResourceCountIsIndeterminate = true;
private boolean requiredResourceCountIsPrecise = true;

/*
* Use setObserver(OfflineRegionObserver observer) to obtain a OfflineRegionStatus object.
Expand Down Expand Up @@ -77,7 +78,7 @@ public long getRequiredResourceCount() {
}

public boolean isRequiredResourceCountPrecise() {
return !requiredResourceCountIsIndeterminate;
return requiredResourceCountIsPrecise;
}

}
12 changes: 6 additions & 6 deletions platform/android/src/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jfieldID offlineRegionStatusDownloadStateId = nullptr;
jfieldID offlineRegionStatusCompletedResourceCountId = nullptr;
jfieldID offlineRegionStatusCompletedResourceSizeId = nullptr;
jfieldID offlineRegionStatusRequiredResourceCountId = nullptr;
jfieldID offlineRegionStatusRequiredResourceCountIsIndeterminateId = nullptr;
jfieldID offlineRegionStatusRequiredResourceCountIsPreciseId = nullptr;

jclass offlineRegionErrorClass = nullptr;
jmethodID offlineRegionErrorConstructorId = nullptr;
Expand Down Expand Up @@ -1907,7 +1907,7 @@ void JNICALL setOfflineRegionObserver(JNIEnv *env, jobject obj, jobject offlineR
env2->SetLongField(jstatus, offlineRegionStatusCompletedResourceCountId, status.completedResourceCount);
env2->SetLongField(jstatus, offlineRegionStatusCompletedResourceSizeId, status.completedResourceSize);
env2->SetLongField(jstatus, offlineRegionStatusRequiredResourceCountId, status.requiredResourceCount);
env2->SetBooleanField(jstatus, offlineRegionStatusRequiredResourceCountIsIndeterminateId, status.requiredResourceCountIsIndeterminate);
env2->SetBooleanField(jstatus, offlineRegionStatusRequiredResourceCountIsPreciseId, status.requiredResourceCountIsPrecise);
env2->CallVoidMethod(observerCallback, offlineRegionObserveronStatusChangedId, jstatus);

// Delete global refs and detach when we're done
Expand Down Expand Up @@ -2014,7 +2014,7 @@ void JNICALL getOfflineRegionStatus(JNIEnv *env, jobject obj, jobject offlineReg
env2->SetLongField(jstatus, offlineRegionStatusCompletedResourceCountId, status->completedResourceCount);
env2->SetLongField(jstatus, offlineRegionStatusCompletedResourceSizeId, status->completedResourceSize);
env2->SetLongField(jstatus, offlineRegionStatusRequiredResourceCountId, status->requiredResourceCount);
env2->SetBooleanField(jstatus, offlineRegionStatusRequiredResourceCountIsIndeterminateId, status->requiredResourceCountIsIndeterminate);
env2->SetBooleanField(jstatus, offlineRegionStatusRequiredResourceCountIsPreciseId, status->requiredResourceCountIsPrecise);
env2->CallVoidMethod(statusCallback, offlineRegionStatusOnStatusId, jstatus);
}

Expand Down Expand Up @@ -2667,8 +2667,8 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}

offlineRegionStatusRequiredResourceCountIsIndeterminateId = env->GetFieldID(offlineRegionStatusClass, "requiredResourceCountIsIndeterminate", "Z");
if (offlineRegionStatusRequiredResourceCountIsIndeterminateId == nullptr) {
offlineRegionStatusRequiredResourceCountIsPreciseId = env->GetFieldID(offlineRegionStatusClass, "requiredResourceCountIsPrecise", "Z");
if (offlineRegionStatusRequiredResourceCountIsPreciseId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
Expand Down Expand Up @@ -3478,7 +3478,7 @@ extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
offlineRegionStatusCompletedResourceCountId = nullptr;
offlineRegionStatusCompletedResourceSizeId = nullptr;
offlineRegionStatusRequiredResourceCountId = nullptr;
offlineRegionStatusRequiredResourceCountIsIndeterminateId = nullptr;
offlineRegionStatusRequiredResourceCountIsPreciseId = nullptr;

env->DeleteGlobalRef(offlineRegionErrorClass);
offlineRegionErrorConstructorId = nullptr;
Expand Down

0 comments on commit 4e5a0cd

Please sign in to comment.