Fix Audio Video notes

This commit is contained in:
vshcherb 2013-08-23 10:10:52 +02:00
parent c177208912
commit 37712a8a42

View file

@ -879,17 +879,17 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
stopRecording(mapActivity);
SHOW_RECORDINGS.set(true);
indexFile(f);
indexFile(true, f);
mapActivity.getMapView().refreshMap();
updateWidgetIcon(recordControl);
}
});
}
public void indexFile(File f) {
public boolean indexSingleFile(File f) {
boolean oldFileExist = recordingByFileName.containsKey(f.getName());
if (oldFileExist) {
return;
return false;
}
Recording r = new Recording(f);
String encodeName = f.getName();
@ -918,6 +918,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
recordings.registerObject(r.lat, r.lon, r);
recordingByFileName.put(f.getName(), r);
return true;
}
@Override
@ -943,10 +944,18 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
File[] files = avPath.listFiles();
if (files != null) {
for (File f : files) {
indexFile(registerNew, f);
}
}
}
return null;
}
private void indexFile(boolean registerInGPX, File f) {
if (f.getName().endsWith(THREEGP_EXTENSION) || f.getName().endsWith(MPEG4_EXTENSION)
|| f.getName().endsWith(IMG_EXTENSION)) {
indexFile(f);
if (registerNew) {
boolean newFileIndexed = indexSingleFile(f);
if (newFileIndexed && registerInGPX) {
Recording rec = recordingByFileName.get(f.getName());
if (rec != null && app.getSettings().SAVE_TRACK_TO_GPX.get()
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
@ -962,10 +971,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
}
}
}
return null;
}
public DataTileManager<Recording> getRecordings() {
return recordings;
@ -1008,7 +1013,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
@Override
public void onMapActivityExternalResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 205) {
if (requestCode == 205 || requestCode == 105) {
indexingFiles(null, true, true);
}
}
@ -1209,7 +1214,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
indexingFiles(null, true, true);
indexFile(true, pictureFile);
dlg.dismiss();
// play sound after photo - sound file must be loaded at this time:
if (AV_PHOTO_PLAY_SOUND.get()) {