From 69826ccb1f595272b0c6cf52818c538ea4e16dda Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Sun, 2 Apr 2023 17:44:01 +0800 Subject: [PATCH] Convert VoteCommentParser to kotlin --- .../client/parser/VoteCommentParser.kt | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/VoteCommentParser.kt b/app/src/main/java/com/hippo/ehviewer/client/parser/VoteCommentParser.kt index 2884bc8f9..9a339d168 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/VoteCommentParser.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/VoteCommentParser.kt @@ -13,29 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.hippo.ehviewer.client.parser -package com.hippo.ehviewer.client.parser; - -import org.json.JSONException; -import org.json.JSONObject; - -public class VoteCommentParser { +import org.json.JSONObject +object VoteCommentParser { // {"comment_id":1253922,"comment_score":-19,"comment_vote":0} - public static Result parse(String body, int vote) throws JSONException { - Result result = new Result(); - JSONObject jo = new JSONObject(body); - result.id = jo.getLong("comment_id"); - result.score = jo.getInt("comment_score"); - result.vote = jo.getInt("comment_vote"); - result.expectVote = vote; - return result; + fun parse(body: String, expectVote: Int): Result { + val jo = JSONObject(body) + val id = jo.getLong("comment_id") + val score = jo.getInt("comment_score") + val vote = jo.getInt("comment_vote") + return Result(id, score, vote, expectVote) } - public static class Result { - public long id; - public int score; - public int vote; - public int expectVote; - } + class Result(val id: Long, val score: Int, val vote: Int, val expectVote: Int) }