Commit 1728f8b2074e939caa8dab03b844e98f94ef856a
1 parent
f009d636
视频图片预览切换逻辑优化
Showing
7 changed files
with
80 additions
and
140 deletions
app/strike/src/main/java/com/cnlive/strike/imgutil/SimplePrevActivity.java
| @@ -14,7 +14,6 @@ import com.cnlive.core.gridview.GridImgUtil; | @@ -14,7 +14,6 @@ import com.cnlive.core.gridview.GridImgUtil; | ||
| 14 | import com.cnlive.core.gridview.adapter.BaseAutoGridHolder; | 14 | import com.cnlive.core.gridview.adapter.BaseAutoGridHolder; |
| 15 | import com.cnlive.core.gridview.adapter.SimpleAutoGridAdapter; | 15 | import com.cnlive.core.gridview.adapter.SimpleAutoGridAdapter; |
| 16 | import com.cnlive.core.imagepreview.ImagePreView; | 16 | import com.cnlive.core.imagepreview.ImagePreView; |
| 17 | -import com.cnlive.core.imagepreview.PhotoLoader; | ||
| 18 | import com.cnlive.core.imagepreview.ViewerStatus; | 17 | import com.cnlive.core.imagepreview.ViewerStatus; |
| 19 | import com.cnlive.core.imagepreview.listener.OnBrowseStatusListener; | 18 | import com.cnlive.core.imagepreview.listener.OnBrowseStatusListener; |
| 20 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; | 19 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
core/imageload/src/main/java/com/cnlive/core/imagepreview/ImageDrawee.java
| @@ -2,6 +2,8 @@ package com.cnlive.core.imagepreview; | @@ -2,6 +2,8 @@ package com.cnlive.core.imagepreview; | ||
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.graphics.drawable.Drawable; | 4 | import android.graphics.drawable.Drawable; |
| 5 | +import android.view.LayoutInflater; | ||
| 6 | +import android.view.View; | ||
| 5 | import android.widget.FrameLayout; | 7 | import android.widget.FrameLayout; |
| 6 | import android.widget.ImageView; | 8 | import android.widget.ImageView; |
| 7 | 9 | ||
| @@ -13,8 +15,8 @@ import com.bumptech.glide.request.target.Target; | @@ -13,8 +15,8 @@ import com.bumptech.glide.request.target.Target; | ||
| 13 | import com.cnlive.core.imageload.R; | 15 | import com.cnlive.core.imageload.R; |
| 14 | import com.cnlive.core.imagepreview.indexui.ProgressUI; | 16 | import com.cnlive.core.imagepreview.indexui.ProgressUI; |
| 15 | import com.github.chrisbanes.photoview.PhotoView; | 17 | import com.github.chrisbanes.photoview.PhotoView; |
| 18 | +import com.libs.video.video.exoplayer.controller.StandardVideoController; | ||
| 16 | import com.libs.video.video.exoplayer.play.CNVideoView; | 19 | import com.libs.video.video.exoplayer.play.CNVideoView; |
| 17 | -import com.libs.video.video.exoplayer.util.PlayerUtils; | ||
| 18 | 20 | ||
| 19 | import androidx.annotation.NonNull; | 21 | import androidx.annotation.NonNull; |
| 20 | import androidx.annotation.Nullable; | 22 | import androidx.annotation.Nullable; |
| @@ -26,24 +28,23 @@ import androidx.annotation.Nullable; | @@ -26,24 +28,23 @@ import androidx.annotation.Nullable; | ||
| 26 | public class ImageDrawee extends FrameLayout { | 28 | public class ImageDrawee extends FrameLayout { |
| 27 | private PhotoView imageView = null; | 29 | private PhotoView imageView = null; |
| 28 | private ProgressUI progressUI; | 30 | private ProgressUI progressUI; |
| 29 | - private ViewData viewData; | ||
| 30 | private CNVideoView videoView; | 31 | private CNVideoView videoView; |
| 32 | + private StandardVideoController mController; | ||
| 31 | 33 | ||
| 32 | - public ImageDrawee(@NonNull Context context,ViewData viewData,CNVideoView videoView) { | 34 | + public ImageDrawee(@NonNull Context context,ViewData viewData) { |
| 33 | super(context); | 35 | super(context); |
| 34 | - this.viewData = viewData; | ||
| 35 | - init(videoView); | 36 | + init(context); |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | - private void init(CNVideoView videoView) { | ||
| 39 | - if(viewData.getType() == 1){ | ||
| 40 | - imageView = new PhotoView(getContext()); | ||
| 41 | - addView(imageView); | ||
| 42 | - }else { | ||
| 43 | - PlayerUtils.removeViewFormParent(videoView); | ||
| 44 | - this.videoView = videoView; | ||
| 45 | - addView(videoView); | ||
| 46 | - } | 39 | + private void init(Context context) { |
| 40 | + LayoutInflater inflater = LayoutInflater.from(context); | ||
| 41 | + View view = inflater.inflate(R.layout.item_lay, null); | ||
| 42 | + imageView = view.findViewById(R.id.photoview); | ||
| 43 | + videoView = view.findViewById(R.id.veiew); | ||
| 44 | + mController = new StandardVideoController(context); | ||
| 45 | + mController.addDefaultControlComponent("", false); | ||
| 46 | + videoView.setVideoController(mController); | ||
| 47 | + addView(view); | ||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | public void setProgressUI(ProgressUI progressUI) { | 50 | public void setProgressUI(ProgressUI progressUI) { |
| @@ -116,9 +117,10 @@ public class ImageDrawee extends FrameLayout { | @@ -116,9 +117,10 @@ public class ImageDrawee extends FrameLayout { | ||
| 116 | } | 117 | } |
| 117 | if(videoView != null){ | 118 | if(videoView != null){ |
| 118 | videoView.release(); | 119 | videoView.release(); |
| 119 | -// PlayerUtils.removeViewFormParent(videoView); | ||
| 120 | } | 120 | } |
| 121 | - if(viewData.getType() == 1 && imageView != null){ | 121 | + if(data.getType() == 1){ |
| 122 | + videoView.setVisibility(GONE); | ||
| 123 | + imageView.setVisibility(VISIBLE); | ||
| 122 | Glide.with(getContext()) | 124 | Glide.with(getContext()) |
| 123 | .load(data.getImageSrc()) | 125 | .load(data.getImageSrc()) |
| 124 | .listener(new RequestListener<Drawable>() { | 126 | .listener(new RequestListener<Drawable>() { |
| @@ -136,7 +138,9 @@ public class ImageDrawee extends FrameLayout { | @@ -136,7 +138,9 @@ public class ImageDrawee extends FrameLayout { | ||
| 136 | }) | 138 | }) |
| 137 | .error(R.drawable.preview_zwtp) | 139 | .error(R.drawable.preview_zwtp) |
| 138 | .into(imageView); | 140 | .into(imageView); |
| 139 | - }else if(viewData.getType() == 2 && videoView != null){ | 141 | + } else if(data.getType() == 2 && videoView != null){ |
| 142 | + videoView.setVisibility(VISIBLE); | ||
| 143 | + imageView.setVisibility(GONE); | ||
| 140 | videoView.setUrl("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); | 144 | videoView.setUrl("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); |
| 141 | videoView.start(); | 145 | videoView.start(); |
| 142 | } | 146 | } |
core/imageload/src/main/java/com/cnlive/core/imagepreview/ImagePreView.java
| @@ -27,10 +27,6 @@ import com.cnlive.core.imagepreview.listener.OnItemClickListener; | @@ -27,10 +27,6 @@ import com.cnlive.core.imagepreview.listener.OnItemClickListener; | ||
| 27 | import com.cnlive.core.imagepreview.listener.OnItemLongPressListener; | 27 | import com.cnlive.core.imagepreview.listener.OnItemLongPressListener; |
| 28 | import com.cnlive.core.imagepreview.viewpager.ImagePagerAdapter; | 28 | import com.cnlive.core.imagepreview.viewpager.ImagePagerAdapter; |
| 29 | import com.cnlive.core.imagepreview.viewpager.ImageViewPager; | 29 | import com.cnlive.core.imagepreview.viewpager.ImageViewPager; |
| 30 | -import com.libs.video.video.exoplayer.controller.StandardVideoController; | ||
| 31 | -import com.libs.video.video.exoplayer.play.CNVideoView; | ||
| 32 | -import com.libs.video.video.exoplayer.util.L; | ||
| 33 | -import com.libs.video.video.exoplayer.util.PlayerUtils; | ||
| 34 | 30 | ||
| 35 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
| 36 | import java.util.List; | 32 | import java.util.List; |
| @@ -92,8 +88,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -92,8 +88,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 92 | private OnItemChangedListener mItemChangedListener; | 88 | private OnItemChangedListener mItemChangedListener; |
| 93 | private OnDragStatusListener mDragStatusListener; | 89 | private OnDragStatusListener mDragStatusListener; |
| 94 | private OnBrowseStatusListener mBrowseStatusListener; | 90 | private OnBrowseStatusListener mBrowseStatusListener; |
| 95 | - private CNVideoView videoView; | ||
| 96 | - private StandardVideoController mController; | 91 | + private boolean isFirst; |
| 97 | 92 | ||
| 98 | 93 | ||
| 99 | public ImagePreView(@NonNull Context context) { | 94 | public ImagePreView(@NonNull Context context) { |
| @@ -124,10 +119,6 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -124,10 +119,6 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 124 | a.recycle(); | 119 | a.recycle(); |
| 125 | } | 120 | } |
| 126 | } | 121 | } |
| 127 | - videoView = new CNVideoView(context); | ||
| 128 | - mController = new StandardVideoController(getContext()); | ||
| 129 | - mController.addDefaultControlComponent("", false); | ||
| 130 | - videoView.setVideoController(mController); | ||
| 131 | initView(); | 122 | initView(); |
| 132 | } | 123 | } |
| 133 | 124 | ||
| @@ -135,17 +126,14 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -135,17 +126,14 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 135 | if (getBackground() == null) { | 126 | if (getBackground() == null) { |
| 136 | setBackgroundColor(Color.BLACK); | 127 | setBackgroundColor(Color.BLACK); |
| 137 | } | 128 | } |
| 138 | - | ||
| 139 | // 添加 ViewPager | 129 | // 添加 ViewPager |
| 140 | viewPager = new ImageViewPager(getContext()); | 130 | viewPager = new ImageViewPager(getContext()); |
| 141 | - viewPager.setOffscreenPageLimit(1); | 131 | + viewPager.setOffscreenPageLimit(0); |
| 142 | viewPager.addOnPageChangeListener(this); | 132 | viewPager.addOnPageChangeListener(this); |
| 143 | addView(viewPager, new LayoutParams( | 133 | addView(viewPager, new LayoutParams( |
| 144 | LayoutParams.MATCH_PARENT, | 134 | LayoutParams.MATCH_PARENT, |
| 145 | LayoutParams.MATCH_PARENT)); | 135 | LayoutParams.MATCH_PARENT)); |
| 146 | - | ||
| 147 | setVisibility(View.INVISIBLE); | 136 | setVisibility(View.INVISIBLE); |
| 148 | - | ||
| 149 | progressUI = new DefaultProgressUI(); | 137 | progressUI = new DefaultProgressUI(); |
| 150 | } | 138 | } |
| 151 | 139 | ||
| @@ -157,7 +145,28 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -157,7 +145,28 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 157 | 145 | ||
| 158 | @Override | 146 | @Override |
| 159 | public void onPageSelected(int position) { | 147 | public void onPageSelected(int position) { |
| 160 | - startPlay(position); | 148 | + if(getCurrentItem() != null){ |
| 149 | + if(mSourceList.get(position).getType() != 2)getCurrentItem().handleProgress(0); | ||
| 150 | + getCurrentItem().setImage(mSourceList.get(position),new LoadImage.LoadCallback(){ | ||
| 151 | + @Override | ||
| 152 | + public void onLoadSucceed(Object source) { | ||
| 153 | + getCurrentItem().hideProgressUI(); | ||
| 154 | + if (mSourceList.get(position).getImageWidth() == 0 || | ||
| 155 | + mSourceList.get(position).getImageHeight() == 0) { | ||
| 156 | + Drawable drawable = getCurrentItem().getImageView().getDrawable(); | ||
| 157 | + if (drawable != null) { | ||
| 158 | + mSourceList.get(position).setImageWidth(drawable.getIntrinsicWidth()); | ||
| 159 | + mSourceList.get(position).setImageHeight(drawable.getIntrinsicHeight()); | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + @Override | ||
| 164 | + public void onLoadFailed() { | ||
| 165 | + getCurrentItem().hideProgressUI(); | ||
| 166 | + } | ||
| 167 | + }); | ||
| 168 | + } | ||
| 169 | + | ||
| 161 | if (showIndex && indexUI != null && mSourceList != null) { | 170 | if (showIndex && indexUI != null && mSourceList != null) { |
| 162 | indexUI.handleItemChanged(position, mSourceList.size()); | 171 | indexUI.handleItemChanged(position, mSourceList.size()); |
| 163 | } | 172 | } |
| @@ -171,20 +180,6 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -171,20 +180,6 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 171 | 180 | ||
| 172 | } | 181 | } |
| 173 | 182 | ||
| 174 | - private void startPlay(int position) { | ||
| 175 | - Log.e(TAG, "startPlay: release"); | ||
| 176 | - videoView.release(); | ||
| 177 | - PlayerUtils.removeViewFormParent(videoView); | ||
| 178 | - if(mSourceList.get(position).getType() == 1){ | ||
| 179 | - | ||
| 180 | - }else if(mSourceList.get(position).getType() == 2 && getCurrentItem().getImageView() == null){ | ||
| 181 | - Log.e(TAG, "startPlay: "+position); | ||
| 182 | - getCurrentItem().removeAllViews(); | ||
| 183 | - getCurrentItem().addView(videoView); | ||
| 184 | - videoView.setUrl("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); | ||
| 185 | - videoView.start(); | ||
| 186 | - } | ||
| 187 | - } | ||
| 188 | 183 | ||
| 189 | public ImagePreView imageData(@NonNull List list) { | 184 | public ImagePreView imageData(@NonNull List list) { |
| 190 | if (mSourceList == null) { | 185 | if (mSourceList == null) { |
| @@ -194,7 +189,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -194,7 +189,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 194 | } | 189 | } |
| 195 | for (int i = 0, len = list.size(); i < len; i++) { | 190 | for (int i = 0, len = list.size(); i < len; i++) { |
| 196 | ViewData vd = new ViewData(list.get(i)); | 191 | ViewData vd = new ViewData(list.get(i)); |
| 197 | - if (i == 0 || i == 2){ | 192 | + if(i == 3){ |
| 198 | vd.setType(2); | 193 | vd.setType(2); |
| 199 | }else { | 194 | }else { |
| 200 | vd.setType(1); | 195 | vd.setType(1); |
| @@ -223,6 +218,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -223,6 +218,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 223 | return this; | 218 | return this; |
| 224 | } | 219 | } |
| 225 | 220 | ||
| 221 | + | ||
| 226 | public ImagePreView viewData(@NonNull List<ViewData> list) { | 222 | public ImagePreView viewData(@NonNull List<ViewData> list) { |
| 227 | this.mSourceList = list; | 223 | this.mSourceList = list; |
| 228 | return this; | 224 | return this; |
| @@ -362,6 +358,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -362,6 +358,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 362 | @NonNull | 358 | @NonNull |
| 363 | @Override | 359 | @Override |
| 364 | public Object instantiateItem(@NonNull ViewGroup container, int position) { | 360 | public Object instantiateItem(@NonNull ViewGroup container, int position) { |
| 361 | + Log.e(TAG, "instantiateItem: "+position ); | ||
| 365 | return ImagePreView.this.instantiateItem(container, position, startPosition, callback); | 362 | return ImagePreView.this.instantiateItem(container, position, startPosition, callback); |
| 366 | } | 363 | } |
| 367 | }; | 364 | }; |
| @@ -378,8 +375,9 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -378,8 +375,9 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 378 | * 取消浏览 | 375 | * 取消浏览 |
| 379 | */ | 376 | */ |
| 380 | public void cancel() { | 377 | public void cancel() { |
| 381 | - videoView.release(); | ||
| 382 | - videoView.onDestroy(); | 378 | + if(getCurrentItem() != null && getCurrentItem().getVideoView() != null){ |
| 379 | + getCurrentItem().getVideoView().onDestroy(); | ||
| 380 | + } | ||
| 383 | cancel(null); | 381 | cancel(null); |
| 384 | } | 382 | } |
| 385 | 383 | ||
| @@ -389,7 +387,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -389,7 +387,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 389 | * @param callback 退场动画执行回调 | 387 | * @param callback 退场动画执行回调 |
| 390 | */ | 388 | */ |
| 391 | public void cancel(final ImageTransfer.OnTransCallback callback) { | 389 | public void cancel(final ImageTransfer.OnTransCallback callback) { |
| 392 | - if(getCurrentItem().getImageView() == null) { | 390 | + if(mSourceList.get(getCurrentPosition()).getType() != 1) { |
| 393 | playEnterAnim = false; | 391 | playEnterAnim = false; |
| 394 | playExitAnim = false; | 392 | playExitAnim = false; |
| 395 | draggable = false; | 393 | draggable = false; |
| @@ -451,7 +449,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -451,7 +449,7 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 451 | } | 449 | } |
| 452 | } | 450 | } |
| 453 | if (drawee == null) { | 451 | if (drawee == null) { |
| 454 | - drawee = new ImageDrawee(container.getContext(),mSourceList.get(position),videoView); | 452 | + drawee = new ImageDrawee(container.getContext(),mSourceList.get(position)); |
| 455 | drawee.setProgressUI(progressUI); | 453 | drawee.setProgressUI(progressUI); |
| 456 | mViewBox.add(drawee); | 454 | mViewBox.add(drawee); |
| 457 | } | 455 | } |
| @@ -536,18 +534,15 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -536,18 +534,15 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 536 | } | 534 | } |
| 537 | }); | 535 | }); |
| 538 | } | 536 | } |
| 539 | - drawee.setImage(mSourceList.get(position).getImageSrc(),new LoadImage.LoadCallback(){ | ||
| 540 | - | ||
| 541 | - @Override | ||
| 542 | - public void onLoadStarted(Object placeholder) { | ||
| 543 | - | ||
| 544 | - } | ||
| 545 | - | ||
| 546 | - @Override | ||
| 547 | - public void onLoading(float progress) { | ||
| 548 | - drawee.handleProgress(progress); | ||
| 549 | - } | ||
| 550 | 537 | ||
| 538 | + }else if(mSourceList.get(position).getType() == 2){ | ||
| 539 | + playEnterAnim = false; | ||
| 540 | + playExitAnim = false; | ||
| 541 | + draggable = false; | ||
| 542 | + } | ||
| 543 | + if(position == 0 && !isFirst){ | ||
| 544 | + isFirst = true; | ||
| 545 | + drawee.setImage(mSourceList.get(position),new LoadImage.LoadCallback(){ | ||
| 551 | @Override | 546 | @Override |
| 552 | public void onLoadSucceed(Object source) { | 547 | public void onLoadSucceed(Object source) { |
| 553 | drawee.hideProgressUI(); | 548 | drawee.hideProgressUI(); |
| @@ -566,26 +561,8 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | @@ -566,26 +561,8 @@ public class ImagePreView extends FrameLayout implements ViewPager.OnPageChangeL | ||
| 566 | drawee.hideProgressUI(); | 561 | drawee.hideProgressUI(); |
| 567 | } | 562 | } |
| 568 | }); | 563 | }); |
| 569 | - }else if(mSourceList.get(position).getType() == 2){ | ||
| 570 | - if(drawee.getImageView() == null){ | ||
| 571 | - videoView.setOnLongClickListener(new OnLongClickListener() { | ||
| 572 | - @Override | ||
| 573 | - public boolean onLongClick(View view) { | ||
| 574 | - if (!hasAnimRunning && mItemLongPressListener != null) { | ||
| 575 | - return mItemLongPressListener.onItemLongPress(position, videoView); | ||
| 576 | - } | ||
| 577 | - return false; | ||
| 578 | - } | ||
| 579 | - }); | ||
| 580 | - } | ||
| 581 | - playEnterAnim = false; | ||
| 582 | - playExitAnim = false; | ||
| 583 | - draggable = false; | ||
| 584 | - if(position == 0){ | ||
| 585 | - videoView.setUrl("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); | ||
| 586 | - videoView.start(); | ||
| 587 | - } | ||
| 588 | } | 564 | } |
| 565 | + | ||
| 589 | } | 566 | } |
| 590 | 567 | ||
| 591 | private void noteDragStatus(int status) { | 568 | private void noteDragStatus(int status) { |
core/imageload/src/main/java/com/cnlive/core/imagepreview/LoadImage.java
| @@ -13,12 +13,7 @@ public abstract class LoadImage { | @@ -13,12 +13,7 @@ public abstract class LoadImage { | ||
| 13 | public abstract void displayImage(Object src, ImageView imageView, LoadCallback callback); | 13 | public abstract void displayImage(Object src, ImageView imageView, LoadCallback callback); |
| 14 | 14 | ||
| 15 | public interface LoadCallback { | 15 | public interface LoadCallback { |
| 16 | - void onLoadStarted(Object placeholder); | ||
| 17 | - | ||
| 18 | - void onLoading(float progress); | ||
| 19 | - | ||
| 20 | void onLoadSucceed(Object source); | 16 | void onLoadSucceed(Object source); |
| 21 | - | ||
| 22 | void onLoadFailed(); | 17 | void onLoadFailed(); |
| 23 | } | 18 | } |
| 24 | } | 19 | } |
core/imageload/src/main/java/com/cnlive/core/imagepreview/PhotoLoader.java deleted
100644 → 0
| 1 | -package com.cnlive.core.imagepreview; | ||
| 2 | - | ||
| 3 | -import android.graphics.drawable.Drawable; | ||
| 4 | -import android.widget.ImageView; | ||
| 5 | - | ||
| 6 | -import com.bumptech.glide.request.target.CustomViewTarget; | ||
| 7 | -import com.bumptech.glide.request.transition.Transition; | ||
| 8 | -import com.cnlive.core.libs.base.application.GlideApp; | ||
| 9 | - | ||
| 10 | -import androidx.annotation.NonNull; | ||
| 11 | -import androidx.annotation.Nullable; | ||
| 12 | - | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * created by hanyayun | ||
| 16 | - * on 2020/2/12 | ||
| 17 | - */ | ||
| 18 | -public class PhotoLoader extends LoadImage { | ||
| 19 | - @Override | ||
| 20 | - public void displayImage(Object src, ImageView imageView, LoadCallback callback) { | ||
| 21 | - GlideApp.with(imageView.getContext()) | ||
| 22 | - .load(src) | ||
| 23 | - .into(new CustomViewTarget<ImageView, Drawable>(imageView) { | ||
| 24 | - @Override | ||
| 25 | - public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 26 | - if(callback!=null) { | ||
| 27 | - callback.onLoadFailed(); | ||
| 28 | - } | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | - @Override | ||
| 32 | - public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { | ||
| 33 | - if(callback!=null) { | ||
| 34 | - callback.onLoadSucceed(resource); | ||
| 35 | - } | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - @Override | ||
| 39 | - protected void onResourceLoading(@Nullable Drawable placeholder) { | ||
| 40 | - super.onResourceLoading(placeholder); | ||
| 41 | - if(callback!=null){ | ||
| 42 | - callback.onLoadStarted(placeholder); | ||
| 43 | - } | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - @Override | ||
| 47 | - protected void onResourceCleared(@Nullable Drawable placeholder) { | ||
| 48 | - | ||
| 49 | - } | ||
| 50 | - }); | ||
| 51 | - } | ||
| 52 | -} |
core/imageload/src/main/java/com/cnlive/core/imagepreview/ViewData.java
| @@ -19,7 +19,7 @@ public class ViewData { | @@ -19,7 +19,7 @@ public class ViewData { | ||
| 19 | private int targetWidth; | 19 | private int targetWidth; |
| 20 | // 目标 view 的高度 | 20 | // 目标 view 的高度 |
| 21 | private int targetHeight; | 21 | private int targetHeight; |
| 22 | - | 22 | + //1图片 2视频 |
| 23 | private int type; | 23 | private int type; |
| 24 | 24 | ||
| 25 | public ViewData() { | 25 | public ViewData() { |
core/imageload/src/main/res/layout/item_lay.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent"> | ||
| 5 | + | ||
| 6 | + <com.github.chrisbanes.photoview.PhotoView | ||
| 7 | + android:id="@+id/photoview" | ||
| 8 | + android:layout_width="wrap_content" | ||
| 9 | + android:layout_height="wrap_content" | ||
| 10 | + android:layout_centerInParent="true"/> | ||
| 11 | + | ||
| 12 | + <com.libs.video.video.exoplayer.play.CNVideoView | ||
| 13 | + android:id="@+id/veiew" | ||
| 14 | + android:layout_width="wrap_content" | ||
| 15 | + android:layout_height="wrap_content" | ||
| 16 | + android:layout_centerInParent="true"/> | ||
| 17 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |