Update java

This commit is contained in:
Victor Shcherb 2015-08-01 20:52:21 +02:00
parent 279bc00f0a
commit d9973447e3
11 changed files with 30 additions and 22 deletions

View file

@ -290,7 +290,7 @@ public class BinaryInspector {
return null; return null;
} }
rafs[c] = new RandomAccessFile(f.getAbsolutePath(), "r"); rafs[c] = new RandomAccessFile(f.getAbsolutePath(), "r");
indexes[c] = new BinaryMapIndexReader(rafs[c]); indexes[c] = new BinaryMapIndexReader(rafs[c], f);
partsSet[c] = new LinkedHashSet<Float>(); partsSet[c] = new LinkedHashSet<Float>();
if(version == -1){ if(version == -1){
version = indexes[c].getVersion(); version = indexes[c].getVersion();
@ -446,12 +446,13 @@ public class BinaryInspector {
public void printFileInformation(File file) throws IOException { public void printFileInformation(File file) throws IOException {
RandomAccessFile r = new RandomAccessFile(file.getAbsolutePath(), "r"); RandomAccessFile r = new RandomAccessFile(file.getAbsolutePath(), "r");
printFileInformation(r, file.getName()); printFileInformation(r, file);
} }
public void printFileInformation(RandomAccessFile r, String filename) throws IOException { public void printFileInformation(RandomAccessFile r, File file ) throws IOException {
String filename = file.getName();
try { try {
BinaryMapIndexReader index = new BinaryMapIndexReader(r); BinaryMapIndexReader index = new BinaryMapIndexReader(r, file);
int i = 1; int i = 1;
println("Binary index " + filename + " version = " + index.getVersion() +" edition = " + new Date(index.getDateCreated())); println("Binary index " + filename + " version = " + index.getVersion() +" edition = " + new Date(index.getDateCreated()));
for(BinaryIndexPart p : index.getIndexes()){ for(BinaryIndexPart p : index.getIndexes()){

View file

@ -26,7 +26,7 @@ public class BinaryMapIndexFilter {
private final BinaryMapIndexReader reader; private final BinaryMapIndexReader reader;
public BinaryMapIndexFilter(File file) throws IOException{ public BinaryMapIndexFilter(File file) throws IOException{
reader = new BinaryMapIndexReader(new RandomAccessFile(file.getPath(), "r")); reader = new BinaryMapIndexReader(new RandomAccessFile(file.getPath(), "r"), file);
} }

View file

@ -81,6 +81,7 @@ public class BinaryMapIndexReader {
public static boolean READ_STATS = false; public static boolean READ_STATS = false;
private final RandomAccessFile raf; private final RandomAccessFile raf;
protected final File file;
/*private*/ int version; /*private*/ int version;
/*private */long dateCreated; /*private */long dateCreated;
// keep them immutable inside // keep them immutable inside
@ -102,8 +103,9 @@ public class BinaryMapIndexReader {
private static String BASEMAP_NAME = "basemap"; private static String BASEMAP_NAME = "basemap";
public BinaryMapIndexReader(final RandomAccessFile raf) throws IOException { public BinaryMapIndexReader(final RandomAccessFile raf, File file) throws IOException {
this.raf = raf; this.raf = raf;
this.file = file;
codedIS = CodedInputStream.newInstance(raf); codedIS = CodedInputStream.newInstance(raf);
codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB
transportAdapter = new BinaryMapTransportReaderAdapter(this); transportAdapter = new BinaryMapTransportReaderAdapter(this);
@ -113,8 +115,9 @@ public class BinaryMapIndexReader {
init(); init();
} }
/*private */BinaryMapIndexReader(final RandomAccessFile raf, boolean init) throws IOException { /*private */BinaryMapIndexReader(final RandomAccessFile raf, File file, boolean init) throws IOException {
this.raf = raf; this.raf = raf;
this.file = file;
codedIS = CodedInputStream.newInstance(raf); codedIS = CodedInputStream.newInstance(raf);
codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB
transportAdapter = new BinaryMapTransportReaderAdapter(this); transportAdapter = new BinaryMapTransportReaderAdapter(this);
@ -128,6 +131,7 @@ public class BinaryMapIndexReader {
public BinaryMapIndexReader(final RandomAccessFile raf, BinaryMapIndexReader referenceToSameFile) throws IOException { public BinaryMapIndexReader(final RandomAccessFile raf, BinaryMapIndexReader referenceToSameFile) throws IOException {
this.raf = raf; this.raf = raf;
this.file = referenceToSameFile.file;
codedIS = CodedInputStream.newInstance(raf); codedIS = CodedInputStream.newInstance(raf);
codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB
version = referenceToSameFile.version; version = referenceToSameFile.version;
@ -362,6 +366,10 @@ public class BinaryMapIndexReader {
return raf; return raf;
} }
public File getFile() {
return file;
}
public int readByte() throws IOException{ public int readByte() throws IOException{
byte b = codedIS.readRawByte(); byte b = codedIS.readRawByte();
if(b < 0){ if(b < 0){
@ -1956,9 +1964,10 @@ public class BinaryMapIndexReader {
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
RandomAccessFile raf = new RandomAccessFile("/Users/victorshcherb/osmand/osm-gen/map.obf", "r"); File fl = new File("/Users/victorshcherb/osmand/osm-gen/map.obf");
RandomAccessFile raf = new RandomAccessFile(fl, "r");
BinaryMapIndexReader reader = new BinaryMapIndexReader(raf); BinaryMapIndexReader reader = new BinaryMapIndexReader(raf, fl);
println("VERSION " + reader.getVersion()); //$NON-NLS-1$ println("VERSION " + reader.getVersion()); //$NON-NLS-1$
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();

View file

@ -185,19 +185,19 @@ public class CachedOsmandIndexes {
BinaryMapIndexReader reader = null; BinaryMapIndexReader reader = null;
if (found == null) { if (found == null) {
long val = System.currentTimeMillis(); long val = System.currentTimeMillis();
reader = new BinaryMapIndexReader(mf); reader = new BinaryMapIndexReader(mf, f);
addToCache(reader, f); addToCache(reader, f);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Initializing db " + f.getAbsolutePath() + " " + (System.currentTimeMillis() - val ) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ log.debug("Initializing db " + f.getAbsolutePath() + " " + (System.currentTimeMillis() - val ) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} }
} else { } else {
reader = initFileIndex(found, mf); reader = initFileIndex(found, mf, f);
} }
return reader; return reader;
} }
private BinaryMapIndexReader initFileIndex(FileIndex found, RandomAccessFile mf) throws IOException { private BinaryMapIndexReader initFileIndex(FileIndex found, RandomAccessFile mf, File f) throws IOException {
BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, false); BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, f, false);
reader.version = found.getVersion(); reader.version = found.getVersion();
reader.dateCreated = found.getDateModified(); reader.dateCreated = found.getDateModified();

View file

@ -4,6 +4,7 @@ package net.osmand.map;
import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.iterator.TIntObjectIterator;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.util.ArrayList; import java.util.ArrayList;
@ -56,7 +57,7 @@ public class OsmandRegions {
public void prepareFile(String fileName) throws IOException { public void prepareFile(String fileName) throws IOException {
reader = new BinaryMapIndexReader(new RandomAccessFile(fileName, "r")); reader = new BinaryMapIndexReader(new RandomAccessFile(fileName, "r"), new File(fileName));
initLocaleNames(); initLocaleNames();
} }

View file

@ -297,7 +297,7 @@ public class TestRouting {
for (File f : files) { for (File f : files) {
RandomAccessFile raf = new RandomAccessFile(f.getAbsolutePath(), "r"); //$NON-NLS-1$ //$NON-NLS-2$ RandomAccessFile raf = new RandomAccessFile(f.getAbsolutePath(), "r"); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(f.getName()); System.out.println(f.getName());
rs[it++] = new BinaryMapIndexReader(raf); rs[it++] = new BinaryMapIndexReader(raf, f);
} }
return rs; return rs;
} }

View file

@ -29,7 +29,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/DashboardSubHeader" style="@style/DashboardSubHeader"
android:text="@string/we_really_care" android:text="@string/we_really_care_about_your_opinion"
android:paddingBottom="@dimen/list_content_padding"/> android:paddingBottom="@dimen/list_content_padding"/>
<View <View

View file

@ -2218,7 +2218,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="use_fast_recalculation">Smart route recalculation</string> <string name="use_fast_recalculation">Smart route recalculation</string>
<string name="use_fast_recalculation_desc">Recalculate only initial part of the route for long trips</string> <string name="use_fast_recalculation_desc">Recalculate only initial part of the route for long trips</string>
<string name="do_you_like_osmand">Do you like OsmAnd?</string> <string name="do_you_like_osmand">Do you like OsmAnd?</string>
<string name="we_really_care">We really care</string> <string name="we_really_care_about_your_opinion">We care much about your opinion and it is important for us to hear you back.</string>
<string name="rate_this_app">Rate this app</string> <string name="rate_this_app">Rate this app</string>
<string name="rate_this_app_long">Please give OsmAnd a score on Google Play</string> <string name="rate_this_app_long">Please give OsmAnd a score on Google Play</string>
<string name="user_hates_app_get_feedback">Tell us why.</string> <string name="user_hates_app_get_feedback">Tell us why.</string>

View file

@ -18,13 +18,9 @@ import net.osmand.plus.R;
import java.util.Calendar; import java.util.Calendar;
/** /**
* Created by Denis on
* 26.03.2015.
*/ */
public class DashRateUsFragment extends DashBaseFragment { public class DashRateUsFragment extends DashBaseFragment {
public static final String TAG = "DASH_RATE_US_FRAGMENT"; public static final String TAG = "DASH_RATE_US_FRAGMENT";
// TODO move to resources
public static final String EMAIL = "support@osmand.net"; public static final String EMAIL = "support@osmand.net";
// Imported in shouldShow method // Imported in shouldShow method

View file

@ -1205,6 +1205,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
IndexItem ii = new IndexItem(iu.fileName, "Incremental update", iu.timestamp, iu.sizeText, IndexItem ii = new IndexItem(iu.fileName, "Incremental update", iu.timestamp, iu.sizeText,
iu.contentSize, iu.containerSize, DownloadActivityType.LIVE_UPDATES_FILE); iu.contentSize, iu.containerSize, DownloadActivityType.LIVE_UPDATES_FILE);
getDownloadActivity().addToDownload(ii); getDownloadActivity().addToDownload(ii);
getDownloadActivity().updateDownloadButton();
} }
} }

View file

@ -295,7 +295,7 @@ public class MapRenderRepositories {
if (!nativeFiles.contains(mapName)) { if (!nativeFiles.contains(mapName)) {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
nativeFiles.add(mapName); nativeFiles.add(mapName);
if (!library.initMapFile(mapName)) { if (!library.initMapFile(fr.getFile().getAbsolutePath())) {
continue; continue;
} }
log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$