Better user experience, force filesystem sync before starting.

We write a large file to disk and then go to read it back.
This was causing a multi second delay in the UI until the
data had been flushed to disk.  Now, we call sync() before
claiming that the assets are ready to be used.
This commit is contained in:
James Sanford 2012-11-03 12:14:30 -07:00
parent 973d9c1422
commit 5f3f8e3b33
2 changed files with 10 additions and 0 deletions

View File

@ -262,6 +262,12 @@ void android_config_init(char *output, int maxlen) {
(*g_env)->DeleteLocalRef(g_env, config_path);
}
JNIEXPORT void JNICALL
Java_com_froop_app_kegs_AssetImages_nativeSync( JNIEnv* env, jobject thiz) {
sync();
sync();
}
// Instead of 'KegsView$KegsThread', the $ is encoded as _00024.
// (not any more, but it was KegsView_00024KegsThread_mainLoop)
JNIEXPORT void JNICALL

View File

@ -46,6 +46,7 @@ class AssetImages extends AsyncTask<Void, Void, Boolean> {
mConfigFile.ensureAssetCopied(mConfigFile.getImagePath(),
"System 6 Shareware.zip", "System 6.hdv");
// TODO: could check to make sure they actually exist now.
nativeSync();
return true;
}
@ -56,4 +57,7 @@ class AssetImages extends AsyncTask<Void, Void, Boolean> {
protected void onPostExecute(final Boolean result) {
mNotify.onAssetsReady(result);
}
// See jni/android_driver.c:nativeSync()
private native void nativeSync();
}