From: zoff99 Date: Fri, 18 Feb 2011 21:08:46 +0000 (+0000) Subject: Add:Android:activate a newly downloaded map (works now only if there is no mapfile... X-Git-Tag: navit-0.5.0.5194svn~988 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aaf401f81b1a96bdfa0d48cac590767e2232b0d0;p=profile%2Fivi%2Fnavit.git Add:Android:activate a newly downloaded map (works now only if there is no mapfile yet) git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4207 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/navit/android/src/org/navitproject/navit/Navit.java b/navit/navit/android/src/org/navitproject/navit/Navit.java index 0db6f77..5f6ee7b 100644 --- a/navit/navit/android/src/org/navitproject/navit/Navit.java +++ b/navit/navit/android/src/org/navitproject/navit/Navit.java @@ -595,6 +595,14 @@ public class Navit extends Activity implements Handler.Callback // dismiss dialog, remove dialog dismissDialog(msg.getData().getInt("dialog_num")); removeDialog(msg.getData().getInt("dialog_num")); + // try to use the new downloaded map (works only when there is now map yet!) + // please fix me in the C-source !! + // please fix me in the C-source !! + Message msg2 = new Message(); + Bundle b2 = new Bundle(); + b2.putInt("Callback", 6); + msg2.setData(b2); + N_NavitGraphics.callback_handler.sendMessage(msg2); break; case 1 : // change progressbar values diff --git a/navit/navit/android/src/org/navitproject/navit/NavitMapDownloader.java b/navit/navit/android/src/org/navitproject/navit/NavitMapDownloader.java index de398aa..d3fe891 100644 --- a/navit/navit/android/src/org/navitproject/navit/NavitMapDownloader.java +++ b/navit/navit/android/src/org/navitproject/navit/NavitMapDownloader.java @@ -180,7 +180,8 @@ public class NavitMapDownloader File file = new File(PATH); File outputFile = new File(file, fileName); File final_outputFile = new File(file, final_fileName); - //outputFile.delete(); + // tests have shown that deleting the file first is sometimes faster -> so we delete it (who cares) + outputFile.delete(); // seems this command overwrites the output file anyway FileOutputStream fos = new FileOutputStream(outputFile); BufferedOutputStream buf = new BufferedOutputStream(fos, MAP_WRITE_FILE_BUFFER); // buffer @@ -194,9 +195,9 @@ public class NavitMapDownloader int alt = UPDATE_PROGRESS_EVERY_CYCLE; // show progress about every xx cylces int alt_cur = 0; String kbytes_per_second = ""; - long last_timestamp = 0; + //long last_timestamp = 0; long start_timestamp = System.currentTimeMillis(); - int last_bytes = 0; + //int last_bytes = 0; NumberFormat formatter = new DecimalFormat("00000.0"); String eta_string = ""; float per_second_overall = 0f; @@ -241,8 +242,8 @@ public class NavitMapDownloader // // .currentTimeMillis() - last_timestamp) / 1000f)); // //kbytes_per_second = formatter.format(temp); // } - last_timestamp = System.currentTimeMillis(); - last_bytes = already_read; + //last_timestamp = System.currentTimeMillis(); + //last_bytes = already_read; per_second_overall = (float) already_read / (float) ((System.currentTimeMillis() - start_timestamp) / 1000); kbytes_per_second = formatter.format((per_second_overall / 1024f));