diff --git a/app/src/main/java/com/yacgroup/yacguide/RockActivity.kt b/app/src/main/java/com/yacgroup/yacguide/RockActivity.kt index 98df0049..da6e2ffc 100644 --- a/app/src/main/java/com/yacgroup/yacguide/RockActivity.kt +++ b/app/src/main/java/com/yacgroup/yacguide/RockActivity.kt @@ -40,13 +40,13 @@ class RockActivity : TableActivityWithOptionsMenu() { private var _onlyOfficialSummits: Boolean = false private var _rockNamePart: String = "" private var _filterName: String = "" - private var _filterMaxRelevanceId: Int = RockComment.RELEVANCE_NONE + private var _filterMaxRelevanceId: Int = RockComment.NO_INFO_ID override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) _filterName = intent.getStringExtra(IntentConstants.FILTER_NAME).orEmpty() - _filterMaxRelevanceId = intent.getIntExtra(IntentConstants.FILTER_RELEVANCE, RockComment.RELEVANCE_NONE) + _filterMaxRelevanceId = intent.getIntExtra(IntentConstants.FILTER_RELEVANCE, RockComment.NO_INFO_ID) properties = arrayListOf( RouteSearchable(this), @@ -136,7 +136,7 @@ class RockActivity : TableActivityWithOptionsMenu() { if (_filterName.isEmpty()) null else rockGetter.getByName().toSet() val relevanceFilteredRocks = - if (_filterMaxRelevanceId == RockComment.RELEVANCE_NONE) null + if (_filterMaxRelevanceId == RockComment.NO_INFO_ID) null else rockGetter.getByRelevance().toSet() listOfNotNull(nameFilteredRocks, relevanceFilteredRocks).reduce { intersection, filteredRocks -> intersection.intersect(filteredRocks) diff --git a/app/src/main/java/com/yacgroup/yacguide/RouteActivity.kt b/app/src/main/java/com/yacgroup/yacguide/RouteActivity.kt index 47439148..f086998a 100644 --- a/app/src/main/java/com/yacgroup/yacguide/RouteActivity.kt +++ b/app/src/main/java/com/yacgroup/yacguide/RouteActivity.kt @@ -43,8 +43,9 @@ class RouteActivity : TableActivityWithOptionsMenu() { private var _onlyOfficialRoutes: Boolean = false private var _routeNamePart: String = "" private var _filterName: String = "" - private var _filterMaxQualityId: Int = RouteComment.QUALITY_NONE - private var _filterMaxProtectionId: Int = RouteComment.PROTECTION_NONE + private var _filterMaxQualityId: Int = RouteComment.NO_INFO_ID + private var _filterMaxProtectionId: Int = RouteComment.NO_INFO_ID + private var _filterMaxDryingId: Int = RouteComment.NO_INFO_ID private var _filterProjects: Boolean = false private var _filterBotches: Boolean = false private var _rock: Rock? = null @@ -53,8 +54,9 @@ class RouteActivity : TableActivityWithOptionsMenu() { super.onCreate(savedInstanceState) _filterName = intent.getStringExtra(IntentConstants.FILTER_NAME).orEmpty() - _filterMaxQualityId = intent.getIntExtra(IntentConstants.FILTER_RELEVANCE, RouteComment.QUALITY_NONE) - _filterMaxProtectionId = intent.getIntExtra(IntentConstants.FILTER_PROTECTION, RouteComment.PROTECTION_NONE) + _filterMaxQualityId = intent.getIntExtra(IntentConstants.FILTER_RELEVANCE, RouteComment.NO_INFO_ID) + _filterMaxProtectionId = intent.getIntExtra(IntentConstants.FILTER_PROTECTION, RouteComment.NO_INFO_ID) + _filterMaxDryingId = intent.getIntExtra(IntentConstants.FILTER_DRYING, RouteComment.NO_INFO_ID) _filterProjects = intent.getBooleanExtra(IntentConstants.FILTER_PROJECTS, false) _filterBotches = intent.getBooleanExtra(IntentConstants.FILTER_BOTCHES, false) @@ -69,6 +71,7 @@ class RouteActivity : TableActivityWithOptionsMenu() { getByName = { db.getRoutesByName(_filterName) }, getByQuality = { db.getRoutesByQuality(_filterMaxQualityId) }, getByProtection = { db.getRoutesByProtection(_filterMaxProtectionId) }, + getByDrying = { db.getRoutesByDrying(_filterMaxDryingId) }, getProjects = { db.getProjectedRoutes() }, getBotches = { db.getBotchedRoutes() } ), @@ -77,6 +80,7 @@ class RouteActivity : TableActivityWithOptionsMenu() { getByName = { db.getRoutesByNameForCountry(activityLevel.parentName, _filterName) }, getByQuality = { db.getRoutesByQualityForCountry(activityLevel.parentName, _filterMaxQualityId) }, getByProtection = { db.getRoutesByProtectionForCountry(activityLevel.parentName, _filterMaxProtectionId) }, + getByDrying = { db.getRoutesByDryingForCountry(activityLevel.parentName, _filterMaxDryingId) }, getProjects = { db.getProjectedRoutesForCountry(activityLevel.parentName) }, getBotches = { db.getBotchedRoutesForCountry(activityLevel.parentName) } ), @@ -85,6 +89,7 @@ class RouteActivity : TableActivityWithOptionsMenu() { getByName = { db.getRoutesByNameForRegion(activityLevel.parentId, _filterName) }, getByQuality = { db.getRoutesByQualityForRegion(activityLevel.parentId, _filterMaxQualityId) }, getByProtection = { db.getRoutesByProtectionForRegion(activityLevel.parentId, _filterMaxProtectionId) }, + getByDrying = { db.getRoutesByDryingForRegion(activityLevel.parentId, _filterMaxDryingId) }, getProjects = { db.getProjectedRoutesForRegion(activityLevel.parentId) }, getBotches = { db.getBotchedRoutesForRegion(activityLevel.parentId) } ), @@ -93,6 +98,7 @@ class RouteActivity : TableActivityWithOptionsMenu() { getByName = { db.getRoutesByNameForSector(activityLevel.parentId, _filterName) }, getByQuality = { db.getRoutesByQualityForSector(activityLevel.parentId, _filterMaxQualityId) }, getByProtection = { db.getRoutesByProtectionForSector(activityLevel.parentId, _filterMaxProtectionId) }, + getByDrying = { db.getRoutesByDryingForSector(activityLevel.parentId, _filterMaxDryingId) }, getProjects = { db.getProjectedRoutesForSector(activityLevel.parentId) }, getBotches = { db.getBotchedRoutesForSector(activityLevel.parentId) } ), @@ -101,6 +107,7 @@ class RouteActivity : TableActivityWithOptionsMenu() { getByName = { db.getRoutesByNameForRock(activityLevel.parentId, _filterName) }, getByQuality = { db.getRoutesByQualityForRock(activityLevel.parentId, _filterMaxQualityId) }, getByProtection = { db.getRoutesByProtectionForRock(activityLevel.parentId, _filterMaxProtectionId) }, + getByDrying = { db.getRoutesByDryingForRock(activityLevel.parentId, _filterMaxDryingId) }, getProjects = { db.getProjectedRoutesForRock(activityLevel.parentId) }, getBotches = { db.getBotchedRoutesForRock(activityLevel.parentId) } ) @@ -184,22 +191,27 @@ class RouteActivity : TableActivityWithOptionsMenu() { } else if (_filterBotches) { routeGetter.getBotches() } else if (_filterName.isEmpty() - && _filterMaxQualityId == RouteComment.QUALITY_NONE - && _filterMaxProtectionId == RouteComment.PROTECTION_NONE) { + && _filterMaxQualityId == RouteComment.NO_INFO_ID + && _filterMaxProtectionId == RouteComment.NO_INFO_ID + && _filterMaxDryingId == RouteComment.NO_INFO_ID) { routeGetter.getAll() } else { val nameFilteredRoutes = if (_filterName.isEmpty()) null else routeGetter.getByName().toSet() val qualityFilteredRoutes = - if (_filterMaxQualityId == RouteComment.QUALITY_NONE) null + if (_filterMaxQualityId == RouteComment.NO_INFO_ID) null else routeGetter.getByQuality().toSet() val protectionFilteredRoutes = - if (_filterMaxProtectionId == RouteComment.PROTECTION_NONE) null + if (_filterMaxProtectionId == RouteComment.NO_INFO_ID) null else routeGetter.getByProtection().toSet() + val dryingFilteredRoutes = + if (_filterMaxDryingId == RouteComment.NO_INFO_ID) null + else routeGetter.getByDrying().toSet() listOfNotNull(nameFilteredRoutes, qualityFilteredRoutes, - protectionFilteredRoutes).reduce { + protectionFilteredRoutes, + dryingFilteredRoutes).reduce { intersection, filteredRoutes -> intersection.intersect(filteredRoutes) }.toList() } @@ -247,6 +259,7 @@ class RouteGetter( val getByName: () -> List, val getByQuality: () -> List, val getByProtection: () -> List, + val getByDrying: () -> List, val getProjects: () -> List, val getBotches: () -> List ) diff --git a/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt b/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt index 633df396..2742edb4 100644 --- a/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt +++ b/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt @@ -117,7 +117,7 @@ abstract class TableActivity : BaseNavigationActivity() { _addCommentPropertyView(it, R.string.route_quality, RouteComment.QUALITY_MAP, comment.qualityId) _addCommentPropertyView(it, R.string.grade, RouteComment.GRADE_MAP, comment.gradeId) _addCommentPropertyView(it, R.string.protection, RouteComment.PROTECTION_MAP, comment.securityId) - _addCommentPropertyView(it, R.string.drying, RouteComment.WETNESS_MAP, comment.wetnessId) + _addCommentPropertyView(it, R.string.drying, RouteComment.DRYING_MAP, comment.wetnessId) _addCommentTextView(it, comment.text.orEmpty()) } it.addView(WidgetUtils.createHorizontalLine(this, 1)) @@ -159,7 +159,7 @@ abstract class TableActivity : BaseNavigationActivity() { } private fun _addCommentPropertyView(layout: LinearLayout, titleRes: Int, propertyMap: Map, propertyKey: Int) { - if (propertyMap.containsKey(propertyKey)) { + if (propertyMap.containsKey(propertyKey) && propertyKey > RouteComment.NO_INFO_ID) { _addCommentTextView(layout, getString(titleRes), propertyMap[propertyKey].orEmpty()) } } diff --git a/app/src/main/java/com/yacgroup/yacguide/activity_properties/RockSearchable.kt b/app/src/main/java/com/yacgroup/yacguide/activity_properties/RockSearchable.kt index a2aec58d..cc24828b 100644 --- a/app/src/main/java/com/yacgroup/yacguide/activity_properties/RockSearchable.kt +++ b/app/src/main/java/com/yacgroup/yacguide/activity_properties/RockSearchable.kt @@ -31,7 +31,7 @@ import com.yacgroup.yacguide.utils.FilterSpinnerListener class RockSearchable(private val _activity: TableActivityWithOptionsMenu) : ActivityProperty, FilterSpinnerListener { - private var _maxRelevanceId: Int = RockComment.RELEVANCE_NONE + private var _maxRelevanceId: Int = RockComment.NO_INFO_ID override fun getMenuGroupId() = R.id.group_rock_search @@ -44,7 +44,7 @@ class RockSearchable(private val _activity: TableActivityWithOptionsMenu) : Acti searchDialog.findViewById