update currency

feature/top10
Razmig Sarkissian 7 years ago
parent ed15e7e9e8
commit 06a5e63bfe
  1. 3
      app/src/main/java/net/pokeranalytics/android/ui/fragment/CurrenciesFragment.kt
  2. 23
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SettingsFragment.kt
  3. 1
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/SettingRow.kt

@ -1,5 +1,7 @@
package net.pokeranalytics.android.ui.fragment
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -83,6 +85,7 @@ class CurrenciesFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataS
// RowRepresentableDelegate
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
Preferences.setCurrencyCode((row as CurrencyRow).currency.currencyCode, this.context!!)
this.activity?.setResult(Activity.RESULT_OK)
this.activity?.finish()
}

@ -1,5 +1,7 @@
package net.pokeranalytics.android.ui.fragment
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -17,11 +19,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.URL
import net.pokeranalytics.android.util.openContactMail
import net.pokeranalytics.android.util.openPlayStorePage
import net.pokeranalytics.android.util.openUrl
import net.pokeranalytics.android.util.*
import java.util.*
class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, StaticRowRepresentableDataSource {
@ -39,11 +38,15 @@ class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Sta
fragment.arguments = bundle
return fragment
}
val REQUEST_CODE_CURRENCY : Int = 0
}
override fun stringForRow(row: RowRepresentable): String {
return when(row) {
SettingRow.VERSION -> BuildConfig.VERSION_NAME + if (BuildConfig.DEBUG) " DEBUG" else ""
SettingRow.CURRENCY -> Currency.getInstance(Preferences.getCurrencyLocale(this.parentActivity)).symbol
else -> ""
}
}
@ -60,6 +63,12 @@ class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Sta
initData()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == SettingsFragment.REQUEST_CODE_CURRENCY && resultCode == Activity.RESULT_OK) {
settingsAdapterRow.refreshRow(SettingRow.CURRENCY)
}
}
override fun adapterRows(): List<RowRepresentable>? {
val rows = ArrayList<RowRepresentable>()
rows.addAll(SettingRow.getRows())
@ -73,7 +82,9 @@ class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Sta
SettingRow.CONTACT_US -> parentActivity.openContactMail()
SettingRow.BUG_REPORT -> Toast.makeText(requireContext(), "Bug report", Toast.LENGTH_SHORT).show()
SettingRow.CURRENCY -> {
CurrenciesActivity.newInstance(requireContext())
val intent = Intent(context, CurrenciesActivity::class.java)
this.startActivityForResult(intent, SettingsFragment.REQUEST_CODE_CURRENCY)
// CurrenciesActivity.newInstance(requireContext())
}
SettingRow.FOLLOW_US -> {
when(position) {

@ -89,6 +89,7 @@ enum class SettingRow : RowRepresentable {
get() {
return when (this) {
VERSION -> RowViewType.TITLE_VALUE.ordinal
CURRENCY -> RowViewType.TITLE_VALUE.ordinal
FOLLOW_US -> RowViewType.ROW_FOLLOW_US.ordinal
else -> RowViewType.TITLE_ARROW.ordinal
}

Loading…
Cancel
Save