|
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.adapter |
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
@ -56,7 +55,7 @@ class FeedTransactionRowRepresentableAdapter( |
|
|
|
|
* Display a header |
|
|
|
|
*/ |
|
|
|
|
inner class HeaderTitleViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
|
fun bind(position: Int, title: String, adapter: FeedTransactionRowRepresentableAdapter) { |
|
|
|
|
fun bind(title: String) { |
|
|
|
|
// Title |
|
|
|
|
itemView.findViewById<AppCompatTextView>(R.id.title)?.let { |
|
|
|
|
it.text = title |
|
|
|
|
@ -65,12 +64,12 @@ class FeedTransactionRowRepresentableAdapter( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { |
|
|
|
|
if (viewType == RowViewType.ROW_TRANSACTION.ordinal) { |
|
|
|
|
return if (viewType == RowViewType.ROW_TRANSACTION.ordinal) { |
|
|
|
|
val layout = LayoutInflater.from(parent.context).inflate(R.layout.row_transaction, parent, false) |
|
|
|
|
return RowTransactionViewHolder(layout) |
|
|
|
|
RowTransactionViewHolder(layout) |
|
|
|
|
} else { |
|
|
|
|
val layout = LayoutInflater.from(parent.context).inflate(R.layout.row_header_title, parent, false) |
|
|
|
|
return HeaderTitleViewHolder(layout) |
|
|
|
|
HeaderTitleViewHolder(layout) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -92,14 +91,14 @@ class FeedTransactionRowRepresentableAdapter( |
|
|
|
|
if (holder is RowTransactionViewHolder) { |
|
|
|
|
holder.bind(position, getTransactionForPosition(position), this) |
|
|
|
|
} else if (holder is HeaderTitleViewHolder) { |
|
|
|
|
holder.bind(position, getHeaderForPosition(holder.itemView.context, position), this) |
|
|
|
|
holder.bind(getHeaderForPosition(position)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the header |
|
|
|
|
*/ |
|
|
|
|
private fun getHeaderForPosition(context: Context, position: Int): String { |
|
|
|
|
private fun getHeaderForPosition(position: Int): String { |
|
|
|
|
if (sortedHeaders.containsKey(position)) { |
|
|
|
|
val realmHeaderPosition = sortedHeaders.keys.indexOf(position) |
|
|
|
|
return distinctTransactionsHeaders[realmHeaderPosition]?.date?.getMonthAndYear() ?: "" |
|
|
|
|
|