From 949f35f3122c1016cf14ad95624485f1c4f07760 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Wed, 9 Jul 2014 21:30:22 -0400 Subject: [PATCH] Don't require the actual Activity, just an injector --- .../minimalbible/activity/downloader/BookItemHolder.java | 5 +++-- .../activity/downloader/BookListAdapter.java | 9 +++++---- .../activity/downloader/manager/BookDownloadManager.java | 5 +++-- .../activity/downloader/manager/BookDownloadThread.java | 5 +++-- .../activity/downloader/manager/RefreshManager.java | 5 +++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java index b851525..3531ac7 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookItemHolder.java @@ -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; } diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListAdapter.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListAdapter.java index 7277dd7..d09618e 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListAdapter.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListAdapter.java @@ -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 bookList; private final LayoutInflater inflater; - private final DownloadActivity activity; + private final Injector injector; - public BookListAdapter(LayoutInflater inflater, List bookList, DownloadActivity activity) { + public BookListAdapter(LayoutInflater inflater, List 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(); } diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadManager.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadManager.java index fd40f7a..c07a1c8 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadManager.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadManager.java @@ -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 dlThreadProvider; @Inject - public BookDownloadManager(DownloadActivity activity) { + public BookDownloadManager(Injector injector) { bookMappings = new HashMap(); inProgressDownloads = new HashMap(); JobManager.addWorkListener(this); - activity.inject(this); + injector.inject(this); Books.installed().addBooksListener(this); } diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadThread.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadThread.java index e03ef7e..86f2614 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadThread.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/BookDownloadThread.java @@ -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) { diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java index ce5dcf2..a09a172 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java @@ -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(); }