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) {
|
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,16 +68,19 @@ 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 (ext.equals(SQLiteTileSource.EXT)) {
|
if (activity != null) {
|
||||||
if (renameSQLiteFile(app, f, editText.getText().toString() + ext,
|
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
callback) != null) {
|
if (ext.equals(SQLiteTileSource.EXT)) {
|
||||||
alertDialog.dismiss();
|
if (renameSQLiteFile(app, f, editText.getText().toString() + ext,
|
||||||
}
|
callback) != null) {
|
||||||
} else {
|
alertDialog.dismiss();
|
||||||
if (renameGpxFile(app, f, editText.getText().toString() + ext,
|
}
|
||||||
false, callback) != null) {
|
} else {
|
||||||
alertDialog.dismiss();
|
if (renameGpxFile(app, f, editText.getText().toString() + ext,
|
||||||
|
false, callback) != null) {
|
||||||
|
alertDialog.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue