mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2025-07-03 23:05:03 -04:00
Unit testing now working
Also demo test case for async testing.
This commit is contained in:
@ -60,4 +60,6 @@ public class MinimalBible extends Application {
|
||||
public void inject(Object o) {
|
||||
graph.inject(o);
|
||||
}
|
||||
|
||||
public ObjectGraph getObjGraph() { return graph; }
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.bspeice.minimalbible.activities.downloader;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
@ -55,14 +54,20 @@ public class BookItemHolder {
|
||||
|
||||
@OnClick(R.id.download_ibtn_download)
|
||||
public void onDownloadItem(View v) {
|
||||
Log.d("BookListAdapter", v.toString());
|
||||
displayProgress(0); // Can assume 0 since the download is now starting
|
||||
// TODO: Write a unit test to make sure that this is called - displayProgress() assumes it
|
||||
downloadManager.getDownloadBus().register(this);
|
||||
downloadManager.getDownloadBus()
|
||||
.post(new DownloadProgressEvent(DownloadProgressEvent.PROGRESS_BEGINNING, b));
|
||||
|
||||
// TODO: Kick off a service to actually do the downloading, rather than simulate
|
||||
downloadManager.getDownloadBus().post(new DownloadProgressEvent(47, b));
|
||||
}
|
||||
|
||||
public void onEventMainThread(DownloadProgressEvent event) {
|
||||
if (event.getB().equals(this.b)) {
|
||||
displayProgress((int) event.toCircular());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the current progress of this download
|
||||
* @param progress The progress out of 360 (degrees of a circle)
|
||||
@ -70,7 +75,7 @@ public class BookItemHolder {
|
||||
private void displayProgress(int progress) {
|
||||
|
||||
|
||||
if (progress <= 0) {
|
||||
if (progress == DownloadProgressEvent.PROGRESS_BEGINNING) {
|
||||
// Download starting
|
||||
RelativeLayout.LayoutParams acronymParams =
|
||||
(RelativeLayout.LayoutParams)acronym.getLayoutParams();
|
||||
|
@ -3,12 +3,15 @@ package org.bspeice.minimalbible.activities.downloader.manager;
|
||||
import org.crosswire.jsword.book.Book;
|
||||
|
||||
/**
|
||||
* Created by bspeice on 5/19/14.
|
||||
* Used for notifying that a book's download progress is ongoing
|
||||
*/
|
||||
public class DownloadProgressEvent {
|
||||
private int progress;
|
||||
private Book b;
|
||||
|
||||
public static final int PROGRESS_COMPLETE = 100;
|
||||
public static final int PROGRESS_BEGINNING = 0;
|
||||
|
||||
public DownloadProgressEvent(int progress, Book b) {
|
||||
this.progress = progress;
|
||||
this.b = b;
|
||||
|
Reference in New Issue
Block a user