|
|
@@ -11,6 +11,7 @@ import android.text.TextUtils;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
+import android.widget.Button;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
@@ -18,7 +19,6 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.kfzs.duanduan.cardview.ScreenUtil;
|
|
|
import com.kfzs.duanduan.utils.ApkUtils;
|
|
|
-import com.kfzs.duanduan.utils.StatusBarUtils;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.Release_task;
|
|
|
@@ -30,6 +30,7 @@ import com.sheep.gamegroup.module.task.helper.VideoAd;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.DeviceUtil;
|
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
+import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.LocationUtils;
|
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.gamegroup.util.UMConfigUtils;
|
|
|
@@ -44,6 +45,7 @@ import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
|
|
|
import com.shuyu.gsyvideoplayer.GSYVideoManager;
|
|
|
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
|
|
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack;
|
|
|
+import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -51,6 +53,7 @@ import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
+import butterknife.OnClick;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
|
@@ -60,8 +63,14 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
SheepGSYVideoView videoPlayerView;
|
|
|
@BindView(R.id.mask_view)
|
|
|
View mask_view;
|
|
|
- @BindView(R.id.desc_bottom_tv)
|
|
|
- TextView desc_bottom_tv;
|
|
|
+ @BindView(R.id.desc_tv)
|
|
|
+ TextView desc_tv;
|
|
|
+ @BindView(R.id.name_tv)
|
|
|
+ TextView name_tv;
|
|
|
+ @BindView(R.id.action_btn)
|
|
|
+ Button action_btn;
|
|
|
+ @BindView(R.id.logo_iv)
|
|
|
+ ImageView logo_iv;
|
|
|
@BindView(R.id.countdown_view)
|
|
|
TextView countdown_view;
|
|
|
|
|
|
@@ -91,6 +100,14 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
@Override
|
|
|
public void onCreate(Bundle b) {
|
|
|
super.onCreate(b);
|
|
|
+ getWindow().addFlags(
|
|
|
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
|
|
|
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onWindowFocusChanged(boolean hasFocus) {
|
|
|
+ super.onWindowFocusChanged(hasFocus);
|
|
|
int flag = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && G.checkDeviceHasNavigationBar(this)) {
|
|
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);//白色
|
|
|
@@ -100,15 +117,13 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
|
}
|
|
|
getWindow().getDecorView().setSystemUiVisibility(flag);
|
|
|
- getWindow().addFlags(
|
|
|
- WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
|
|
|
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
|
videoPlayerView.onVideoResume();
|
|
|
+ configActionBtn();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -138,19 +153,16 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
videoPlayerView.getBackButton().setVisibility(View.GONE);
|
|
|
videoPlayerView.getFullscreenButton().setVisibility(View.GONE);
|
|
|
videoPlayerView.getBottomProgressBar().setVisibility(View.GONE);
|
|
|
+
|
|
|
mask_view.setOnTouchListener((v, event) -> {
|
|
|
if (event.getAction() == MotionEvent.ACTION_UP && currentVideoAd != null) {
|
|
|
currentVideoAd.clickX = (int) event.getRawX();
|
|
|
currentVideoAd.clickY = (int) event.getRawY();
|
|
|
currentVideoAd.trigger(VideoAd.TYPE_CLICK);
|
|
|
- String path = ADDownloader.getUrlPath(currentVideoAd.url);
|
|
|
- if (PackageUtil.isAppInstalled(SheepApp.getInstance(), currentVideoAd.package_name)) {
|
|
|
- showOpenAppConfirmDialog();
|
|
|
- } else if (!TextUtils.isEmpty(path)) {
|
|
|
- currentVideoAd.path = path;
|
|
|
- showInstallConfigDialog();
|
|
|
- } else {
|
|
|
- showDownloadConfirmDialog();
|
|
|
+ if (videoPlayerView.getCurrentState() == GSYVideoView.CURRENT_STATE_PAUSE) {
|
|
|
+ videoPlayerView.onVideoResume();
|
|
|
+ } else if (videoPlayerView.getCurrentState() == GSYVideoView.CURRENT_STATE_PLAYING) {
|
|
|
+ videoPlayerView.onVideoPause();
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
@@ -205,8 +217,11 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
runOnUiThread(() -> {
|
|
|
if (ret) {
|
|
|
currentVideoAd = ad;
|
|
|
- desc_bottom_tv.setText(currentVideoAd.desc);
|
|
|
+ desc_tv.setText(currentVideoAd.desc);
|
|
|
+ name_tv.setText(currentVideoAd.title);
|
|
|
+ GlideImageLoader.circleImage(logo_iv, currentVideoAd.logo);
|
|
|
playVideo();
|
|
|
+ configActionBtn();
|
|
|
} else {
|
|
|
ViewUtil.showConfirmDialog(VideoTaskActivity.this,
|
|
|
"不好",
|
|
|
@@ -219,6 +234,46 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void configActionBtn() {
|
|
|
+ if (this.isDestroyed() || currentVideoAd == null || currentVideoAd.url == null) return;
|
|
|
+ if (!currentVideoAd.url.endsWith(".apk")) {
|
|
|
+ action_btn.setText("查看详情");
|
|
|
+ action_btn.setTag(0);
|
|
|
+ } else {
|
|
|
+ String path = ADDownloader.getUrlPath(currentVideoAd.url);
|
|
|
+ if (PackageUtil.isAppInstalled(SheepApp.getInstance(), currentVideoAd.package_name)) {
|
|
|
+ action_btn.setText("打开应用");
|
|
|
+ action_btn.setTag(1);
|
|
|
+ } else if (!TextUtils.isEmpty(path)) {
|
|
|
+ action_btn.setText("立即安装");
|
|
|
+ action_btn.setTag(2);
|
|
|
+ currentVideoAd.path = path;
|
|
|
+ } else {
|
|
|
+ action_btn.setText("下载应用");
|
|
|
+ action_btn.setTag(3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @OnClick(R.id.action_btn)
|
|
|
+ public void onActionClick(View v) {
|
|
|
+ int action = (int) v.getTag();
|
|
|
+ switch (action) {
|
|
|
+ case 0:
|
|
|
+ jumpWeb();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ openApp();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ installApp();
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ downloadApp();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void playVideo() {
|
|
|
GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder();
|
|
|
gsyVideoOption.setIsTouchWiget(false)
|
|
|
@@ -340,29 +395,35 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
d -> commitAutoTask()).show();
|
|
|
}
|
|
|
|
|
|
- private void showOpenAppConfirmDialog() {
|
|
|
+ private void jumpWeb() {
|
|
|
if (currentVideoAd == null) return;
|
|
|
- showAppConfirmDialog("跳转", "打开应用", d -> {
|
|
|
- currentVideoAd.trigger(VideoAd.TYPE_ACTIVE);
|
|
|
- currentVideoAd.trigger(VideoAd.TYPE_OPEN);
|
|
|
- PackageUtil.startApp(this, currentVideoAd.package_name);
|
|
|
- });
|
|
|
+ Jump2View.getInstance().goWeb(this, currentVideoAd.url);
|
|
|
}
|
|
|
|
|
|
- private void showDownloadConfirmDialog() {
|
|
|
+ private void openApp() {
|
|
|
if (currentVideoAd == null) return;
|
|
|
- showAppConfirmDialog("下载", "立即下载", d -> {
|
|
|
- currentVideoAd.trigger(VideoAd.TYPE_DOWNLOAD);
|
|
|
- showDownloadDialog();
|
|
|
- });
|
|
|
+ currentVideoAd.trigger(VideoAd.TYPE_ACTIVE);
|
|
|
+ currentVideoAd.trigger(VideoAd.TYPE_OPEN);
|
|
|
+ PackageUtil.startApp(this, currentVideoAd.package_name);
|
|
|
}
|
|
|
|
|
|
- private void showInstallConfigDialog() {
|
|
|
+ private void downloadApp() {
|
|
|
if (currentVideoAd == null) return;
|
|
|
- showAppConfirmDialog("安装", "立即安装", d -> {
|
|
|
- currentVideoAd.trigger(VideoAd.TYPE_INSTALL);
|
|
|
- ApkUtils.installApk(this, currentVideoAd.path);
|
|
|
- });
|
|
|
+ videoPlayerView.onVideoPause();
|
|
|
+ currentVideoAd.trigger(VideoAd.TYPE_DOWNLOAD);
|
|
|
+ showDownloadDialog();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void installApp() {
|
|
|
+ if (currentVideoAd == null) return;
|
|
|
+ currentVideoAd.trigger(VideoAd.TYPE_INSTALL);
|
|
|
+ ApkUtils.installApk(this, currentVideoAd.path);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void installApp(VideoAd ad) {
|
|
|
+ if (ad == null) return;
|
|
|
+ ad.trigger(VideoAd.TYPE_INSTALL);
|
|
|
+ ApkUtils.installApk(this, ad.path);
|
|
|
}
|
|
|
|
|
|
private void showAppConfirmDialog(String title, String btnText, ViewUtil.OnConfirDialogListener listener) {
|
|
|
@@ -384,7 +445,11 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
private void showDownloadDialog() {
|
|
|
- final DialogProgress progress = DialogProgress.showDialog(this, false);
|
|
|
+ final DialogProgress progress = DialogProgress.showDialog(this, true);
|
|
|
+ progress.getAlertDialog().setOnDismissListener(d -> {
|
|
|
+
|
|
|
+ });
|
|
|
+ final VideoAd thisAd = currentVideoAd.clone();
|
|
|
new ADDownloader()
|
|
|
.setListener(new ADDownloader.ProgressListener() {
|
|
|
|
|
|
@@ -393,19 +458,25 @@ public class VideoTaskActivity extends BaseActivity {
|
|
|
LogUtil.logE(offset + " /// " + total);
|
|
|
long percent = offset * 100 / total;
|
|
|
runOnUiThread(() -> {
|
|
|
- progress.getTextView().setText(percent + "%");
|
|
|
+ if (progress.getAlertDialog().isShowing()) {
|
|
|
+ progress.getTextView().setText(percent + "%");
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onStatus(String status, String msg) {
|
|
|
runOnUiThread(() -> {
|
|
|
- if ("COMPLETED".equals(status)) {
|
|
|
+ if (VideoTaskActivity.this.isDestroyed()) return;
|
|
|
+ if (progress.getAlertDialog().isShowing()) {
|
|
|
progress.getAlertDialog().dismiss();
|
|
|
- showInstallConfigDialog();
|
|
|
+ }
|
|
|
+ if ("COMPLETED".equals(status)) {
|
|
|
+ thisAd.path = msg;
|
|
|
+ configActionBtn();
|
|
|
+ installApp(thisAd);
|
|
|
} else {
|
|
|
videoPlayerView.onVideoResume();
|
|
|
- progress.getAlertDialog().dismiss();
|
|
|
LogUtil.logE(status + " /// " + msg);
|
|
|
}
|
|
|
});
|