-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from ininmm/refactor_article_read_to_koin
Refactor ArticleListFragment.kt and ArticleReadFragment.kt to dependency injection with Koin
- Loading branch information
Showing
7 changed files
with
293 additions
and
273 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package tw.y_studio.ptt.di | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.qualifier.named | ||
import org.koin.dsl.module | ||
|
||
val appModules = module { | ||
single<CoroutineDispatcher>(named("IO")) { Dispatchers.IO } | ||
|
||
single<SharedPreferences> { | ||
androidContext().getSharedPreferences("MainSetting", Context.MODE_PRIVATE) | ||
} | ||
} |
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,23 +1,17 @@ | ||
package tw.y_studio.ptt.di | ||
|
||
import tw.y_studio.ptt.api.PostAPI | ||
import tw.y_studio.ptt.api.SearchBoardAPI | ||
import tw.y_studio.ptt.source.remote.post.PostRemoteDataSourceImpl | ||
import tw.y_studio.ptt.source.remote.search.ISearchBoardRemoteDataSource | ||
import tw.y_studio.ptt.source.remote.search.SearchBoardRemoteDataSourceImpl | ||
|
||
object Injection { | ||
object API { | ||
val searchBoardAPI by lazy { SearchBoardAPI() } | ||
val postAPI by lazy { PostAPI() } | ||
} | ||
|
||
object RemoteDataSource { | ||
val searchBoardRemoteDataSource: ISearchBoardRemoteDataSource by lazy { | ||
SearchBoardRemoteDataSourceImpl(API.searchBoardAPI) | ||
} | ||
val postRemoteDataSourceImpl by lazy { | ||
PostRemoteDataSourceImpl(API.postAPI) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.