BigImageViewer icon indicating copy to clipboard operation
BigImageViewer copied to clipboard

getSSIV().resetScaleAndCenter() does not work

Open scifinder opened this issue 7 years ago • 7 comments

Hello! I need the picture to be scaled (fit) when the screen rotates. In SSIV it worked:

    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if(oldh != 0 && oldw != 0){
            resetScaleAndCenter();
        }
    }

But, if I override onSizeChanged for BIV, it does not work:

    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if(oldh != 0 && oldw != 0){
            getSSIV().resetScaleAndCenter();
        }
    }

How can I fix it?

scifinder avatar Feb 03 '18 07:02 scifinder

You mean onSizeChanged not called?

Piasy avatar Feb 03 '18 11:02 Piasy

onSizeChanged is called (Log.d(...) inside the onSizeChanged prints a log). But getSSIV().resetScaleAndCenter() not called. I asked the initial question here. I override onSizeChanged for SubsamplingScaleImageView, and the picture began to fit into the screen when the screen was rotated. It work:

public class MyImageView extends SubsamplingScaleImageView {
...
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if(oldh != 0 && oldw != 0){
            resetScaleAndCenter();
        }
    }
}

Then I switched to using BigImageViewer. And a similar code did not work:

public class MyImageView extends BigImageView {
...
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if(oldh != 0 && oldw != 0){
            getSSIV().resetScaleAndCenter();
        }
    }
}

getSSIV().resetScaleAndCenter() not called. I need to enter the picture in the screen size when turning the screen.

scifinder avatar Feb 03 '18 13:02 scifinder

What do you mean by "getSSIV().resetScaleAndCenter() not called"? oldh != 0 && oldw != 0 always be false?

Piasy avatar Feb 04 '18 01:02 Piasy

Now, if I turn the screen, the image will go beyond it (I use BIV in Fragment): i get I want the image to be placed in it when turning the screen: i want For this, I override onSizeChanged so that when the screen was rotated, the scale and center were reset. But it does not work. It works for the original SSIV, but does not work for BIV. The problem is not oldh != 0 && oldw != 0. I can write like this:

protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        getSSIV().resetScaleAndCenter();
}

But I still get this result: i get I conclude that the reset (getSSIV().resetScaleAndCenter()) does not work.

scifinder avatar Feb 04 '18 04:02 scifinder

I see.

Could you please clone this project, and debug it under your use case?

Piasy avatar Feb 04 '18 05:02 Piasy

Any update? @scifinder

Piasy avatar Mar 13 '18 14:03 Piasy

I just used original SSIV =(

scifinder avatar Mar 13 '18 15:03 scifinder