Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haihang
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
徐丛奇
haihang
Commits
2afe3d69
Commit
2afe3d69
authored
Sep 13, 2018
by
chengxiuhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test main
parent
81d4e6d1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
46 deletions
+123
-46
EyeTestActivity.java
app/src/main/java/com/oo/eye/activity/EyeTestActivity.java
+49
-43
EyeTestMainActivity.java
app/src/main/java/com/oo/eye/activity/EyeTestMainActivity.java
+46
-0
BaseActivity.java
library/baselibrary/src/main/java/com/app/baselibrary/base/common/BaseActivity.java
+28
-3
No files found.
app/src/main/java/com/oo/eye/activity/EyeTestActivity.java
View file @
2afe3d69
...
...
@@ -56,7 +56,7 @@ public class EyeTestActivity extends BaseActivity {
static
final
int
BOTTOM
=
2
;
static
final
int
LEFT
=
3
;
static
final
int
RIGHT_TOP
=
4
;
static
final
int
RIGHT_BOTTOM
=
5
;
static
final
int
RIGHT_BOTTOM
=
5
;
static
final
int
LEFT_BOTTOM
=
6
;
static
final
int
LEFT_TOP
=
7
;
...
...
@@ -137,9 +137,9 @@ public class EyeTestActivity extends BaseActivity {
mDirection
=
PreferencesUtils
.
getInt
(
EyeConfig
.
EYE_DIRECTION_SETTING_KEY
,
EYE_DIRECTION_4
);
mGroupDecimal
=
PreferencesUtils
.
getInt
(
EyeConfig
.
EYE_SETTING_KEY
,
EyeConfig
.
EYE_SETTING_5
);
mAutoJudge
=
PreferencesUtils
.
getInt
(
EyeConfig
.
EYE_WAIT_SETTING_KEY
,
0
);
isTemporary
=
getIntent
().
getBooleanExtra
(
"isTemporary"
,
false
);
String
dis
=
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
?
"5"
:
"2.5"
;
mDistanceText
.
setText
(
"当前测视距离为"
+
dis
+
"米"
);
isTemporary
=
getIntent
().
getBooleanExtra
(
"isTemporary"
,
false
);
String
dis
=
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
?
"5"
:
"2.5"
;
mDistanceText
.
setText
(
"当前测视距离为"
+
dis
+
"米"
);
mList
.
clear
();
for
(
int
i
=
0
;
i
<
14
;
i
++)
{
mList
.
add
(
initLineList
(
i
));
...
...
@@ -165,9 +165,10 @@ public class EyeTestActivity extends BaseActivity {
/**
* 准备测试
*
* @param index
*/
private
void
prepareStudentTest
(
int
index
){
private
void
prepareStudentTest
(
int
index
)
{
currentIndex
=
index
;
isStartTest
=
false
;
mCollect
.
clear
();
...
...
@@ -177,9 +178,9 @@ public class EyeTestActivity extends BaseActivity {
}
else
{
nameText
.
setText
(
""
);
}
if
(
index
<
mStudentList
.
size
()-
1
)
{
if
(
index
<
mStudentList
.
size
()
-
1
)
{
mNextText
.
setText
(
"放弃当前,跳到下一位"
);
}
else
{
}
else
{
mNextText
.
setText
(
"结束测试"
);
}
continueTest
();
...
...
@@ -208,7 +209,7 @@ public class EyeTestActivity extends BaseActivity {
@Override
public
void
onTick
(
long
millisUntilFinished
)
{
long
time
=
millisUntilFinished
/
1000
;
timeText1
.
setText
(
time
+
""
);
timeText1
.
setText
(
time
+
""
);
}
@Override
...
...
@@ -239,7 +240,7 @@ public class EyeTestActivity extends BaseActivity {
}
private
void
speak
(
String
text
)
{
if
(
BDttsUtils
.
getInstance
()
!=
null
)
{
if
(
BDttsUtils
.
getInstance
()
!=
null
)
{
BDttsUtils
.
getInstance
().
speak
(
text
);
}
}
...
...
@@ -251,7 +252,7 @@ public class EyeTestActivity extends BaseActivity {
*/
private
void
drewE
(
E
e
)
{
int
angle
=
0
;
switch
(
e
.
getDirect
()){
switch
(
e
.
getDirect
())
{
case
TOP:
angle
=
0
;
break
;
...
...
@@ -278,7 +279,7 @@ public class EyeTestActivity extends BaseActivity {
break
;
}
eImageView1
.
destroyDrawingCache
();
eImageView1
.
setImageBitmap
(
Eye
.
getBitmap
(
this
,
e
.
getLevel
(),
mDistance
,
angle
));
eImageView1
.
setImageBitmap
(
Eye
.
getBitmap
(
this
,
e
.
getLevel
(),
mDistance
,
angle
));
isKeyDwon
=
true
;
}
...
...
@@ -300,7 +301,7 @@ public class EyeTestActivity extends BaseActivity {
if
(
i
>
0
)
{
direct
=
getRandomDirect
(
list
,
direct
,
sum
);
}
e
=
new
E
(
i
,
direct
,
index
,
levelValue
);
e
=
new
E
(
i
,
direct
,
index
,
levelValue
);
list
.
add
(
e
);
}
return
list
;
...
...
@@ -406,37 +407,38 @@ public class EyeTestActivity extends BaseActivity {
drewE
(
mSelectE
);
isJudgeChoose
=
false
;
startRunnable
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
void
startRunnable
()
{
if
(
mRunnable
==
null
)
{
private
void
startRunnable
()
{
if
(
mRunnable
==
null
)
{
mRunnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
LogUtil
.
e
(
"mRunnable------"
);
if
(
isChoose
)
{
if
(
isChoose
)
{
return
;
}
userChooseError
();
}
};
}
if
(
mAutoJudge
>
0
)
{
if
(
mAutoJudge
>
0
)
{
LogUtil
.
e
(
"开启mRunnable"
);
mHandler
.
postDelayed
(
mRunnable
,
mAutoJudge
*
1000
);
}
isChoose
=
false
;
}
private
void
removeRunnable
(){
private
void
removeRunnable
()
{
isChoose
=
true
;
try
{
if
(
mHandler
!=
null
&&
mRunnable
!=
null
)
{
mHandler
.
removeCallbacks
(
mRunnable
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
...
...
@@ -448,7 +450,7 @@ public class EyeTestActivity extends BaseActivity {
*/
private
synchronized
void
userChoose
(
int
direct
)
{
removeRunnable
();
if
(!
isJudgeChoose
)
{
if
(!
isJudgeChoose
)
{
isJudgeChoose
=
true
;
//获取当前行答过的e
List
<
E
>
list
=
mCollect
.
get
(
mLevelIndex
);
...
...
@@ -522,7 +524,7 @@ public class EyeTestActivity extends BaseActivity {
*/
private
synchronized
void
userChooseError
()
{
removeRunnable
();
if
(!
isJudgeChoose
)
{
if
(!
isJudgeChoose
)
{
isJudgeChoose
=
true
;
int
direct
=
mSelectE
.
getDirect
()
+
1
;
//获取当前行答过的e
...
...
@@ -563,7 +565,7 @@ public class EyeTestActivity extends BaseActivity {
private
void
showStudentTestDialog
()
{
final
int
next
=
currentIndex
+
1
;
final
int
next
=
currentIndex
+
1
;
boolean
isShow
=
false
;
String
nextName
=
""
;
if
(
next
<
mStudentList
.
size
())
{
...
...
@@ -572,26 +574,26 @@ public class EyeTestActivity extends BaseActivity {
}
double
left
=
mLeftEye
;
double
right
=
mRightEye
;
if
(
mGroupDecimal
!=
EyeConfig
.
EYE_SETTING_5
)
{
int
leftIndex
=
Eye
.
getIndexByValue
(
mLeftEye
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
left
=
Eye
.
getLevelByIndex
(
leftIndex
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
int
rightIndex
=
Eye
.
getIndexByValue
(
mRightEye
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
right
=
Eye
.
getLevelByIndex
(
rightIndex
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
if
(
mGroupDecimal
!=
EyeConfig
.
EYE_SETTING_5
)
{
int
leftIndex
=
Eye
.
getIndexByValue
(
mLeftEye
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
left
=
Eye
.
getLevelByIndex
(
leftIndex
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
int
rightIndex
=
Eye
.
getIndexByValue
(
mRightEye
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
right
=
Eye
.
getLevelByIndex
(
rightIndex
,
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
);
}
if
(
isTemporary
)
{
if
(
isTemporary
)
{
measureStudent
.
setLeft_eye
(
left
);
measureStudent
.
setRight_eye
(
right
);
DbManager
.
getDaoSession
(
EyeTestActivity
.
this
).
insert
(
measureStudent
);
}
else
{
}
else
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"sid"
,
!
CheckUtil
.
isEmpty
(
measureStudent
.
getSid
())
?
measureStudent
.
getSid
():
""
);
map
.
put
(
"uid"
,
!
CheckUtil
.
isEmpty
(
measureStudent
.
getUid
())
?
measureStudent
.
getUid
():
""
);
map
.
put
(
"sid"
,
!
CheckUtil
.
isEmpty
(
measureStudent
.
getSid
())
?
measureStudent
.
getSid
()
:
""
);
map
.
put
(
"uid"
,
!
CheckUtil
.
isEmpty
(
measureStudent
.
getUid
())
?
measureStudent
.
getUid
()
:
""
);
map
.
put
(
"eid"
,
"0"
);
map
.
put
(
"left_eye"
,
""
+
left
);
map
.
put
(
"right_eye"
,
""
+
right
);
map
.
put
(
"distance"
,
""
+(
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
?
5
:
2.5
)
);
map
.
put
(
"left_eye"
,
""
+
left
);
map
.
put
(
"right_eye"
,
""
+
right
);
map
.
put
(
"distance"
,
""
+
(
mDistance
==
EyeConfig
.
EYE_DISTANCE_5
?
5
:
2.5
)
);
map
.
put
(
"deviceId"
,
Build
.
ID
);
map
.
put
(
"pid"
,
!
CheckUtil
.
isEmpty
(
measureStudent
.
getPid
())
?
measureStudent
.
getPid
():
""
);
map
.
put
(
"pid"
,
!
CheckUtil
.
isEmpty
(
measureStudent
.
getPid
())
?
measureStudent
.
getPid
()
:
""
);
EyeDataManager
.
getInstance
().
postEyeTestData
(
map
).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
new
RxCallback
<
OldResponseImpl
<
Object
>>()
{
@Override
...
...
@@ -605,10 +607,10 @@ public class EyeTestActivity extends BaseActivity {
}
});
}
mAfterTestDialog
=
new
AfterTestDialog
.
Builder
(
EyeTestActivity
.
this
,
R
.
style
.
style_common_dialog
)
.
setLeftEye
(
""
+
mLeftEye
)
.
setRightEye
(
""
+
mRightEye
)
.
setUserName
(
""
+
measureStudent
.
getRealname
())
mAfterTestDialog
=
new
AfterTestDialog
.
Builder
(
EyeTestActivity
.
this
,
R
.
style
.
style_common_dialog
)
.
setLeftEye
(
""
+
mLeftEye
)
.
setRightEye
(
""
+
mRightEye
)
.
setUserName
(
""
+
measureStudent
.
getRealname
())
.
setShowContinueText
(
isShow
)
.
setNextName
(
nextName
)
.
setTrainTime
(
new
Date
())
...
...
@@ -638,7 +640,9 @@ public class EyeTestActivity extends BaseActivity {
return
true
;
}
mLastOnKeyTime
=
currentTime
;
if
(
isKeyDwon
)
{
LogUtil
.
e
(
"---查看按键对应的数字---"
+
event
.
getKeyCode
());
ToastUtil
.
showMessage
(
"---查看按键对应的数字---"
+
event
.
getKeyCode
());
if
(
isKeyDwon
)
{
switch
(
event
.
getKeyCode
())
{
case
KeyEvent
.
KEYCODE_DPAD_UP
:
userChoose
(
TOP
);
...
...
@@ -668,7 +672,9 @@ public class EyeTestActivity extends BaseActivity {
//用户点击返回键:
userChooseError
();
return
true
;
case
KeyEvent
.
KEYCODE_DEL
:
//返回键
finish
();
return
true
;
}
}
}
...
...
@@ -725,10 +731,10 @@ public class EyeTestActivity extends BaseActivity {
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
next_left
:
int
next
=
currentIndex
+
1
;
int
next
=
currentIndex
+
1
;
if
(
next
<
mStudentList
.
size
())
{
prepareStudentTest
(
next
);
}
else
{
}
else
{
finish
();
}
break
;
...
...
app/src/main/java/com/oo/eye/activity/EyeTestMainActivity.java
View file @
2afe3d69
package
com
.
oo
.
eye
.
activity
;
import
android.content.Intent
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.app.baselibrary.base.common.BaseActivity
;
import
com.app.baselibrary.commonUtil.BDttsUtils
;
...
...
@@ -18,6 +20,8 @@ import com.oo.eye.db.DbManager;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
butterknife.BindView
;
import
butterknife.OnClick
;
...
...
@@ -76,6 +80,41 @@ public class EyeTestMainActivity extends BaseActivity {
isRequestFinish
=
false
;
ToastUtil
.
showLongMessage
(
msg
);
}
@Override
public
boolean
dispatchKeyEvent
(
KeyEvent
event
)
{
if
(
event
.
getAction
()
==
KeyEvent
.
ACTION_UP
)
{
LogUtil
.
e
(
"---查看按键对应的数字---"
+
event
.
getKeyCode
());
switch
(
event
.
getKeyCode
())
{
case
KeyEvent
.
KEYCODE_DEL
:
//返回键
exitBy2Click
();
return
true
;
}
}
return
super
.
dispatchKeyEvent
(
event
);
}
/**
* 双击退出函数
*/
private
static
Boolean
isExit
=
false
;
private
Timer
tExit
;
private
void
exitBy2Click
()
{
if
(
isExit
==
false
)
{
isExit
=
true
;
// 准备退出
ToastUtil
.
showMessage
(
"再按一次退出程序"
);
tExit
=
new
Timer
();
tExit
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
isExit
=
false
;
// 取消退出
}
},
2000
);
// 如果2秒钟内没有按下返回键,则启动定时器取消掉刚才执行的任务
}
else
{
finish
();
System
.
exit
(
0
);
}
}
@Override
public
boolean
dispatchTouchEvent
(
MotionEvent
ev
)
{
...
...
@@ -112,4 +151,11 @@ public class EyeTestMainActivity extends BaseActivity {
break
;
}
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
tExit
.
cancel
();
tExit
=
null
;
}
}
library/baselibrary/src/main/java/com/app/baselibrary/base/common/BaseActivity.java
View file @
2afe3d69
...
...
@@ -5,11 +5,14 @@ import android.content.pm.ActivityInfo;
import
android.content.res.Configuration
;
import
android.os.Bundle
;
import
android.support.v4.content.ContextCompat
;
import
android.view.KeyEvent
;
import
com.app.baselibrary.BuildConfig
;
import
com.app.baselibrary.R
;
import
com.app.baselibrary.base.app.AppManager
;
import
com.app.baselibrary.commonUtil.LogUtil
;
import
com.app.baselibrary.commonUtil.StatusBarCompat
;
import
com.app.baselibrary.commonUtil.ToastUtil
;
import
com.tbruyelle.rxpermissions.RxPermissions
;
import
com.trello.rxlifecycle.components.support.RxAppCompatActivity
;
import
com.umeng.analytics.MobclickAgent
;
...
...
@@ -157,23 +160,45 @@ public abstract class BaseActivity extends RxAppCompatActivity {
/**
* 画页是否存活
*
* @return
*/
public
boolean
isActive
(){
public
boolean
isActive
()
{
return
!
isFinishing
();
}
/**
* 弹出加载对话框
*/
public
void
showLoadingDialog
(){
public
void
showLoadingDialog
()
{
}
/**
* 关闭加载对话框
*/
public
void
closeLoadingDialog
(){
public
void
closeLoadingDialog
()
{
}
private
long
mLastOnKeyTime
=
-
1
;
@Override
public
boolean
dispatchKeyEvent
(
KeyEvent
event
)
{
if
(
event
.
getAction
()
==
KeyEvent
.
ACTION_UP
)
{
//两次点击大于1秒
long
currentTime
=
System
.
currentTimeMillis
();
if
(
mLastOnKeyTime
>
0
&&
currentTime
-
mLastOnKeyTime
<
500
)
{
return
true
;
}
mLastOnKeyTime
=
currentTime
;
LogUtil
.
e
(
"---查看按键对应的数字---"
+
event
.
getKeyCode
());
switch
(
event
.
getKeyCode
())
{
case
KeyEvent
.
KEYCODE_DEL
:
//返回键
finish
();
return
true
;
}
}
return
super
.
dispatchKeyEvent
(
event
);
}
}
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