Fix recent crashes

This commit is contained in:
len 2016-04-30 01:44:53 +02:00
parent 47bc1f7a9f
commit 49628e9cf5
5 changed files with 14 additions and 15 deletions

View file

@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.activity.ActivityMixin
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
import eu.kanade.tachiyomi.util.toast import eu.kanade.tachiyomi.util.toast
import kotlinx.android.synthetic.main.fragment_backup.* import kotlinx.android.synthetic.main.fragment_backup.*
@ -40,7 +41,7 @@ class BackupFragment : BaseRxFragment<BackupPresenter>() {
} }
override fun onViewCreated(view: View, savedState: Bundle?) { override fun onViewCreated(view: View, savedState: Bundle?) {
baseActivity.requestPermissionsOnMarshmallow() (activity as ActivityMixin).requestPermissionsOnMarshmallow()
subscriptions = SubscriptionList() subscriptions = SubscriptionList()
backup_button.setOnClickListener { backup_button.setOnClickListener {

View file

@ -1,22 +1,19 @@
package eu.kanade.tachiyomi.ui.base.fragment package eu.kanade.tachiyomi.ui.base.fragment
import android.support.v4.app.FragmentActivity import android.support.v7.app.AppCompatActivity
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity import eu.kanade.tachiyomi.ui.base.activity.ActivityMixin
interface FragmentMixin { interface FragmentMixin {
fun setToolbarTitle(title: String) { fun setToolbarTitle(title: String) {
baseActivity.setToolbarTitle(title) (getActivity() as ActivityMixin).setToolbarTitle(title)
} }
fun setToolbarTitle(resourceId: Int) { fun setToolbarTitle(resourceId: Int) {
baseActivity.setToolbarTitle(getString(resourceId)) (getActivity() as ActivityMixin).setToolbarTitle(getString(resourceId))
} }
val baseActivity: BaseActivity fun getActivity(): AppCompatActivity
get() = getActivity() as BaseActivity
fun getActivity(): FragmentActivity
fun getString(resource: Int): String fun getString(resource: Int): String
} }

View file

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.catalogue
import android.content.res.Configuration import android.content.res.Configuration
import android.os.Bundle import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.GridLayoutManager import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.SearchView import android.support.v7.widget.SearchView
import android.support.v7.widget.Toolbar import android.support.v7.widget.Toolbar
@ -161,7 +162,7 @@ class CatalogueFragment : BaseRxFragment<CataloguePresenter>(), FlexibleViewHold
switcher.outAnimation = AnimationUtils.loadAnimation(activity, android.R.anim.fade_out) switcher.outAnimation = AnimationUtils.loadAnimation(activity, android.R.anim.fade_out)
// Create toolbar spinner // Create toolbar spinner
val themedContext = baseActivity.supportActionBar?.themedContext ?: activity val themedContext = activity.supportActionBar?.themedContext ?: activity
val spinnerAdapter = ArrayAdapter(themedContext, val spinnerAdapter = ArrayAdapter(themedContext,
android.R.layout.simple_spinner_item, presenter.sources) android.R.layout.simple_spinner_item, presenter.sources)

View file

@ -413,7 +413,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
*/ */
fun createActionModeIfNeeded() { fun createActionModeIfNeeded() {
if (actionMode == null) { if (actionMode == null) {
actionMode = baseActivity.startSupportActionMode(this) actionMode = activity.startSupportActionMode(this)
} }
} }

View file

@ -369,7 +369,7 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
override fun onListItemLongClick(position: Int) { override fun onListItemLongClick(position: Int) {
if (actionMode == null) if (actionMode == null)
actionMode = baseActivity.startSupportActionMode(this) actionMode = activity.startSupportActionMode(this)
toggleSelection(position) toggleSelection(position)
} }
@ -391,10 +391,10 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
} }
fun setReadFilter() { fun setReadFilter() {
this.activity.supportInvalidateOptionsMenu() activity.supportInvalidateOptionsMenu()
} }
fun setDownloadedFilter() { fun setDownloadedFilter() {
this.activity.supportInvalidateOptionsMenu() activity.supportInvalidateOptionsMenu()
} }
} }