| | |
| | | |
| | | 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; |
| | | |
| | |
| | | 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 |