GeezerVison is showing github.com — 完成自主开发的DropboxHeader · StandOpen/SmartRefreshLayout@495b53d
File treeExpand file treeCollapse file tree Open diff view settings refresh-header/src/main/java/com/scwang/smartrefresh/header
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: refresh-header/src/main/java/com/scwang/smartrefresh/header/DropboxHeader.java +25-29Lines changed: 25 additions & 29 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -91,6 +91,20 @@ private void initView(Context context, AttributeSet attrs) { | 91 | 91 | } else { | 92 | 92 | PathsDrawable drawable1 = new PathsDrawable(); | 93 | 93 | drawable1.parserPaths( | | 94 | + "M3 2h18v20h-18z", | | 95 | + "m4,1c-1.105,0 -2,0.895 -2,2v3,11 3,1c0,1.105 0.895,2 2,2h2,12 2c1.105,0 2,-0.895 2,-2v-1,-3 -11,-3c0,-1.105 -0.895,-2 -2,-2h-2,-12 -2zM3.5,3h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,3h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,6h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,6h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,9h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,9h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,12h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,12h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,15h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,15h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,18h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,18h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5z" | | 96 | + ); | | 97 | + drawable1.parserColors( | | 98 | + 0xffecf0f1, | | 99 | + 0xfffc4108 | | 100 | + ); | | 101 | + mDrawable1 = drawable1; | | 102 | + } | | 103 | + if (ta.hasValue(R.styleable.DropboxHeader_dhDrawable2)) { | | 104 | + mDrawable2 = ta.getDrawable(R.styleable.DropboxHeader_dhDrawable2); | | 105 | + } else { | | 106 | + PathsDrawable drawable2 = new PathsDrawable(); | | 107 | + drawable2.parserPaths( | 94 | 108 | "M49,16.5l-14,-14l-27,0l0,53l41,0z", | 95 | 109 | "m16,23.5h25c0.55,0 1,-0.45 1,-1 0,-0.55 -0.45,-1 -1,-1L16,21.5c-0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1z", | 96 | 110 | "m16,15.5h10c0.55,0 1,-0.45 1,-1 0,-0.55 -0.45,-1 -1,-1L16,13.5c-0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1z", | @@ -99,32 +113,18 @@ private void initView(Context context, AttributeSet attrs) { | 99 | 113 | "M41,45.5L16,45.5c-0.55,0 -1,0.45 -1,1 0,0.55 0.45,1 1,1h25c0.55,0 1,-0.45 1,-1 0,-0.55 -0.45,-1 -1,-1z", | 100 | 114 | "M49,16.5l-14,-14l0,14z" | 101 | 115 | ); | 102 | | - drawable1.parserColors( | | 116 | + drawable2.parserColors( | 103 | 117 | 0xfffed469, | 104 | 118 | 0xffd5ae57 | 105 | 119 | ); | 106 | | - mDrawable1 = drawable1; | 107 | | - } | 108 | | - if (ta.hasValue(R.styleable.DropboxHeader_dhDrawable2)) { | 109 | | - mDrawable2 = ta.getDrawable(R.styleable.DropboxHeader_dhDrawable2); | 110 | | - } else { | 111 | | - PathsDrawable drawable2 = new PathsDrawable(); | 112 | | - drawable2.parserPaths("M6.021,2.188L6.021,11.362C5.46,11.327 4.843,11.414 4.229,11.663C2.624,12.312 1.696,13.729 2.155,14.825C2.62,15.924 4.294,16.284 5.898,15.634C7.131,15.134 7.856,14.184 7.965,13.272L7.958,4.387L15.02,3.028L15.02,9.406C14.422,9.343 13.746,9.432 13.076,9.703C11.471,10.353 10.544,11.77 11.004,12.866C11.467,13.964 13.141,14.325 14.746,13.675C15.979,13.174 16.836,12.224 16.947,11.313L16.958,0.002L6.021,2.188L6.021,2.188Z"); | 113 | | - drawable2.parserColors(0xff98d761); | 114 | 120 | mDrawable2 = drawable2; | 115 | 121 | } | 116 | 122 | if (ta.hasValue(R.styleable.DropboxHeader_dhDrawable3)) { | 117 | 123 | mDrawable3 = ta.getDrawable(R.styleable.DropboxHeader_dhDrawable3); | 118 | 124 | } else { | 119 | 125 | PathsDrawable drawable3 = new PathsDrawable(); | 120 | | - drawable3.parserPaths( | 121 | | - "M3 2h18v20h-18z", | 122 | | - "m4,1c-1.105,0 -2,0.895 -2,2v3,11 3,1c0,1.105 0.895,2 2,2h2,12 2c1.105,0 2,-0.895 2,-2v-1,-3 -11,-3c0,-1.105 -0.895,-2 -2,-2h-2,-12 -2zM3.5,3h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,3h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,6h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,6h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,9h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,9h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,12h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,12h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,15h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,15h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM3.5,18h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5zM19.5,18h1c0.276,0 0.5,0.224 0.5,0.5v1c0,0.276 -0.224,0.5 -0.5,0.5h-1c-0.276,0 -0.5,-0.224 -0.5,-0.5v-1c0,-0.276 0.224,-0.5 0.5,-0.5z" | 123 | | - ); | 124 | | - drawable3.parserColors( | 125 | | - 0xffecf0f1, | 126 | | - 0xfffc4108 | 127 | | - ); | | 126 | + drawable3.parserPaths("M6.021,2.188L6.021,11.362C5.46,11.327 4.843,11.414 4.229,11.663C2.624,12.312 1.696,13.729 2.155,14.825C2.62,15.924 4.294,16.284 5.898,15.634C7.131,15.134 7.856,14.184 7.965,13.272L7.958,4.387L15.02,3.028L15.02,9.406C14.422,9.343 13.746,9.432 13.076,9.703C11.471,10.353 10.544,11.77 11.004,12.866C11.467,13.964 13.141,14.325 14.746,13.675C15.979,13.174 16.836,12.224 16.947,11.313L16.958,0.002L6.021,2.188L6.021,2.188Z"); | | 127 | + drawable3.parserColors(0xff98d761); | 128 | 128 | mDrawable3 = drawable3; | 129 | 129 | } | 130 | 130 | ta.recycle(); | @@ -186,7 +186,6 @@ protected void onDraw(Canvas canvas) { | 186 | 186 |
| 187 | 187 | if (isInEditMode()) { | 188 | 188 | mDropOutPercent = 2.5f; | 189 | | - mDropOutOverFlow = true; | 190 | 189 | } | 191 | 190 | if (mDropOutPercent > 0) { | 192 | 191 | canvas.clipPath(generateClipPath(body, width)); | @@ -205,20 +204,17 @@ protected void onDraw(Canvas canvas) { | 205 | 204 | Rect bounds3 = mDrawable3.getBounds(); | 206 | 205 | bounds3.offsetTo(width / 2 - bounds3.width() / 2, (int) ((body.boxCenterY - bounds3.height() / 2 + bounds3.height()) * percent3) - bounds3.height()); | 207 | 206 | mDrawable3.draw(canvas); | 208 | | - } | 209 | 207 |
| 210 | | - if (mDropOutOverFlow) { | 211 | | - Rect bounds1 = mDrawable1.getBounds(); | 212 | | - bounds1.offsetTo(width / 2 - bounds1.width() / 2, ((body.boxCenterY - bounds1.height() / 2))); | 213 | | - mDrawable1.draw(canvas); | | 208 | + if (mDropOutOverFlow) { | | 209 | + bounds1.offsetTo(width / 2 - bounds1.width() / 2, ((body.boxCenterY - bounds1.height() / 2))); | | 210 | + mDrawable1.draw(canvas); | 214 | 211 |
| 215 | | - Rect bounds2 = mDrawable2.getBounds(); | 216 | | - bounds2.offsetTo(width / 2 - bounds2.width() / 2, ((body.boxCenterY - bounds2.height() / 2))); | 217 | | - mDrawable2.draw(canvas); | | 212 | + bounds2.offsetTo(width / 2 - bounds2.width() / 2, ((body.boxCenterY - bounds2.height() / 2))); | | 213 | + mDrawable2.draw(canvas); | 218 | 214 |
| 219 | | - Rect bounds3 = mDrawable3.getBounds(); | 220 | | - bounds3.offsetTo(width / 2 - bounds3.width() / 2, ((body.boxCenterY - bounds3.height() / 2))); | 221 | | - mDrawable3.draw(canvas); | | 215 | + bounds3.offsetTo(width / 2 - bounds3.width() / 2, ((body.boxCenterY - bounds3.height() / 2))); | | 216 | + mDrawable3.draw(canvas); | | 217 | + } | 222 | 218 | } | 223 | 219 |
| 224 | 220 | } | |
|