This commit is contained in:
veliymolfar 2020-05-28 15:32:20 +03:00
parent fac931e801
commit 848eb2cfbe
2 changed files with 22 additions and 13 deletions

View file

@ -46,8 +46,9 @@ public class FileUtils {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
Editable text = editText.getText(); Editable text = editText.getText();
if (text.length() >= 1) { if (text.length() >= 1) {
if (ILLEGAL_FILE_NAME_CHARACTERS.matcher(text).find()) { Activity activity = weakActivity.get();
editText.setError(weakActivity.get().getString(R.string.file_name_containes_illegal_char)); if (ILLEGAL_FILE_NAME_CHARACTERS.matcher(text).find() && activity != null) {
editText.setError(activity.getString(R.string.file_name_containes_illegal_char));
} }
} }
} }
@ -67,7 +68,9 @@ public class FileUtils {
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
OsmandApplication app = (OsmandApplication) weakActivity.get().getApplication(); Activity activity = weakActivity.get();
if (activity != null) {
OsmandApplication app = (OsmandApplication) activity.getApplication();
if (ext.equals(SQLiteTileSource.EXT)) { if (ext.equals(SQLiteTileSource.EXT)) {
if (renameSQLiteFile(app, f, editText.getText().toString() + ext, if (renameSQLiteFile(app, f, editText.getText().toString() + ext,
callback) != null) { callback) != null) {
@ -80,6 +83,7 @@ public class FileUtils {
} }
} }
} }
}
}); });
} }
}); });

View file

@ -337,6 +337,7 @@ public class SQLiteTileSource implements ITileSource {
} }
public void updateFromTileSourceTemplate(TileSourceTemplate r) { public void updateFromTileSourceTemplate(TileSourceTemplate r) {
boolean openedBefore = isDbOpened();
SQLiteConnection db = getDatabase(); SQLiteConnection db = getDatabase();
if (!onlyReadonlyAvailable && db != null) { if (!onlyReadonlyAvailable && db != null) {
int maxZoom = r.getMaximumZoomSupported(); int maxZoom = r.getMaximumZoomSupported();
@ -362,11 +363,15 @@ public class SQLiteTileSource implements ITileSource {
db.execSQL("update info set " + EXPIRE_MINUTES + " = '" + r.getExpirationTimeMinutes() + "'"); db.execSQL("update info set " + EXPIRE_MINUTES + " = '" + r.getExpirationTimeMinutes() + "'");
} }
} }
if (db != null) { if (db != null && !openedBefore) {
db.close(); db.close();
} }
} }
public boolean isDbOpened() {
return db != null && !db.isClosed();
}
private void addInfoColumn(SQLiteConnection db, String columnName, String value) { private void addInfoColumn(SQLiteConnection db, String columnName, String value) {
if(!onlyReadonlyAvailable) { if(!onlyReadonlyAvailable) {
try { try {