スキル一覧に戻る
mrndstvndv

search-repository

by mrndstvndv

1🍴 1📅 2026年1月20日
GitHubで見るManusで実行

SKILL.md


name: search-repository description: Search app repository layer - 7 repositories (ProviderSettings, ProviderRanking, Alias, FileSearch, Contacts, RecentApps, PinnedApps), singleton pattern with double-checked locking, StateFlow reactive settings pattern for UI binding.

Repository Layer

Repository Overview

RepositoryPurposeStorage Type
ProviderSettingsRepositoryAll provider/app settingsSharedPreferences (JSON)
ProviderRankingRepositoryResult ordering & frequencySharedPreferences
AliasRepositoryUser-defined shortcutsSharedPreferences (JSON)
FileSearchRepositoryFile indexing & FTS4 searchRoom Database
ContactsRepositoryContact data accessSystem ContentProvider
RecentAppsRepositoryRecent app trackingUsageStatsManager
PinnedAppsRepositoryPinned apps listSharedPreferences

Repository Locations

RepositoryLocation
ProviderSettingsRepositorysettings/ProviderSettingsRepository.kt
ProviderRankingRepositorysettings/ProviderRankingRepository.kt
AliasRepositoryalias/AliasRepository.kt
FileSearchRepositoryprovider/files/FileSearchRepository.kt
ContactsRepositoryprovider/contacts/ContactsRepository.kt
RecentAppsRepositoryprovider/apps/RecentAppsRepository.kt

Singleton Pattern

Heavy repositories use double-checked locking singletons:

// Location: FileSearchRepository.kt

class FileSearchRepository private constructor(context: Context) {
    
    companion object {
        @Volatile 
        private var INSTANCE: FileSearchRepository? = null
        
        fun getInstance(context: Context): FileSearchRepository =
            INSTANCE ?: synchronized(this) {
                INSTANCE ?: FileSearchRepository(context.applicationContext)
                    .also { INSTANCE = it }
            }
    }
    
    // Repository implementation...
}

// Usage in Activity
val fileSearchRepository = remember { 
    FileSearchRepository.getInstance(applicationContext) 
}

StateFlow Pattern for Reactive Settings

// Location: ProviderSettingsRepository.kt

class ProviderSettingsRepository(context: Context, scope: CoroutineScope) {
    
    // Private mutable state
    private val _webSearchSettings = MutableStateFlow(loadWebSearchSettings())
    
    // Public immutable exposure
    val webSearchSettings: StateFlow<WebSearchSettings> = _webSearchSettings.asStateFlow()
    
    // Update triggers StateFlow emission
    fun updateWebSearchSettings(settings: WebSearchSettings) {
        saveToPrefs(settings)
        _webSearchSettings.value = settings  // UI recomposes automatically
    }
}

// Usage in Composable
@Composable
fun WebSearchSettingsScreen(repository: ProviderSettingsRepository) {
    val settings by repository.webSearchSettings.collectAsState()
    
    // UI automatically updates when settings change
}

Adding a New Repository

  1. Create repository class with singleton pattern (if heavy):

    class NewRepository private constructor(context: Context) {
        companion object {
            @Volatile private var INSTANCE: NewRepository? = null
            fun getInstance(context: Context) = INSTANCE ?: synchronized(this) {
                INSTANCE ?: NewRepository(context.applicationContext).also { INSTANCE = it }
            }
        }
    }
    
  2. Add StateFlow for reactive data:

    private val _data = MutableStateFlow(loadData())
    val data: StateFlow<DataType> = _data.asStateFlow()
    
  3. Use in Activity/Composable:

    val repository = remember { NewRepository.getInstance(context) }
    val data by repository.data.collectAsState()
    
  • search-dataflow - How repositories fit into data flow
  • search-guides - Adding settings to repositories

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です