Cleans commented code

filterfix
Laurent 5 years ago
parent 6722ba2218
commit 7cd1117ce3
  1. 12
      app/src/main/java/net/pokeranalytics/android/model/realm/Filter.kt
  2. 91
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FilterDetailsFragment.kt
  3. 22
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FilterDetailsViewModel.kt
  4. 5
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FilterHandler.kt
  5. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FilterViewModel.kt
  6. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FiltersActivity.kt
  7. 17
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FiltersFragment.kt
  8. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FiltersListActivity.kt

@ -146,18 +146,6 @@ open class Filter : RealmObject(), RowRepresentable, Editable, Deletable, Counta
}
}
// /**
// * Get the saved value for the given [filterElementRow]
// */
// fun loadValueForElement(filterElementRow: QueryCondition) {
// val filtered = filterConditions.filter {
// it.queryCondition.id == filterElementRow.id
// }
// if (filtered.isNotEmpty()) {
// return filterElementRow.updateValueBy(filtered.first())
// }
// }
inline fun <reified T : Filterable> query(firstField: String? = null, vararg remainingFields: String): RealmQuery<T> {
val realmQuery = realm.where<T>()

@ -56,8 +56,6 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
override fun onBackPressed() {
super.onBackPressed()
saveData()
// requireFragmentManager().popBackStackImmediate("f1", 0)
// requireFragmentManager().popBackStackImmediate()
}
/**
@ -94,9 +92,6 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
} ?: throw PAIllegalStateException("Missing bundle")
//currentFilter = Filter.getFilterBydId(getRealm(), primaryKey)
// currentFilter = FiltersFragment.currentFilter
Timber.d(">> Filter = ${this.activityModel.currentFilter}")
Timber.d("selectedRow = ${this.activityModel.selectedCategoryRow}")
@ -132,9 +127,6 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
}
is QueryCondition.SingleValue<*>, is QueryCondition.ListOfValues<*> -> {
val valueAsString = (row as FilterItemRow).singleValue?.toString()
// row.list.firstOrNull()?.let {
// valueAsString = row.list.firstOrNull()?.toString()
// }
val data = row.editingDescriptors(mapOf("valueAsString" to valueAsString))
showBottomSheet(row, this, data, true)
}
@ -142,60 +134,6 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
}
}
// when (row) {
// is DateFilterItemRow -> {
// when (val condition = row.rawCondition) {
//
// }
// }
// is IntFilterItemRow -> {
// when (val condition = row.rawCondition) {
//
// }
// }
// is ValueListFilterItemRow<*> -> {
// when (row.rawCondition) {
//
// }
// }
// }
// (row as? BaseFilterItemRow)?.let { filterItemRow ->
// val rawCondition = filterItemRow.rawCondition
// when (rawCondition) {
// is QueryCondition.DateQuery -> DateTimePickerManager.create(
// requireContext(),
// row,
// this,
// filterItemRow.value,
// onlyDate = !row.showTime,
// onlyTime = row.showTime
// )
// is QueryCondition.Duration -> {
// val hours: String? = (row.minutes / 60).toString()
// val minutes: String? = (row.minutes % 60).toString()
//// row.minutes?.let {
//// hours = if (it / 60 > 0) (it / 60).toString() else null
//// minutes = if (it % 60 > 0) (it % 60).toString() else null
//// }
// val data = row.editingDescriptors(mapOf("hours" to hours, "minutes" to minutes))
// showBottomSheet(row, this, data, true)
// }
// is QueryCondition.ListOfValues<*> -> {
// var valueAsString: String? = null
// row.listOfValues.firstOrNull()?.let {
// valueAsString = row.listOfValues.firstOrNull()?.toString()
// }
// val data = row.editingDescriptors(mapOf("valueAsString" to valueAsString))
// showBottomSheet(row, this, data, true)
// }
// else -> { }
// }
//
// }
}
override fun onRowValueChanged(value: Any?, row: RowRepresentable) {
@ -246,33 +184,6 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
}
}
// when (row) {
// is QueryCondition.DateQuery -> {
// if (value != null && value is Date) {
// row.singleValue = value
// }
// }
// is QueryCondition.Duration -> {
// if (value is ArrayList<*>) {
//
// }
// }
// is QueryCondition.SingleInt -> {
// if (value != null && value is String) {
// row.singleValue = value.toInt()
// }
// }
// is QueryCondition.ListOfDouble -> row.listOfValues = arrayListOf<Double>().apply {
// if (value != null && value is String) this.add(value.toDouble())
// }
// is QueryCondition.ListOfInt -> row.listOfValues = arrayListOf<Int>().apply {
// if (value != null && value is String) this.add(value.toInt())
// }
// is QueryCondition.ListOfString -> row.listOfValues = arrayListOf<String>().apply {
// if (value != null && value is String) this.add(value)
// }
// }
// Remove the row before updating the selected rows list
this.model.selectedRows.remove(row as FilterItemRow)
updateRowsSelection(row, value == null)
@ -286,8 +197,6 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
this.model.updateRowsSelection(this.rowRepresentableAdapter, row, forceDeselection)
// println("list of selected rows : $selectedRows")
// Update UI
this.rowRepresentableAdapter.refreshRow(row)
}

@ -26,9 +26,6 @@ class FilterDetailsViewModel(categoryRow: FilterCategoryRow, var filter: Filter)
private var rows: ArrayList<RowRepresentable> = ArrayList()
val selectedRows = ArrayList<FilterItemRow>()
// private var rowsForFilterSubcategoryRow: HashMap<FilterSectionRow, ArrayList<RowRepresentable>> =
// HashMap()
init {
this.rows.addAll(categoryRow.filterElements)
this.defineSelectedItems()
@ -47,25 +44,6 @@ class FilterDetailsViewModel(categoryRow: FilterCategoryRow, var filter: Filter)
else -> super.charSequenceForRow(row, context, 0)
} ?: NULL_TEXT
// val filterItemRow = row as? BaseFilterItemRow
// filterItemRow?.let {
// return when (val condition = it.rawCondition) {
//// is QueryCondition.SingleValue<*> -> filter
// is QueryCondition.ListOfValues<*> -> {
// condition.firstValue(context) ?: NULL_TEXT
// }
// else -> super.charSequenceForRow(row, context, 0)
// }
// }
// return NULL_TEXT
// return when (row) {
// is BaseFilterItemRow -> {
//
// }
// is QueryCondition.ListOfValues<*> -> row.firstValue(context)
// else -> super.charSequenceForRow(row, context, 0)
// } ?: NULL_TEXT
}
override fun isSelected(position: Int, row: RowRepresentable, tag: Int): Boolean {

@ -34,6 +34,7 @@ enum class FilterableType(override var uniqueIdentifier: Int) : IntIdentifiable
}
interface FilterHandler {
companion object {
const val INTENT_FILTER_UPDATE_FILTER_UI = "net.pokeranalytics.android.UPDATE_FILTER_UI"
}
@ -55,8 +56,7 @@ interface FilterHandler {
// Send broadcast
val intent = Intent()
intent.action =
INTENT_FILTER_UPDATE_FILTER_UI
intent.action = INTENT_FILTER_UPDATE_FILTER_UI
context.sendBroadcast(intent)
}
@ -70,7 +70,6 @@ interface FilterHandler {
var currentFilterable: FilterableType
/**
* Manage filters
*/

@ -25,12 +25,6 @@ class FilterViewModel : ViewModel(), StaticRowRepresentableDataSource {
var isUpdating = false
// val filterCategoryRow: FilterCategoryRow
// get() {
// return this.selectedCategoryRow as FilterCategoryRow
// }
fun init(realm: Realm) {
if (this.currentFilter != null) { // can be called twice and we don't want that

@ -90,15 +90,9 @@ class FiltersActivity : BaseActivity() {
this.model.filterableType = FilterableType.valueByIdentifier(uniqueIdentifier)
val filtersFragment = FiltersFragment()
// val bundle = Bundle()
// bundle.putString(BaseFragment.BundleKey.PRIMARY_KEY.value, filterId)
// bundle.putInt(BaseFragment.BundleKey.DATA_TYPE.value, uniqueIdentifier)
// fragment.arguments = bundle
// fragment.setData(filterId, filterableType)
val fragmentTransaction = this.supportFragmentManager.beginTransaction()
fragmentTransaction.add(R.id.container, filtersFragment, Tag.CATEGORIES.identifier)
// fragmentTransaction.addToBackStack(null)
fragmentTransaction.commit()
filtersFragment.updateMostUsedFiltersVisibility(!hideMostUsedFilters)

@ -79,9 +79,6 @@ open class FiltersFragment : RealmFragment(), RowRepresentableDelegate {
this.model.selectedCategoryRow?.let {
rowRepresentableAdapter.refreshRow(it)
}
// this.rowRepresentableAdapter.notifyDataSetChanged()
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -133,12 +130,6 @@ open class FiltersFragment : RealmFragment(), RowRepresentableDelegate {
*/
private fun initData() {
// this.arguments?.let { bundle ->
// this.model.primaryKey = bundle.getString(BundleKey.PRIMARY_KEY.value)
// val type = bundle.getInt(BundleKey.DATA_TYPE.value)
// this.model.filterableType = FilterableType.valueByIdentifier(type)
// } ?: throw PAIllegalStateException("Missing bundle")
this.model.init(getRealm())
this.rowRepresentableAdapter = RowRepresentableAdapter(this.model, this)
@ -152,15 +143,7 @@ open class FiltersFragment : RealmFragment(), RowRepresentableDelegate {
val categoryRow = row as FilterCategoryRow
this.model.selectedCategoryRow = categoryRow
this.model.currentFilter?.let { _ ->
(activity as FiltersActivity).showDetailsFragment(categoryRow)
// this.model.filterCategoryRow = row as FilterCategoryRow
// FilterDetailsActivity.newInstanceForResult(
// this, filterId, (row as FilterCategoryRow).ordinal,
// REQUEST_CODE_FILTER_DETAILS
// )
}
}

@ -24,15 +24,6 @@ class FiltersListActivity : BaseActivity() {
companion object {
// fun newInstance(context: Context, dataType: Int) {
// context.startActivity(
// getIntent(
// context,
// dataType
// )
// )
// }
fun newSelectInstance(fragment: Fragment, showAddButton: Boolean = true) {
val context = fragment.requireContext()
fragment.startActivityForResult(
@ -74,8 +65,6 @@ class FiltersListActivity : BaseActivity() {
this.model.showAddButton = showAddButton
// fragment.setData(dataType)
// fragment.updateUI(showAddButton)
}
}
Loading…
Cancel
Save