| | |
| | | package com.yeshi.makemoney.video.app.ui.main; |
| | | |
| | | import android.animation.ValueAnimator; |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.animation.AccelerateDecelerateInterpolator; |
| | | import android.view.animation.Animation; |
| | | import android.view.animation.AnimationUtils; |
| | | import android.view.animation.DecelerateInterpolator; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.bytedance.sdk.dp.DPWidgetDrawParams; |
| | | import com.bytedance.sdk.dp.IDPDrawListener; |
| | | import com.bytedance.sdk.dp.IDPNewsListener; |
| | | import com.bytedance.sdk.dp.IDPWidget; |
| | | import com.demo.lib.common.RetainViewFragment; |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.demo.library_flutter.FlutterRecommendFragment; |
| | | import com.demo.library_flutter.utils.FlutterPageUtil; |
| | | import com.idlefish.flutterboost.FlutterBoost; |
| | | import com.idlefish.flutterboost.containers.FlutterBoostFragment; |
| | | import com.jaeger.library.StatusBarUtil; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.entity.goldcorn.GoldCornTaskInfo; |
| | | import com.yeshi.makemoney.video.app.entity.user.UserInfo; |
| | | import com.yeshi.makemoney.video.app.ui.subview.CircleProgressView; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | import com.yeshi.makemoney.video.app.utils.videos.DPHolder; |
| | | import com.yeshi.makemoney.video.app.utils.videos.DrawVideoGoldCornManager; |
| | | import com.yeshi.makemoney.video.app.utils.videos.DrawVideoHBManager; |
| | | import com.yeshi.makemoney.video.app.utils.videos.VideoGoldCornUtil; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | |
| | | private AQuery mAquery; |
| | | private IDPWidget mIDPWidget; |
| | | |
| | | private DrawVideoHBManager mDrawVideoHBManager; |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_home; |
| | | } |
| | | |
| | | |
| | | private void init() { |
| | | initVideo(); |
| | | mAquery.id(R.id.tv_login).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | //去登录 |
| | | FlutterPageUtil.jumpPage("LoginPage", null, null); |
| | | } |
| | | }); |
| | | |
| | | //初始化视频播放计时器 |
| | | if (VideoGoldCornUtil.getPrice(getContext()) != null) { |
| | | DrawVideoGoldCornManager.getInstance().init(new DrawVideoGoldCornManager.PlayTimerCallBack() { |
| | | @Override |
| | | public void onProcess(int process) { |
| | | // Log.i(TAG, "process:" + process); |
| | | mDrawVideoHBManager.onProcess(process); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | StatusBarUtil.setDarkMode(getActivity()); |
| | | mAquery = new AQuery(contentView); |
| | | initVideo(); |
| | | mDrawVideoHBManager = new DrawVideoHBManager(); |
| | | mDrawVideoHBManager.init(contentView, getActivity()); |
| | | init(); |
| | | } |
| | | |
| | | private void initVideo() { |
| | | mIDPWidget = DPHolder.getInstance().buildDrawWidget(DPWidgetDrawParams.obtain().hideClose(true, null) |
| | | .drawContentType(DPWidgetDrawParams.DRAW_CONTENT_TYPE_ALL) |
| | | .enableRefresh(true) |
| | | .customCategory("风景") |
| | | .listener(new IDPNewsListener() { |
| | | // .customCategory("风景") |
| | | .listener(new IDPDrawListener() { |
| | | @Override |
| | | public void onDPRefreshFinish() { |
| | | log("onDPRefreshFinish"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsItemClick(Map<String, Object> map) { |
| | | log("onDPNewsItemClick"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPlay(Map<String, Object> map) { |
| | | log("onDPVideoPlay"); |
| | | DrawVideoGoldCornManager.getInstance().videoPlay(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPause(Map<String, Object> map) { |
| | | log("onDPVideoPause"); |
| | | DrawVideoGoldCornManager.getInstance().videoPause(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoContinue(Map<String, Object> map) { |
| | | log("onDPVideoContinue"); |
| | | DrawVideoGoldCornManager.getInstance().videoPlay(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoOver(Map<String, Object> map) { |
| | | log("onDPVideoOver"); |
| | | DrawVideoGoldCornManager.getInstance().videoPause(); |
| | | // DPEventCollectUtil.playDrawVideo(getContext(), null, "dy", "home", false); |
| | | } |
| | | |
| | |
| | | public void onDPVideoCompletion(Map<String, Object> map) { |
| | | log("onDPVideoCompletion"); |
| | | super.onDPVideoCompletion(map); |
| | | DrawVideoGoldCornManager.getInstance().videoPause(); |
| | | // DPEventCollectUtil.playDrawVideo(getContext(), null, "dy", "home", true); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailEnter(Map<String, Object> map) { |
| | | log("onDPNewsDetailEnter"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailExit(Map<String, Object> map) { |
| | | log("onDPNewsDetailExit"); |
| | | } |
| | | |
| | | |
| | | })); |
| | | |
| | |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG, "onResume"); |
| | | if (UserUtil.isLogin(getContext())) { |
| | | mAquery.id(R.id.ll_login).visibility(View.GONE); |
| | | } else { |
| | | mAquery.id(R.id.ll_login).visibility(View.VISIBLE); |
| | | } |
| | | |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onResume(); |
| | | } |
| | | |
| | | |
| | | mDrawVideoHBManager.refreshTaskInfo(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void onPause() { |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | DrawVideoGoldCornManager.getInstance().destory(); |
| | | mDrawVideoHBManager.destory(); |
| | | } |
| | | } |