aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt
blob: cb3bb7130c106d826d69bc1f76df166f0a9b54b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.pitchedapps.frost.fragments

import android.content.Context
import android.support.v4.app.Fragment
import com.pitchedapps.frost.utils.KeyPairObservable
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.putInt
import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer

/**
 * Created by Allan Wang on 2017-05-29.
 */
interface BaseFragmentContract {
    fun onBackPressed(): Boolean
}

abstract class BaseFragment : Fragment(), BaseFragmentContract {
    val position: Int by lazy { arguments.getInt(ARG_POSITION) }

    companion object {
        val ARG_POSITION = "arg_position"

        fun <T : BaseFragment> newInstance(fragment: T, position: Int): T {
            fragment.putInt(ARG_POSITION, position)
            return fragment
        }
    }

}