Add a list of books to exclude

Still need to fix some references to Books.installed(), please use injection for this.
This commit is contained in:
Bradlee Speice
2014-12-29 16:42:10 -05:00
parent b1ecf8a404
commit ef314efa2f
9 changed files with 143 additions and 64 deletions

View File

@ -16,6 +16,7 @@ import java.util.Date
*/
class RefreshManager(val installers: Collection<Installer>,
val exclude: List<String>,
val prefs: DownloadPrefs,
val connManager: ConnectivityManager?) {
val refreshComplete = AtomicBoolean()
@ -26,7 +27,9 @@ class RefreshManager(val installers: Collection<Installer>,
it.reloadBookList() // TODO: Handle InstallException
prefs.downloadRefreshedOn(Date().getTime())
}
mapOf(Pair(it, it.getBooks()))
val validBooks = it.getBooks()
.filterNot { exclude contains it.getInitials() }
mapOf(Pair(it, validBooks))
}
.subscribeOn(Schedulers.io())
.cache();

View File

@ -1,28 +0,0 @@
package org.bspeice.minimalbible.activity.settings
import android.preference.PreferenceActivity
import android.os.Bundle
import org.bspeice.minimalbible.R
import android.support.v7.widget.Toolbar
import org.bspeice.minimalbible.activity.BaseActivity
import android.widget.LinearLayout
/**
* Created by bspeice on 12/1/14.
*/
class MinimalBibleSettings() : PreferenceActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super<PreferenceActivity>.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.preferences)
setContentView(R.layout.activity_settings)
BaseActivity.setupStatusBar(this)
val toolbar = findViewById(R.id.toolbar) as Toolbar
toolbar.setTitle(R.string.action_settings)
val root = findViewById(R.id.container) as LinearLayout
BaseActivity.setupInsets(this, root)
}
}

View File

@ -14,11 +14,9 @@ import javax.inject.Singleton
*/
Singleton
open class BookManager() {
// Some extra books like to think they're installed, but trigger NPE all over the place...
val ignore = array("ERen_no", "ot1nt2");
open class BookManager(val ignore: List<String>) {
// TODO: Remove static reference to Books.installed()
open val installedBooks = Observable.from(Books.installed()!!.getBooks())
?.filter { !ignore.contains(it!!.getInitials()) }
?.cache() ?: throw NoBooksInstalledException()