Use newInstanceForResult

feature/top10
Aurelien Hubert 7 years ago
parent 071226c1c7
commit 8db673dd48
  1. 17
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SettingsFragment.kt

@ -20,7 +20,8 @@ import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.SettingRow
import net.pokeranalytics.android.util.*
import net.pokeranalytics.android.util.Preferences
import net.pokeranalytics.android.util.URL
import net.pokeranalytics.android.util.extensions.openContactMail
import net.pokeranalytics.android.util.extensions.openPlayStorePage
import net.pokeranalytics.android.util.extensions.openUrl
@ -43,17 +44,17 @@ class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Sta
return fragment
}
val rowRepresentation : List<RowRepresentable> by lazy {
val rowRepresentation: List<RowRepresentable> by lazy {
val rows = ArrayList<RowRepresentable>()
rows.addAll(SettingRow.getRows())
rows
}
val REQUEST_CODE_CURRENCY : Int = 0
val REQUEST_CODE_CURRENCY: Int = 0
}
override fun stringForRow(row: RowRepresentable): String {
return when(row) {
return when (row) {
SettingRow.VERSION -> BuildConfig.VERSION_NAME + if (BuildConfig.DEBUG) " DEBUG" else ""
SettingRow.CURRENCY -> Currency.getInstance(Preferences.getCurrencyLocale(this.parentActivity)).symbol
@ -89,13 +90,9 @@ class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Sta
SettingRow.RATE_APP -> parentActivity.openPlayStorePage()
SettingRow.CONTACT_US -> parentActivity.openContactMail(R.string.contact)
SettingRow.BUG_REPORT -> parentActivity.openContactMail(R.string.bug_report_subject)
SettingRow.CURRENCY -> {
val intent = Intent(context, CurrenciesActivity::class.java)
this.startActivityForResult(intent, SettingsFragment.REQUEST_CODE_CURRENCY)
// CurrenciesActivity.newInstance(requireContext())
}
SettingRow.CURRENCY -> CurrenciesActivity.newInstanceForResult(this@SettingsFragment, SettingsFragment.REQUEST_CODE_CURRENCY)
SettingRow.FOLLOW_US -> {
when(position) {
when (position) {
0 -> parentActivity.openUrl(URL.BLOG.value)
1 -> parentActivity.openUrl(URL.INSTAGRAM.value)
2 -> parentActivity.openUrl(URL.TWITTER.value)

Loading…
Cancel
Save