summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david@procyon.(none)>2010-04-25 08:22:19 (GMT)
committerDavid A. Madore <david@procyon.(none)>2010-04-25 08:22:19 (GMT)
commit0e64b9e42047a96e26395002b8287a70f2da2eea (patch)
tree036f8d93ca3b74e215fc937a5803d0126c24c455
parent2521f18e396b989043387ef0cd14eeb101c14263 (diff)
downloadUnicodeMap-0e64b9e42047a96e26395002b8287a70f2da2eea.zip
UnicodeMap-0e64b9e42047a96e26395002b8287a70f2da2eea.tar.gz
UnicodeMap-0e64b9e42047a96e26395002b8287a70f2da2eea.tar.bz2
Repair progress bar. Use a transaction for populating db.
Default max for progress bar is not 10000 contrary to what doc says. SQLite is excruciatingly slow in the absence of transactions, so we use one.
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeDatabase.java7
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java4
2 files changed, 8 insertions, 3 deletions
diff --git a/src/org/madore/android/unicodeMap/UnicodeDatabase.java b/src/org/madore/android/unicodeMap/UnicodeDatabase.java
index b0b5c77..c40cf67 100644
--- a/src/org/madore/android/unicodeMap/UnicodeDatabase.java
+++ b/src/org/madore/android/unicodeMap/UnicodeDatabase.java
@@ -73,6 +73,7 @@ public class UnicodeDatabase {
public void populate(Handler progressHandler) {
SQLiteDatabase db = dbinit.getWritableDatabase();
+ db.beginTransaction();
db.execSQL("DELETE FROM "+UNICODE_TABLE_NAME);
AssetManager amgr = activity.getAssets();
SQLiteStatement cmd
@@ -116,9 +117,11 @@ public class UnicodeDatabase {
throw new AssertionError("US-ASCII encoding unsupported");
} catch (IOException e) {
throw new RuntimeException(e);
+ } finally {
+ db.endTransaction();
+ db.close();
+ reportProgress(progressHandler, pieces.length, pieces.length);
}
- reportProgress(progressHandler, pieces.length, pieces.length);
- db.close();
}
protected final static String[] queryColumns = { "id", "name", "category" };
diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
index 7d70186..a1917a4 100644
--- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
+++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
@@ -44,12 +44,14 @@ public final class UnicodeMapActivity extends ListActivity {
progress.setTitle("Loading Unicode database");
progress.setMessage("Please wait");
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ progress.setCancelable(false);
progress.show();
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
int done = msg.getData().getInt("done");
int total = msg.getData().getInt("total");
- progress.setProgress(done*10000/total);
+ progress.setMax(total);
+ progress.setProgress(done);
if ( done >= total )
progress.dismiss();
}