@@ -18,7 +18,6 @@ package com.madness.collision.unit.api_viewing
1818
1919import android.content.Context
2020import android.content.SharedPreferences
21- import android.view.ViewGroup
2221import com.madness.collision.unit.api_viewing.data.ApiViewingApp
2322import com.madness.collision.unit.api_viewing.tag.app.AppTagInfo
2423import com.madness.collision.unit.api_viewing.tag.app.AppTagManager
@@ -164,69 +163,10 @@ internal object AppTag {
164163 }
165164 }
166165
167- /* *
168- * [ensureTagIcons] and [ensureRequisites] need to be called beforehand.
169- */
170- fun inflateAllTags (context : Context , container : ViewGroup , res : AppTagInfo .Resources ) {
171- AppTagManager .tags.values.sortedBy { it.rank }.forEach { tagInfo ->
172- inflateSingleTag(context, container, tagInfo, res)
173- }
174- }
175-
176- /* *
177- * [ensureTagIcons] and [ensureRequisites] are called within.
178- */
179- suspend fun inflateAllTagsAsync (context : Context , container : ViewGroup , app : ApiViewingApp )
180- = supervisorScope {
181- ensureTagIcons(context)
182- // inflate tags that do not have requisite first
183- val directTagIds = AppTagManager .tags.mapNotNull {
184- if (it.value.requisites == null ) it.key else null
185- }
186- launch(Dispatchers .Main ) {
187- inflateMultipleTags(context, container, directTagIds, AppTagInfo .Resources (context, app))
188- }
189- // ensure resources and inflate requisite tags
190- val inflatedTagIds = directTagIds.toHashSet()
191- val res = ensureRequisitesAsync(context, app) { _, tagIds, res ->
192- inflatedTagIds.addAll(tagIds)
193- launch(Dispatchers .Main ) { inflateMultipleTags(context, container, tagIds, res) }
194- }
195- // inflate any tag left (should be none)
196- val leftTagIds = (AppTagManager .tags.keys - inflatedTagIds)
197- if (leftTagIds.isNotEmpty()) withContext(Dispatchers .Main ) {
198- inflateMultipleTags(context, container, leftTagIds, res)
199- }
200- }
201-
202- fun inflateMultipleTags (context : Context , container : ViewGroup , tagIds : Collection <String >, res : AppTagInfo .Resources ) {
203- tagIds.forEach { id ->
204- val tag = AppTagManager .tags[id] ? : return @forEach // continue
205- inflateSingleTag(context, container, tag, res)
206- }
207- }
208-
209- // Tag inflating: selected and expressed true (no anti-ed tag icon support yet).
210- fun inflateSingleTag (context : Context , container : ViewGroup , tagInfo : AppTagInfo , res : AppTagInfo .Resources ): Boolean {
211- // terminate if any requisite not satisfied
212- if (tagInfo.requisites?.any { it.checker(res).not () } == true ) return false
213- // selected and expressed true
214- if (displayingTags[tagInfo.id].isSelected && tagInfo.express(res)) {
215- val info = getTagViewInfo(tagInfo, res, context) ? : return false
216- AppTagInflater .inflateTag(context, container, info)
217- return true
218- }
219- return false
220- }
221-
222166 fun AppTagInfo.selExpressed (res : AppTagInfo .Resources ): Boolean {
223167 return displayingTags[id].isSelected && express(res)
224168 }
225169
226- private fun getTagViewInfo (tagInfo : AppTagInfo , res : AppTagInfo .Resources , context : Context ): AppTagInflater .TagInfo ? {
227- return getTagViewInfo(tagInfo, res, context) { it.label.normal }
228- }
229-
230170 fun getTagViewInfo (tagInfo : AppTagInfo , res : AppTagInfo .Resources , context : Context , labelSelector : (AppTagInfo ) -> AppTagInfo .Label ? ): AppTagInflater .TagInfo ? {
231171 // normal label or dynamic label
232172 val label = labelSelector(tagInfo) ? : kotlin.run {
0 commit comments