|
|
|
@ -57,54 +57,6 @@ interface FilterHandler { |
|
|
|
* Manage filters |
|
|
|
* Manage filters |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun manageFilters(fragment: Fragment) { |
|
|
|
fun manageFilters(fragment: Fragment) { |
|
|
|
|
|
|
|
|
|
|
|
val context = fragment.requireContext() |
|
|
|
|
|
|
|
val filterId = Preferences.getActiveFilterId(context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FiltersActivity.newInstanceForResult(fragment = fragment, currentFilterable = currentFilterable) |
|
|
|
FiltersActivity.newInstanceForResult(fragment = fragment, currentFilterable = currentFilterable) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Clean |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
val filterSelected = filterId != null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
val count = realm.where<Filter>().count().toInt() |
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val choices = ArrayList<CharSequence>() |
|
|
|
|
|
|
|
choices.add(fragment.getString(R.string.new_str)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (count > 0) { |
|
|
|
|
|
|
|
choices.add(fragment.getString(R.string.load_from_db)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (filterSelected) { |
|
|
|
|
|
|
|
choices.add(fragment.getString(R.string.modify_current_filter)) |
|
|
|
|
|
|
|
choices.add(fragment.getString(R.string.remove_filter)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val builder = AlertDialog.Builder(context) |
|
|
|
|
|
|
|
builder.setTitle(R.string.filter_selection) |
|
|
|
|
|
|
|
.setCancelable(true) |
|
|
|
|
|
|
|
.setItems(choices.toTypedArray()) { _, which -> |
|
|
|
|
|
|
|
Timber.d("Click on $which") |
|
|
|
|
|
|
|
when (which) { |
|
|
|
|
|
|
|
0 -> FiltersActivity.newInstanceForResult(fragment = fragment, currentFilterable = currentFilterable) |
|
|
|
|
|
|
|
1 -> DataListActivity.newSelectInstance(fragment, LiveData.FILTER.ordinal) |
|
|
|
|
|
|
|
2 -> FiltersActivity.newInstanceForResult(fragment = fragment, filterId = filterId, currentFilterable = currentFilterable) |
|
|
|
|
|
|
|
3 -> { |
|
|
|
|
|
|
|
Preferences.removeActiveFilterId(context) |
|
|
|
|
|
|
|
filterWasUpdated = true |
|
|
|
|
|
|
|
removeFilter() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.setNegativeButton(R.string.cancel) { _, _ -> |
|
|
|
|
|
|
|
Timber.d("Click on cancel") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
builder.show() |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |