Twidere-App-Android-Twitter.../twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseSupportFragment.kt

92 lines
2.9 KiB
Kotlin
Raw Normal View History

2016-06-29 15:47:52 +02:00
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.fragment
import android.content.Context
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.text.BidiFormatter
import com.squareup.otto.Bus
import org.mariotaku.twidere.fragment.iface.IBaseFragment
import org.mariotaku.twidere.util.*
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
import javax.inject.Inject
open class BaseSupportFragment : Fragment(), IBaseFragment<BaseSupportFragment> {
2016-06-29 15:47:52 +02:00
// Utility classes
@Inject
lateinit var twitterWrapper: AsyncTwitterWrapper
@Inject
lateinit var readStateManager: ReadStateManager
@Inject
lateinit var mediaLoader: MediaLoaderWrapper
@Inject
lateinit var bus: Bus
@Inject
lateinit var asyncTaskManager: AsyncTaskManager
@Inject
lateinit var multiSelectManager: MultiSelectManager
@Inject
lateinit var userColorNameManager: UserColorNameManager
@Inject
lateinit var preferences: SharedPreferencesWrapper
@Inject
lateinit var notificationManager: NotificationManagerWrapper
@Inject
lateinit var bidiFormatter: BidiFormatter
@Inject
lateinit var errorInfoStore: ErrorInfoStore
@Inject
lateinit var validator: TwidereValidator
private val actionHelper = IBaseFragment.ActionHelper(this)
override fun onViewStateRestored(savedInstanceState: Bundle?) {
super.onViewStateRestored(savedInstanceState)
requestFitSystemWindows()
}
override fun onAttach(context: Context?) {
super.onAttach(context)
GeneralComponentHelper.build(context!!).inject(this)
}
override fun executeAfterFragmentResumed(useHandler: Boolean, action: (BaseSupportFragment) -> Unit) {
2016-12-28 07:08:17 +01:00
actionHelper.executeAfterFragmentResumed(useHandler, action)
2016-06-29 15:47:52 +02:00
}
override fun onResume() {
super.onResume()
actionHelper.dispatchOnResumeFragments()
}
2016-07-06 15:21:34 +02:00
override fun onPause() {
actionHelper.dispatchOnPause()
super.onPause()
}
2016-06-29 15:47:52 +02:00
override fun onDestroy() {
super.onDestroy()
DebugModeUtils.watchReferenceLeak(this)
}
}