-
Notifications
You must be signed in to change notification settings - Fork 9
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 #71 from ininmm/task/refactor_set_post_rank
Refactor SetPostRankAPI and add tests
- Loading branch information
Showing
8 changed files
with
103 additions
and
126 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
94 changes: 0 additions & 94 deletions
94
app/src/main/java/tw/y_studio/ptt/api/SetPostRankAPIHelper.java
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
app/src/main/java/tw/y_studio/ptt/source/remote/post/IPostRemoteDataSource.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,12 +1,23 @@ | ||
package tw.y_studio.ptt.source.remote.post | ||
|
||
import tw.y_studio.ptt.api.PostRankMark | ||
import tw.y_studio.ptt.model.PartialPost | ||
import tw.y_studio.ptt.model.Post | ||
import tw.y_studio.ptt.model.PostRank | ||
|
||
interface IPostRemoteDataSource { | ||
fun getPost(board: String, fileName: String): Post | ||
|
||
fun setPostRank( | ||
boardName: String, | ||
aid: String, | ||
pttId: String, | ||
rank: PostRankMark | ||
) | ||
|
||
fun getPostRank(board: String, aid: String): PostRank | ||
|
||
fun getPostList(broadName: String, page: Int): List<PartialPost> | ||
|
||
fun disposeAll() | ||
} |
20 changes: 15 additions & 5 deletions
20
app/src/main/java/tw/y_studio/ptt/source/remote/post/PostRemoteDataSourceImpl.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,26 +1,36 @@ | ||
package tw.y_studio.ptt.source.remote.post | ||
|
||
import tw.y_studio.ptt.api.PostAPI | ||
import tw.y_studio.ptt.api.PostRankMark | ||
import tw.y_studio.ptt.model.PartialPost | ||
import tw.y_studio.ptt.model.Post | ||
import tw.y_studio.ptt.model.PostRank | ||
|
||
class PostRemoteDataSourceImpl( | ||
private val postAPIHelper: PostAPI | ||
private val postAPI: PostAPI | ||
) : IPostRemoteDataSource { | ||
override fun getPost(board: String, fileName: String): Post { | ||
return postAPIHelper.getPost(board, fileName) | ||
return postAPI.getPost(board, fileName) | ||
} | ||
|
||
override fun setPostRank( | ||
boardName: String, | ||
aid: String, | ||
pttId: String, | ||
rank: PostRankMark | ||
) { | ||
postAPI.setPostRank(boardName, aid, pttId, rank) | ||
} | ||
|
||
override fun getPostRank(board: String, aid: String): PostRank { | ||
return postAPIHelper.getPostRank(board, aid) | ||
return postAPI.getPostRank(board, aid) | ||
} | ||
|
||
override fun getPostList(broadName: String, page: Int): List<PartialPost> { | ||
return postAPIHelper.getPostList(broadName, page) | ||
return postAPI.getPostList(broadName, page) | ||
} | ||
|
||
override fun disposeAll() { | ||
postAPIHelper.close() | ||
postAPI.close() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package tw.y_studio.ptt.utils | ||
|
||
import com.google.gson.Gson | ||
import com.google.gson.reflect.TypeToken | ||
|
||
/** | ||
* Created by Michael.Lien | ||
* on 2020/12/25 | ||
*/ | ||
inline fun <reified T> Gson.fromJson(json: String): T = fromJson(json, object : TypeToken<T>() {}.type) |
File renamed without changes.
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