Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
machine
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
hooloo
android
machine
Commits
cb8d0442
Commit
cb8d0442
authored
Jul 04, 2022
by
wjg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、添加购物数量动画
parent
f6203fad
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
271 additions
and
0 deletions
+271
-0
app/src/main/java/com/ihaoin/hooloo/device/component/Rotate3dAnimation.java
+88
-0
app/src/main/java/com/ihaoin/hooloo/device/view/TrolleyView.java
+11
-0
app/src/main/res/layout/view_trolley.xml
+1
-0
app/src/main/res/values-w1120dp/dimens.xml
+171
-0
No files found.
app/src/main/java/com/ihaoin/hooloo/device/component/Rotate3dAnimation.java
0 → 100644
View file @
cb8d0442
package
com
.
ihaoin
.
hooloo
.
device
.
component
;
import
android.graphics.Camera
;
import
android.graphics.Matrix
;
import
android.view.animation.Animation
;
import
android.view.animation.Transformation
;
/**
* An animation that rotates the view on the X,Y,Z axis between two specified angles.
* This animation also adds a translation on the Z axis (depth) to improve the effect.
*/
public
class
Rotate3dAnimation
extends
Animation
{
public
static
final
Byte
ROTATE_X_AXIS
=
0x00
;
public
static
final
Byte
ROTATE_Y_AXIS
=
0x01
;
public
static
final
Byte
ROTATE_Z_AXIS
=
0x02
;
private
final
float
mFromDegrees
;
private
final
float
mToDegrees
;
private
final
float
mCenterX
;
private
final
float
mCenterY
;
private
final
float
mDepthZ
;
private
final
boolean
mReverse
;
private
Camera
mCamera
;
private
Byte
mRotateAxis
;
// 0:X轴 1:Y轴 2:Z轴
/**创建3D旋转动画
* @param fromDegrees the start angle of the 3D rotation
* @param toDegrees the end angle of the 3D rotation
* @param centerX the X center of the 3D rotation
* @param centerY the Y center of the 3D rotation
* @param depthZ the Z depth of the 3D rotation
* @param rotateAxis the rotate axis of the 3D rotation
* @param reverse true if the translation should be reversed, false otherwise
*/
public
Rotate3dAnimation
(
float
fromDegrees
,
float
toDegrees
,
float
centerX
,
float
centerY
,
float
depthZ
,
Byte
rotateAxis
,
boolean
reverse
)
{
mFromDegrees
=
fromDegrees
;
mToDegrees
=
toDegrees
;
mCenterX
=
centerX
;
mCenterY
=
centerY
;
mDepthZ
=
depthZ
;
mRotateAxis
=
rotateAxis
;
mReverse
=
reverse
;
}
@Override
public
void
initialize
(
int
width
,
int
height
,
int
parentWidth
,
int
parentHeight
)
{
super
.
initialize
(
width
,
height
,
parentWidth
,
parentHeight
);
mCamera
=
new
Camera
();
}
@Override
protected
void
applyTransformation
(
float
interpolatedTime
,
Transformation
t
)
{
final
float
fromDegrees
=
mFromDegrees
;
float
degrees
=
fromDegrees
+
((
mToDegrees
-
fromDegrees
)
*
interpolatedTime
);
final
float
centerX
=
mCenterX
;
final
float
centerY
=
mCenterY
;
final
Camera
camera
=
mCamera
;
final
Matrix
matrix
=
t
.
getMatrix
();
// 将当前的摄像头位置保存下来,以便变换进行完成后恢复成原位
camera
.
save
();
if
(
mReverse
)
{
// z的偏移会越来越大。这就会形成这样一个效果,view从近到远
camera
.
translate
(
0.0f
,
0.0f
,
mDepthZ
*
interpolatedTime
);
}
else
{
// z的偏移会越来越小。这就会形成这样一个效果,我们的View从一个很远的地方向我们移过来,越来越近,最终移到了我们的窗口上面
camera
.
translate
(
0.0f
,
0.0f
,
mDepthZ
*
(
1.0f
-
interpolatedTime
));
}
// 是给我们的View加上旋转效果,在移动的过程中,视图还会以XYZ轴为中心进行旋转。
if
(
ROTATE_X_AXIS
.
equals
(
mRotateAxis
))
{
camera
.
rotateX
(
degrees
);
}
else
if
(
ROTATE_Y_AXIS
.
equals
(
mRotateAxis
))
{
camera
.
rotateY
(
degrees
);
}
else
{
camera
.
rotateZ
(
degrees
);
}
// 这个是将我们刚才定义的一系列变换应用到变换矩阵上面,调用完这句之后,我们就可以将camera的位置恢复了,以便下一次再使用。
camera
.
getMatrix
(
matrix
);
// camera位置恢复
camera
.
restore
();
// 下面两句是为了动画是以View中心为旋转点
matrix
.
preTranslate
(-
centerX
,
-
centerY
);
matrix
.
postTranslate
(
centerX
,
centerY
);
}
}
app/src/main/java/com/ihaoin/hooloo/device/view/TrolleyView.java
View file @
cb8d0442
...
...
@@ -9,6 +9,7 @@ import android.view.View;
import
android.view.ViewGroup
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.view.animation.BounceInterpolator
;
import
android.widget.ListView
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
...
...
@@ -20,6 +21,7 @@ import com.ihaoin.hooloo.device.HLApplication;
import
com.ihaoin.hooloo.device.R
;
import
com.ihaoin.hooloo.device.adapter.TrolleyAdapter
;
import
com.ihaoin.hooloo.device.component.NetworkHandler
;
import
com.ihaoin.hooloo.device.component.Rotate3dAnimation
;
import
com.ihaoin.hooloo.device.config.Base
;
import
com.ihaoin.hooloo.device.data.TrolleyGoods
;
import
com.ihaoin.hooloo.device.data.enums.SkuState
;
...
...
@@ -176,6 +178,15 @@ public class TrolleyView extends RelativeLayout {
this
.
txtTotal
.
setText
(
Utils
.
toString
(
HLApplication
.
getGoodsCheckedTotal
()));
this
.
setView
();
this
.
measureListHeight
();
float
centerX
=
txtCount
.
getWidth
()
/
2
f
;
float
centerY
=
txtCount
.
getHeight
()
/
2
f
;
Animation
anim
=
new
Rotate3dAnimation
(
180
f
,
360
f
,
centerX
,
centerY
,
0
f
,
Rotate3dAnimation
.
ROTATE_Y_AXIS
,
true
);
anim
.
setFillAfter
(
true
);
// 设置保持动画最后的状态
anim
.
setDuration
(
800
);
// 设置动画时间
anim
.
setInterpolator
(
new
BounceInterpolator
());
// 设置插入器
txtCount
.
startAnimation
(
anim
);
}
public
Boolean
checkGoodsCount
()
{
...
...
app/src/main/res/layout/view_trolley.xml
View file @
cb8d0442
...
...
@@ -93,6 +93,7 @@
android:layout_alignParentEnd=
"true"
android:background=
"@drawable/ic_dot"
android:gravity=
"center"
android:text=
"0"
android:textColor=
"@color/white"
android:textSize=
"@dimen/ts_trolley_count"
android:textStyle=
"bold"
/>
...
...
app/src/main/res/values-w1120dp/dimens.xml
0 → 100644
View file @
cb8d0442
<resources>
<dimen
name=
"padding20"
>
20dp
</dimen>
<dimen
name=
"padding15"
>
15dp
</dimen>
<dimen
name=
"padding10"
>
10dp
</dimen>
<dimen
name=
"padding7"
>
7dp
</dimen>
<dimen
name=
"padding5"
>
5dp
</dimen>
<dimen
name=
"padding3"
>
3dp
</dimen>
<dimen
name=
"toast_width"
>
376dp
</dimen>
<dimen
name=
"toast_padding_hor"
>
32dp
</dimen>
<dimen
name=
"toast_padding_ver"
>
55dp
</dimen>
<dimen
name=
"recommend_padding"
>
5dp
</dimen>
<dimen
name=
"recommend_image_height_0"
>
794dp
</dimen>
<dimen
name=
"recommend_image_height_other"
>
392dp
</dimen>
<dimen
name=
"recommend_name_margin_top"
>
82dp
</dimen>
<dimen
name=
"recommend_name_margin_left"
>
68dp
</dimen>
<dimen
name=
"recommend_desc_margin_top"
>
30dp
</dimen>
<dimen
name=
"recommend_desc_margin_left"
>
68dp
</dimen>
<dimen
name=
"goods_padding_top"
>
30dp
</dimen>
<dimen
name=
"goods_padding_ver"
>
15dp
</dimen>
<dimen
name=
"goods_padding_right"
>
38dp
</dimen>
<dimen
name=
"goods_last_padding_bottom"
>
200dp
</dimen>
<dimen
name=
"goods_thum_size"
>
100dp
</dimen>
<dimen
name=
"goods_thum_margin_right"
>
10dp
</dimen>
<dimen
name=
"goods_recommend_margin"
>
5dp
</dimen>
<dimen
name=
"goods_category_margin_top"
>
10dp
</dimen>
<dimen
name=
"goods_tag_margin_top"
>
5dp
</dimen>
<dimen
name=
"goods_tag_padding_ver"
>
2dp
</dimen>
<dimen
name=
"goods_tag_padding_hor"
>
10dp
</dimen>
<dimen
name=
"goods_tag_margin_right"
>
16dp
</dimen>
<dimen
name=
"goods_desc_margin_top"
>
5dp
</dimen>
<dimen
name=
"goods_butns_margin_top"
>
5dp
</dimen>
<dimen
name=
"goods_price_margin"
>
5dp
</dimen>
<dimen
name=
"category_padding_ver"
>
20dp
</dimen>
<dimen
name=
"category_padding_hor"
>
20dp
</dimen>
<dimen
name=
"category_margin"
>
20dp
</dimen>
<dimen
name=
"category_divider_padding"
>
0dp
</dimen>
<dimen
name=
"tip_margin_top"
>
10dp
</dimen>
<dimen
name=
"tip_padding_top"
>
33dp
</dimen>
<dimen
name=
"tip_padding_bottom"
>
33dp
</dimen>
<dimen
name=
"menu_divider_padding_hor"
>
10dp
</dimen>
<dimen
name=
"menu_divider_padding_top"
>
20dp
</dimen>
<dimen
name=
"menu_divider_padding_bottom"
>
20dp
</dimen>
<dimen
name=
"menu_content_padding_hor"
>
25dp
</dimen>
<dimen
name=
"menu_content_padding_top"
>
18dp
</dimen>
<dimen
name=
"menu_content_padding_bottom"
>
18dp
</dimen>
<dimen
name=
"menu_order_margin_top"
>
23dp
</dimen>
<dimen
name=
"menu_spacing_hor"
>
10dp
</dimen>
<dimen
name=
"menu_spacing_ver"
>
100dp
</dimen>
<dimen
name=
"goods_detail_padding_ver"
>
55dp
</dimen>
<dimen
name=
"goods_detail_padding_hor"
>
40dp
</dimen>
<dimen
name=
"goods_detail_content_margin_left"
>
40dp
</dimen>
<dimen
name=
"goods_detail_image_margin_top"
>
50dp
</dimen>
<dimen
name=
"goods_detail_spec_margin_top"
>
25dp
</dimen>
<dimen
name=
"goods_detail_rule_width"
>
80dp
</dimen>
<dimen
name=
"goods_detail_rule_margin_top"
>
28dp
</dimen>
<dimen
name=
"goods_detail_rule_margin_right"
>
16dp
</dimen>
<dimen
name=
"goods_detail_rule_padding_hor"
>
60dp
</dimen>
<dimen
name=
"goods_detail_rule_padding_ver"
>
10dp
</dimen>
<dimen
name=
"goods_detail_layout_rule_margin_top"
>
17dp
</dimen>
<dimen
name=
"goods_detail_rec_padding_hor"
>
12dp
</dimen>
<dimen
name=
"goods_detail_rec_padding_ver"
>
5dp
</dimen>
<dimen
name=
"goods_detail_oper_margin_top"
>
24dp
</dimen>
<dimen
name=
"goods_detail_oper_margin_left"
>
55dp
</dimen>
<dimen
name=
"goods_detail_oper_margin_bottom"
>
28dp
</dimen>
<dimen
name=
"goods_detail_oper_margin_right"
>
35dp
</dimen>
<dimen
name=
"goods_detail_price_margin_right"
>
3dp
</dimen>
<dimen
name=
"goods_detail_butn_margin_top"
>
28dp
</dimen>
<dimen
name=
"goods_detail_butn_padding"
>
23dp
</dimen>
<dimen
name=
"goods_detail_count_margin_left"
>
36dp
</dimen>
<dimen
name=
"goods_detail_count_margin_right"
>
40dp
</dimen>
<dimen
name=
"goods_detail_indicator_margin"
>
20dp
</dimen>
<dimen
name=
"dialog_detail_width"
>
600dp
</dimen>
<dimen
name=
"dialog_tip_width"
>
600dp
</dimen>
<dimen
name=
"dialog_clear_width"
>
715dp
</dimen>
<dimen
name=
"dialog_clear_height"
>
385dp
</dimen>
<dimen
name=
"dialog_close_margin"
>
35dp
</dimen>
<dimen
name=
"clear_butn_height"
>
100dp
</dimen>
<dimen
name=
"clear_butn_text"
>
40dp
</dimen>
<dimen
name=
"trolley_width"
>
400dp
</dimen>
<dimen
name=
"trolley_item_height"
>
100dp
</dimen>
<dimen
name=
"trolley_bar_height"
>
60dp
</dimen>
<dimen
name=
"trolley_pay_width"
>
150dp
</dimen>
<dimen
name=
"trolley_ic_margin_left"
>
80dp
</dimen>
<dimen
name=
"trolley_ic_parent_width"
>
110dp
</dimen>
<dimen
name=
"trolley_ic_parent_height"
>
120dp
</dimen>
<dimen
name=
"trolley_ic_width"
>
92dp
</dimen>
<dimen
name=
"trolley_ic_height"
>
110dp
</dimen>
<dimen
name=
"trolley_ic_border_size"
>
50dp
</dimen>
<dimen
name=
"trolley_count_size"
>
20dp
</dimen>
<dimen
name=
"trolley_title_margin_ver"
>
30dp
</dimen>
<dimen
name=
"trolley_title_margin_hor"
>
38dp
</dimen>
<dimen
name=
"trolley_clear_text_margin_left"
>
8dp
</dimen>
<dimen
name=
"trolley_clear_text_margin_right"
>
30dp
</dimen>
<dimen
name=
"trolley_line_margin"
>
40dp
</dimen>
<dimen
name=
"trolley_thum_size"
>
142dp
</dimen>
<dimen
name=
"trolley_thum_margin"
>
40dp
</dimen>
<dimen
name=
"trolley_item_padding_top"
>
40dp
</dimen>
<dimen
name=
"trolley_item_padding_left"
>
40dp
</dimen>
<dimen
name=
"trolley_item_padding_bottom"
>
20dp
</dimen>
<dimen
name=
"trolley_item_padding_right"
>
40dp
</dimen>
<dimen
name=
"trolley_options_margin_top"
>
16dp
</dimen>
<dimen
name=
"trolley_price_margin_top"
>
25dp
</dimen>
<dimen
name=
"trolley_price_margin_left"
>
11dp
</dimen>
<dimen
name=
"trolley_count_margin"
>
28dp
</dimen>
<dimen
name=
"trolley_oper_margin"
>
20dp
</dimen>
<dimen
name=
"confirm_order_width"
>
1000dp
</dimen>
<dimen
name=
"confirm_order_padding_top"
>
62dp
</dimen>
<dimen
name=
"confirm_order_padding_bottom"
>
37dp
</dimen>
<dimen
name=
"confirm_order_qr_margin_top"
>
45dp
</dimen>
<dimen
name=
"confirm_order_qrcode_size"
>
375dp
</dimen>
<dimen
name=
"confirm_order_icon_margin"
>
40dp
</dimen>
<dimen
name=
"confirm_order_text_one"
>
62dp
</dimen>
<dimen
name=
"confirm_order_text_two"
>
7dp
</dimen>
<dimen
name=
"ic_recommend"
>
10dp
</dimen>
<dimen
name=
"ic_clear_size"
>
15dp
</dimen>
<dimen
name=
"ic_add_size"
>
20dp
</dimen>
<dimen
name=
"ic_subtract_size"
>
20dp
</dimen>
<dimen
name=
"ic_checkbox"
>
25dp
</dimen>
<dimen
name=
"ic_detail_add_size"
>
20dp
</dimen>
<dimen
name=
"ic_detail_subtract_size"
>
20dp
</dimen>
<dimen
name=
"ic_dialog_close"
>
20dp
</dimen>
<dimen
name=
"ic_scan_succ_width"
>
101dp
</dimen>
<dimen
name=
"ic_scan_succ_height"
>
97dp
</dimen>
<dimen
name=
"ts_toast"
>
28sp
</dimen>
<dimen
name=
"ts_trolley_item_price"
>
20sp
</dimen>
<dimen
name=
"ts_trolley_item_discount"
>
22sp
</dimen>
<dimen
name=
"ts_recommend_name"
>
20sp
</dimen>
<dimen
name=
"ts_recommend_desc"
>
20sp
</dimen>
<dimen
name=
"ts_category_radio"
>
12sp
</dimen>
<dimen
name=
"ts_category_item"
>
18sp
</dimen>
<dimen
name=
"ts_goods_item_name"
>
14sp
</dimen>
<dimen
name=
"ts_goods_item_intro"
>
12sp
</dimen>
<dimen
name=
"ts_goods_item_price"
>
9sp
</dimen>
<dimen
name=
"ts_goods_item_discount"
>
12sp
</dimen>
<dimen
name=
"ts_goods_item_sellout"
>
12sp
</dimen>
<dimen
name=
"ts_goods_item_tag"
>
9sp
</dimen>
<dimen
name=
"ts_trolley_item_count"
>
12sp
</dimen>
<dimen
name=
"ts_trolley_name"
>
18sp
</dimen>
<dimen
name=
"ts_trolley_clear"
>
12sp
</dimen>
<dimen
name=
"ts_trolley_total"
>
16sp
</dimen>
<dimen
name=
"ts_trolley_count"
>
12sp
</dimen>
<dimen
name=
"ts_trolley_pay"
>
16sp
</dimen>
<dimen
name=
"ts_tips"
>
9sp
</dimen>
<dimen
name=
"ts_detail_name"
>
20sp
</dimen>
<dimen
name=
"ts_detail_spec"
>
14sp
</dimen>
<dimen
name=
"ts_detail_spec_rec"
>
6sp
</dimen>
<dimen
name=
"ts_detail_rule"
>
12sp
</dimen>
<dimen
name=
"ts_detail_count"
>
14sp
</dimen>
<dimen
name=
"ts_detail_price"
>
12sp
</dimen>
<dimen
name=
"ts_detail_discount"
>
14sp
</dimen>
<dimen
name=
"ts_detail_add_trolley"
>
14sp
</dimen>
<dimen
name=
"ts_detail_buynow"
>
14sp
</dimen>
<dimen
name=
"ts_header_text"
>
14sp
</dimen>
<dimen
name=
"ts_dialog_title"
>
18sp
</dimen>
<dimen
name=
"ts_scan"
>
14sp
</dimen>
<dimen
name=
"ts_expire"
>
12sp
</dimen>
<dimen
name=
"ts_order_number"
>
12sp
</dimen>
<dimen
name=
"ts_menu_title"
>
22sp
</dimen>
<dimen
name=
"ts_menu_subtitle"
>
18sp
</dimen>
<dimen
name=
"ts_menu_subtitle1"
>
12sp
</dimen>
<dimen
name=
"ts_setting_name"
>
16sp
</dimen>
<dimen
name=
"ts_setting_desc"
>
14sp
</dimen>
</resources>
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