Commit e9d55089a4b0bb480c4fad0776ca6865e1af02cf
1 parent
e25988c4
代码更新
Showing
10 changed files
with
228 additions
and
3 deletions
core/imageload/build.gradle
| @@ -28,6 +28,7 @@ dependencies { | @@ -28,6 +28,7 @@ dependencies { | ||
| 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) | 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) |
| 29 | 29 | ||
| 30 | implementation 'androidx.appcompat:appcompat:1.1.0' | 30 | implementation 'androidx.appcompat:appcompat:1.1.0' |
| 31 | + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
| 31 | testImplementation 'junit:junit:4.12' | 32 | testImplementation 'junit:junit:4.12' |
| 32 | androidTestImplementation 'androidx.test:runner:1.1.1' | 33 | androidTestImplementation 'androidx.test:runner:1.1.1' |
| 33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | 34 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
| @@ -37,6 +38,4 @@ dependencies { | @@ -37,6 +38,4 @@ dependencies { | ||
| 37 | implementation 'jp.wasabeef:glide-transformations:3.0.1' | 38 | implementation 'jp.wasabeef:glide-transformations:3.0.1' |
| 38 | //滤镜 | 39 | //滤镜 |
| 39 | implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1' | 40 | implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1' |
| 40 | - //图片预览 | ||
| 41 | -// implementation 'com.ycjiang:imgepreviewlibrary:1.1.3' | ||
| 42 | } | 41 | } |
core/imageload/src/main/AndroidManifest.xml
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 2 | - package="com.cnlive.core.imageload" /> | 3 | + package="com.cnlive.core.imageload"> |
| 4 | + | ||
| 5 | + <application> | ||
| 6 | + <activity android:name=".preview.PreviewImageViewActivity"></activity> | ||
| 7 | + </application> | ||
| 8 | + | ||
| 9 | +</manifest> | ||
| 3 | \ No newline at end of file | 10 | \ No newline at end of file |
core/imageload/src/main/java/com/cnlive/core/imageload/preview/PreviewImageViewActivity.java
0 → 100644
| 1 | +package com.cnlive.core.imageload.preview; | ||
| 2 | + | ||
| 3 | +import android.Manifest; | ||
| 4 | +import android.graphics.Color; | ||
| 5 | + | ||
| 6 | +import com.cnlive.core.imageload.R; | ||
| 7 | +import com.cnlive.core.imageload.preview.model.ImagePreviewShowInfo; | ||
| 8 | +import com.cnlive.core.imageload.preview.presenter.PreviewImagePresenter; | ||
| 9 | +import com.cnlive.core.imageload.preview.view.PreviewImageView; | ||
| 10 | +import com.cnlive.core.libs.base.frame.activity.BaseActivity; | ||
| 11 | +import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener; | ||
| 12 | +import com.cnlive.core.libs.base.util.StatusBarUtil; | ||
| 13 | + | ||
| 14 | +public class PreviewImageViewActivity extends BaseActivity<PreviewImageView, PreviewImagePresenter> { | ||
| 15 | + | ||
| 16 | + ImagePreviewShowInfo previewInfo; | ||
| 17 | + | ||
| 18 | + @Override | ||
| 19 | + protected void initView() { | ||
| 20 | + getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT); | ||
| 21 | + StatusBarUtil.setTransparentForWindow(this); | ||
| 22 | + StatusBarUtil.addTranslucentView(this,0); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + protected int getViewLayoutId() { | ||
| 27 | + return R.layout.activity_preview_image_view; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public void onBackPressed() { | ||
| 32 | + if(!isFinishing()) { | ||
| 33 | + finish(); | ||
| 34 | + overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + //弹出处理图片的工具页面 | ||
| 40 | + public void showProcessDialog(ImagePreviewShowInfo info){ | ||
| 41 | + previewInfo=info; | ||
| 42 | + requestPermission(R.string.dialog_imagepicker_permission_save_pic,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, new OnPermissionResponseListener() { | ||
| 43 | + @Override | ||
| 44 | + public void onSuccess(String[] permissions) { | ||
| 45 | + if(getMvpView() != null) { //getMvpView().showQrDialog("", info.getImgPath()); | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public void onFail() { | ||
| 51 | + | ||
| 52 | + } | ||
| 53 | + }); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + protected void onDestroy() { | ||
| 58 | + super.onDestroy(); | ||
| 59 | + if(getPresenter() != null){ | ||
| 60 | + //getPresenter().cancel(); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | +} |
core/imageload/src/main/java/com/cnlive/core/imageload/preview/model/ImagePreviewShowInfo.java
0 → 100644
| 1 | +package com.cnlive.core.imageload.preview.model; | ||
| 2 | + | ||
| 3 | +import java.io.Serializable; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * created by hanyayun | ||
| 7 | + * on 2019/11/26 | ||
| 8 | + */ | ||
| 9 | +public class ImagePreviewShowInfo implements Serializable { | ||
| 10 | + private String imgPath; | ||
| 11 | + private String previewPath; | ||
| 12 | + | ||
| 13 | + public String getImgPath() { | ||
| 14 | + return imgPath; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public void setImgPath(String imgPath) { | ||
| 18 | + this.imgPath = imgPath; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public String getPreviewPath() { | ||
| 22 | + return previewPath; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void setPreviewPath(String previewPath) { | ||
| 26 | + this.previewPath = previewPath; | ||
| 27 | + } | ||
| 28 | +} |
core/imageload/src/main/java/com/cnlive/core/imageload/preview/presenter/PreviewImagePresenter.java
0 → 100644
| 1 | +package com.cnlive.core.imageload.preview.presenter; | ||
| 2 | + | ||
| 3 | +import com.cnlive.core.imageload.preview.view.PreviewImageView; | ||
| 4 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * created by hanyayun | ||
| 8 | + * on 2019/11/26 | ||
| 9 | + */ | ||
| 10 | +public class PreviewImagePresenter extends BasePresenter<PreviewImageView> { | ||
| 11 | + | ||
| 12 | +} |
core/imageload/src/main/java/com/cnlive/core/imageload/preview/view/PreviewImageView.java
0 → 100644
core/imageload/src/main/java/com/cnlive/core/imageload/preview/widget/MutipleTouchViewPager.java
0 → 100644
| 1 | +package com.cnlive.core.imageload.preview.widget; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.util.AttributeSet; | ||
| 5 | +import android.view.MotionEvent; | ||
| 6 | + | ||
| 7 | +import androidx.annotation.NonNull; | ||
| 8 | +import androidx.annotation.Nullable; | ||
| 9 | +import androidx.viewpager.widget.ViewPager; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * created by hanyayun | ||
| 13 | + * on 2019/11/26 | ||
| 14 | + * 解决 pointerIndex out of range的异常 | ||
| 15 | + */ | ||
| 16 | +public class MutipleTouchViewPager extends ViewPager { | ||
| 17 | + | ||
| 18 | + private boolean mIsDisallowIntercept = false; | ||
| 19 | + | ||
| 20 | + public MutipleTouchViewPager(@NonNull Context context) { | ||
| 21 | + super(context); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public MutipleTouchViewPager(@NonNull Context context, @Nullable AttributeSet attrs) { | ||
| 25 | + super(context, attrs); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { | ||
| 30 | + mIsDisallowIntercept = disallowIntercept; | ||
| 31 | + super.requestDisallowInterceptTouchEvent(disallowIntercept); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public boolean dispatchTouchEvent(MotionEvent ev) { | ||
| 36 | + if (ev.getPointerCount() > 1 && mIsDisallowIntercept) { | ||
| 37 | + requestDisallowInterceptTouchEvent(false); | ||
| 38 | + boolean handled = super.dispatchTouchEvent(ev); | ||
| 39 | + requestDisallowInterceptTouchEvent(true); | ||
| 40 | + return handled; | ||
| 41 | + } else { | ||
| 42 | + return super.dispatchTouchEvent(ev); | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | +} |
core/imageload/src/main/res/drawable-xhdpi/preview_zwtp.9.png
0 → 100644
2.24 KB
core/imageload/src/main/res/layout/activity_preview_image_view.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="match_parent" | ||
| 7 | + android:background="@color/black" | ||
| 8 | + tools:context=".preview.PreviewImageViewActivity"> | ||
| 9 | + | ||
| 10 | + <ImageView | ||
| 11 | + android:id="@+id/iv_error" | ||
| 12 | + android:layout_width="wrap_content" | ||
| 13 | + android:layout_height="wrap_content" | ||
| 14 | + android:layout_centerInParent="true" | ||
| 15 | + android:scaleType="fitCenter" | ||
| 16 | + android:background="@drawable/preview_zwtp" | ||
| 17 | + android:visibility="gone"/> | ||
| 18 | + | ||
| 19 | + <com.cnlive.core.imageload.preview.widget.MutipleTouchViewPager | ||
| 20 | + android:id="@+id/vp_photos" | ||
| 21 | + android:layout_width="match_parent" | ||
| 22 | + android:layout_height="wrap_content" | ||
| 23 | + android:background="@color/black" | ||
| 24 | + android:layout_centerInParent="true" | ||
| 25 | + /> | ||
| 26 | + | ||
| 27 | + <LinearLayout | ||
| 28 | + android:id="@+id/rl_indicator" | ||
| 29 | + android:layout_width="wrap_content" | ||
| 30 | + android:layout_height="wrap_content" | ||
| 31 | + android:layout_alignParentBottom="true" | ||
| 32 | + android:layout_centerHorizontal="true" | ||
| 33 | + android:layout_marginBottom="40dp" | ||
| 34 | + android:orientation="horizontal" | ||
| 35 | + android:visibility="gone"> | ||
| 36 | + <TextView | ||
| 37 | + android:id="@+id/tv_current" | ||
| 38 | + android:layout_width="wrap_content" | ||
| 39 | + android:layout_height="wrap_content" | ||
| 40 | + android:textColor="@color/white" | ||
| 41 | + android:textSize="18sp" /> | ||
| 42 | + | ||
| 43 | + <TextView | ||
| 44 | + android:id="@+id/tv" | ||
| 45 | + android:layout_width="wrap_content" | ||
| 46 | + android:layout_height="wrap_content" | ||
| 47 | + android:layout_marginLeft="3dp" | ||
| 48 | + android:textColor="@color/white" | ||
| 49 | + android:text="/" | ||
| 50 | + android:textSize="18sp" /> | ||
| 51 | + | ||
| 52 | + <TextView | ||
| 53 | + android:id="@+id/tv_All" | ||
| 54 | + android:layout_width="wrap_content" | ||
| 55 | + android:layout_height="wrap_content" | ||
| 56 | + android:layout_marginLeft="3dp" | ||
| 57 | + android:textSize="18sp" | ||
| 58 | + android:textColor="@color/white"/> | ||
| 59 | + </LinearLayout> | ||
| 60 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 61 | \ No newline at end of file |
core/imageload/src/main/res/values/strings.xml