refactor
This commit is contained in:
parent
fac931e801
commit
848eb2cfbe
2 changed files with 22 additions and 13 deletions
|
@ -46,8 +46,9 @@ public class FileUtils {
|
|||
public void afterTextChanged(Editable s) {
|
||||
Editable text = editText.getText();
|
||||
if (text.length() >= 1) {
|
||||
if (ILLEGAL_FILE_NAME_CHARACTERS.matcher(text).find()) {
|
||||
editText.setError(weakActivity.get().getString(R.string.file_name_containes_illegal_char));
|
||||
Activity activity = weakActivity.get();
|
||||
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() {
|
||||
@Override
|
||||
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 (renameSQLiteFile(app, f, editText.getText().toString() + ext,
|
||||
callback) != null) {
|
||||
|
@ -80,6 +83,7 @@ public class FileUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -337,6 +337,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
}
|
||||
|
||||
public void updateFromTileSourceTemplate(TileSourceTemplate r) {
|
||||
boolean openedBefore = isDbOpened();
|
||||
SQLiteConnection db = getDatabase();
|
||||
if (!onlyReadonlyAvailable && db != null) {
|
||||
int maxZoom = r.getMaximumZoomSupported();
|
||||
|
@ -362,11 +363,15 @@ public class SQLiteTileSource implements ITileSource {
|
|||
db.execSQL("update info set " + EXPIRE_MINUTES + " = '" + r.getExpirationTimeMinutes() + "'");
|
||||
}
|
||||
}
|
||||
if (db != null) {
|
||||
if (db != null && !openedBefore) {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDbOpened() {
|
||||
return db != null && !db.isClosed();
|
||||
}
|
||||
|
||||
private void addInfoColumn(SQLiteConnection db, String columnName, String value) {
|
||||
if(!onlyReadonlyAvailable) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue