Skip to content

Commit

Permalink
1、完善缩放问题
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Nov 27, 2024
1 parent 98f0713 commit fd5e630
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.flyjingfish.openimagefulllib;

import android.content.Context;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.ViewTreeObserver;
Expand Down Expand Up @@ -33,7 +32,6 @@ public ScaleRelativeLayout(@NonNull Context context) {
public ScaleRelativeLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs,0);
}

public ScaleRelativeLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
attacher = new VideoPlayerAttacher(ScaleRelativeLayout.this);
Expand Down Expand Up @@ -101,19 +99,11 @@ public void onGlobalLayout() {
}

private void syncAttacher(){
float scaleX = photoViewAttacher.getValue(Matrix.MSCALE_X);
float translateX = photoViewAttacher.getValue(Matrix.MTRANS_X);
float translateY = photoViewAttacher.getValue(Matrix.MTRANS_Y);
attacher.setScaleIgnoreBounds(scaleX);
attacher.postTranslate(translateX,translateY);
attacher.syncMatrixValue(photoViewAttacher.getMatrixValues());
}

private void syncPhotoAttacher(){
float scaleX = attacher.getValue(Matrix.MSCALE_X);
float translateX = attacher.getValue(Matrix.MTRANS_X);
float translateY = attacher.getValue(Matrix.MTRANS_Y);
photoViewAttacher.setScaleIgnoreBounds(scaleX);
photoViewAttacher.postTranslate(translateX,translateY);
photoViewAttacher.syncMatrixValue(attacher.getMatrixValues());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,16 +739,10 @@ public void setScale(float scale, float focalX, float focalY,
checkAndDisplayMatrix();
}
}
public void setScaleIgnoreBounds(float scale) {
mSuppMatrix.setScale(scale, scale, (mImageView.getRight()) / 2,
(mImageView.getBottom()) / 2);
mBigImageMatrix.setScale(scale, scale, (mImageView.getRight()) / 2,
(mImageView.getBottom()) / 2);
checkAndDisplayMatrix();
}
public void postTranslate(float dx, float dy) {
mSuppMatrix.postTranslate(dx, dy);
mBigImageMatrix.postTranslate(dx, dy);

public void syncMatrixValue(float[] values) {
mSuppMatrix.setValues(values);
mBigImageMatrix.setValues(values);
checkAndDisplayMatrix();
}
/**
Expand Down Expand Up @@ -845,8 +839,10 @@ private float getValue(Matrix matrix, int whichValue) {
matrix.getValues(mMatrixValues);
return mMatrixValues[whichValue];
}
public float getValue(int whichValue) {
return getValue(mSuppMatrix, whichValue);

public float[] getMatrixValues() {
mSuppMatrix.getValues(mMatrixValues);
return mMatrixValues;
}
/**
* Resets the Matrix back to FIT_CENTER, and then displays its contents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@
android:text="00:00"
android:layout_marginEnd="16dp"
android:textColor="#ffffff" />
<ImageView
android:id="@+id/fullscreen"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="10dp"
android:layout_marginEnd="6dp"
android:src="@drawable/video_enlarge"/>
</LinearLayout>

<ProgressBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,16 +730,10 @@ public void setScale(float scale, float focalX, float focalY,
}
}

public void setScaleIgnoreBounds(float scale) {
mSuppMatrix.setScale(scale, scale, (mImageView.getRight()) / 2,
(mImageView.getBottom()) / 2);
mBigImageMatrix.setScale(scale, scale, (mImageView.getRight()) / 2,
(mImageView.getBottom()) / 2);
checkAndDisplayMatrix();
}
public void postTranslate(float dx, float dy) {
mSuppMatrix.postTranslate(dx, dy);
mBigImageMatrix.postTranslate(dx, dy);

public void syncMatrixValue(float[] values) {
mSuppMatrix.setValues(values);
mBigImageMatrix.setValues(values);
checkAndDisplayMatrix();
}

Expand Down Expand Up @@ -838,10 +832,10 @@ private float getValue(Matrix matrix, int whichValue) {
return mMatrixValues[whichValue];
}

public float getValue(int whichValue) {
return getValue(mSuppMatrix, whichValue);
public float[] getMatrixValues() {
mSuppMatrix.getValues(mMatrixValues);
return mMatrixValues;
}

/**
* Resets the Matrix back to FIT_CENTER, and then displays its contents
*/
Expand Down
Binary file modified apk/coil2/release/app-coil2-release.apk
Binary file not shown.

0 comments on commit fd5e630

Please sign in to comment.