|
|
|
|
@ -9,6 +9,10 @@ import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_player.* |
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
import kotlinx.coroutines.GlobalScope |
|
|
|
|
import kotlinx.coroutines.delay |
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.model.realm.Comment |
|
|
|
|
import net.pokeranalytics.android.model.realm.Player |
|
|
|
|
@ -16,6 +20,7 @@ import net.pokeranalytics.android.ui.activity.ColorPickerActivity |
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.MediaActivity |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.showAlertDialog |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.PlayerRow |
|
|
|
|
@ -127,26 +132,15 @@ class PlayerDataFragment : EditableDataFragment(), StaticRowRepresentableDataSou |
|
|
|
|
super.onRowDeleted(row) |
|
|
|
|
when (row) { |
|
|
|
|
is Comment -> { |
|
|
|
|
if (!row.isValidForDelete(getRealm())) { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
player.deleteComment(row) |
|
|
|
|
rowRepresentableAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
if (!row.isValidForDelete(getRealm())) { |
|
|
|
|
val status = row.getDeleteStatus(requireContext(), getRealm()) |
|
|
|
|
val message = row.getFailedDeleteMessage(status) |
|
|
|
|
showAlertDialog(requireContext(), R.string.cf_entry_delete_popup_title, message, showCancelButton = true, positiveAction = { |
|
|
|
|
customField.deleteEntry(row) |
|
|
|
|
rowRepresentableAdapter.notifyDataSetChanged() |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
customField.deleteEntry(row) |
|
|
|
|
rowRepresentableAdapter.notifyDataSetChanged() |
|
|
|
|
if (row.isValidForDelete(getRealm())) { |
|
|
|
|
GlobalScope.launch(Dispatchers.Main) { |
|
|
|
|
delay(300) |
|
|
|
|
showAlertDialog(requireContext(), message = R.string.are_you_sure_you_want_to_delete, showCancelButton = true, positiveAction = { |
|
|
|
|
player.deleteComment(row) |
|
|
|
|
rowRepresentableAdapter.notifyDataSetChanged() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -201,4 +195,10 @@ class PlayerDataFragment : EditableDataFragment(), StaticRowRepresentableDataSou |
|
|
|
|
builder.show() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onDataSaved() { |
|
|
|
|
super.onDataSaved() |
|
|
|
|
player.cleanupComments() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |