|
|
|
@ -26,14 +26,18 @@ import net.pokeranalytics.android.ui.activity.components.RequestCode |
|
|
|
import net.pokeranalytics.android.ui.adapter.FeedSessionRowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.FeedSessionRowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.FeedTransactionRowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.FeedTransactionRowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.extensions.toByteArray |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.FilterableFragment |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.FilterableFragment |
|
|
|
import net.pokeranalytics.android.ui.interfaces.FilterActivityRequestCode |
|
|
|
import net.pokeranalytics.android.ui.interfaces.FilterActivityRequestCode |
|
|
|
import net.pokeranalytics.android.ui.interfaces.FilterableType |
|
|
|
import net.pokeranalytics.android.ui.interfaces.FilterableType |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager |
|
|
|
import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.handhistory.VideoView |
|
|
|
import net.pokeranalytics.android.util.Preferences |
|
|
|
import net.pokeranalytics.android.util.Preferences |
|
|
|
import net.pokeranalytics.android.util.billing.AppGuard |
|
|
|
import net.pokeranalytics.android.util.billing.AppGuard |
|
|
|
import net.pokeranalytics.android.util.extensions.count |
|
|
|
import net.pokeranalytics.android.util.extensions.count |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.video.MMediaMuxer |
|
|
|
|
|
|
|
import timber.log.Timber |
|
|
|
import java.text.SimpleDateFormat |
|
|
|
import java.text.SimpleDateFormat |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
@ -70,9 +74,13 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
private var selectedTransaction: Transaction? = null |
|
|
|
private var selectedTransaction: Transaction? = null |
|
|
|
private var selectedTransactionPosition: Int = -1 |
|
|
|
private var selectedTransactionPosition: Int = -1 |
|
|
|
|
|
|
|
|
|
|
|
override val observedEntities: List<Class<out RealmModel>> = listOf(Session::class.java, Transaction::class.java) |
|
|
|
override val observedEntities: List<Class<out RealmModel>> = |
|
|
|
|
|
|
|
listOf(Session::class.java, Transaction::class.java) |
|
|
|
|
|
|
|
|
|
|
|
override fun entitiesChanged(clazz: Class<out RealmModel>, results: RealmResults<out RealmModel>) { |
|
|
|
override fun entitiesChanged( |
|
|
|
|
|
|
|
clazz: Class<out RealmModel>, |
|
|
|
|
|
|
|
results: RealmResults<out RealmModel> |
|
|
|
|
|
|
|
) { |
|
|
|
super.entitiesChanged(clazz, results) |
|
|
|
super.entitiesChanged(clazz, results) |
|
|
|
|
|
|
|
|
|
|
|
when (clazz.kotlin) { |
|
|
|
when (clazz.kotlin) { |
|
|
|
@ -88,12 +96,20 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
override fun onCreateView( |
|
|
|
|
|
|
|
inflater: LayoutInflater, |
|
|
|
|
|
|
|
container: ViewGroup?, |
|
|
|
|
|
|
|
savedInstanceState: Bundle? |
|
|
|
|
|
|
|
): View? { |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
return inflater.inflate(R.layout.fragment_feed, container, false) |
|
|
|
return inflater.inflate(R.layout.fragment_feed, container, false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateContextMenu(menu: ContextMenu?, v: View?, menuInfo: ContextMenu.ContextMenuInfo?) { |
|
|
|
override fun onCreateContextMenu( |
|
|
|
|
|
|
|
menu: ContextMenu?, |
|
|
|
|
|
|
|
v: View?, |
|
|
|
|
|
|
|
menuInfo: ContextMenu.ContextMenuInfo? |
|
|
|
|
|
|
|
) { |
|
|
|
super.onCreateContextMenu(menu, v, menuInfo) |
|
|
|
super.onCreateContextMenu(menu, v, menuInfo) |
|
|
|
|
|
|
|
|
|
|
|
if (v?.id == R.id.menuRecyclerView) { |
|
|
|
if (v?.id == R.id.menuRecyclerView) { |
|
|
|
@ -168,6 +184,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
0 -> createNewSession(false) |
|
|
|
0 -> createNewSession(false) |
|
|
|
1 -> createNewSession(true) |
|
|
|
1 -> createNewSession(true) |
|
|
|
2 -> createNewTransaction() |
|
|
|
2 -> createNewTransaction() |
|
|
|
|
|
|
|
3 -> createNewHandHistory() |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (requestCode == RequestCode.FEED_TRANSACTION_DETAILS.value && resultCode == RESULT_OK && data != null) { |
|
|
|
} else if (requestCode == RequestCode.FEED_TRANSACTION_DETAILS.value && resultCode == RESULT_OK && data != null) { |
|
|
|
if (data.getStringExtra(DataListActivity.IntentKey.ITEM_DELETED.keyName) != null) { |
|
|
|
if (data.getStringExtra(DataListActivity.IntentKey.ITEM_DELETED.keyName) != null) { |
|
|
|
@ -175,7 +192,10 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (requestCode == FilterActivityRequestCode.CREATE_FILTER.ordinal && resultCode == RESULT_OK) { |
|
|
|
} else if (requestCode == FilterActivityRequestCode.CREATE_FILTER.ordinal && resultCode == RESULT_OK) { |
|
|
|
data?.let { |
|
|
|
data?.let { |
|
|
|
this.saveFilter(this.requireContext(), it.getStringExtra(FiltersActivity.IntentKey.FILTER_ID.keyName)) |
|
|
|
this.saveFilter( |
|
|
|
|
|
|
|
this.requireContext(), |
|
|
|
|
|
|
|
it.getStringExtra(FiltersActivity.IntentKey.FILTER_ID.keyName) |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (requestCode == RequestCode.NEW_TRANSACTION.value && resultCode == RESULT_OK) { |
|
|
|
} else if (requestCode == RequestCode.NEW_TRANSACTION.value && resultCode == RESULT_OK) { |
|
|
|
this.selectTab(Tab.TRANSACTIONS) |
|
|
|
this.selectTab(Tab.TRANSACTIONS) |
|
|
|
@ -192,7 +212,10 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
when (row) { |
|
|
|
when (row) { |
|
|
|
is Session -> SessionActivity.newInstance(requireContext(), sessionId = (row as Editable).id) |
|
|
|
is Session -> SessionActivity.newInstance( |
|
|
|
|
|
|
|
requireContext(), |
|
|
|
|
|
|
|
sessionId = (row as Editable).id |
|
|
|
|
|
|
|
) |
|
|
|
is Transaction -> { |
|
|
|
is Transaction -> { |
|
|
|
selectedTransaction = row |
|
|
|
selectedTransaction = row |
|
|
|
selectedTransactionPosition = position |
|
|
|
selectedTransactionPosition = position |
|
|
|
@ -215,7 +238,8 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
|
|
registerForContextMenu(this.menuRecyclerView) |
|
|
|
registerForContextMenu(this.menuRecyclerView) |
|
|
|
|
|
|
|
|
|
|
|
val messageToShow: Preferences.FeedMessage? = Preferences.feedMessageToShow(requireContext()) |
|
|
|
val messageToShow: Preferences.FeedMessage? = |
|
|
|
|
|
|
|
Preferences.feedMessageToShow(requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
if (messageToShow != null) { |
|
|
|
if (messageToShow != null) { |
|
|
|
messageBox.isVisible = true |
|
|
|
messageBox.isVisible = true |
|
|
|
@ -322,7 +346,8 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Transactions |
|
|
|
// Transactions |
|
|
|
this.realmTransactions = transactionFilter?.results() ?: run { getRealm().where<Transaction>().findAll() } |
|
|
|
this.realmTransactions = |
|
|
|
|
|
|
|
transactionFilter?.results() ?: run { getRealm().where<Transaction>().findAll() } |
|
|
|
this.realmTransactions = this.realmTransactions.sort("date", Sort.DESCENDING) |
|
|
|
this.realmTransactions = this.realmTransactions.sort("date", Sort.DESCENDING) |
|
|
|
|
|
|
|
|
|
|
|
var distinctDateTransactions = transactionFilter?.results("year", "month") ?: run { |
|
|
|
var distinctDateTransactions = transactionFilter?.results("year", "month") ?: run { |
|
|
|
@ -330,14 +355,22 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
distinctDateTransactions = distinctDateTransactions.sort("date", Sort.DESCENDING) |
|
|
|
distinctDateTransactions = distinctDateTransactions.sort("date", Sort.DESCENDING) |
|
|
|
this.feedTransactionAdapter = |
|
|
|
this.feedTransactionAdapter = |
|
|
|
FeedTransactionRowRepresentableAdapter(this, realmTransactions, distinctDateTransactions) |
|
|
|
FeedTransactionRowRepresentableAdapter( |
|
|
|
|
|
|
|
this, |
|
|
|
|
|
|
|
realmTransactions, |
|
|
|
|
|
|
|
distinctDateTransactions |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new cash game |
|
|
|
* Create a new cash game |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun createNewSession(isTournament: Boolean, sessionId: String? = null, duplicate: Boolean = false) { |
|
|
|
private fun createNewSession( |
|
|
|
|
|
|
|
isTournament: Boolean, |
|
|
|
|
|
|
|
sessionId: String? = null, |
|
|
|
|
|
|
|
duplicate: Boolean = false |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
val sessionCount = getRealm().count(Session::class.java) |
|
|
|
val sessionCount = getRealm().count(Session::class.java) |
|
|
|
if (!AppGuard.isProUser && sessionCount >= AppGuard.MAX_SESSIONS_BEFORE_REQUESTING_SUBSCRIPTION) { // && !BuildConfig.DEBUG |
|
|
|
if (!AppGuard.isProUser && sessionCount >= AppGuard.MAX_SESSIONS_BEFORE_REQUESTING_SUBSCRIPTION) { // && !BuildConfig.DEBUG |
|
|
|
@ -374,7 +407,56 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EditableDataActivity.newInstanceForResult(this, LiveData.TRANSACTION, null, RequestCode.NEW_TRANSACTION.value) |
|
|
|
EditableDataActivity.newInstanceForResult( |
|
|
|
|
|
|
|
this, |
|
|
|
|
|
|
|
LiveData.TRANSACTION, |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
RequestCode.NEW_TRANSACTION.value |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Create a new hand history |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun createNewHandHistory() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Timber.d("**** Start video test") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val testView = View(requireContext()) |
|
|
|
|
|
|
|
testView.setBackgroundColor(requireContext().getColor(R.color.blue)) |
|
|
|
|
|
|
|
testView.layoutParams = ViewGroup.LayoutParams(480, 480) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val videoView = VideoView(requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
videoView.let { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val muxer = MMediaMuxer() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Timber.d("width = ${it.width}, height = ${it.height}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val width = (it.width / 2) * 2 |
|
|
|
|
|
|
|
val height= (it.height / 2) * 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
muxer.Init(requireActivity(), width, height, "hhVideo", "YES!") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Timber.d("**** Adds frames") |
|
|
|
|
|
|
|
for (i in 0..50) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
val byteArray = it.toByteArray() |
|
|
|
|
|
|
|
muxer.AddFrame(byteArray) |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
Timber.e("error = ${e.message}") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Timber.d("**** Create video") |
|
|
|
|
|
|
|
muxer.CreateVideo() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val path = muxer.GetPath() |
|
|
|
|
|
|
|
Timber.d("**** Video path = $path") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -399,7 +481,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
).show() |
|
|
|
).show() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Filter Handler |
|
|
|
// Filter Handler |
|
|
|
|
|
|
|
|
|
|
|
override fun applyFilter() { |
|
|
|
override fun applyFilter() { |
|
|
|
super.applyFilter() |
|
|
|
super.applyFilter() |
|
|
|
|