@Override
    protected void onRefresh() {
        mForegroundProgress = mForegroundProgress + mSpeed;

        if (mForegroundProgress > 1) {
            mForegroundProgress = mForegroundProgress - 1;
            getNextForegroundColor();
        }

        final float progress = mForegroundProgress;
        final float maxLine = mMaxForegroundLine;
        final float centerOffset = (mEndX - mStartX) * progress;
        float centerX = mStartX + centerOffset;


        float hrefWidth;
        if (mProgressType == 1) {
            // in this on progress=0.5 the line have max value
            if (progress > 0.5f) {
                hrefWidth = maxLine * (1 - progress);
            } else {
                hrefWidth = maxLine * progress;
            }
        } else if (mProgressType == 2) {
            // in this the line up to maxLine, then slide to the end, stick to the end until it ends.
            float width = maxLine * progress;
            hrefWidth = width / 2;
            if ((centerX + hrefWidth) > mEndX) {
                hrefWidth = mEndX - centerX;
            }
        } else {
            // in this the adhesion increases with the head until the maximum value,
            // sliding to the end, and the end of the adhesive tail.
            if ((centerOffset + centerOffset) > maxLine) {
                hrefWidth = maxLine / 2;
            } else {
                hrefWidth = centerOffset;
            }
            // if > the end, we cut it
            if ((centerX + hrefWidth) > mEndX) {
                hrefWidth = mEndX - centerX;
            }
        }

        mForegroundLeft = centerX - hrefWidth;
        mForegroundRight = centerX + hrefWidth;

    }
A drawable to draw loading form Line Type
caprice/ui/src/main/java/net/qiujuer/genius/ui/drawable/LoadingLineDrawable.java