Commit cd0d79d41e5b462f169f4ffc4f0708571854627d
1 parent
342d5129
视频预览逻辑添加
Showing
5 changed files
with
43 additions
and
8 deletions
core/app_qr/src/main/java/com/cnlive/cloud/moudle/qr/uitl/ScanUtil.java
0 → 100644
| 1 | +package com.cnlive.cloud.moudle.qr.uitl; | |
| 2 | + | |
| 3 | +import java.io.File; | |
| 4 | + | |
| 5 | +import cn.bertsir.zbar.utils.QRUtils; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * created by hanyayun | |
| 9 | + * on 2020/6/17 | |
| 10 | + */ | |
| 11 | +public class ScanUtil { | |
| 12 | + | |
| 13 | + public static String getRecode(File file){ | |
| 14 | + try { | |
| 15 | + return QRUtils.getInstance().decodeQRcode(file.getAbsolutePath()); | |
| 16 | + } catch (Exception e) { | |
| 17 | + e.printStackTrace(); | |
| 18 | + } | |
| 19 | + return ""; | |
| 20 | + } | |
| 21 | +} | ... | ... |
core/imageload/src/main/java/com/cnlive/core/imagepreview/ImageDrawee.java
| ... | ... | @@ -32,17 +32,20 @@ public class ImageDrawee extends FrameLayout { |
| 32 | 32 | private ProgressUI progressUI; |
| 33 | 33 | private ViewData viewData; |
| 34 | 34 | |
| 35 | - public ImageDrawee(@NonNull Context context,ViewData viewData) { | |
| 35 | + public ImageDrawee(@NonNull Context context,ViewData viewData,CNVideoView videoView) { | |
| 36 | 36 | super(context); |
| 37 | 37 | this.viewData = viewData; |
| 38 | - init(); | |
| 38 | + init(videoView); | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - private void init() { | |
| 41 | + private void init(CNVideoView videoView) { | |
| 42 | 42 | // 添加 imageView |
| 43 | 43 | if(viewData.getType() == 1){ |
| 44 | 44 | imageView = new PhotoView(getContext()); |
| 45 | 45 | addView(imageView); |
| 46 | + }else { | |
| 47 | + removeAllViews(); | |
| 48 | + addView(videoView); | |
| 46 | 49 | } |
| 47 | 50 | } |
| 48 | 51 | ... | ... |
core/imageload/src/main/java/com/cnlive/core/imagepreview/ImagePreView.java
| ... | ... | @@ -376,6 +376,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL |
| 376 | 376 | * 取消浏览 |
| 377 | 377 | */ |
| 378 | 378 | public void cancel() { |
| 379 | + videoView.release(); | |
| 379 | 380 | videoView.onDestroy(); |
| 380 | 381 | cancel(null); |
| 381 | 382 | } |
| ... | ... | @@ -386,6 +387,11 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL |
| 386 | 387 | * @param callback 退场动画执行回调 |
| 387 | 388 | */ |
| 388 | 389 | public void cancel(final ImageTransfer.OnTransCallback callback) { |
| 390 | + if(getCurrentItem().getImageView() == null) { | |
| 391 | + playEnterAnim = false; | |
| 392 | + playExitAnim = false; | |
| 393 | + draggable = false; | |
| 394 | + } | |
| 389 | 395 | if (indexUI != null) { |
| 390 | 396 | indexUI.hide(); |
| 391 | 397 | } |
| ... | ... | @@ -443,9 +449,8 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL |
| 443 | 449 | } |
| 444 | 450 | } |
| 445 | 451 | if (drawee == null) { |
| 446 | - drawee = new ImageDrawee(container.getContext(),mSourceList.get(position)); | |
| 452 | + drawee = new ImageDrawee(container.getContext(),mSourceList.get(position),videoView); | |
| 447 | 453 | drawee.setProgressUI(progressUI); |
| 448 | - if(mSourceList.get(position).getType() == 2)drawee.addView(videoView); | |
| 449 | 454 | mViewBox.add(drawee); |
| 450 | 455 | } |
| 451 | 456 | container.addView(drawee); |
| ... | ... | @@ -711,6 +716,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL |
| 711 | 716 | |
| 712 | 717 | @Override |
| 713 | 718 | public boolean onTouchEvent(MotionEvent event) { |
| 719 | + if(getCurrentItem().getImageView() == null) return false; | |
| 714 | 720 | int action = event.getAction() & event.getActionMasked(); |
| 715 | 721 | if (action == MotionEvent.ACTION_MOVE) { |
| 716 | 722 | if (draggable && isDragging && mDragHandler != null) { |
| ... | ... | @@ -797,6 +803,11 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL |
| 797 | 803 | // 消费返回键点击事件,不传递出去 |
| 798 | 804 | return true; |
| 799 | 805 | } |
| 806 | + if(getCurrentItem().getImageView() == null){ | |
| 807 | + cancel(); | |
| 808 | + // 消费返回键点击事件,不传递出去 | |
| 809 | + return true; | |
| 810 | + } | |
| 800 | 811 | } |
| 801 | 812 | } |
| 802 | 813 | return super.onKeyDown(keyCode, event); | ... | ... |
core/imageload/src/main/java/com/cnlive/core/ui/activity/PreViewImageActivity.java
| ... | ... | @@ -8,7 +8,6 @@ import android.widget.ImageView; |
| 8 | 8 | import com.alibaba.android.arouter.facade.annotation.Route; |
| 9 | 9 | import com.cnlive.core.imageload.R; |
| 10 | 10 | import com.cnlive.core.imageload.databinding.ActivityPreviewImageBinding; |
| 11 | -import com.cnlive.core.imagepreview.ViewerStatus; | |
| 12 | 11 | import com.cnlive.core.imagepreview.listener.OnItemClickListener; |
| 13 | 12 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 14 | 13 | import com.cnlive.core.ui.model.PreViewImgData; |
| ... | ... | @@ -71,7 +70,7 @@ public class PreViewImageActivity extends BaseActivity<PreViewImageView, PreView |
| 71 | 70 | @Override |
| 72 | 71 | protected void onDestroy() { |
| 73 | 72 | super.onDestroy(); |
| 74 | - if(binding.imagePre != null && binding.imagePre.getViewStatus() == ViewerStatus.STATUS_WATCHING){ | |
| 73 | + if(binding.imagePre != null){ | |
| 75 | 74 | binding.imagePre.cancel(); |
| 76 | 75 | } |
| 77 | 76 | } | ... | ... |
core/imageload/src/main/java/com/cnlive/core/ui/presenter/PreViewImagePresenter.java
| ... | ... | @@ -12,6 +12,7 @@ import android.util.Log; |
| 12 | 12 | import com.bumptech.glide.Glide; |
| 13 | 13 | import com.bumptech.glide.request.FutureTarget; |
| 14 | 14 | import com.bumptech.glide.request.target.Target; |
| 15 | +import com.cnlive.cloud.moudle.qr.uitl.ScanUtil; | |
| 15 | 16 | import com.cnlive.core.imageload.api.ApiServiceStock; |
| 16 | 17 | import com.cnlive.core.libs.base.application.AppConfig; |
| 17 | 18 | import com.cnlive.core.libs.base.frame.presenter.BasePresenter; |
| ... | ... | @@ -278,7 +279,7 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { |
| 278 | 279 | File scanFile = getFile(emitter, imgUrl, activity); |
| 279 | 280 | if (scanFile != null && FileUtils.isFileExists(scanFile) && scanFile.length() > 0) { |
| 280 | 281 | String content = null; |
| 281 | - content = QRUtils.getInstance().decodeQRcode(scanFile.getAbsolutePath()); | |
| 282 | + content = ScanUtil.getRecode(scanFile);//QRUtils.getInstance().decodeQRcode(scanFile.getAbsolutePath()); | |
| 282 | 283 | if (TextUtils.isEmpty(scanFile.getAbsolutePath())) { |
| 283 | 284 | content = QRUtils.getInstance().decodeQRcodeByZxing(scanFile.getAbsolutePath()); |
| 284 | 285 | } | ... | ... |