Add:Android:activate a newly downloaded map (works now only if there is no mapfile...
authorzoff99 <zoff99@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 18 Feb 2011 21:08:46 +0000 (21:08 +0000)
committerzoff99 <zoff99@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 18 Feb 2011 21:08:46 +0000 (21:08 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4207 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/android/src/org/navitproject/navit/Navit.java
navit/navit/android/src/org/navitproject/navit/NavitMapDownloader.java

index 0db6f77..5f6ee7b 100644 (file)
@@ -595,6 +595,14 @@ public class Navit extends Activity implements Handler.Callback
                                                                                                                                // dismiss dialog, remove dialog\r
                                                                                                                                dismissDialog(msg.getData().getInt("dialog_num"));\r
                                                                                                                                removeDialog(msg.getData().getInt("dialog_num"));\r
+                                                                                                                               // try to use the new downloaded map (works only when there is now map yet!)\r
+                                                                                                                               // please fix me in the C-source !!\r
+                                                                                                                               // please fix me in the C-source !!\r
+                                                                                                                               Message msg2 = new Message();\r
+                                                                                                                               Bundle b2 = new Bundle();\r
+                                                                                                                               b2.putInt("Callback", 6);\r
+                                                                                                                               msg2.setData(b2);\r
+                                                                                                                               N_NavitGraphics.callback_handler.sendMessage(msg2);\r
                                                                                                                                break;\r
                                                                                                                        case 1 :\r
                                                                                                                                // change progressbar values\r
index de398aa..d3fe891 100644 (file)
@@ -180,7 +180,8 @@ public class NavitMapDownloader
                        File file = new File(PATH);\r
                        File outputFile = new File(file, fileName);\r
                        File final_outputFile = new File(file, final_fileName);\r
-                       //outputFile.delete();\r
+                       // tests have shown that deleting the file first is sometimes faster -> so we delete it (who cares)\r
+                       outputFile.delete();\r
                        // seems this command overwrites the output file anyway\r
                        FileOutputStream fos = new FileOutputStream(outputFile);\r
                        BufferedOutputStream buf = new BufferedOutputStream(fos, MAP_WRITE_FILE_BUFFER); // buffer\r
@@ -194,9 +195,9 @@ public class NavitMapDownloader
                        int alt = UPDATE_PROGRESS_EVERY_CYCLE; // show progress about every xx cylces\r
                        int alt_cur = 0;\r
                        String kbytes_per_second = "";\r
-                       long last_timestamp = 0;\r
+                       //long last_timestamp = 0;\r
                        long start_timestamp = System.currentTimeMillis();\r
-                       int last_bytes = 0;\r
+                       //int last_bytes = 0;\r
                        NumberFormat formatter = new DecimalFormat("00000.0");\r
                        String eta_string = "";\r
                        float per_second_overall = 0f;\r
@@ -241,8 +242,8 @@ public class NavitMapDownloader
                                        //                                              //              .currentTimeMillis() - last_timestamp) / 1000f));\r
                                        //                                              //kbytes_per_second = formatter.format(temp);\r
                                        //                                      }\r
-                                       last_timestamp = System.currentTimeMillis();\r
-                                       last_bytes = already_read;\r
+                                       //last_timestamp = System.currentTimeMillis();\r
+                                       //last_bytes = already_read;\r
                                        per_second_overall = (float) already_read\r
                                                        / (float) ((System.currentTimeMillis() - start_timestamp) / 1000);\r
                                        kbytes_per_second = formatter.format((per_second_overall / 1024f));\r