-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a9a385
commit 9aa834b
Showing
5 changed files
with
83 additions
and
12 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
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
49 changes: 49 additions & 0 deletions
49
app/src/main/java/de/ph1b/audiobook/injection/SortingModule.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package de.ph1b.audiobook.injection | ||
|
||
import com.f2prateek.rx.preferences2.RxSharedPreferences | ||
import dagger.MapKey | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.multibindings.IntoMap | ||
import de.ph1b.audiobook.features.bookOverview.list.BookComparator | ||
import de.ph1b.audiobook.features.bookOverview.list.header.BookOverviewCategory | ||
import de.ph1b.audiobook.persistence.pref.PersistentPref | ||
import de.ph1b.audiobook.persistence.pref.Pref | ||
import javax.inject.Singleton | ||
|
||
@MapKey | ||
annotation class BookOverviewCategoryKey(val value: BookOverviewCategory) | ||
|
||
@Module | ||
object SortingModule { | ||
|
||
@JvmStatic | ||
@Provides | ||
@Singleton | ||
@IntoMap | ||
@BookOverviewCategoryKey(BookOverviewCategory.CURRENT) | ||
fun currentComparatorPref(prefs: RxSharedPreferences): Pref<BookComparator> { | ||
val pref = prefs.getEnum(BookOverviewCategory.CURRENT.name, BookComparator.BY_NAME, BookComparator::class.java) | ||
return PersistentPref(pref) | ||
} | ||
|
||
@JvmStatic | ||
@Provides | ||
@Singleton | ||
@IntoMap | ||
@BookOverviewCategoryKey(BookOverviewCategory.NOT_STARTED) | ||
fun notStartedComparatorPref(prefs: RxSharedPreferences): Pref<BookComparator> { | ||
val pref = prefs.getEnum(BookOverviewCategory.NOT_STARTED.name, BookComparator.BY_NAME, BookComparator::class.java) | ||
return PersistentPref(pref) | ||
} | ||
|
||
@JvmStatic | ||
@Provides | ||
@Singleton | ||
@IntoMap | ||
@BookOverviewCategoryKey(BookOverviewCategory.FINISHED) | ||
fun finishedComparatorPref(prefs: RxSharedPreferences): Pref<BookComparator> { | ||
val pref = prefs.getEnum(BookOverviewCategory.FINISHED.name, BookComparator.BY_NAME, BookComparator::class.java) | ||
return PersistentPref(pref) | ||
} | ||
} |
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