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