Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cutting bubble on screen rotate #53

Closed
lewkka opened this issue Oct 9, 2015 · 3 comments
Closed

Cutting bubble on screen rotate #53

lewkka opened this issue Oct 9, 2015 · 3 comments

Comments

@lewkka
Copy link

lewkka commented Oct 9, 2015

https://i.gyazo.com/0765c4c94eb04a16335b1fc1880f9bea.gif

Have changed screen orientation to horizontal: bubble hides on a half way. But if app starts in horizontal – it's OK.

@mrfix1t
Copy link

mrfix1t commented Nov 23, 2015

I found solution. This problem is caused by old display metrics values in PopupIndicator class after screen rotation. I moved initialization of DisplayMetrics in onSizeChanged method:

public void onSizeChanged() {
        DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
        screenSize.set(displayMetrics.widthPixels, displayMetrics.heightPixels);
}

Then simply call this method for PopupIndicator instance in onSizeChanged() method for DiscreteSeekBar class:

@Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        Log.i("www", "onSizeChanged");
        int thumbWidth = mThumb.getIntrinsicWidth();
        int thumbHeight = mThumb.getIntrinsicHeight();
        int addedThumb = mAddedTouchBounds;
        int halfThumb = thumbWidth / 2;
        int paddingLeft = getPaddingLeft() + addedThumb;
        int paddingRight = getPaddingRight();
        int bottom = getHeight() - getPaddingBottom() - addedThumb;
        mThumb.setBounds(paddingLeft, bottom - thumbHeight, paddingLeft + thumbWidth, bottom);
        int trackHeight = Math.max(mTrackHeight / 2, 1);
        mTrack.setBounds(paddingLeft + halfThumb, bottom - halfThumb - trackHeight,
                getWidth() - halfThumb - paddingRight - addedThumb, bottom - halfThumb + trackHeight);
        int scrubberHeight = Math.max(mScrubberHeight / 2, 2);
        mScrubber.setBounds(paddingLeft + halfThumb, bottom - halfThumb - scrubberHeight,
                paddingLeft + halfThumb, bottom - halfThumb + scrubberHeight);

        //Update the thumb position after size changed
        updateThumbPosFromCurrentProgress();
        mIndicator.onSizeChanged();
}

@AnderWeb
Copy link
Owner

I can't reproduce the issue.
Could you reproduce it with the sample app?
I've tried adding "configchanges:orientation" to the sample app's MainActivity but the popup was properly shown.

Does it happen on every android version?

If you manage to reproduce it for the sample app, I've created a (I think) better solution but I'd need to reproduce the issue to see if it works.

Thanks.

@mrfix1t
Copy link

mrfix1t commented Jan 26, 2016

Hi! I tested on 5.1 Android Galaxy S6 phone. Also this issue reproduce on Htc One Android 5.0 and Huawei P6 Android 4.2. Try this set of flags android:configChanges="keyboardHidden|orientation|screenSize" to MainActivity in manifest. This problem ussually appears when activity first created on Portrait mode.PS. You can see attached screenshot from Huawei.
Thanks.
screenshot_2016-01-26-16-32-49

AnderWeb added a commit that referenced this issue Jan 26, 2016
…Activities/Fragments handling their own orientation changes. Closes github issue #53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants