Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
4366e5fd
Commit
4366e5fd
authored
Jul 16, 2020
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
布局旋转5°
parent
00cc6945
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
163 additions
and
534 deletions
+163
-534
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
+0
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetailRandom.java
...n/java/cn/garymb/ygomobile/ui/cards/CardDetailRandom.java
+7
-12
mobile/src/main/java/cn/garymb/ygomobile/utils/ThreeDLayoutUtil.java
...main/java/cn/garymb/ygomobile/utils/ThreeDLayoutUtil.java
+0
-355
mobile/src/main/res/layout/dialog_cardinfo_small.xml
mobile/src/main/res/layout/dialog_cardinfo_small.xml
+156
-164
No files found.
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
View file @
4366e5fd
...
...
@@ -3,7 +3,6 @@ package cn.garymb.ygomobile;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.ComponentName
;
import
android.content.Intent
;
import
android.content.pm.ActivityInfo
;
import
android.graphics.Bitmap
;
...
...
@@ -12,7 +11,6 @@ import android.os.Build;
import
android.util.Log
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.Toast
;
import
androidx.appcompat.app.ActionBar
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -28,7 +26,6 @@ import java.util.HashMap;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.ViewTargetPlus
;
import
cn.garymb.ygomobile.utils.ComponentUtils
;
public
class
YGOStarter
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetailRandom.java
View file @
4366e5fd
package
cn.garymb.ygomobile.ui.cards
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.util.SparseArray
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.widget.ImageView
;
...
...
@@ -11,11 +9,7 @@ import android.widget.Toast;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.CardUtils
;
import
cn.garymb.ygomobile.utils.ThreeDLayoutUtil
;
import
ocgcore.CardManager
;
import
ocgcore.DataManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
...
...
@@ -24,7 +18,7 @@ import ocgcore.enums.CardType;
import
static
android
.
view
.
View
.
inflate
;
public
class
CardDetailRandom
{
private
static
ThreeDLayoutUtil
viewCardDetail
;
private
static
View
viewCardDetail
;
private
static
ImageView
cardImage
;
private
static
TextView
name
;
private
static
TextView
desc
;
...
...
@@ -35,13 +29,13 @@ public class CardDetailRandom {
private
static
TextView
cardDef
;
private
static
TextView
attrView
;
private
static
View
monsterlayout
;
private
static
View
atkdefView
;
private
static
View
atkdefView
,
textdefView
;
private
static
ImageLoader
imageLoader
;
private
static
StringManager
mStringManager
;
public
static
void
RandomCardDetail
(
Context
context
,
Card
cardInfo
)
{
imageLoader
=
ImageLoader
.
get
(
context
);
viewCardDetail
=
(
ThreeDLayoutUtil
)
inflate
(
context
,
R
.
layout
.
dialog_cardinfo_small
,
null
);
viewCardDetail
=
inflate
(
context
,
R
.
layout
.
dialog_cardinfo_small
,
null
);
cardImage
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_image_toast
);
name
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_name_toast
);
monsterlayout
=
viewCardDetail
.
findViewById
(
R
.
id
.
star_attr_race_toast
);
...
...
@@ -52,6 +46,7 @@ public class CardDetailRandom {
cardAtk
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_atk_toast
);
cardDef
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_def_toast
);
atkdefView
=
viewCardDetail
.
findViewById
(
R
.
id
.
layout_atkdef2_toast
);
textdefView
=
viewCardDetail
.
findViewById
(
R
.
id
.
TextDef_toast
);
desc
=
viewCardDetail
.
findViewById
(
R
.
id
.
text_desc_toast
);
if
(
cardInfo
==
null
)
return
;
...
...
@@ -72,15 +67,14 @@ public class CardDetailRandom {
level
.
setTextColor
(
context
.
getResources
().
getColor
(
R
.
color
.
star
));
}
cardAtk
.
setText
((
cardInfo
.
Attack
<
0
?
"?"
:
String
.
valueOf
(
cardInfo
.
Attack
)));
if
(
cardInfo
.
isType
(
CardType
.
Pendulum
))
{
desc
.
setTextSize
(
10
);
}
//连接怪兽设置
if
(
cardInfo
.
isType
(
CardType
.
Link
))
{
level
.
setVisibility
(
View
.
GONE
);
textdefView
.
setVisibility
(
View
.
GONE
);
cardDef
.
setText
((
cardInfo
.
getStar
()
<
0
?
"?"
:
"LINK-"
+
String
.
valueOf
(
cardInfo
.
getStar
())));
}
else
{
level
.
setVisibility
(
View
.
VISIBLE
);
textdefView
.
setVisibility
(
View
.
VISIBLE
);
cardDef
.
setText
((
cardInfo
.
Defense
<
0
?
"?"
:
String
.
valueOf
(
cardInfo
.
Defense
)));
}
race
.
setText
(
mStringManager
.
getRaceString
(
cardInfo
.
Race
));
...
...
@@ -88,6 +82,7 @@ public class CardDetailRandom {
atkdefView
.
setVisibility
(
View
.
GONE
);
monsterlayout
.
setVisibility
(
View
.
GONE
);
}
viewCardDetail
.
setRotationY
(
5
);
}
public
static
void
showRandromCardDetailToast
(
Context
context
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ThreeDLayoutUtil.java
deleted
100644 → 0
View file @
00cc6945
package
cn.garymb.ygomobile.utils
;
import
android.animation.Animator
;
import
android.animation.ValueAnimator
;
import
android.content.Context
;
import
android.graphics.Camera
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Matrix
;
import
android.util.AttributeSet
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
/*
* Created by wing on 10/14/16.
*/
public
class
ThreeDLayoutUtil
extends
ViewGroup
{
private
Camera
mCamera
;
private
Matrix
mMatrix
;
//this viewgroup's center
private
int
mCenterX
;
private
int
mCenterY
;
//rotateDegree
private
float
mCanvasRotateY
;
private
float
mCanvasRotateX
;
private
float
mCanvasMaxRotateDegree
=
50
;
//the touch mode
public
static
int
MODE_X
=
0
;
public
static
int
MODE_Y
=
1
;
public
static
int
MODE_BOTH_X_Y
=
2
;
private
int
mMode
=
MODE_BOTH_X_Y
;
private
float
mDensity
;
private
float
[]
mValues
=
new
float
[
9
];
//the flag of touch
private
boolean
isCanTouch
=
false
;
//the degree of animation
private
float
mDegreeY
=
0
;
private
float
mDegreeX
=
0
;
//the flag of animate
private
boolean
isPlaying
=
false
;
//the degree of longer animate
private
int
mLoopAnimateY
=
0
;
public
ThreeDLayoutUtil
(
Context
context
)
{
this
(
context
,
null
);
}
public
ThreeDLayoutUtil
(
Context
context
,
AttributeSet
attrs
)
{
this
(
context
,
attrs
,
0
);
}
public
ThreeDLayoutUtil
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
//set a default background to make sure onDraw() dispatch
if
(
getBackground
()
==
null
)
{
setBackgroundColor
(
Color
.
parseColor
(
"#00ffffff"
));
}
DisplayMetrics
dm
=
new
DisplayMetrics
();
dm
=
getResources
().
getDisplayMetrics
();
mDensity
=
dm
.
density
;
mCamera
=
new
Camera
();
mMatrix
=
new
Matrix
();
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
if
(
getChildCount
()
!=
1
)
{
throw
new
IllegalStateException
(
"ThreeDLayout can only have one child"
);
}
View
child
=
getChildAt
(
0
);
measureChild
(
child
,
widthMeasureSpec
,
heightMeasureSpec
);
//only one child view,so give the same size
setMeasuredDimension
(
child
.
getMeasuredWidth
(),
child
.
getMeasuredHeight
());
}
@Override
protected
void
onLayout
(
boolean
changed
,
int
l
,
int
t
,
int
r
,
int
b
)
{
View
child
=
getChildAt
(
0
);
child
.
layout
(
0
,
0
,
child
.
getMeasuredWidth
(),
child
.
getMeasuredHeight
());
}
@Override
protected
void
onSizeChanged
(
int
w
,
int
h
,
int
oldw
,
int
oldh
)
{
super
.
onSizeChanged
(
w
,
h
,
oldw
,
oldh
);
mCenterX
=
w
/
2
;
mCenterY
=
h
/
2
;
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
mMatrix
.
reset
();
mCamera
.
save
();
if
(
mMode
==
MODE_Y
||
mMode
==
MODE_BOTH_X_Y
)
{
mCamera
.
rotateX
(
mCanvasRotateX
);
}
if
(
mMode
==
MODE_X
||
mMode
==
MODE_BOTH_X_Y
)
{
mCamera
.
rotateY
(
mCanvasRotateY
);
}
mCamera
.
rotateY
(
mDegreeY
);
mCamera
.
rotateX
(
mDegreeX
);
if
(
isPlaying
)
{
mCamera
.
rotateY
(
mLoopAnimateY
++);
Log
.
e
(
"wing"
,
mLoopAnimateY
+
""
);
if
(
mLoopAnimateY
==
360
)
{
mLoopAnimateY
=
0
;
}
invalidate
();
}
mCamera
.
getMatrix
(
mMatrix
);
// fix the Camera bug,
mMatrix
.
getValues
(
mValues
);
mValues
[
6
]
=
mValues
[
6
]
/
mDensity
;
mValues
[
7
]
=
mValues
[
7
]
/
mDensity
;
mMatrix
.
setValues
(
mValues
);
mCamera
.
restore
();
mMatrix
.
preTranslate
(-
mCenterX
,
-
mCenterY
);
mMatrix
.
postTranslate
(
mCenterX
,
mCenterY
);
canvas
.
concat
(
mMatrix
);
super
.
onDraw
(
canvas
);
}
@Override
public
boolean
onInterceptTouchEvent
(
MotionEvent
ev
)
{
if
(
isCanTouch
)
{
return
true
;
}
else
{
return
super
.
onInterceptTouchEvent
(
ev
);
}
}
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
if
(
isCanTouch
)
{
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
int
action
=
event
.
getAction
();
switch
(
action
)
{
case
MotionEvent
.
ACTION_MOVE
:
{
rotateCanvasWhenMove
(
x
,
y
);
invalidate
();
return
true
;
}
case
MotionEvent
.
ACTION_UP
:
{
mDegreeY
=
0
;
rotateCanvasWhenMove
(
mCenterX
,
mCenterY
);
invalidate
();
return
true
;
}
}
return
true
;
}
else
{
return
super
.
onTouchEvent
(
event
);
}
}
/**
* get the value to rotate
*/
private
void
rotateCanvasWhenMove
(
float
x
,
float
y
)
{
float
dx
=
x
-
mCenterX
;
float
dy
=
y
-
mCenterY
;
float
percentX
=
dx
/
mCenterX
;
float
percentY
=
dy
/
mCenterY
;
if
(
percentX
>
1
f
)
{
percentX
=
1
f
;
}
else
if
(
percentX
<
-
1
f
)
{
percentX
=
-
1
f
;
}
if
(
percentY
>
1
f
)
{
percentY
=
1
f
;
}
else
if
(
percentY
<
-
1
f
)
{
percentY
=
-
1
f
;
}
mCanvasRotateY
=
mCanvasMaxRotateDegree
*
percentX
;
mCanvasRotateX
=
-(
mCanvasMaxRotateDegree
*
percentY
);
}
public
void
setTouchable
(
boolean
canTouch
)
{
isCanTouch
=
canTouch
;
}
public
void
setTouchMode
(
int
mode
)
{
mMode
=
mode
;
isCanTouch
=
true
;
}
/**
* set the max rotate degree
*/
public
void
setMaxRotateDegree
(
int
degree
)
{
mCanvasMaxRotateDegree
=
degree
;
}
/**
* start horizontal turn animate
*/
public
void
startHorizontalAnimate
(
long
duration
)
{
final
ValueAnimator
animator
=
ValueAnimator
.
ofFloat
(-
180
f
,
0
f
);
animator
.
addUpdateListener
(
new
ValueAnimator
.
AnimatorUpdateListener
()
{
@Override
public
void
onAnimationUpdate
(
ValueAnimator
animation
)
{
mDegreeY
=
(
float
)
animation
.
getAnimatedValue
();
invalidate
();
}
});
animator
.
addListener
(
new
Animator
.
AnimatorListener
()
{
@Override
public
void
onAnimationStart
(
Animator
animation
)
{
}
@Override
public
void
onAnimationEnd
(
Animator
animation
)
{
mDegreeY
=
0
;
animator
.
removeAllUpdateListeners
();
}
@Override
public
void
onAnimationCancel
(
Animator
animation
)
{
}
@Override
public
void
onAnimationRepeat
(
Animator
animation
)
{
}
});
animator
.
setDuration
(
duration
);
animator
.
start
();
}
/**
* start horizontal turn animate delayed
*/
public
void
startHorizontalAnimateDelayed
(
final
long
delayed
,
final
long
duration
)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
delayed
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
startHorizontalAnimate
(
duration
);
}
});
}
}).
start
();
}
/**
* start vertical turn animate
*/
public
void
startVerticalAnimate
(
long
duration
)
{
final
ValueAnimator
animator
=
ValueAnimator
.
ofFloat
(-
180
f
,
0
f
);
animator
.
addUpdateListener
(
new
ValueAnimator
.
AnimatorUpdateListener
()
{
@Override
public
void
onAnimationUpdate
(
ValueAnimator
animation
)
{
mDegreeX
=
(
float
)
animation
.
getAnimatedValue
();
invalidate
();
}
});
animator
.
addListener
(
new
Animator
.
AnimatorListener
()
{
@Override
public
void
onAnimationStart
(
Animator
animation
)
{
}
@Override
public
void
onAnimationEnd
(
Animator
animation
)
{
mDegreeX
=
0
;
animator
.
removeAllUpdateListeners
();
}
@Override
public
void
onAnimationCancel
(
Animator
animation
)
{
}
@Override
public
void
onAnimationRepeat
(
Animator
animation
)
{
}
});
animator
.
setDuration
(
duration
);
animator
.
start
();
}
/**
* start vertical turn animate delayed
*/
public
void
startVerticalAnimateDelayed
(
final
long
delayed
,
final
long
duration
)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
delayed
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
startVerticalAnimate
(
duration
);
}
});
}
}).
start
();
}
/**
* start loop animate
*/
public
void
startHorizontalAnimate
()
{
isPlaying
=
true
;
invalidate
();
}
/**
* stop the loop animate
*/
public
void
stopAnimate
()
{
isPlaying
=
false
;
mLoopAnimateY
=
0
;
invalidate
();
}
}
mobile/src/main/res/layout/dialog_cardinfo_small.xml
View file @
4366e5fd
<
cn.garymb.ygomobile.utils.ThreeDLayoutUtil
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/td_cardinfo"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<LinearLayout
android:id=
"@id/smContentView"
android:layout_width=
"match_parent"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:orientation=
"vertical"
>
<RelativeLayout
android:layout_width=
"140dp"
android:layout_height=
"203dp"
>
<ImageView
android:id=
"@+id/card_image_toast"
android:layout_width=
"match_parent
"
android:layout_height=
"match_parent
"
android:layout_width=
"140dp
"
android:layout_height=
"203dp
"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:layout_gravity=
"center_vertical"
android:scaleType=
"fitXY"
/>
</RelativeLayout>
android:scaleType=
"fitXY"
/>
<LinearLayout
android:id=
"@+id/layout_atkdef2_toast"
android:layout_width=
"wrap_cont
ent"
android:layout_width=
"match_par
ent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"3dp"
android:orientation=
"horizontal"
>
<LinearLayout
android:id=
"@+id/layout_atk_toast"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
android:paddingRight=
"5dp"
>
<TextView
android:layout_width=
"wrap_content"
...
...
@@ -66,12 +59,13 @@
<LinearLayout
android:id=
"@+id/layout_def_toast"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
android:paddingLeft=
"5dp"
>
<TextView
android:id=
"@+id/TextDef_toast"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_cont
ent"
android:layout_height=
"match_par
ent"
android:maxLines=
"1"
android:singleLine=
"true"
android:text=
"DEF/"
...
...
@@ -96,7 +90,7 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft
=
"10dp"
android:layout_margin
=
"10dp"
android:orientation=
"vertical"
>
<cn.garymb.ygomobile.ui.widget.AlwaysMarqueeTextView
...
...
@@ -209,14 +203,12 @@
<TextView
android:id=
"@+id/text_desc_toast"
android:layout_width=
"match_parent"
android:layout_height=
"match_par
ent"
android:layout_height=
"wrap_cont
ent"
android:gravity=
"left|top"
android:minHeight=
"@dimen/card_desc_height"
android:paddingBottom=
"5dp"
android:minHeight=
"155dp"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textColor=
"@color/white"
android:textSize=
"12
sp"
android:textSize=
"10
sp"
tools:text=
"desc"
/>
</LinearLayout>
</LinearLayout>
</cn.garymb.ygomobile.utils.ThreeDLayoutUtil>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
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