mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-24 17:08:18 -05:00
Refactor the DLProgressEvent to Kotlin
This commit is contained in:
parent
b778748ee0
commit
86adeb4951
@ -110,8 +110,9 @@ public class BookDownloadManager implements WorkListener, BooksListener {
|
|||||||
downloadEvents.onNext(new DLProgressEvent(DLProgressEvent.PROGRESS_COMPLETE, b));
|
downloadEvents.onNext(new DLProgressEvent(DLProgressEvent.PROGRESS_COMPLETE, b));
|
||||||
} else {
|
} else {
|
||||||
// Track the ongoing download
|
// Track the ongoing download
|
||||||
DLProgressEvent event = new DLProgressEvent(job.getWorkDone(),
|
DLProgressEvent event = new DLProgressEvent(
|
||||||
job.getTotalWork(), b);
|
(job.getWorkDone() / job.getTotalWork()) * 100,
|
||||||
|
b);
|
||||||
inProgressDownloads.put(b, event);
|
inProgressDownloads.put(b, event);
|
||||||
downloadEvents.onNext(event);
|
downloadEvents.onNext(event);
|
||||||
}
|
}
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package org.bspeice.minimalbible.activity.downloader.manager;
|
|
||||||
|
|
||||||
import org.crosswire.jsword.book.Book;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for notifying that a book's download progress is ongoing
|
|
||||||
*/
|
|
||||||
public class DLProgressEvent {
|
|
||||||
private final int progress;
|
|
||||||
private final Book b;
|
|
||||||
|
|
||||||
public static final int PROGRESS_COMPLETE = 100;
|
|
||||||
public static final int PROGRESS_BEGINNING = 0;
|
|
||||||
|
|
||||||
public DLProgressEvent(int workDone, int totalWork, Book b) {
|
|
||||||
if (totalWork == 0) {
|
|
||||||
this.progress = 0;
|
|
||||||
} else {
|
|
||||||
this.progress = (int)((float) workDone / totalWork * 100);
|
|
||||||
}
|
|
||||||
this.b = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DLProgressEvent(int workDone, Book b) {
|
|
||||||
this.progress = workDone;
|
|
||||||
this.b = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getProgress() {
|
|
||||||
return progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float toCircular() {
|
|
||||||
return ((float)progress) * 360 / 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Book getB() {
|
|
||||||
return this.b;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,16 @@
|
|||||||
|
package org.bspeice.minimalbible.activity.downloader.manager
|
||||||
|
|
||||||
|
import org.crosswire.jsword.book.Book
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by bspeice on 11/11/14.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DLProgressEvent(val progress: Int, val b: Book) {
|
||||||
|
class object {
|
||||||
|
val PROGRESS_COMPLETE = 100
|
||||||
|
val PROGRESS_BEGINNING = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toCircular() = progress.toFloat() * 360 / 100
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user