Minor changes. Also fix #240
This commit is contained in:
@@ -9,7 +9,6 @@ import android.view.View
|
||||
import android.widget.TextView
|
||||
import eu.kanade.tachiyomi.App
|
||||
import eu.kanade.tachiyomi.R
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
open class BaseActivity : AppCompatActivity() {
|
||||
|
||||
@@ -51,14 +50,6 @@ open class BaseActivity : AppCompatActivity() {
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
fun registerForEvents() {
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
fun unregisterForEvents() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
fun snack(text: String?, duration: Int = Snackbar.LENGTH_LONG) {
|
||||
val snack = Snackbar.make(findViewById(android.R.id.content)!!, text ?: getString(R.string.unknown_error), duration)
|
||||
val textView = snack.view.findViewById(android.support.design.R.id.snackbar_text) as TextView
|
||||
|
||||
@@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.base.fragment
|
||||
|
||||
import android.support.v4.app.Fragment
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
open class BaseFragment : Fragment() {
|
||||
|
||||
@@ -17,12 +16,4 @@ open class BaseFragment : Fragment() {
|
||||
val baseActivity: BaseActivity
|
||||
get() = activity as BaseActivity
|
||||
|
||||
fun registerForEvents() {
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
fun unregisterForEvents() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,21 +2,12 @@ package eu.kanade.tachiyomi.ui.base.presenter
|
||||
|
||||
import android.content.Context
|
||||
import nucleus.view.ViewWithPresenter
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import rx.Observable
|
||||
|
||||
open class BasePresenter<V : ViewWithPresenter<*>> : RxPresenter<V>() {
|
||||
|
||||
lateinit var context: Context
|
||||
|
||||
fun registerForEvents() {
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
fun unregisterForEvents() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeFirst(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit)? = null)
|
||||
= compose(deliverFirst<T>()).subscribe(split(onNext, onError))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user