mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-12-22 06:38:28 -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.activities.BaseFragment;
|
||||
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.crosswire.jsword.book.Book;
|
||||
import org.crosswire.jsword.book.BookCategory;
|
||||
|
@ -18,8 +18,9 @@ public class BookDownloadThread {
|
||||
private final String TAG = "BookDownloadThread";
|
||||
|
||||
@Inject
|
||||
DownloadManager downloadManager;
|
||||
@Inject RefreshManager refreshManager;
|
||||
BookDownloadManager bookDownloadManager;
|
||||
@Inject
|
||||
RefreshManager refreshManager;
|
||||
|
||||
public BookDownloadThread() {
|
||||
MinimalBible.getApplication().inject(this);
|
||||
@ -29,31 +30,27 @@ public class BookDownloadThread {
|
||||
// So, the JobManager can't be injected, but we'll make do
|
||||
|
||||
// First, look up where the Book came from
|
||||
final Installer i = refreshManager.installerFromBook(b);
|
||||
refreshManager.installerFromBook(b)
|
||||
.subscribe((installer) -> {
|
||||
try {
|
||||
installer.install(b);
|
||||
} catch (InstallException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
}
|
||||
|
||||
final Thread worker = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
i.install(b);
|
||||
} catch (InstallException e) {
|
||||
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.
|
||||
* Likely prone to be brittle.
|
||||
* TODO: Make sure to test that this is an accurate job name
|
||||
*
|
||||
* @param b The book to predict the download job name of
|
||||
* @return The name of the job that will/is download/ing this book
|
||||
*/
|
||||
|
||||
public static String getJobId(Book b) {
|
||||
return "INSTALL_BOOK-" + b.getInitials();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user