From 63788c87d7df2ffa57e2d3f90ba30d03731d978c Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Sun, 24 May 2015 12:11:37 +0100 Subject: [PATCH] actions constants in LibraryServiceActions interface --- .../libraryService/BookCollectionShadow.java | 9 ++++--- .../libraryService/LibraryService.java | 6 +---- .../libraryService/LibraryServiceActions.java | 26 +++++++++++++++++++ 3 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 src/org/geometerplus/android/fbreader/libraryService/LibraryServiceActions.java diff --git a/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java b/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java index 757a95ec7..2a74afd7e 100644 --- a/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java +++ b/src/org/geometerplus/android/fbreader/libraryService/BookCollectionShadow.java @@ -21,6 +21,7 @@ package org.geometerplus.android.fbreader.libraryService; import java.util.*; +import android.app.Service; import android.content.*; import android.os.IBinder; import android.os.RemoteException; @@ -47,7 +48,7 @@ public class BookCollectionShadow extends AbstractBookCollection implement try { final String type = intent.getStringExtra("type"); - if (LibraryService.BOOK_EVENT_ACTION.equals(intent.getAction())) { + if (LibraryServiceActions.BOOK_EVENT_ACTION.equals(intent.getAction())) { final Book book = SerializerUtil.deserializeBook(intent.getStringExtra("book"), BookCollectionShadow.this); fireBookEvent(BookEvent.valueOf(type), book); } else { @@ -72,7 +73,7 @@ public class BookCollectionShadow extends AbstractBookCollection implement final boolean result = context.bindService( FBReaderIntents.internalIntent(FBReaderIntents.Action.LIBRARY_SERVICE), this, - LibraryService.BIND_AUTO_CREATE + Service.BIND_AUTO_CREATE ); if (result) { myContext = context; @@ -596,8 +597,8 @@ public class BookCollectionShadow extends AbstractBookCollection implement Config.Instance().runOnConnect(myOnBindActions.remove(0)); } if (myContext != null) { - myContext.registerReceiver(myReceiver, new IntentFilter(LibraryService.BOOK_EVENT_ACTION)); - myContext.registerReceiver(myReceiver, new IntentFilter(LibraryService.BUILD_EVENT_ACTION)); + myContext.registerReceiver(myReceiver, new IntentFilter(LibraryServiceActions.BOOK_EVENT_ACTION)); + myContext.registerReceiver(myReceiver, new IntentFilter(LibraryServiceActions.BUILD_EVENT_ACTION)); } } diff --git a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java index a5c4e6149..60258416f 100644 --- a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java +++ b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java @@ -42,16 +42,12 @@ import org.geometerplus.android.fbreader.httpd.DataService; import org.geometerplus.android.fbreader.httpd.DataUtil; import org.geometerplus.android.fbreader.util.AndroidImageSynchronizer; -public class LibraryService extends Service { +public class LibraryService extends Service implements LibraryServiceActions { private static SQLiteBooksDatabase ourDatabase; private static final Object ourDatabaseLock = new Object(); final DataService.Connection DataConnection = new DataService.Connection(); - static final String BOOK_EVENT_ACTION = "fbreader.library_service.book_event"; - static final String BUILD_EVENT_ACTION = "fbreader.library_service.build_event"; - static final String COVER_READY_ACTION = "fbreader.library_service.cover_ready"; - private final AndroidImageSynchronizer myImageSynchronizer = new AndroidImageSynchronizer(this); private static final class Observer extends FileObserver { diff --git a/src/org/geometerplus/android/fbreader/libraryService/LibraryServiceActions.java b/src/org/geometerplus/android/fbreader/libraryService/LibraryServiceActions.java new file mode 100644 index 000000000..904c84551 --- /dev/null +++ b/src/org/geometerplus/android/fbreader/libraryService/LibraryServiceActions.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2010-2015 FBReader.ORG Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +package org.geometerplus.android.fbreader.libraryService; + +interface LibraryServiceActions { + String BOOK_EVENT_ACTION = "fbreader.library_service.book_event"; + String BUILD_EVENT_ACTION = "fbreader.library_service.build_event"; + String COVER_READY_ACTION = "fbreader.library_service.cover_ready"; +}