mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
naming/access rights cleanup
This commit is contained in:
parent
fb557d2de0
commit
d8bb1ad585
7 changed files with 11 additions and 11 deletions
|
@ -51,7 +51,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
migrate(context);
|
migrate(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public /*protected*/ void executeAsATransaction(Runnable actions) {
|
protected void executeAsTransaction(Runnable actions) {
|
||||||
boolean transactionStarted = false;
|
boolean transactionStarted = false;
|
||||||
try {
|
try {
|
||||||
myDatabase.beginTransaction();
|
myDatabase.beginTransaction();
|
||||||
|
@ -681,7 +681,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
"INSERT OR IGNORE INTO RecentBooks (book_id) VALUES (?)"
|
"INSERT OR IGNORE INTO RecentBooks (book_id) VALUES (?)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
executeAsATransaction(new Runnable() {
|
executeAsTransaction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
myDatabase.delete("RecentBooks", null, null);
|
myDatabase.delete("RecentBooks", null, null);
|
||||||
for (long id : ids) {
|
for (long id : ids) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
||||||
myDatabase.setVersion(currentCodeVersion);
|
myDatabase.setVersion(currentCodeVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void executeAsATransaction(Runnable actions) {
|
protected void executeAsTransaction(Runnable actions) {
|
||||||
myDatabase.beginTransaction();
|
myDatabase.beginTransaction();
|
||||||
try {
|
try {
|
||||||
actions.run();
|
actions.run();
|
||||||
|
@ -131,7 +131,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
||||||
private SQLiteStatement myUpdateCustomLinkUrlStatement;
|
private SQLiteStatement myUpdateCustomLinkUrlStatement;
|
||||||
@Override
|
@Override
|
||||||
protected synchronized void saveLink(final INetworkLink link) {
|
protected synchronized void saveLink(final INetworkLink link) {
|
||||||
executeAsATransaction(new Runnable() {
|
executeAsTransaction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
final SQLiteStatement statement;
|
final SQLiteStatement statement;
|
||||||
if (link.getId() == INetworkLink.INVALID_ID) {
|
if (link.getId() == INetworkLink.INVALID_ID) {
|
||||||
|
@ -232,7 +232,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
||||||
if (link.getId() == INetworkLink.INVALID_ID) {
|
if (link.getId() == INetworkLink.INVALID_ID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
executeAsATransaction(new Runnable() {
|
executeAsTransaction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
final String stringLinkId = String.valueOf(link.getId());
|
final String stringLinkId = String.valueOf(link.getId());
|
||||||
myDatabase.delete("Links", "link_id = ?", new String[] { stringLinkId });
|
myDatabase.delete("Links", "link_id = ?", new String[] { stringLinkId });
|
||||||
|
@ -258,7 +258,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected synchronized void setLinkExtras(final INetworkLink link, final Map<String,String> extras) {
|
protected synchronized void setLinkExtras(final INetworkLink link, final Map<String,String> extras) {
|
||||||
executeAsATransaction(new Runnable() {
|
executeAsTransaction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (link.getId() == INetworkLink.INVALID_ID) {
|
if (link.getId() == INetworkLink.INVALID_ID) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -426,7 +426,7 @@ public class Book {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
database.executeAsATransaction(new Runnable() {
|
database.executeAsTransaction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (myId >= 0) {
|
if (myId >= 0) {
|
||||||
final FileInfoSet fileInfos = new FileInfoSet(database, File);
|
final FileInfoSet fileInfos = new FileInfoSet(database, File);
|
||||||
|
|
|
@ -593,7 +593,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
// Step 4: save changes into database
|
// Step 4: save changes into database
|
||||||
fileInfos.save();
|
fileInfos.save();
|
||||||
|
|
||||||
myDatabase.executeAsATransaction(new Runnable() {
|
myDatabase.executeAsTransaction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Book book : newBooks) {
|
for (Book book : newBooks) {
|
||||||
saveBook(book, false);
|
saveBook(book, false);
|
||||||
|
|
|
@ -53,7 +53,7 @@ public abstract class BooksDatabase {
|
||||||
book.setSeriesInfoWithNoCheck(series, index);
|
book.setSeriesInfoWithNoCheck(series, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public /*protected*/ abstract void executeAsATransaction(Runnable actions);
|
protected abstract void executeAsTransaction(Runnable actions);
|
||||||
|
|
||||||
// returns map fileId -> book
|
// returns map fileId -> book
|
||||||
protected abstract Map<Long,Book> loadBooks(FileInfoSet infos, boolean existing);
|
protected abstract Map<Long,Book> loadBooks(FileInfoSet infos, boolean existing);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public final class FileInfoSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
myDatabase.executeAsATransaction(new Runnable() {
|
myDatabase.executeAsTransaction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
for (FileInfo info : myInfosToRemove) {
|
for (FileInfo info : myInfosToRemove) {
|
||||||
myDatabase.removeFileInfo(info.Id);
|
myDatabase.removeFileInfo(info.Id);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public abstract class NetworkDatabase {
|
||||||
ourInstance = this;
|
ourInstance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void executeAsATransaction(Runnable actions);
|
protected abstract void executeAsTransaction(Runnable actions);
|
||||||
|
|
||||||
protected INetworkLink createLink(int id, INetworkLink.Type type, String predefinedId, String siteName, String title, String summary, String language, UrlInfoCollection<UrlInfoWithDate> infos) {
|
protected INetworkLink createLink(int id, INetworkLink.Type type, String predefinedId, String siteName, String title, String summary, String language, UrlInfoCollection<UrlInfoWithDate> infos) {
|
||||||
if (siteName == null || title == null || infos.getInfo(UrlInfo.Type.Catalog) == null) {
|
if (siteName == null || title == null || infos.getInfo(UrlInfo.Type.Catalog) == null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue