mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-22 07:58:20 -05:00
Continue refactoring out static fields
This commit is contained in:
parent
60ea2a6097
commit
b0327dd491
@ -4,8 +4,11 @@ import org.bspeice.minimalbible.Injector;
|
|||||||
import org.bspeice.minimalbible.MinimalBibleModules;
|
import org.bspeice.minimalbible.MinimalBibleModules;
|
||||||
import org.bspeice.minimalbible.activity.downloader.manager.BookDownloadManager;
|
import org.bspeice.minimalbible.activity.downloader.manager.BookDownloadManager;
|
||||||
import org.bspeice.minimalbible.activity.downloader.manager.BookDownloadThread;
|
import org.bspeice.minimalbible.activity.downloader.manager.BookDownloadThread;
|
||||||
|
import org.bspeice.minimalbible.activity.downloader.manager.InstalledManager;
|
||||||
import org.bspeice.minimalbible.activity.downloader.manager.RefreshManager;
|
import org.bspeice.minimalbible.activity.downloader.manager.RefreshManager;
|
||||||
|
import org.crosswire.jsword.book.Book;
|
||||||
import org.crosswire.jsword.book.BookCategory;
|
import org.crosswire.jsword.book.BookCategory;
|
||||||
|
import org.crosswire.jsword.book.Books;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -29,7 +32,8 @@ import de.devland.esperandro.Esperandro;
|
|||||||
BookDownloadThread.class,
|
BookDownloadThread.class,
|
||||||
RefreshManager.class,
|
RefreshManager.class,
|
||||||
DownloadNavDrawerFragment.class,
|
DownloadNavDrawerFragment.class,
|
||||||
DownloadActivity.class
|
DownloadActivity.class,
|
||||||
|
InstalledManager.class
|
||||||
},
|
},
|
||||||
addsTo = MinimalBibleModules.class
|
addsTo = MinimalBibleModules.class
|
||||||
)
|
)
|
||||||
@ -70,4 +74,15 @@ public class DownloadActivityModules {
|
|||||||
add(BookCategory.MAPS);
|
add(BookCategory.MAPS);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Move this to a true async
|
||||||
|
@Provides @Singleton
|
||||||
|
Books provideInstalledBooksManager() {
|
||||||
|
return Books.installed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
List<Book> provideInstalledBooks(Books b) {
|
||||||
|
return b.getBooks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package org.bspeice.minimalbible.activity.downloader.manager;
|
|||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.bspeice.minimalbible.Injector;
|
||||||
import org.crosswire.jsword.book.Book;
|
import org.crosswire.jsword.book.Book;
|
||||||
import org.crosswire.jsword.book.BookException;
|
import org.crosswire.jsword.book.BookException;
|
||||||
import org.crosswire.jsword.book.Books;
|
import org.crosswire.jsword.book.Books;
|
||||||
@ -19,28 +20,18 @@ import javax.inject.Singleton;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class InstalledManager implements BooksListener {
|
public class InstalledManager implements BooksListener {
|
||||||
|
|
||||||
private Books installedBooks;
|
@Inject Books installedBooks;
|
||||||
private List<Book> installedBooksList;
|
@Inject List<Book> installedBooksList;
|
||||||
|
|
||||||
private String TAG = "InstalledManager";
|
private String TAG = "InstalledManager";
|
||||||
|
|
||||||
@Inject InstalledManager() {}
|
@Inject
|
||||||
|
InstalledManager(Injector injector) {
|
||||||
/**
|
injector.inject(this);
|
||||||
* Register our manager to receive events on Book install
|
|
||||||
* This is a relatively expensive operation,
|
|
||||||
* so we don't put it in the constructor.
|
|
||||||
*/
|
|
||||||
public void initialize() {
|
|
||||||
//TODO: Move this to a true async, rather than separate initialize() function
|
|
||||||
installedBooks = Books.installed();
|
|
||||||
installedBooksList = installedBooks.getBooks();
|
|
||||||
installedBooks.addBooksListener(this);
|
installedBooks.addBooksListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInstalled(Book b) {
|
public boolean isInstalled(Book b) {
|
||||||
if (installedBooks == null) {
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
return installedBooksList.contains(b);
|
return installedBooksList.contains(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +54,6 @@ public class InstalledManager implements BooksListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeBook(Book b) {
|
public void removeBook(Book b) {
|
||||||
if (installedBooks == null) {
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
// Not sure why we need to call this multiple times, but...
|
// Not sure why we need to call this multiple times, but...
|
||||||
while (Books.installed().getBooks().contains(b)) {
|
while (Books.installed().getBooks().contains(b)) {
|
||||||
try {
|
try {
|
||||||
|
@ -105,7 +105,7 @@ public class BookFragment extends BaseFragment {
|
|||||||
private void displayBook(Book b) {
|
private void displayBook(Book b) {
|
||||||
Log.d("BookFragment", b.getName());
|
Log.d("BookFragment", b.getName());
|
||||||
((BibleViewer)getActivity()).setActionBarTitle(b.getInitials());
|
((BibleViewer)getActivity()).setActionBarTitle(b.getInitials());
|
||||||
mainContent.loadUrl(getString(R.string.content_page));
|
mainContent.loadUrl(getString(R.string.book_html));
|
||||||
mainContent.setWebViewClient(new WebViewClient(){
|
mainContent.setWebViewClient(new WebViewClient(){
|
||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="content_page">file:///android_asset/book.html</string>
|
<string name="asset_url">file:///android_asset/</string>
|
||||||
|
<string name="book_html">file:///android_asset/book.html</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user