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

Commit

Permalink
[android] #3891 - deleteOfflineRegion jni method
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Zugaldia committed Feb 21, 2016
1 parent d379120 commit 7384460
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions platform/android/src/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2033,13 +2033,42 @@ void JNICALL setOfflineRegionDownloadState(JNIEnv *env, jobject obj, jobject off
defaultFileSource->setOfflineRegionDownloadState(*offlineRegion, state);
}

void JNICALL getOfflineRegionStatus(JNIEnv *env, jobject obj, jobject offlineRegion, jobject statusCallback) {
void JNICALL getOfflineRegionStatus(JNIEnv *env, jobject obj, jobject offlineRegion_, jobject statusCallback) {
mbgl::Log::Error(mbgl::Event::JNI, "getOfflineRegionStatus");

// Offline region
// jlong offlineRegionPtr = env->GetLongField(offlineRegion_, offlineRegionPtrId);
// mbgl::OfflineRegion *offlineRegion = reinterpret_cast<mbgl::OfflineRegion *>(offlineRegionPtr);

// File source
// jobject jmanager = env->GetObjectField(offlineRegion_, offlineRegionOfflineManagerId);
// jlong defaultFileSourcePtr = env->GetLongField(jmanager, offlineManagerClassPtrId);
// mbgl::DefaultFileSource *defaultFileSource = reinterpret_cast<mbgl::DefaultFileSource *>(defaultFileSourcePtr);

// Set new state
// defaultFileSource->getOfflineRegionStatus(*offlineRegion, std::function<void (std::exception_ptr, optional<OfflineRegionStatus>)>);
}

void JNICALL deleteOfflineRegion(JNIEnv *env, jobject obj, jobject offlineRegion, jobject deleteCallback) {
void JNICALL deleteOfflineRegion(JNIEnv *env, jobject obj, jobject offlineRegion_, jobject deleteCallback) {
mbgl::Log::Error(mbgl::Event::JNI, "deleteOfflineRegion");

// Offline region
jlong offlineRegionPtr = env->GetLongField(offlineRegion_, offlineRegionPtrId);
mbgl::OfflineRegion *offlineRegion = reinterpret_cast<mbgl::OfflineRegion *>(offlineRegionPtr);

// File source
jobject jmanager = env->GetObjectField(offlineRegion_, offlineRegionOfflineManagerId);
jlong defaultFileSourcePtr = env->GetLongField(jmanager, offlineManagerClassPtrId);
mbgl::DefaultFileSource *defaultFileSource = reinterpret_cast<mbgl::DefaultFileSource *>(defaultFileSourcePtr);

// Set new state
defaultFileSource->deleteOfflineRegion(std::move(*offlineRegion), [](std::exception_ptr error) {
if (error) {
mbgl::Log::Error(mbgl::Event::JNI, "Delete region failed.");
} else {
mbgl::Log::Error(mbgl::Event::JNI, "Region deleted.");
}
});
}

// Offline calls end
Expand Down

0 comments on commit 7384460

Please sign in to comment.