eschao / android-PageFlip

3D Style Page Flip on Android
Apache License 2.0
1.74k stars 262 forks source link

Unnecessary steps (?) #19

Closed yuwono95 closed 6 years ago

yuwono95 commented 7 years ago

https://github.com/eschao/android-PageFlip/blob/09d2755a021981eb791b586bd56b484ef14cb1f4/Sample/src/main/java/com/eschao/android/widget/sample/pageflip/LoadBitmapTask.java#L206

By the end of this method, variable mBGSizeIndex will always have value equals to LARGE_BG. Is this by intention? If it is, we could rewrite this method like below:

public void set(int w, int h, int maxCached) {
    mIsLandscape = w > h;

    if (maxCached != mQueueMaxSize) {
        mQueueMaxSize = maxCached;
    }

    mBGSizeIndex = LARGE_BG;
    synchronized (this) {
        cleanQueue();
        notify();
    }
}

Regards.

eschao commented 7 years ago

I didn't see the mBGSizeIndex = LARGE_BG; in my code. The intention of this piece of codes is used to determine which bitmap size is fit for current screen resolution and mode(portrait or landscape). So I don't think it will always be in LARGE_BG

yuwono95 commented 7 years ago

Please pay attention to the method

Line 183: newIndex = LARGE_BG; Line 199: if mBGSizeIndex not equals to newIndex then set mBGSizeIndex = newIndex; Line 206: hence at the end of the method, mBGSizeIndex will always have value = LARGE_BG

Huskyyy commented 7 years ago

楼主说的是对的,这一块的逻辑走到最后 mBGSizeIndex = LARGE_BG,导致在低尺寸的手机上也会加载大图。

yuwono95 commented 6 years ago

I believe this has been fixed. Thanks.