-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update AboutMeActivity + MainActivity logic + use RelativeLinksCard +…
… BottomTipView + minor improvements
- Loading branch information
1 parent
35caca5
commit 65e1a04
Showing
13 changed files
with
207 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
app/src/main/java/de/lemke/oneurl/domain/GetSearchListUseCase.kt
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
app/src/main/java/de/lemke/oneurl/domain/GetURLsUseCase.kt
This file was deleted.
Oops, something went wrong.
32 changes: 30 additions & 2 deletions
32
app/src/main/java/de/lemke/oneurl/domain/ObserveURLsUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,41 @@ | ||
package de.lemke.oneurl.domain | ||
|
||
|
||
import android.util.Log | ||
import de.lemke.oneurl.data.URLRepository | ||
import de.lemke.oneurl.domain.model.URL | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flatMapLatest | ||
import kotlinx.coroutines.flow.flowOn | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class ObserveURLsUseCase @Inject constructor( | ||
private val urlRepository: URLRepository, | ||
private val urlRepository: URLRepository | ||
) { | ||
operator fun invoke() = urlRepository.observeURLs().flowOn(Dispatchers.Default) | ||
@OptIn(ExperimentalCoroutinesApi::class) | ||
operator fun invoke(searchQuery: Flow<String?>, filterFavorite: Flow<Boolean>): Flow<List<URL>> = | ||
searchQuery.flatMapLatest { query -> // observe search query | ||
if (query != null) { | ||
if (query.isBlank()) { | ||
urlRepository.observeURLs().map { emptyList() } | ||
} else { | ||
urlRepository.observeURLs().map { urls -> | ||
urls.filter { url -> url.contains(query) } | ||
} | ||
} | ||
} else { | ||
filterFavorite.flatMapLatest { filterFavorite -> // observe favorite filter | ||
if (filterFavorite) { | ||
urlRepository.observeURLs().map { urls -> | ||
urls.filter { url -> url.favorite } | ||
} | ||
} else { | ||
urlRepository.observeURLs() | ||
} | ||
} | ||
} | ||
}.flowOn(Dispatchers.Default) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.