Skip to content

不可见时自动停止自动滚动 #12

@ysemylord

Description

@ysemylord

如果SimpleSilder放在一个可以滑动的控件里,SimplerSlider在不可见时是没有必要滚动的,所以

 private boolean initAutoCycling = autoCycling;
    private boolean firstSetAuto = true;
  public void setAutoCycling(boolean autoCycling) {
        this.autoCycling = autoCycling;
        if (firstSetAuto) {
            firstSetAuto = false;
            initAutoCycling = autoCycling;
        }
        if (autoCycling) startAutoCycling();
        else stopAutoCycling();
    }

    @Override
    protected void onWindowVisibilityChanged(int visibility) {
        super.onWindowVisibilityChanged(visibility);
        if (visibility == View.VISIBLE) {
            if (initAutoCycling) {
                setAutoCycling(true);
            }
        } else if (visibility == INVISIBLE || visibility == GONE) {
            if (initAutoCycling) {
                setAutoCycling(false);
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions