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

Commit

Permalink
[android] #3891 - tracking thread issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zugaldia committed Feb 19, 2016
1 parent f72d31e commit fa25c54
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down Expand Up @@ -95,7 +94,12 @@
android:screenOrientation="portrait" />
<activity
android:name=".OfflineActivity"
android:label="@string/activity_offline" />
android:label="@string/activity_offline">
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>

<meta-data
android:name="com.mapbox.AccessToken"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,26 +300,30 @@ public void onResponseError(Exception error) {
*/

private void startProgress() {
Log.d(LOG_TAG, "startProgress");

// Disable buttons
downloadRegion.setEnabled(false);
listRegions.setEnabled(false);
// downloadRegion.setEnabled(false);
// listRegions.setEnabled(false);

// Start and show the progress bar
mProgressBar.setIndeterminate(true);
mProgressBar.setVisibility(View.VISIBLE);
// mProgressBar.setIndeterminate(true);
// mProgressBar.setVisibility(View.VISIBLE);
}

private void endProgress(String message) {
Log.d(LOG_TAG, "endProgress");

// Enable buttons
downloadRegion.setEnabled(true);
listRegions.setEnabled(true);
// downloadRegion.setEnabled(true);
// listRegions.setEnabled(true);

// Stop and hide the progress bar
mProgressBar.setIndeterminate(false);
mProgressBar.setVisibility(View.GONE);
// mProgressBar.setIndeterminate(false);
// mProgressBar.setVisibility(View.GONE);

// Show a toast
showMessage(message);
// showMessage(message);
}

private void showMessage(String message) {
Expand Down
4 changes: 3 additions & 1 deletion platform/android/src/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ void JNICALL createOfflineRegion(JNIEnv *env, jobject obj, jlong defaultFileSour

// Launch createCallback
mbgl::DefaultFileSource *defaultFileSource = reinterpret_cast<mbgl::DefaultFileSource *>(defaultFileSourcePtr);
defaultFileSource->createOfflineRegion(definition, metadata, [&] (std::exception_ptr error, mbgl::optional<mbgl::OfflineRegion> region) {
defaultFileSource->createOfflineRegion(definition, metadata, [&env, &createCallback] (std::exception_ptr error, mbgl::optional<mbgl::OfflineRegion> region) {

// Reattach, the callback comes from a different thread
jboolean renderDetach = attach_jni_thread(theJVM, &env, "Offline Thread");
Expand All @@ -1737,6 +1737,8 @@ void JNICALL createOfflineRegion(JNIEnv *env, jobject obj, jlong defaultFileSour
mbgl::Log::Debug(mbgl::Event::JNI, "Region created.");
jobject jRegion = env->NewObject(offlineRegionClass, offlineRegionConstructorId);
env->SetLongField(jRegion, offlineRegionIdId, region->getID());

// This currently causes an exception on Android
env->CallVoidMethod(createCallback, createOnCreateMethodId, jRegion);
}

Expand Down

0 comments on commit fa25c54

Please sign in to comment.