|
|
|
|
@ -10,7 +10,6 @@ import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.databinding.FragmentFilterDetailsBinding |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
|
import net.pokeranalytics.android.model.realm.Filter |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.RealmFragment |
|
|
|
|
@ -18,7 +17,6 @@ import net.pokeranalytics.android.ui.helpers.DateTimePickerManager |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
import net.pokeranalytics.android.ui.view.rows.* |
|
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
@ -92,7 +90,7 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
this.arguments?.let { bundle -> |
|
|
|
|
|
|
|
|
|
val filter = this.activityModel.currentFilter ?: throw PAIllegalStateException("Filter is null") |
|
|
|
|
val filter = this.activityModel.currentFilter |
|
|
|
|
val category = bundle.getInt(BundleKey.DATA_TYPE.value) |
|
|
|
|
val categoryRow = FilterCategoryRow.values()[category] |
|
|
|
|
Timber.d("Category row = $categoryRow") |
|
|
|
|
@ -102,7 +100,7 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
} ?: throw PAIllegalStateException("Missing bundle") |
|
|
|
|
|
|
|
|
|
Timber.d(">> Filter = ${this.activityModel.currentFilter}") |
|
|
|
|
// Timber.d(">> Filter = ${this.activityModel.currentFilter}") |
|
|
|
|
Timber.d("selectedRow = ${this.activityModel.selectedCategoryRow}") |
|
|
|
|
|
|
|
|
|
this.binding.toolbar.title = this.activityModel.selectedCategoryRow?.localizedTitle(requireContext()) |
|
|
|
|
@ -232,22 +230,22 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate { |
|
|
|
|
*/ |
|
|
|
|
private fun saveData() { |
|
|
|
|
|
|
|
|
|
// val currentFilter = this.activityModel.currentFilter |
|
|
|
|
val filter = this.activityModel.currentFilter |
|
|
|
|
|
|
|
|
|
this.activityModel.currentFilter?.id?.let { filterId -> |
|
|
|
|
// this.activityModel.currentFilter?.id?.let { filterId -> |
|
|
|
|
|
|
|
|
|
this.activityModel.selectedCategoryRow?.let { category -> |
|
|
|
|
|
|
|
|
|
getRealm().executeTransactionAsync { asyncRealm -> |
|
|
|
|
asyncRealm.findById<Filter>(filterId)?.let { filter -> |
|
|
|
|
// getRealm().executeTransactionAsync { asyncRealm -> |
|
|
|
|
// asyncRealm.findById<Filter>(filterId)?.let { filter -> |
|
|
|
|
filter.remove(category) |
|
|
|
|
val validConditions = this.model.selectedRows.filter { it.queryCondition != null } |
|
|
|
|
filter.createOrUpdateFilterConditions(validConditions) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// //TODO: Save currentFilter details data |
|
|
|
|
// Timber.d("Save data for queryWith: ${currentFilter?.id}") |
|
|
|
|
|