commit
71d2b9c0ec
@ -1,8 +0,0 @@ |
|||||||
package net.pokeranalytics.android.model.realm |
|
||||||
|
|
||||||
import io.realm.RealmObject |
|
||||||
|
|
||||||
open class FilterElementBlind(var sb : Double? = null, |
|
||||||
var bb : Double? = null, |
|
||||||
var currencyCode : String? = null |
|
||||||
) : RealmObject() |
|
||||||
@ -0,0 +1,33 @@ |
|||||||
|
package net.pokeranalytics.android.ui.activity |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.content.Intent |
||||||
|
import android.os.Bundle |
||||||
|
import androidx.fragment.app.Fragment |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||||
|
|
||||||
|
class ComparisonChartActivity : PokerAnalyticsActivity() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
fun newInstance(context: Context) { |
||||||
|
val intent = Intent(context, ComparisonChartActivity::class.java) |
||||||
|
context.startActivity(intent) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new instance for result |
||||||
|
*/ |
||||||
|
fun newInstanceForResult(fragment: Fragment, requestCode: Int) { |
||||||
|
val intent = Intent(fragment.requireContext(), ComparisonChartActivity::class.java) |
||||||
|
fragment.startActivityForResult(intent, requestCode) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
|
super.onCreate(savedInstanceState) |
||||||
|
setContentView(R.layout.activity_comparison_chart) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,80 @@ |
|||||||
|
package net.pokeranalytics.android.ui.adapter |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.util.SparseArray |
||||||
|
import android.view.ViewGroup |
||||||
|
import androidx.fragment.app.FragmentManager |
||||||
|
import androidx.fragment.app.FragmentStatePagerAdapter |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.fragment.* |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
||||||
|
import java.lang.ref.WeakReference |
||||||
|
|
||||||
|
/** |
||||||
|
* Comparison Chart Pager Adapter |
||||||
|
*/ |
||||||
|
class ComparisonChartPagerAdapter(val context: Context, fragmentManager: FragmentManager) : FragmentStatePagerAdapter(fragmentManager) { |
||||||
|
|
||||||
|
var weakReferences = SparseArray<WeakReference<PokerAnalyticsFragment>>() |
||||||
|
|
||||||
|
override fun getItem(position: Int): PokerAnalyticsFragment { |
||||||
|
return when (position) { |
||||||
|
0 -> GraphFragment() |
||||||
|
1 -> GraphFragment() |
||||||
|
2 -> CalendarFragment.newInstance() |
||||||
|
else -> HistoryFragment.newInstance() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun getCount(): Int { |
||||||
|
return 3 |
||||||
|
} |
||||||
|
|
||||||
|
override fun getPageTitle(position: Int): CharSequence? { |
||||||
|
return when(position) { |
||||||
|
0 -> context.getString(R.string.bar) |
||||||
|
1 -> context.getString(R.string.line) |
||||||
|
2-> context.getString(R.string.table) |
||||||
|
else -> super.getPageTitle(position) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { |
||||||
|
super.destroyItem(container, position, `object`) |
||||||
|
weakReferences.remove(position) |
||||||
|
} |
||||||
|
|
||||||
|
override fun instantiateItem(container: ViewGroup, position: Int): Any { |
||||||
|
val fragment = super.instantiateItem(container, position) as PokerAnalyticsFragment |
||||||
|
weakReferences.put(position, WeakReference(fragment)) |
||||||
|
return fragment |
||||||
|
} |
||||||
|
|
||||||
|
override fun getItemPosition(obj: Any): Int { |
||||||
|
return when (obj) { |
||||||
|
//CLEAN |
||||||
|
/* |
||||||
|
HistoryFragment::class.java -> 0 |
||||||
|
StatsFragment::class.java -> 1 |
||||||
|
SettingsFragment::class.java -> 2 |
||||||
|
*/ |
||||||
|
HistoryFragment::class.java -> 0 |
||||||
|
StatsFragment::class.java -> 1 |
||||||
|
CalendarFragment::class.java -> 2 |
||||||
|
ReportsFragment::class.java -> 3 |
||||||
|
MoreFragment::class.java -> 4 |
||||||
|
else -> -1 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the fragment at the position key |
||||||
|
*/ |
||||||
|
fun getFragment(key: Int): PokerAnalyticsFragment? { |
||||||
|
if (weakReferences.get(key) != null) { |
||||||
|
return weakReferences.get(key).get() |
||||||
|
} |
||||||
|
return null |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,100 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment |
||||||
|
|
||||||
|
import android.os.Bundle |
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import kotlinx.android.synthetic.main.fragment_comparison_chart.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.activity.BankrollActivity |
||||||
|
import net.pokeranalytics.android.ui.activity.SettingsActivity |
||||||
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||||
|
import net.pokeranalytics.android.ui.adapter.ComparisonChartPagerAdapter |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
||||||
|
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.MoreTabRow |
||||||
|
|
||||||
|
class ComparisonChartFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate { |
||||||
|
|
||||||
|
companion object { |
||||||
|
|
||||||
|
/** |
||||||
|
* Create new instance |
||||||
|
*/ |
||||||
|
fun newInstance(): ComparisonChartFragment { |
||||||
|
val fragment = ComparisonChartFragment() |
||||||
|
val bundle = Bundle() |
||||||
|
fragment.arguments = bundle |
||||||
|
return fragment |
||||||
|
} |
||||||
|
|
||||||
|
val rowRepresentation: List<RowRepresentable> by lazy { |
||||||
|
val rows = ArrayList<RowRepresentable>() |
||||||
|
rows.addAll(MoreTabRow.values()) |
||||||
|
rows |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private lateinit var parentActivity: PokerAnalyticsActivity |
||||||
|
private lateinit var viewPagerAdapter: ComparisonChartPagerAdapter |
||||||
|
|
||||||
|
|
||||||
|
// Life Cycle |
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||||
|
return inflater.inflate(R.layout.fragment_comparison_chart, container, false) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||||
|
super.onViewCreated(view, savedInstanceState) |
||||||
|
initData() |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
// Rows |
||||||
|
override fun adapterRows(): List<RowRepresentable>? { |
||||||
|
return rowRepresentation |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
||||||
|
super.onRowSelected(position, row, fromAction) |
||||||
|
when(row) { |
||||||
|
MoreTabRow.BANKROLL -> BankrollActivity.newInstance(requireContext()) |
||||||
|
MoreTabRow.SETTINGS -> SettingsActivity.newInstance(requireContext()) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Business |
||||||
|
|
||||||
|
/** |
||||||
|
* Init data |
||||||
|
*/ |
||||||
|
private fun initData() { |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
parentActivity = activity as PokerAnalyticsActivity |
||||||
|
|
||||||
|
toolbar.title = "" |
||||||
|
|
||||||
|
parentActivity.setSupportActionBar(toolbar) |
||||||
|
parentActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
||||||
|
setHasOptionsMenu(true) |
||||||
|
|
||||||
|
toolbar.title = "Comparison chart" |
||||||
|
|
||||||
|
viewPagerAdapter = ComparisonChartPagerAdapter(requireContext(), parentActivity.supportFragmentManager) |
||||||
|
viewPager.adapter = viewPagerAdapter |
||||||
|
|
||||||
|
tabs.setupWithViewPager(viewPager) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,64 +0,0 @@ |
|||||||
package net.pokeranalytics.android.util |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import net.pokeranalytics.android.model.realm.Bankroll |
|
||||||
import java.text.NumberFormat |
|
||||||
import java.util.* |
|
||||||
|
|
||||||
class CurrencyUtils { |
|
||||||
|
|
||||||
companion object { |
|
||||||
|
|
||||||
/** |
|
||||||
* return the currency associated with this bankroll |
|
||||||
*/ |
|
||||||
fun getCurrency(bankroll: Bankroll? = null) : Currency { |
|
||||||
val currencyCode = bankroll?.currency?.code ?: CurrencyUtils.getLocaleCurrency().currencyCode |
|
||||||
return Currency.getInstance(currencyCode) |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get a currency formatter |
|
||||||
*/ |
|
||||||
fun getCurrencyFormatter(context: Context, currency: Currency? = null) : NumberFormat { |
|
||||||
val currencyFormatter = NumberFormat.getCurrencyInstance(Preferences.getCurrencyLocale(context)) |
|
||||||
currency?.let { |
|
||||||
currencyFormatter.currency = it |
|
||||||
} |
|
||||||
currencyFormatter.minimumFractionDigits = 0 |
|
||||||
currencyFormatter.maximumFractionDigits = 2 |
|
||||||
return currencyFormatter |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get a currency rate formatter |
|
||||||
*/ |
|
||||||
fun getCurrencyRateFormatter() : NumberFormat { |
|
||||||
val currencyFormatter = NumberFormat.getInstance() |
|
||||||
currencyFormatter.minimumFractionDigits = 0 |
|
||||||
currencyFormatter.maximumFractionDigits = 6 |
|
||||||
return currencyFormatter |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the locale currency, or en_US if there |
|
||||||
*/ |
|
||||||
fun getLocaleCurrency() : Currency { |
|
||||||
return try { |
|
||||||
Currency.getInstance(Locale.getDefault()) |
|
||||||
} catch (ex: Exception) { |
|
||||||
when (Locale.getDefault().language) { |
|
||||||
"en" -> Currency.getInstance(Locale("en", "US")) |
|
||||||
"fr" -> Currency.getInstance(Locale("fr", "FR")) |
|
||||||
"es" -> Currency.getInstance(Locale("es", "ES")) |
|
||||||
"de" -> Currency.getInstance(Locale("de", "DE")) |
|
||||||
"ja" -> Currency.getInstance(Locale("ja", "JP")) |
|
||||||
"zh" -> Currency.getInstance(Locale("zh", "CN")) |
|
||||||
else -> Currency.getInstance(Locale("en", "US")) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,15 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
|
android:orientation="vertical"> |
||||||
|
|
||||||
|
<fragment |
||||||
|
android:id="@+id/comparisonChartFragment" |
||||||
|
android:name="net.pokeranalytics.android.ui.fragment.ComparisonChartFragment" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
tools:layout="@layout/fragment_comparison_chart" /> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
@ -1,8 +1,26 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<FrameLayout |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
xmlns:android="http://schemas.android.com/apk/res/android" |
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
android:id="@+id/container" |
xmlns:tools="http://schemas.android.com/tools" |
||||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||||
android:layout_height="match_parent"> |
android:layout_height="match_parent"> |
||||||
|
|
||||||
</FrameLayout> |
<androidx.appcompat.widget.Toolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?attr/actionBarSize" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" |
||||||
|
tools:title="@string/app_name" /> |
||||||
|
|
||||||
|
<FrameLayout |
||||||
|
android:id="@+id/container" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="0dp" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@+id/toolbar" /> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
|
|||||||
@ -0,0 +1,57 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout |
||||||
|
android:id="@+id/appBar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:theme="@style/PokerAnalyticsTheme.Toolbar.Session" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent"> |
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?attr/actionBarSize" |
||||||
|
app:layout_collapseMode="pin" |
||||||
|
app:titleTextColor="@color/white" |
||||||
|
tools:title="Poker Analytics" /> |
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabLayout |
||||||
|
android:id="@+id/tabs" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content"> |
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:text="@string/bar" /> |
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:text="@string/line" /> |
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:text="@string/table" /> |
||||||
|
|
||||||
|
</com.google.android.material.tabs.TabLayout> |
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout> |
||||||
|
|
||||||
|
<androidx.viewpager.widget.ViewPager |
||||||
|
android:id="@+id/viewPager" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="0dp" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@+id/appBar" /> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
Loading…
Reference in new issue