Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
67331f4e
Commit
67331f4e
authored
Sep 27, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update fake activity
parent
d4f340bd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
784 deletions
+87
-784
script/code/rename_api.py
+2
-0
src/main/java/com/common/activity/ReviewHookActivity.java
+23
-19
src/main/java/com/common/widget/CircleLayout.java
+0
-212
src/main/java/com/common/widget/TouchView.java
+0
-510
src/main/res/layout/activity_review_hook.xml
+62
-43
No files found.
script/code/rename_api.py
View file @
67331f4e
...
@@ -13,6 +13,8 @@ def rename_api(path):
...
@@ -13,6 +13,8 @@ def rename_api(path):
api_map
=
line
.
replace
(
"rewrite ^/"
,
""
)
.
replace
(
"/(.+)"
,
""
)
.
replace
(
"$ /"
,
"*-*"
)
.
replace
(
" last;"
,
""
)
.
replace
(
"
\n
"
,
""
)
\
api_map
=
line
.
replace
(
"rewrite ^/"
,
""
)
.
replace
(
"/(.+)"
,
""
)
.
replace
(
"$ /"
,
"*-*"
)
.
replace
(
" last;"
,
""
)
.
replace
(
"
\n
"
,
""
)
\
.
replace
(
"/$1"
,
""
)
.
replace
(
"/$2"
,
""
)
.
replace
(
"/$3"
,
""
)
.
replace
(
"/$4"
,
""
)
.
replace
(
"/$5"
,
""
)
\
.
replace
(
"/$1"
,
""
)
.
replace
(
"/$2"
,
""
)
.
replace
(
"/$3"
,
""
)
.
replace
(
"/$4"
,
""
)
.
replace
(
"/$5"
,
""
)
\
.
split
(
"*-*"
)
.
split
(
"*-*"
)
api_map
[
0
]
.
replace
(
" "
,
""
)
api_map
[
1
]
.
replace
(
" "
,
""
)
# print(api_map[1]+ " -> " + api_map[0])
# print(api_map[1]+ " -> " + api_map[0])
with
open
(
path
,
"r"
,
encoding
=
"utf-8"
)
as
api_file
:
with
open
(
path
,
"r"
,
encoding
=
"utf-8"
)
as
api_file
:
...
...
src/main/java/com/common/activity/ReviewHookActivity.java
View file @
67331f4e
...
@@ -2,28 +2,21 @@ package com.common.activity;
...
@@ -2,28 +2,21 @@ package com.common.activity;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.provider.ContactsContract
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.EditText
;
import
android.widget.CheckBox
;
import
android.widget.ImageButton
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.common.base.BaseActivity
;
import
com.common.base.BaseActivity
;
import
com.common.bean.ProductBean
;
import
com.common.bean.ProductBean
;
import
com.common.toolbox.app_utils.DeviceInfo
;
import
com.common.toolbox.app_utils.DeviceInfo
;
import
com.common.toolbox.tracker.TrackEvent
;
import
com.common.widget.CircleLayout
;
import
com.common.widget.PenetrateFrameLayout
;
import
com.common.widget.PenetrateFrameLayout
;
import
com.common.widget.TopBar
;
import
com.common.widget.TopBar
;
import
com.common.widget.TouchView
;
import
com.facebook.accountkit.AccountKitError
;
import
com.facebook.accountkit.AccountKitError
;
import
com.facebook.accountkit.AccountKitLoginResult
;
import
com.facebook.accountkit.AccountKitLoginResult
;
import
com.qmuiteam.qmui.util.QMUIStatusBarHelper
;
import
com.qmuiteam.qmui.util.QMUIStatusBarHelper
;
...
@@ -37,15 +30,9 @@ import java.util.Random;
...
@@ -37,15 +30,9 @@ import java.util.Random;
import
tech.starwin.BuildConfig
;
import
tech.starwin.BuildConfig
;
import
tech.starwin.LibConfig
;
import
tech.starwin.LibConfig
;
import
tech.starwin.R
;
import
tech.starwin.R
;
import
tech.starwin.base.RecyclerViewHolder
;
import
tech.starwin.impl.OnEventClickListener
;
import
tech.starwin.impl.OnEventClickListener
;
import
tech.starwin.impl.OnNoShakeClickListener
;
import
tech.starwin.mvp.ui.adapter.ReviewProductAdapter
;
import
tech.starwin.mvp.ui.adapter.ReviewProductAdapter
;
import
tech.starwin.network.Gateway
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.TrackEventHelper
;
import
tech.starwin.utils.collection.UploadManager
;
import
tech.starwin.utils.context_utils.ActivityJumper
;
import
tech.starwin.utils.context_utils.ActivityJumper
;
import
tech.starwin.utils.ui_utils.DialogFactory
;
import
tech.starwin.utils.ui_utils.DialogFactory
;
import
tech.starwin.utils.ui_utils.UIHelper
;
import
tech.starwin.utils.ui_utils.UIHelper
;
...
@@ -85,11 +72,28 @@ public class ReviewHookActivity extends BaseActivity {
...
@@ -85,11 +72,28 @@ public class ReviewHookActivity extends BaseActivity {
@Override
@Override
public
void
initView
()
{
public
void
initView
()
{
if
(
BuildConfig
.
HIBERNATION
){
if
(
BuildConfig
.
HIBERNATION
)
{
findViewById
(
R
.
id
.
activity_review_content
).
setVisibility
(
View
.
GONE
);
findViewById
(
R
.
id
.
activity_review_conversion_btn
).
setOnClickListener
(
v
->
{
findViewById
(
R
.
id
.
activity_review_certify_btn
).
setVisibility
(
View
.
GONE
);
String
[]
unit
=
new
String
[]{
"USA"
,
"EUR"
,
"CNY"
,
"JPY"
,
"GBP"
};
findViewById
(
R
.
id
.
activity_review_myloan_btn
).
setVisibility
(
View
.
GONE
);
double
[]
exchange
=
new
double
[]{
0.00007050d
,
0.00006456d
,
0.0005031d
,
0.007592d
,
0.00005716d
};
findViewById
(
R
.
id
.
activity_review_helpCenter_btn
).
setVisibility
(
View
.
GONE
);
DialogFactory
.
createMenuDialog
(
ReviewHookActivity
.
this
,
unit
,
(
dialog
,
which
)
->
{
dialog
.
dismiss
();
EditText
before
=
findViewById
(
R
.
id
.
activity_review_before_amount_tv
);
TextView
after
=
findViewById
(
R
.
id
.
activity_review_after_amount_tv
);
try
{
double
idr
=
Double
.
parseDouble
(
before
.
getText
().
toString
());
double
change
=
idr
*
exchange
[
which
];
after
.
setText
(
String
.
valueOf
(
change
));
}
catch
(
Exception
e
)
{
UIHelper
.
showToast
(
ReviewHookActivity
.
this
,
"input error!"
);
}
}).
show
();
});
}
else
{
findViewById
(
R
.
id
.
activity_review_exchange
).
setVisibility
(
View
.
GONE
);
}
}
mUserNameTv
=
findViewById
(
R
.
id
.
activity_review_userName_tv
);
mUserNameTv
=
findViewById
(
R
.
id
.
activity_review_userName_tv
);
mDrawer
=
findViewById
(
R
.
id
.
activity_review_drawer_layout
);
mDrawer
=
findViewById
(
R
.
id
.
activity_review_drawer_layout
);
...
...
src/main/java/com/common/widget/CircleLayout.java
deleted
100755 → 0
View file @
d4f340bd
package
com
.
common
.
widget
;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.graphics.Point
;
import
android.graphics.PointF
;
import
android.os.Build
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created by SiKang on 2016/3/2.
*/
public
class
CircleLayout
extends
ViewGroup
{
private
final
String
TAG
=
"CircleLayoutDebug"
;
private
int
mWidth
;
private
int
mHeight
;
private
double
mLayoutRadius
;
private
PointF
mCenterPoint
;
public
CircleLayout
(
Context
context
)
{
super
(
context
);
init
();
}
public
CircleLayout
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
();
}
private
void
init
()
{
mCenterPoint
=
new
PointF
();
}
@Override
public
void
onViewAdded
(
View
child
)
{
if
(
getChildCount
()
<=
12
)
{
super
.
onViewAdded
(
child
);
}
else
{
removeViewAt
(
getChildCount
()
-
1
);
}
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
mWidth
=
measureHanlder
(
widthMeasureSpec
);
mHeight
=
measureHanlder
(
heightMeasureSpec
);
mCenterPoint
.
x
=
mWidth
/
2
;
mCenterPoint
.
y
=
mHeight
/
2
;
mLayoutRadius
=
mWidth
<
mHeight
?
mWidth
/
2
:
mHeight
/
2
;
Log
.
d
(
TAG
,
"onMeasure()"
);
}
@TargetApi
(
Build
.
VERSION_CODES
.
HONEYCOMB
)
@Override
protected
void
onLayout
(
boolean
changed
,
int
l
,
int
t
,
int
r
,
int
b
)
{
if
(!
changed
)
return
;
setChildLayout
();
}
//设置所有子View位置
private
void
setChildLayout
()
{
int
childCount
=
getChildCount
();
double
childAngle
=
360
/
childCount
;
double
layoutAngle
=
270
;
double
rotateAngle
=
0
;
Log
.
d
(
TAG
,
"onLayout() "
+
childAngle
);
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
//得到子View
TouchView
childView
=
(
TouchView
)
getChildAt
(
i
);
//为子View设置宽高
int
childHalfWidth
=
100
;
int
childHalfHeight
=
100
;
Log
.
d
(
"RotateViewDebug"
,
"fathre onLayout"
+
childHalfWidth
);
//计算半径
double
radius
=
mLayoutRadius
-
(
childHalfWidth
<
childHalfHeight
?
childHalfWidth
:
childHalfHeight
);
//计算元素的坐标
Point
viewPoint
=
getPoint
(
mCenterPoint
,
layoutAngle
,
radius
);
//初始化必要参数
childView
.
setmParentCenterPoint
(
mCenterPoint
);
childView
.
setmPointInParent
(
viewPoint
);
childView
.
setNowAngle
(
layoutAngle
);
childView
.
initMatrix
((
float
)
rotateAngle
,
childHalfWidth
*
2
,
childHalfHeight
*
2
);
//设置子View的位置
childView
.
layout
(
viewPoint
.
x
-
childHalfWidth
,
viewPoint
.
y
-
childHalfHeight
,
viewPoint
.
x
+
childHalfWidth
,
viewPoint
.
y
+
childHalfHeight
);
//更新角度
layoutAngle
=
(
layoutAngle
+
childAngle
)
%
360
;
rotateAngle
=
(
rotateAngle
+
childAngle
)
%
360
;
}
}
@Override
public
void
onViewRemoved
(
View
child
)
{
TouchView
view
=
(
TouchView
)
child
;
view
.
destory
();
if
(
view
.
isNormalDestory
())
{
setChildCount
(
getChildCount
());
}
super
.
onViewRemoved
(
child
);
}
public
void
setChildCount
(
int
count
)
{
removeAllViews
();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
addView
(
new
TouchView
(
getContext
()));
}
setChildLayout
();
}
/**
* 根据圆心和角度计算下一个view的位置
*/
private
Point
getPoint
(
PointF
center
,
double
angle
,
double
radius
)
{
Point
point
=
new
Point
();
double
angleHude
=
angle
*
Math
.
PI
/
180
;
point
.
x
=
(
int
)
(
radius
*
Math
.
cos
(
angleHude
)
+
center
.
x
);
point
.
y
=
(
int
)
(
radius
*
Math
.
sin
(
angleHude
)
+
center
.
y
);
return
point
;
}
//处理Spec
private
int
measureHanlder
(
int
measureSpec
)
{
int
result
;
int
specMode
=
MeasureSpec
.
getMode
(
measureSpec
);
int
specSize
=
MeasureSpec
.
getSize
(
measureSpec
);
if
(
specMode
==
MeasureSpec
.
EXACTLY
)
{
result
=
specSize
;
}
else
if
(
specMode
==
MeasureSpec
.
AT_MOST
)
{
result
=
Math
.
min
(
100
,
specSize
);
}
else
{
result
=
100
;
}
return
result
;
}
public
static
class
TouchActionController
{
private
List
<
ViewTouchActionListener
>
mActionListener
=
new
ArrayList
<
ViewTouchActionListener
>(
12
);
public
static
TouchActionController
mTouchActionController
=
null
;
private
boolean
isMaxMove
,
isMinMove
;
private
TouchActionController
()
{
isMaxMove
=
false
;
isMinMove
=
false
;
}
public
static
TouchActionController
getInstance
()
{
if
(
mTouchActionController
==
null
)
{
synchronized
(
TouchActionController
.
class
)
{
if
(
mTouchActionController
==
null
)
{
mTouchActionController
=
new
TouchActionController
();
}
}
}
return
mTouchActionController
;
}
public
void
registerTouchActionListener
(
ViewTouchActionListener
listener
)
{
if
(!
mActionListener
.
contains
(
listener
))
{
mActionListener
.
add
(
listener
);
}
}
public
void
unRegisterActionListener
(
ViewTouchActionListener
listener
)
{
if
(
mActionListener
.
contains
(
listener
))
{
mActionListener
.
remove
(
listener
);
}
}
public
void
notifyListener
(
ViewTouchActionListener
sender
,
final
int
ACTION_ID
,
final
Object
...
args
)
{
for
(
final
ViewTouchActionListener
listener
:
mActionListener
)
{
if
(
sender
!=
listener
)
{
listener
.
onTouchAction
(
ACTION_ID
,
args
);
}
}
}
public
boolean
isMaxMove
()
{
return
isMaxMove
;
}
public
boolean
isMinMove
()
{
return
isMinMove
;
}
public
void
setIsMaxMove
(
boolean
isMaxMove
)
{
this
.
isMaxMove
=
isMaxMove
;
}
public
void
setIsMinMove
(
boolean
isMinMove
)
{
this
.
isMinMove
=
isMinMove
;
}
}
/**
* Created by SiKang on 2016/3/3.
*/
public
interface
ViewTouchActionListener
{
void
onTouchAction
(
int
ACTION_ID
,
Object
...
args
);
}
}
src/main/java/com/common/widget/TouchView.java
deleted
100755 → 0
View file @
d4f340bd
package
com
.
common
.
widget
;
/**
* Created by SiKang on 2016/3/1.
*/
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.content.res.Resources
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Matrix
;
import
android.graphics.Paint
;
import
android.graphics.Path
;
import
android.graphics.Point
;
import
android.graphics.PointF
;
import
android.os.Build
;
import
android.util.AttributeSet
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewConfiguration
;
import
android.view.ViewGroup
;
import
tech.starwin.LibConfig
;
public
class
TouchView
extends
View
implements
CircleLayout
.
ViewTouchActionListener
{
private
final
String
TAG
=
"RotateViewDebug"
;
public
static
final
int
ACTION_CANCLE
=
1
;
public
static
final
int
ACTION_MOVE
=
2
;
public
static
final
int
ACTION_ROTATE
=
3
;
public
static
final
int
ACTION_SCALE
=
4
;
public
static
final
int
ACTION_VIEW_CLICK
=
5
;
public
static
final
int
ACTION_UNEDIT
=
6
;
public
static
final
int
ACTION_FLIP
=
7
;
public
static
final
int
ACTION_SCALE_FINISHED
=
8
;
private
int
mWidth
,
mHeight
,
mSrcWidth
,
mSrcHeight
;
private
boolean
mEndle
,
isSrcFilp
,
normalDestory
;
//编辑状态`
private
Paint
mLinePaint
,
mButtonPaint
,
mTextPaint
,
mSrcPaint
;
private
Path
mPath
;
private
Point
mCancleBtnPoint
,
mMoveBtnPoint
,
mRotateBtnPoint
,
mScaleBtnPoint
,
mPointInParent
;
//按钮坐标
private
PointF
mCenterPoint
,
mParentCenterPoint
;
private
float
mButtonRadius
,
srcAngle
,
srcScale
;
private
double
nowAngle
;
private
int
mButtonCode
,
mTouchSlop
,
mLeft
,
mTop
,
mRight
,
mBottom
;
private
Bitmap
mSrcBm
,
actionBm
;
// private Bitmap mSrcBm, actionBm, actionBm, actionBm, actionBm;
private
Matrix
mSrcMatrix
;
private
CircleLayout
.
TouchActionController
mActionController
;
public
TouchView
(
Context
context
)
{
super
(
context
);
init
(
context
);
}
public
TouchView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
(
context
);
}
@TargetApi
(
Build
.
VERSION_CODES
.
HONEYCOMB
)
private
void
init
(
Context
context
)
{
mActionController
=
CircleLayout
.
TouchActionController
.
getInstance
();
mActionController
.
registerTouchActionListener
(
this
);
mTouchSlop
=
ViewConfiguration
.
get
(
context
).
getScaledTouchSlop
();
mEndle
=
false
;
mLinePaint
=
new
Paint
();
mButtonPaint
=
new
Paint
();
mTextPaint
=
new
Paint
();
mSrcPaint
=
new
Paint
();
mPath
=
new
Path
();
//init path
mLinePaint
.
setColor
(
Color
.
RED
);
mLinePaint
.
setStrokeWidth
(
4
);
mLinePaint
.
setAntiAlias
(
true
);
mLinePaint
.
setStyle
(
Paint
.
Style
.
STROKE
);
mButtonPaint
.
setAntiAlias
(
true
);
mButtonPaint
.
setColor
(
Color
.
BLUE
);
mTextPaint
.
setColor
(
Color
.
WHITE
);
mTextPaint
.
setTextSize
(
10
);
mSrcPaint
.
setAlpha
(
70
);
//init Point
mCancleBtnPoint
=
new
Point
();
mRotateBtnPoint
=
new
Point
();
mMoveBtnPoint
=
new
Point
();
mScaleBtnPoint
=
new
Point
();
mCenterPoint
=
new
PointF
();
startPoint
=
new
PointF
();
endPoint
=
new
PointF
();
startRawPoint
=
new
PointF
();
startForParentPoint
=
new
PointF
();
endForParentPoint
=
new
PointF
();
//init Bitmap
Resources
res
=
context
.
getResources
();
// actionBm = zoomImage(BitmapFactory.decodeResource(res, R.mipmap.cancle), 15, 15);
// actionBm = zoomImage(BitmapFactory.decodeResource(res, R.mipmap.rotate), 15, 15);
// actionBm = zoomImage(BitmapFactory.decodeResource(res, R.mipmap.move), 15, 15);
// actionBm = zoomImage(BitmapFactory.decodeResource(res, R.mipmap.scale), 15, 15);
actionBm
=
Bitmap
.
createBitmap
(
20
,
20
,
Bitmap
.
Config
.
ARGB_8888
);
mButtonRadius
=
8
;
mSrcMatrix
=
new
Matrix
();
nowTranX
=
getTranslationX
();
nowTranY
=
getTranslationY
();
setSrc
(
1
);
isSrcFilp
=
false
;
normalDestory
=
false
;
}
@Override
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
int
bottom
)
{
mWidth
=
right
-
left
;
mHeight
=
bottom
-
top
;
resetPoint
((
int
)
mButtonRadius
);
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
}
//init matrix
public
void
initMatrix
(
float
angle
,
float
width
,
float
height
)
{
if
(
mSrcBm
!=
null
)
{
this
.
srcAngle
=
angle
;
mSrcBm
=
Bitmap
.
createBitmap
(
mSrcBm
,
0
,
0
,
mSrcBm
.
getWidth
(),
mSrcBm
.
getHeight
(),
mSrcMatrix
,
false
);
srcScale
=
width
<
height
?
width
/
(
float
)
mSrcWidth
:
height
/
(
float
)
mSrcHeight
;
setMatrix
(
width
/
2
,
height
/
2
);
}
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
super
.
onDraw
(
canvas
);
if
(
mSrcBm
!=
null
)
{
//绘制主图
canvas
.
drawBitmap
(
mSrcBm
,
mSrcMatrix
,
mSrcPaint
);
}
if
(
mEndle
)
{
//绘制编辑框
mPath
.
reset
();
mPath
.
moveTo
(
mCancleBtnPoint
.
x
,
mCancleBtnPoint
.
y
);
mPath
.
lineTo
(
mMoveBtnPoint
.
x
,
mMoveBtnPoint
.
y
);
mPath
.
lineTo
(
mScaleBtnPoint
.
x
,
mScaleBtnPoint
.
y
);
mPath
.
lineTo
(
mRotateBtnPoint
.
x
,
mRotateBtnPoint
.
y
);
mPath
.
lineTo
(
mCancleBtnPoint
.
x
,
mCancleBtnPoint
.
y
);
canvas
.
drawPath
(
mPath
,
mLinePaint
);
//绘制功能按钮
canvas
.
drawBitmap
(
actionBm
,
0
,
0
,
mButtonPaint
);
canvas
.
drawBitmap
(
actionBm
,
0
,
mHeight
-
mButtonRadius
*
2
,
mButtonPaint
);
canvas
.
drawBitmap
(
actionBm
,
mWidth
-
mButtonRadius
*
2
,
mHeight
-
mButtonRadius
*
2
,
mButtonPaint
);
canvas
.
drawBitmap
(
actionBm
,
mWidth
-
mButtonRadius
*
2
,
0
,
mButtonPaint
);
}
}
private
PointF
startPoint
,
startRawPoint
,
endPoint
,
startForParentPoint
,
endForParentPoint
;
private
float
nowTranX
,
nowTranY
;
private
boolean
isClick
;
@TargetApi
(
Build
.
VERSION_CODES
.
HONEYCOMB
)
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
int
action
=
event
.
getAction
();
float
moveX
;
float
moveY
;
switch
(
action
)
{
//判断触点坐标所属区域(旋转、移动、缩放、取消、内容)
case
MotionEvent
.
ACTION_DOWN
:
isClick
=
true
;
//记录相对坐标
startPoint
.
x
=
event
.
getX
();
startPoint
.
y
=
event
.
getY
();
//记录绝对坐标
startRawPoint
.
x
=
event
.
getRawX
();
startRawPoint
.
y
=
event
.
getRawY
();
startForParentPoint
.
x
=
mCenterPoint
.
x
+
nowTranX
+
getLeft
();
startForParentPoint
.
y
=
mCenterPoint
.
y
+
nowTranY
+
getTop
();
mButtonCode
=
whichOneTouched
(
event
);
updateLayout
();
mActionController
.
notifyListener
(
this
,
ACTION_SCALE_FINISHED
);
break
;
//移动手指时
case
MotionEvent
.
ACTION_MOVE
:
moveX
=
event
.
getRawX
()
-
startRawPoint
.
x
;
moveY
=
event
.
getRawY
()
-
startRawPoint
.
y
;
if
(
Math
.
abs
(
moveX
)
>
10
||
Math
.
abs
(
moveY
)
>
10
)
{
isClick
=
false
;
}
switch
(
mButtonCode
)
{
//操作旋转按钮时,旋转
case
ACTION_ROTATE:
endPoint
.
x
=
event
.
getX
();
endPoint
.
y
=
event
.
getY
();
//得到目标角度
float
angle
=
(
this
.
getRotation
()
+
getAngle
(
mCenterPoint
,
startPoint
,
endPoint
))
%
360
;
setRotation
(
angle
);
//通知其他View
mActionController
.
notifyListener
(
this
,
ACTION_ROTATE
,
angle
);
break
;
//操作缩放按钮时
case
ACTION_SCALE:
//计算缩放比例
int
moveWidth
=
(
int
)
(
moveX
>
moveY
?
moveX
:
moveY
);
updateScale
(
moveWidth
);
mActionController
.
notifyListener
(
this
,
ACTION_SCALE
,
moveWidth
);
break
;
case
ACTION_MOVE:
//计算开始和结束的触摸点坐标,设置偏移量
endForParentPoint
.
x
=
startForParentPoint
.
x
+
moveX
;
endForParentPoint
.
y
=
startForParentPoint
.
y
+
moveY
;
double
moveAngle
=
getAngle
(
mParentCenterPoint
,
startForParentPoint
,
endForParentPoint
)
%
360
;
double
radius
=
pointDistance
(
mParentCenterPoint
,
endForParentPoint
);
updatePoint
(
moveAngle
,
radius
);
//通知其他view
mActionController
.
notifyListener
(
this
,
ACTION_MOVE
,
moveAngle
,
radius
);
startRawPoint
.
x
=
event
.
getRawX
();
startRawPoint
.
y
=
event
.
getRawY
();
startForParentPoint
.
x
=
endForParentPoint
.
x
;
startForParentPoint
.
y
=
endForParentPoint
.
y
;
break
;
}
break
;
//抬起手指
case
MotionEvent
.
ACTION_UP
:
moveX
=
event
.
getRawX
()
-
startRawPoint
.
x
;
moveY
=
event
.
getRawY
()
-
startRawPoint
.
y
;
switch
(
mButtonCode
)
{
//从布局中删除当前View
case
ACTION_CANCLE:
if
(
Math
.
abs
(
moveX
)
<
mTouchSlop
||
Math
.
abs
(
moveY
)
<
mTouchSlop
)
normalDestory
=
true
;
((
ViewGroup
)
getParent
()).
removeView
(
this
);
break
;
case
ACTION_MOVE:
if
(
isClick
)
{
//如果是点击则显示编辑框
mEndle
=
!
mEndle
;
if
(
mEndle
)
{
mActionController
.
notifyListener
(
this
,
ACTION_UNEDIT
);
bringToFront
();
}
invalidate
();
}
else
{
nowTranX
=
getTranslationX
();
nowTranY
=
getTranslationY
();
}
break
;
case
ACTION_FLIP:
//镜像翻转
if
(
Math
.
abs
(
moveX
)
<
mTouchSlop
||
Math
.
abs
(
moveY
)
<
mTouchSlop
)
{
isSrcFilp
=
!
isSrcFilp
;
setMatrix
(
mCenterPoint
.
x
,
mCenterPoint
.
y
);
invalidate
();
mActionController
.
notifyListener
(
this
,
ACTION_FLIP
);
}
case
ACTION_SCALE:
//记录最新Layout值
updateLayout
();
mActionController
.
notifyListener
(
this
,
ACTION_SCALE_FINISHED
);
break
;
}
break
;
}
return
true
;
}
/**
* 指定bitmap大小
*/
public
Bitmap
zoomImage
(
Bitmap
bitmap
,
double
newWidth
,
double
newHeight
)
{
float
width
=
bitmap
.
getWidth
();
float
height
=
bitmap
.
getHeight
();
Matrix
matrix
=
new
Matrix
();
float
scaleWidth
=
((
float
)
newWidth
)
/
width
;
float
scaleHeight
=
((
float
)
newHeight
)
/
height
;
matrix
.
postScale
(
scaleWidth
,
scaleHeight
);
return
Bitmap
.
createBitmap
(
bitmap
,
0
,
0
,
(
int
)
width
,
(
int
)
height
,
matrix
,
true
);
}
//设置缩放值
private
void
updateScale
(
int
moveWidth
)
{
if
(
mWidth
<
50
||
mHeight
<
50
)
{
if
(
moveWidth
<=
0
)
return
;
}
layout
(
mLeft
-
moveWidth
,
mTop
-
moveWidth
,
mRight
+
moveWidth
,
mBottom
+
moveWidth
);
srcScale
=
mWidth
<
mHeight
?
(
float
)
mWidth
/
(
float
)
mSrcWidth
:
(
float
)
mHeight
/
(
float
)
mSrcHeight
;
setMatrix
(
mCenterPoint
.
x
,
mCenterPoint
.
y
);
}
//更新布局参数
private
void
updateLayout
()
{
mLeft
=
getLeft
();
mRight
=
getRight
();
mTop
=
getTop
();
mBottom
=
getBottom
();
}
private
void
setMatrix
(
float
x
,
float
y
)
{
mSrcMatrix
.
setScale
(
srcScale
,
srcScale
);
if
(
isSrcFilp
)
{
mSrcMatrix
.
postScale
(-
1
,
1
);
mSrcMatrix
.
postTranslate
(
x
*
2
,
0
);
isSrcFilp
=
true
;
}
mSrcMatrix
.
postRotate
(
srcAngle
,
x
,
y
);
}
/**
* 判断触摸点在哪个区域,返回ButtonCode
*/
private
int
whichOneTouched
(
MotionEvent
event
)
{
if
(!
mEndle
)
{
return
ACTION_MOVE
;
}
int
buttonCode
=
ACTION_MOVE
;
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
if
(
x
<
mButtonRadius
*
2
)
{
if
(
y
<
mButtonRadius
*
2
)
{
buttonCode
=
ACTION_CANCLE
;
}
else
if
(
y
>
mHeight
-
(
mButtonRadius
*
2
))
{
buttonCode
=
ACTION_FLIP
;
}
}
else
if
(
x
>
mWidth
-
(
mButtonRadius
*
2
))
{
if
(
y
<
mButtonRadius
*
2
)
{
buttonCode
=
ACTION_ROTATE
;
}
else
if
(
y
>
mHeight
-
(
mButtonRadius
*
2
))
{
buttonCode
=
ACTION_SCALE
;
}
}
return
buttonCode
;
}
/**
* 计算两点之间的距离
*/
private
double
pointDistance
(
PointF
p1
,
PointF
p2
)
{
float
x
=
p2
.
x
-
p1
.
x
;
float
y
=
p2
.
y
-
p1
.
y
;
return
Math
.
sqrt
(
x
*
x
+
y
*
y
);
}
/**
* 设置图片
*/
public
void
setSrc
(
int
id
)
{
mSrcBm
=
BitmapFactory
.
decodeResource
(
getContext
().
getResources
(),
LibConfig
.
APP_ICON
);
mSrcWidth
=
mSrcBm
.
getWidth
();
mSrcHeight
=
mSrcBm
.
getHeight
();
}
/**
* 根据圆心和角度计算下一个view的位置
*/
private
void
setNewPoint
(
PointF
center
,
double
angle
,
double
radius
)
{
double
angleHude
=
angle
*
Math
.
PI
/
180
;
mPointInParent
.
x
=
(
int
)
(
radius
*
Math
.
cos
(
angleHude
)
+
center
.
x
);
mPointInParent
.
y
=
(
int
)
(
radius
*
Math
.
sin
(
angleHude
)
+
center
.
y
);
}
/**
* 得到两点之间的角度
*/
public
float
getAngle
(
PointF
centerPoint
,
PointF
start
,
PointF
end
)
{
//根据起始点和结束点以及View中心点求出三角形的三条边长
double
side1
=
pointDistance
(
centerPoint
,
start
);
double
side2
=
pointDistance
(
start
,
end
);
double
side3
=
pointDistance
(
centerPoint
,
end
);
//得出弧度
double
cosb
=
(
side1
*
side1
+
side3
*
side3
-
side2
*
side2
)
/
(
2
*
side1
*
side3
);
if
(
cosb
>=
1
)
{
cosb
=
1
f
;
}
double
radian
=
Math
.
acos
(
cosb
);
//弧度换算为角度
float
angle
=
(
float
)
(
radian
*
180
/
Math
.
PI
);
float
beforeX
=
start
.
x
-
centerPoint
.
x
;
float
beforeY
=
start
.
y
-
centerPoint
.
y
;
float
afterX
=
end
.
x
-
centerPoint
.
x
;
float
afterY
=
end
.
y
-
centerPoint
.
y
;
//向量叉乘结果, 如果结果为负数, 表示为逆时针, 结果为正数表示顺时针
float
result
=
beforeX
*
afterY
-
beforeY
*
afterX
;
if
(
result
<
0
)
{
angle
=
-
angle
;
}
return
angle
;
}
/**
* 更新当前View位置
*/
@TargetApi
(
Build
.
VERSION_CODES
.
HONEYCOMB
)
public
void
updatePoint
(
double
moveAngle
,
double
radius
)
{
nowAngle
=
(
nowAngle
+
moveAngle
)
%
360
;
setNewPoint
(
mParentCenterPoint
,
nowAngle
,
radius
);
nowTranX
=
mPointInParent
.
x
-
getLeft
()
-
mCenterPoint
.
x
;
nowTranY
=
mPointInParent
.
y
-
getTop
()
-
mCenterPoint
.
y
;
setTranslationX
(
nowTranX
);
setTranslationY
(
nowTranY
);
}
private
float
getDimension
(
int
id
)
{
return
getResources
().
getDimension
(
id
);
}
@TargetApi
(
Build
.
VERSION_CODES
.
HONEYCOMB
)
@Override
public
void
onTouchAction
(
int
ACTION_ID
,
Object
...
args
)
{
switch
(
ACTION_ID
)
{
case
ACTION_ROTATE:
setRotation
((
float
)
args
[
0
]);
break
;
case
ACTION_MOVE:
updatePoint
((
double
)
args
[
0
],
(
double
)
args
[
1
]);
break
;
case
ACTION_UNEDIT:
if
(
mEndle
)
{
mEndle
=
false
;
invalidate
();
}
break
;
case
ACTION_SCALE:
updateScale
((
Integer
)
args
[
0
]);
break
;
case
ACTION_SCALE_FINISHED:
updateLayout
();
break
;
case
ACTION_FLIP:
isSrcFilp
=
!
isSrcFilp
;
setMatrix
(
mCenterPoint
.
x
,
mCenterPoint
.
y
);
invalidate
();
break
;
}
}
public
void
destory
()
{
// 销毁时调用
mActionController
.
unRegisterActionListener
(
this
);
if
(
mSrcBm
!=
null
&&
!
mSrcBm
.
isRecycled
())
{
mSrcBm
.
recycle
();
mSrcBm
=
null
;
}
if
(
actionBm
!=
null
&&
!
actionBm
.
isRecycled
())
{
actionBm
.
recycle
();
actionBm
=
null
;
}
if
(
actionBm
!=
null
&&
!
actionBm
.
isRecycled
())
{
actionBm
.
recycle
();
actionBm
=
null
;
}
if
(
actionBm
!=
null
&&
!
actionBm
.
isRecycled
())
{
actionBm
.
recycle
();
actionBm
=
null
;
}
if
(
actionBm
!=
null
&&
!
actionBm
.
isRecycled
())
{
actionBm
.
recycle
();
actionBm
=
null
;
}
}
private
void
resetPoint
(
int
radius
)
{
mCancleBtnPoint
.
set
(
0
+
radius
,
0
+
radius
);
mMoveBtnPoint
.
set
(
0
+
radius
,
mHeight
-
radius
);
mScaleBtnPoint
.
set
(
mWidth
-
radius
,
mHeight
-
radius
);
mRotateBtnPoint
.
set
(
mWidth
-
radius
,
0
+
radius
);
mCenterPoint
.
set
(
mWidth
/
2
,
mHeight
/
2
);
}
public
void
setmParentCenterPoint
(
PointF
mParentCenterPoint
)
{
this
.
mParentCenterPoint
=
mParentCenterPoint
;
}
public
void
setmPointInParent
(
Point
mPointInParent
)
{
this
.
mPointInParent
=
mPointInParent
;
}
public
void
setNowAngle
(
double
nowAngle
)
{
this
.
nowAngle
=
nowAngle
;
}
public
boolean
isNormalDestory
()
{
return
normalDestory
;
}
}
src/main/res/layout/activity_review_hook.xml
View file @
67331f4e
...
@@ -20,47 +20,65 @@
...
@@ -20,47 +20,65 @@
android:background=
"@color/gray_bg"
android:background=
"@color/gray_bg"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<
com.common.widget.Circle
Layout
<
Linear
Layout
android:id=
"@+id/activity_
hook_circl
e"
android:id=
"@+id/activity_
review_exchang
e"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
android:background=
"@color/white"
android:gravity=
"center_vertical"
<com.common.widget.TouchView
android:orientation=
"vertical"
android:layout_width=
"100dp"
android:padding=
"20dp"
>
android:layout_height=
"100dp"
android:alpha=
"50"
/>
<TextView
<com.common.widget.TouchView
android:layout_width=
"wrap_content"
android:layout_width=
"100dp"
android:layout_height=
"wrap_content"
android:layout_height=
"100dp"
android:textSize=
"30sp"
android:alpha=
"50"
/>
android:text=
"IDR"
/>
<com.common.widget.TouchView
<EditText
android:layout_width=
"100dp"
android:id=
"@+id/activity_review_before_amount_tv"
android:layout_height=
"100dp"
android:layout_width=
"match_parent"
android:alpha=
"50"
/>
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
<com.common.widget.TouchView
android:hint=
"input amount"
android:layout_width=
"100dp"
android:inputType=
"numberDecimal"
android:layout_height=
"100dp"
android:text=
"1000000"
android:alpha=
"50"
/>
android:paddingLeft=
"10dp"
android:textSize=
"30sp"
/>
<com.common.widget.TouchView
android:layout_width=
"100dp"
android:layout_height=
"100dp"
<Button
android:alpha=
"50"
/>
android:id=
"@+id/activity_review_conversion_btn"
style=
"@style/main_color_roundBtn"
<com.common.widget.TouchView
android:layout_marginTop=
"40dp"
android:layout_width=
"100dp"
android:layout_marginBottom=
"40dp"
android:layout_height=
"100dp"
android:layout_width=
"match_parent"
android:alpha=
"50"
/>
android:layout_height=
"wrap_content"
android:text=
"Conversion"
/>
<com.common.widget.TouchView
android:layout_width=
"100dp"
android:layout_height=
"100dp"
<TextView
android:alpha=
"50"
/>
android:id=
"@+id/activity_review_unit_tv"
</com.common.widget.CircleLayout>
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"30sp"
android:text=
"USD"
/>
<TextView
android:id=
"@+id/activity_review_after_amount_tv"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:text=
"70.4722"
android:padding=
"10dp"
android:paddingLeft=
"10dp"
android:background=
"@color/gray_bg"
android:textSize=
"30sp"
/>
</LinearLayout>
<ImageView
<ImageView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -77,6 +95,7 @@
...
@@ -77,6 +95,7 @@
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
</LinearLayout>
</LinearLayout>
</com.common.widget.PenetrateFrameLayout>
</com.common.widget.PenetrateFrameLayout>
<LinearLayout
<LinearLayout
...
@@ -199,7 +218,8 @@
...
@@ -199,7 +218,8 @@
android:layout_height=
"50dp"
android:layout_height=
"50dp"
android:background=
"@drawable/selector_recycler_item"
android:background=
"@drawable/selector_recycler_item"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:paddingLeft=
"15dp"
>
android:paddingLeft=
"15dp"
android:visibility=
"gone"
>
<TextView
<TextView
style=
"@style/span_text"
style=
"@style/span_text"
...
@@ -262,15 +282,14 @@
...
@@ -262,15 +282,14 @@
android:background=
"@drawable/selector_recycler_item"
android:background=
"@drawable/selector_recycler_item"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:paddingLeft=
"15dp"
android:paddingLeft=
"15dp"
>
android:visibility=
"gone"
>
<TextView
<TextView
style=
"@style/span_text"
style=
"@style/span_text"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
/>
android:text=
"@string/text_me_policy"
/>
</com.common.widget.SpanButton>
</com.common.widget.SpanButton>
<TextView
<TextView
...
...
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