|
|
|
@ -1,15 +1,12 @@ |
|
|
|
package net.pokeranalytics.android.ui.adapter |
|
|
|
package net.pokeranalytics.android.ui.adapter |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.os.Handler |
|
|
|
|
|
|
|
import android.view.ViewGroup |
|
|
|
import android.view.ViewGroup |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import androidx.recyclerview.widget.DividerItemDecoration |
|
|
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import kotlinx.android.synthetic.main.fragment_settings.* |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.BindableHolder |
|
|
|
import net.pokeranalytics.android.ui.view.BindableHolder |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
|
|
|
|
|
|
|
interface RowRepresentableDataSource : DisplayableDataSource { |
|
|
|
interface RowRepresentableDataSource : DisplayableDataSource { |
|
|
|
@ -130,15 +127,18 @@ class RowRepresentableAdapter( |
|
|
|
* Refresh the row in the adapter |
|
|
|
* Refresh the row in the adapter |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun refreshRow(row: RowRepresentable) { |
|
|
|
fun refreshRow(row: RowRepresentable) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (row.viewType == RowViewType.TITLE_SWITCH.ordinal) { |
|
|
|
|
|
|
|
// Avoid to refresh the view because it will refresh itself |
|
|
|
|
|
|
|
// Caution if we want to update the title for example |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val index = this.dataSource.indexForRow(row) |
|
|
|
val index = this.dataSource.indexForRow(row) |
|
|
|
if (index >= 0) { |
|
|
|
if (index >= 0) { |
|
|
|
val handler = Handler() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handler.post { |
|
|
|
|
|
|
|
notifyItemChanged(index) |
|
|
|
notifyItemChanged(index) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Update UI |
|
|
|
* Update UI |
|
|
|
|