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;
}
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>();
if(version == -1){
version = indexes[c].getVersion();
@ -446,12 +446,13 @@ public class BinaryInspector {
public void printFileInformation(File file) throws IOException {
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 {
BinaryMapIndexReader index = new BinaryMapIndexReader(r);
BinaryMapIndexReader index = new BinaryMapIndexReader(r, file);
int i = 1;
println("Binary index " + filename + " version = " + index.getVersion() +" edition = " + new Date(index.getDateCreated()));
for(BinaryIndexPart p : index.getIndexes()){

View file

@ -26,7 +26,7 @@ public class BinaryMapIndexFilter {
private final BinaryMapIndexReader reader;
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;
private final RandomAccessFile raf;
protected final File file;
/*private*/ int version;
/*private */long dateCreated;
// keep them immutable inside
@ -102,8 +103,9 @@ public class BinaryMapIndexReader {
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.file = file;
codedIS = CodedInputStream.newInstance(raf);
codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB
transportAdapter = new BinaryMapTransportReaderAdapter(this);
@ -113,8 +115,9 @@ public class BinaryMapIndexReader {
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.file = file;
codedIS = CodedInputStream.newInstance(raf);
codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB
transportAdapter = new BinaryMapTransportReaderAdapter(this);
@ -128,6 +131,7 @@ public class BinaryMapIndexReader {
public BinaryMapIndexReader(final RandomAccessFile raf, BinaryMapIndexReader referenceToSameFile) throws IOException {
this.raf = raf;
this.file = referenceToSameFile.file;
codedIS = CodedInputStream.newInstance(raf);
codedIS.setSizeLimit(Integer.MAX_VALUE); // 2048 MB
version = referenceToSameFile.version;
@ -362,6 +366,10 @@ public class BinaryMapIndexReader {
return raf;
}
public File getFile() {
return file;
}
public int readByte() throws IOException{
byte b = codedIS.readRawByte();
if(b < 0){
@ -1956,9 +1964,10 @@ public class BinaryMapIndexReader {
}
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$
long time = System.currentTimeMillis();

View file

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

View file

@ -4,6 +4,7 @@ package net.osmand.map;
import gnu.trove.iterator.TIntObjectIterator;
import gnu.trove.list.array.TIntArrayList;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
@ -56,7 +57,7 @@ public class OsmandRegions {
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();
}

View file

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

View file

@ -29,7 +29,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/DashboardSubHeader"
android:text="@string/we_really_care"
android:text="@string/we_really_care_about_your_opinion"
android:paddingBottom="@dimen/list_content_padding"/>
<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_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="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_long">Please give OsmAnd a score on Google Play</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;
/**
* Created by Denis on
* 26.03.2015.
*/
public class DashRateUsFragment extends DashBaseFragment {
public static final String TAG = "DASH_RATE_US_FRAGMENT";
// TODO move to resources
public static final String EMAIL = "support@osmand.net";
// 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,
iu.contentSize, iu.containerSize, DownloadActivityType.LIVE_UPDATES_FILE);
getDownloadActivity().addToDownload(ii);
getDownloadActivity().updateDownloadButton();
}
}

View file

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