parent
f824f352c1
commit
04fd7beb63
@ -0,0 +1,36 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment.components |
||||||
|
|
||||||
|
import android.os.Bundle |
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import io.realm.Realm |
||||||
|
|
||||||
|
open class RealmFragment : PokerAnalyticsFragment() { |
||||||
|
|
||||||
|
private var realm: Realm? = null |
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||||
|
realm = Realm.getDefaultInstance() |
||||||
|
return super.onCreateView(inflater, container, savedInstanceState) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onDestroyView() { |
||||||
|
super.onDestroyView() |
||||||
|
this.realm?.close() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the realm instance |
||||||
|
*/ |
||||||
|
fun getRealm(): Realm { |
||||||
|
this.realm?.let { |
||||||
|
return it |
||||||
|
} ?: run { |
||||||
|
val realm = Realm.getDefaultInstance() |
||||||
|
this.realm = realm |
||||||
|
return realm |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue