mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-04 23:28:19 -05:00
Don't require the actual Activity, just an injector
This commit is contained in:
parent
e7cf3be6bc
commit
949f35f312
@ -7,6 +7,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.todddavies.components.progressbar.ProgressWheel;
|
||||
|
||||
import org.bspeice.minimalbible.Injector;
|
||||
import org.bspeice.minimalbible.R;
|
||||
import org.bspeice.minimalbible.activity.downloader.manager.BookDownloadManager;
|
||||
import org.bspeice.minimalbible.activity.downloader.manager.DLProgressEvent;
|
||||
@ -49,9 +50,9 @@ public class BookItemHolder {
|
||||
private Subscription subscription;
|
||||
|
||||
// TODO: Factory style?
|
||||
public BookItemHolder(View v, Book b, DownloadActivity activity) {
|
||||
public BookItemHolder(View v, Book b, Injector injector) {
|
||||
ButterKnife.inject(this, v);
|
||||
activity.inject(this);
|
||||
injector.inject(this);
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import org.bspeice.minimalbible.Injector;
|
||||
import org.bspeice.minimalbible.R;
|
||||
import org.crosswire.jsword.book.Book;
|
||||
|
||||
@ -17,12 +18,12 @@ import java.util.List;
|
||||
public class BookListAdapter extends BaseAdapter implements AbsListView.RecyclerListener {
|
||||
private final List<Book> bookList;
|
||||
private final LayoutInflater inflater;
|
||||
private final DownloadActivity activity;
|
||||
private final Injector injector;
|
||||
|
||||
public BookListAdapter(LayoutInflater inflater, List<Book> bookList, DownloadActivity activity) {
|
||||
public BookListAdapter(LayoutInflater inflater, List<Book> bookList, Injector injector) {
|
||||
this.bookList = bookList;
|
||||
this.inflater = inflater;
|
||||
this.activity = activity;
|
||||
this.injector = injector;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,7 +48,7 @@ public class BookListAdapter extends BaseAdapter implements AbsListView.Recycler
|
||||
// and you'll get some really strange issues
|
||||
if (convertView == null || convertView.getTag() == null) {
|
||||
convertView = inflater.inflate(R.layout.list_download_items, parent, false);
|
||||
viewHolder = new BookItemHolder(convertView, getItem(position), activity);
|
||||
viewHolder = new BookItemHolder(convertView, getItem(position), injector);
|
||||
} else {
|
||||
viewHolder = (BookItemHolder) convertView.getTag();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.bspeice.minimalbible.activity.downloader.manager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.bspeice.minimalbible.Injector;
|
||||
import org.bspeice.minimalbible.MinimalBible;
|
||||
import org.bspeice.minimalbible.activity.downloader.DownloadActivity;
|
||||
import org.crosswire.common.progress.JobManager;
|
||||
@ -47,11 +48,11 @@ public class BookDownloadManager implements WorkListener, BooksListener {
|
||||
Provider<BookDownloadThread> dlThreadProvider;
|
||||
|
||||
@Inject
|
||||
public BookDownloadManager(DownloadActivity activity) {
|
||||
public BookDownloadManager(Injector injector) {
|
||||
bookMappings = new HashMap<String, Book>();
|
||||
inProgressDownloads = new HashMap<Book, DLProgressEvent>();
|
||||
JobManager.addWorkListener(this);
|
||||
activity.inject(this);
|
||||
injector.inject(this);
|
||||
Books.installed().addBooksListener(this);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package org.bspeice.minimalbible.activity.downloader.manager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.bspeice.minimalbible.Injector;
|
||||
import org.bspeice.minimalbible.MinimalBible;
|
||||
import org.bspeice.minimalbible.activity.downloader.DownloadActivity;
|
||||
import org.crosswire.jsword.book.Book;
|
||||
@ -28,8 +29,8 @@ public class BookDownloadThread {
|
||||
RefreshManager refreshManager;
|
||||
|
||||
@Inject
|
||||
public BookDownloadThread(DownloadActivity activity) {
|
||||
activity.inject(this);
|
||||
public BookDownloadThread(Injector injector) {
|
||||
injector.inject(this);
|
||||
}
|
||||
|
||||
public void downloadBook(final Book b) {
|
||||
|
@ -2,6 +2,7 @@ package org.bspeice.minimalbible.activity.downloader.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.bspeice.minimalbible.Injector;
|
||||
import org.bspeice.minimalbible.MinimalBible;
|
||||
import org.bspeice.minimalbible.activity.downloader.DownloadActivity;
|
||||
import org.crosswire.jsword.book.Book;
|
||||
@ -39,8 +40,8 @@ public class RefreshManager {
|
||||
private final AtomicBoolean refreshComplete = new AtomicBoolean();
|
||||
|
||||
@Inject
|
||||
public RefreshManager(DownloadActivity activity) {
|
||||
activity.inject(this);
|
||||
public RefreshManager(Injector injector) {
|
||||
injector.inject(this);
|
||||
refreshModules();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user