Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
91505e27
Commit
91505e27
authored
Sep 07, 2022
by
刘鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 首页轮播动画
parent
fdb200c4
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
103 additions
and
72 deletions
+103
-72
CircleCropTransform.java
m-home/src/xlzx/java/com/yidianling/home/ui/transform/CircleCropTransform.java
+95
-0
LoopScrollAvatar.kt
m-home/src/xlzx/java/com/yidianling/home/ui/view/LoopScrollAvatar.kt
+7
-4
XCRoundImageView.kt
m-home/src/xlzx/java/com/yidianling/home/ui/view/XCRoundImageView.kt
+0
-67
home_button_banner_view.xml
m-home/src/xlzx/res/layout/home_button_banner_view.xml
+1
-1
home_banner_header1.png
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header1.png
+0
-0
home_banner_header1.webp
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header1.webp
+0
-0
home_banner_header2.png
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header2.png
+0
-0
home_banner_header2.webp
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header2.webp
+0
-0
home_banner_header3.png
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header3.png
+0
-0
home_banner_header3.webp
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header3.webp
+0
-0
home_banner_header4.png
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header4.png
+0
-0
home_banner_header4.webp
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header4.webp
+0
-0
home_banner_header5.png
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header5.png
+0
-0
home_banner_header5.webp
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header5.webp
+0
-0
No files found.
m-home/src/xlzx/java/com/yidianling/home/ui/transform/CircleCropTransform.java
0 → 100644
View file @
91505e27
package
com
.
yidianling
.
home
.
ui
.
transform
;
import
android.content.Context
;
import
android.content.res.Resources
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapShader
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.util.DisplayMetrics
;
import
android.util.TypedValue
;
import
androidx.annotation.NonNull
;
import
com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
;
import
java.security.MessageDigest
;
import
jp.wasabeef.glide.transformations.BitmapTransformation
;
public
class
CircleCropTransform
extends
BitmapTransformation
{
private
final
Paint
mBorderPaint
;
private
final
float
mBorderSize
;
public
CircleCropTransform
()
{
this
(
0
,
Color
.
TRANSPARENT
);
}
@Override
protected
Bitmap
transform
(
@NonNull
Context
context
,
@NonNull
BitmapPool
pool
,
@NonNull
Bitmap
toTransform
,
int
outWidth
,
int
outHeight
)
{
return
circleCrop
(
pool
,
toTransform
);
}
/**
* @param borderSize 边框宽度(px)
* @param borderColor 边框颜色
*/
public
CircleCropTransform
(
float
borderSize
,
int
borderColor
)
{
this
(
TypedValue
.
COMPLEX_UNIT_PX
,
borderSize
,
borderColor
);
}
/**
* @param unit borderSize 单位
* @param borderSize 边框宽度(px)
* @param borderColor 边框颜色
*/
public
CircleCropTransform
(
int
unit
,
float
borderSize
,
int
borderColor
)
{
DisplayMetrics
displayMetrics
=
Resources
.
getSystem
().
getDisplayMetrics
();
mBorderSize
=
TypedValue
.
applyDimension
(
unit
,
borderSize
,
displayMetrics
);
mBorderPaint
=
new
Paint
();
mBorderPaint
.
setDither
(
true
);
mBorderPaint
.
setAntiAlias
(
true
);
mBorderPaint
.
setColor
(
borderColor
);
mBorderPaint
.
setStyle
(
Paint
.
Style
.
STROKE
);
mBorderPaint
.
setStrokeWidth
(
mBorderSize
);
}
private
Bitmap
circleCrop
(
BitmapPool
pool
,
Bitmap
source
)
{
if
(
source
==
null
)
return
null
;
int
size
=
(
int
)
(
Math
.
min
(
source
.
getWidth
(),
source
.
getHeight
())
-
(
mBorderSize
/
2
));
int
x
=
(
source
.
getWidth
()
-
size
)
/
2
;
int
y
=
(
source
.
getHeight
()
-
size
)
/
2
;
Bitmap
squared
=
Bitmap
.
createBitmap
(
source
,
x
,
y
,
size
,
size
);
Bitmap
result
=
pool
.
get
(
size
,
size
,
Bitmap
.
Config
.
ARGB_8888
);
Canvas
canvas
=
new
Canvas
(
result
);
Paint
paint
=
new
Paint
();
paint
.
setShader
(
new
BitmapShader
(
squared
,
BitmapShader
.
TileMode
.
CLAMP
,
BitmapShader
.
TileMode
.
CLAMP
));
paint
.
setAntiAlias
(
true
);
float
r
=
size
/
2
f
;
canvas
.
drawCircle
(
r
,
r
,
r
,
paint
);
if
(
mBorderPaint
!=
null
)
{
float
borderRadius
=
r
-
mBorderSize
/
2
;
canvas
.
drawCircle
(
r
,
r
,
borderRadius
,
mBorderPaint
);
}
return
result
;
}
@Override
public
void
updateDiskCacheKey
(
@NonNull
MessageDigest
messageDigest
)
{
}
@Override
public
boolean
equals
(
Object
o
)
{
return
false
;
}
@Override
public
int
hashCode
()
{
return
0
;
}
}
m-home/src/xlzx/java/com/yidianling/home/ui/view/LoopScrollAvatar.kt
View file @
91505e27
...
...
@@ -4,6 +4,7 @@ import android.animation.Animator
import
android.animation.AnimatorListenerAdapter
import
android.app.Activity
import
android.content.Context
import
android.graphics.Color
import
android.os.Handler
import
android.os.Message
import
android.util.AttributeSet
...
...
@@ -11,7 +12,9 @@ import android.util.Log
import
android.widget.ImageView
import
android.widget.RelativeLayout
import
com.blankj.utilcode.util.SizeUtils
import
com.ydl.ydl_image.module.GlideApp
import
com.yidianling.home.R
import
com.yidianling.home.ui.transform.CircleCropTransform
import
java.lang.ref.WeakReference
const
val
START_AVATAR_LOOP
=
111
...
...
@@ -98,7 +101,7 @@ class LoopScrollAvatar @JvmOverloads constructor(
* 创建圆形头像ImageView
*/
private
fun
createImageView
():
ImageView
{
return
XCRound
ImageView
(
context
)
return
ImageView
(
context
)
}
/**
...
...
@@ -114,9 +117,6 @@ class LoopScrollAvatar @JvmOverloads constructor(
//当前已在屏幕显示的控件不要复用,防止params混乱
ivCache
.
remove
(
iv
)
iv
.
setImageResource
(
res
[
index
])
iv
.
scaleType
=
ImageView
.
ScaleType
.
FIT_XY
//图片资源全部播放完之后要从头重播
index
=
(
index
+
1
)
%
res
.
size
...
...
@@ -126,6 +126,9 @@ class LoopScrollAvatar @JvmOverloads constructor(
iv
.
layoutParams
=
lp
addView
(
iv
)
//圆角带描边
GlideApp
.
with
(
this
).
load
(
res
[
index
]).
transform
(
CircleCropTransform
(
1f
,
Color
.
WHITE
))
.
into
(
iv
)
}
/**
...
...
m-home/src/xlzx/java/com/yidianling/home/ui/view/XCRoundImageView.kt
deleted
100644 → 0
View file @
fdb200c4
package
com.yidianling.home.ui.view
import
android.annotation.SuppressLint
import
android.content.Context
import
android.graphics.*
import
android.graphics.drawable.BitmapDrawable
import
android.util.AttributeSet
import
androidx.appcompat.widget.AppCompatImageView
/**
* @author liupeng
*/
class
XCRoundImageView
@JvmOverloads
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
,
defStyle
:
Int
=
0
)
:
AppCompatImageView
(
context
,
attrs
,
defStyle
)
{
private
val
paint
:
Paint
=
Paint
()
/**
* 绘制圆形图片
* @author caizhiming
*/
@SuppressLint
(
"DrawAllocation"
)
override
fun
onDraw
(
canvas
:
Canvas
)
{
val
drawable
=
drawable
if
(
null
!=
drawable
)
{
val
bitmap
=
(
drawable
as
BitmapDrawable
).
bitmap
val
b
=
getCircleBitmap
(
bitmap
,
14
)
val
rectSrc
=
Rect
(
0
,
0
,
b
.
width
,
b
.
height
)
val
rectDest
=
Rect
(
0
,
0
,
width
,
height
)
paint
.
reset
()
canvas
.
drawBitmap
(
b
,
rectSrc
,
rectDest
,
paint
)
}
else
{
super
.
onDraw
(
canvas
)
}
}
/**
* 获取圆形图片方法
* @param bitmap
* @param pixels
* @return Bitmap
* @author caizhiming
*/
private
fun
getCircleBitmap
(
bitmap
:
Bitmap
,
pixels
:
Int
):
Bitmap
{
val
output
=
Bitmap
.
createBitmap
(
bitmap
.
width
,
bitmap
.
height
,
Bitmap
.
Config
.
ARGB_8888
)
val
canvas
=
Canvas
(
output
)
val
color
=
-
0
xbdbdbe
val
rect
=
Rect
(
0
,
0
,
bitmap
.
width
,
bitmap
.
height
)
paint
.
isAntiAlias
=
true
canvas
.
drawARGB
(
0
,
0
,
0
,
0
)
paint
.
color
=
color
val
x
=
bitmap
.
width
canvas
.
drawCircle
((
x
/
2
).
toFloat
(),
(
x
/
2
).
toFloat
(),
(
x
/
2
).
toFloat
(),
paint
)
paint
.
xfermode
=
PorterDuffXfermode
(
PorterDuff
.
Mode
.
SRC_IN
)
canvas
.
drawBitmap
(
bitmap
,
rect
,
rect
,
paint
)
return
output
}
}
\ No newline at end of file
m-home/src/xlzx/res/layout/home_button_banner_view.xml
View file @
91505e27
...
...
@@ -62,7 +62,7 @@
android:src=
"@mipmap/home_banner_header1"
app:layout_constraintTop_toBottomOf=
"@id/homeModuleFirstDec"
app:layout_constraintLeft_toLeftOf=
"@id/homeModuleButtonBannerFirstTitle"
android:layout_width=
"
50
dp"
android:layout_width=
"
45
dp"
app:layout_constraintHorizontal_weight=
"1"
android:layout_height=
"20dp"
/>
...
...
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header1.png
deleted
100644 → 0
View file @
fdb200c4
This diff is collapsed.
Click to expand it.
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header1.webp
0 → 100644
View file @
91505e27
File added
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header2.png
deleted
100644 → 0
View file @
fdb200c4
150 KB
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header2.webp
0 → 100644
View file @
91505e27
File added
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header3.png
deleted
100644 → 0
View file @
fdb200c4
407 KB
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header3.webp
0 → 100644
View file @
91505e27
File added
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header4.png
deleted
100644 → 0
View file @
fdb200c4
484 KB
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header4.webp
0 → 100644
View file @
91505e27
File added
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header5.png
deleted
100644 → 0
View file @
fdb200c4
691 KB
m-home/src/xlzx/res/mipmap-xhdpi/home_banner_header5.webp
0 → 100644
View file @
91505e27
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment