From 4c7cde7ae5ed57335405459e47de4bbd2726c4ba Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 07 五月 2022 19:43:39 +0800 Subject: [PATCH] 功能完善 --- android/app/src/main/java/com/yeshi/makemoney/video/app/ui/main/NovelFragment.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 58 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/com/yeshi/makemoney/video/app/ui/main/NovelFragment.java b/android/app/src/main/java/com/yeshi/makemoney/video/app/ui/main/NovelFragment.java index b400147..03b0f10 100644 --- a/android/app/src/main/java/com/yeshi/makemoney/video/app/ui/main/NovelFragment.java +++ b/android/app/src/main/java/com/yeshi/makemoney/video/app/ui/main/NovelFragment.java @@ -6,7 +6,15 @@ import com.bytedance.novel.pangolin.NovelSDK; import com.demo.lib.common.RetainViewFragment; -import com.yeshi.makemoney.video.app.R; +import com.yeshi.makemoney.video.R; +import com.yeshi.makemoney.video.app.utils.UserUtil; +import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; +import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; +import com.yeshi.makemoney.video.app.utils.videos.NovelGoldCornUtil; +import com.yeshi.makemoney.video.app.utils.videos.VideoGoldCornUtil; + +import org.apache.http.Header; +import org.json.JSONObject; import androidx.fragment.app.FragmentManager; @@ -46,7 +54,55 @@ public void onResume() { super.onResume(); NovelSDK.INSTANCE.getNovelFragment().onResume(); -// DPEventCollectUtil.uploadNovelReadTime(getContext()); + //浠婃棩闃呰鐨勬椂闂� + uploadReadTime(); + } + + + private void uploadReadTime() { + long todayReadTime = NovelSDK.INSTANCE.getNovelReadingDuration(); + if (todayReadTime <= 0L) { + return; + } + + long lastDuration = NovelGoldCornUtil.getReadTime(getContext()); + if (lastDuration == todayReadTime) { + return; + } + + NovelGoldCornUtil.setReadTime(todayReadTime, getContext()); + + if (!UserUtil.isLogin(getContext())) { + return; + } + //涓婁紶 + HttpApiUtil.readNovel(getContext(), (int) (todayReadTime / 1000), new BasicTextHttpResponseHandler() { + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { + super.onSuccessPerfect(statusCode, headers, jsonObject); + if (jsonObject.optInt("code") == 0) { + JSONObject data = jsonObject.optJSONObject("data"); + VideoGoldCornUtil.showInComeToast(data.optInt("goldCorn"), getContext()); + } + } + + @Override + public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { + super.onFailure(statusCode, headers, jsonObject, e); + } + + @Override + public void onFinish() { + super.onFinish(); + } + }); + + } @Override -- Gitblit v1.8.0