mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-11-16 04:58:26 -05:00
[broken probably] Refactoring to Rx should be done...
But having issues with compiling. Checking if Dagger and retrolambda play nice.
This commit is contained in:
parent
fb0c5fdaaa
commit
28dfec81d7
@ -16,7 +16,6 @@ import org.bspeice.minimalbible.MinimalBible;
|
|||||||
import org.bspeice.minimalbible.R;
|
import org.bspeice.minimalbible.R;
|
||||||
import org.bspeice.minimalbible.activities.BaseFragment;
|
import org.bspeice.minimalbible.activities.BaseFragment;
|
||||||
import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager;
|
import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager;
|
||||||
import org.bspeice.minimalbible.activities.downloader.manager.EventBookList;
|
|
||||||
import org.bspeice.minimalbible.activities.downloader.manager.RefreshManager;
|
import org.bspeice.minimalbible.activities.downloader.manager.RefreshManager;
|
||||||
import org.crosswire.jsword.book.Book;
|
import org.crosswire.jsword.book.Book;
|
||||||
import org.crosswire.jsword.book.BookCategory;
|
import org.crosswire.jsword.book.BookCategory;
|
||||||
|
@ -18,8 +18,9 @@ public class BookDownloadThread {
|
|||||||
private final String TAG = "BookDownloadThread";
|
private final String TAG = "BookDownloadThread";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DownloadManager downloadManager;
|
BookDownloadManager bookDownloadManager;
|
||||||
@Inject RefreshManager refreshManager;
|
@Inject
|
||||||
|
RefreshManager refreshManager;
|
||||||
|
|
||||||
public BookDownloadThread() {
|
public BookDownloadThread() {
|
||||||
MinimalBible.getApplication().inject(this);
|
MinimalBible.getApplication().inject(this);
|
||||||
@ -29,31 +30,27 @@ public class BookDownloadThread {
|
|||||||
// So, the JobManager can't be injected, but we'll make do
|
// So, the JobManager can't be injected, but we'll make do
|
||||||
|
|
||||||
// First, look up where the Book came from
|
// First, look up where the Book came from
|
||||||
final Installer i = refreshManager.installerFromBook(b);
|
refreshManager.installerFromBook(b)
|
||||||
|
.subscribe((installer) -> {
|
||||||
final Thread worker = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
i.install(b);
|
installer.install(b);
|
||||||
} catch (InstallException e) {
|
} catch (InstallException e) {
|
||||||
Log.d(TAG, e.getMessage());
|
Log.d(TAG, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
worker.start();
|
|
||||||
// The worker automatically communicates with the JobManager for its progress.
|
|
||||||
|
|
||||||
downloadManager.getDownloadBus().post(new DLProgressEvent(DLProgressEvent.PROGRESS_BEGINNING, b));
|
bookDownloadManager.getDownloadEvents().onNext(new DLProgressEvent(DLProgressEvent.PROGRESS_BEGINNING, b));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build what the installer creates the job name as.
|
* Build what the installer creates the job name as.
|
||||||
* Likely prone to be brittle.
|
* Likely prone to be brittle.
|
||||||
* TODO: Make sure to test that this is an accurate job name
|
* TODO: Make sure to test that this is an accurate job name
|
||||||
|
*
|
||||||
* @param b The book to predict the download job name of
|
* @param b The book to predict the download job name of
|
||||||
* @return The name of the job that will/is download/ing this book
|
* @return The name of the job that will/is download/ing this book
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static String getJobId(Book b) {
|
public static String getJobId(Book b) {
|
||||||
return "INSTALL_BOOK-" + b.getInitials();
|
return "INSTALL_BOOK-" + b.getInitials();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user