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
4525849e
Commit
4525849e
authored
Dec 14, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/fallenstardust/YGOMobile-cn-ko-en
parents
41d69b38
9b1dbef3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
189 additions
and
27 deletions
+189
-27
mobile/src/main/java/cn/garymb/ygomobile/App.java
mobile/src/main/java/cn/garymb/ygomobile/App.java
+5
-0
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+23
-16
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+1
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+10
-10
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
...c/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/CrashHandler.java
...src/main/java/cn/garymb/ygomobile/utils/CrashHandler.java
+141
-0
mobile/src/main/res/layout/file_log_activity.xml
mobile/src/main/res/layout/file_log_activity.xml
+7
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/App.java
View file @
4525849e
...
...
@@ -5,6 +5,8 @@ import android.app.Activity;
import
android.content.Intent
;
import
android.support.v7.app.AppCompatDelegate
;
import
cn.garymb.ygomobile.utils.CrashHandler
;
public
class
App
extends
GameApplication
{
@Override
...
...
@@ -12,6 +14,9 @@ public class App extends GameApplication {
super
.
onCreate
();
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
);
AppsSettings
.
init
(
this
);
//初始化异常工具类
CrashHandler
crashHandler
=
CrashHandler
.
getInstance
();
crashHandler
.
init
(
getApplicationContext
());
if
(
AppsSettings
.
get
().
isSoundEffect
())
{
initSoundEffectPool
();
setInitSoundEffectPool
(
true
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
4525849e
...
...
@@ -119,7 +119,8 @@ public class AppsSettings {
mScreenHeight
=
context
.
getResources
().
getDisplayMetrics
().
heightPixels
;
mScreenWidth
=
context
.
getResources
().
getDisplayMetrics
().
widthPixels
;
if
(
isImmerSiveMode
()
&&
context
instanceof
Activity
)
{
if
(
context
instanceof
Activity
)
{
DisplayMetrics
dm
=
SystemUtils
.
getHasVirtualDisplayMetrics
((
Activity
)
context
);
if
(
dm
!=
null
)
{
int
height
=
Math
.
max
(
dm
.
widthPixels
,
dm
.
heightPixels
);
...
...
@@ -131,29 +132,28 @@ public class AppsSettings {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
Log
.
e
(
"YGOMobile"
,
"原始长"
+
mScreenHeight
);
Log
.
e
(
"YGOMobile"
,
"原始宽"
+
mScreenWidth
);
Log
.
e
(
"YGOMobile"
,
"界面长"
+
dm
.
heightPixels
);
Log
.
e
(
"YGOMobile"
,
"界面宽"
+
dm
.
widthPixels
);
// if (mScreenHeight> mScreenWidth) {
// mScreenHeight = height;
// } else {
// mScreenWidth = height;
// }
if
(
isImmerSiveMode
())
return
;
ScreenUtil
.
findNotchInformation
(((
Activity
)
context
),
new
ScreenUtil
.
FindNotchInformation
()
{
@Override
public
void
onNotchInformation
(
boolean
isNotch
,
int
notchHeight
,
int
phoneType
)
{
int
height
=
Math
.
max
(
dm
.
widthPixels
,
dm
.
heightPixels
);
try
{
FileLogUtil
.
writeAndTime
(
"是否有刘海: "
+
isNotch
);
FileLogUtil
.
writeAndTime
(
"刘海高"
+
notchHeight
);
FileLogUtil
.
writeAndTime
(
"height值: "
+
height
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
isNotch
)
{
try
{
FileLogUtil
.
writeAndTime
(
"刘海高"
+
notchHeight
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
height
-=
notchHeight
;
}
try
{
FileLogUtil
.
writeAndTime
(
"处理后height值: "
+
height
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
mScreenHeight
>
mScreenWidth
)
{
mScreenHeight
=
height
;
...
...
@@ -395,6 +395,13 @@ public class AppsSettings {
return
new
File
(
getResourcePath
(),
Constants
.
CORE_IMAGE_PATH
).
getAbsolutePath
();
}
/***
* log文件夹
*/
public
String
getMobileLogPath
()
{
return
new
File
(
getResourcePath
(),
Constants
.
MOBILE_LOG
).
getAbsolutePath
();
}
/***
* 当前数据库文件夹
*/
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
4525849e
...
...
@@ -65,6 +65,7 @@ public interface Constants {
String
CORE_EXPANSIONS
=
"expansions"
;
String
CORE_SINGLE_PATH
=
"single"
;
String
CORE_IMAGE_PATH
=
"pics"
;
String
MOBILE_LOG
=
"log"
;
String
CORE_EXPANSIONS_IMAGE_PATH
=
"expansions/pics"
;
String
CORE_IMAGE_FIELD_PATH
=
"field"
;
String
CORE_SCRIPT_PATH
=
"script"
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
4525849e
...
...
@@ -529,23 +529,23 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
public
void
AnimationShake
()
{
Animation
shake
=
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
shake
);
//加载动画资源文件
ImageView
iv
=
findViewById
(
R
.
id
.
cube
);
iv
.
startAnimation
(
shake
);
//给组件播放动画效果
iv
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
startActivity
(
new
Intent
(
HomeActivity
.
this
,
FileLogActivity
.
class
));
return
true
;
}
});
findViewById
(
R
.
id
.
cube
).
startAnimation
(
shake
);
//给组件播放动画效果
}
public
void
StartMycard
()
{
$
(
R
.
id
.
btn_mycard
).
setOnClickListener
((
v
)
->
{
ImageView
iv_mc
=
$
(
R
.
id
.
btn_mycard
);
iv_mc
.
setOnClickListener
((
v
)
->
{
if
(
Constants
.
SHOW_MYCARD
)
{
startActivity
(
new
Intent
(
this
,
MyCardActivity
.
class
));
}
});
iv_mc
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
startActivity
(
new
Intent
(
HomeActivity
.
this
,
FileLogActivity
.
class
));
return
true
;
}
});
}
public
boolean
joinQQGroup
(
String
key
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
View file @
4525849e
...
...
@@ -274,7 +274,8 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
Constants
.
CORE_DECK_PATH
,
Constants
.
CORE_REPLAY_PATH
,
Constants
.
FONT_DIRECTORY
,
Constants
.
CORE_IMAGE_PATH
Constants
.
CORE_IMAGE_PATH
,
Constants
.
MOBILE_LOG
};
File
dirFile
=
null
;
for
(
String
dir
:
dirs
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/CrashHandler.java
0 → 100644
View file @
4525849e
package
cn.garymb.ygomobile.utils
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.os.Looper
;
import
android.util.Log
;
import
android.widget.Toast
;
import
java.io.FileOutputStream
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.lang.reflect.Field
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
cn.garymb.ygomobile.AppsSettings
;
public
class
CrashHandler
implements
Thread
.
UncaughtExceptionHandler
{
public
static
final
String
TAG
=
"YGOMobile-Exception"
;
public
static
final
CrashHandler
INSTANCE
=
new
CrashHandler
();
private
Map
<
String
,
String
>
infos
=
new
HashMap
<
String
,
String
>();
private
DateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH.mm.ss"
);
private
Context
context
;
private
Thread
.
UncaughtExceptionHandler
defaultHandler
;
private
CrashHandler
()
{
}
public
static
CrashHandler
getInstance
()
{
return
INSTANCE
;
}
public
void
init
(
Context
context
)
{
this
.
context
=
context
;
defaultHandler
=
Thread
.
getDefaultUncaughtExceptionHandler
();
Thread
.
setDefaultUncaughtExceptionHandler
(
this
);
}
@Override
public
void
uncaughtException
(
Thread
thread
,
Throwable
ex
)
{
if
(!
handleException
(
ex
)
&&
defaultHandler
!=
null
)
{
defaultHandler
.
uncaughtException
(
thread
,
ex
);
}
else
{
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
Log
.
e
(
TAG
,
"error : "
,
e
);
}
System
.
exit
(
1
);
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
}
}
private
boolean
handleException
(
Throwable
ex
)
{
if
(
ex
==
null
)
{
return
false
;
}
//使用Toast来显示异常信息
new
Thread
()
{
@Override
public
void
run
()
{
Looper
.
prepare
();
Toast
.
makeText
(
context
,
"软件错误退出"
,
Toast
.
LENGTH_LONG
).
show
();
Looper
.
loop
();
}
}.
start
();
collectDeviceInfo
(
context
);
saveCrashInfo2File
(
ex
);
return
true
;
}
public
void
collectDeviceInfo
(
Context
ctx
)
{
try
{
PackageManager
pm
=
ctx
.
getPackageManager
();
PackageInfo
pi
=
pm
.
getPackageInfo
(
ctx
.
getPackageName
(),
PackageManager
.
GET_ACTIVITIES
);
if
(
pi
!=
null
)
{
String
versionName
=
pi
.
versionName
==
null
?
"null"
:
pi
.
versionName
;
String
versionCode
=
pi
.
versionCode
+
""
;
infos
.
put
(
"versionName"
,
versionName
);
infos
.
put
(
"versionCode"
,
versionCode
);
}
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
Log
.
e
(
TAG
,
"an error occured when collect package info"
,
e
);
}
Field
[]
fields
=
Build
.
class
.
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
try
{
field
.
setAccessible
(
true
);
infos
.
put
(
field
.
getName
(),
field
.
get
(
null
).
toString
());
Log
.
d
(
TAG
,
field
.
getName
()
+
" : "
+
field
.
get
(
null
));
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"an error occured when collect crash info"
,
e
);
}
}
}
private
String
saveCrashInfo2File
(
Throwable
ex
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
infos
.
entrySet
())
{
String
key
=
entry
.
getKey
();
String
value
=
entry
.
getValue
();
sb
.
append
(
key
+
"="
+
value
+
"\n"
);
}
Writer
writer
=
new
StringWriter
();
PrintWriter
printWriter
=
new
PrintWriter
(
writer
);
ex
.
printStackTrace
(
printWriter
);
Throwable
cause
=
ex
.
getCause
();
while
(
cause
!=
null
)
{
cause
.
printStackTrace
(
printWriter
);
cause
=
cause
.
getCause
();
}
printWriter
.
close
();
String
result
=
writer
.
toString
();
sb
.
append
(
result
);
Log
.
e
(
TAG
,
sb
.
toString
());
try
{
// long timestamp = System.currentTimeMillis();
String
time
=
formatter
.
format
(
new
Date
());
String
fileName
=
"【Demo】"
+
time
+
/* timestamp +*/
".log"
;
String
path
=
AppsSettings
.
get
().
getMobileLogPath
()
+
"/"
;
FileOutputStream
fos
=
new
FileOutputStream
(
path
+
fileName
);
fos
.
write
(
sb
.
toString
().
getBytes
());
fos
.
close
();
return
fileName
;
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"an error occured while writing file..."
,
e
);
}
return
null
;
}
}
mobile/src/main/res/layout/file_log_activity.xml
View file @
4525849e
...
...
@@ -6,6 +6,9 @@
<include
layout=
"@layout/content_toolbar"
/>
<android.support.v4.widget.NestedScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<TextView
android:textStyle=
"bold"
android:id=
"@+id/tv_log"
...
...
@@ -15,4 +18,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</android.support.v4.widget.NestedScrollView>
</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