Commit 3daae609 by chengxiuhong

test main

parent a298da3f
......@@ -5,9 +5,11 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.LogUtil;
......@@ -18,6 +20,7 @@ import com.oo.eye.manager.DaemonSender;
import com.oo.eye.manager.OOMsg;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
......@@ -26,147 +29,154 @@ import butterknife.OnClick;
public class BeforeEyeTestActivity extends BaseActivity {
@BindView(R2.id.ll_before_eye_start1)
LinearLayout startLayout1;
@BindView(R2.id.ll_before_eye_prepare1)
LinearLayout prepareLayout1;
private DaemonReceiver mDaemonReceiver;
private ActionReceiver mActionReceiver;
private Handler mHandler ;
@Override
protected int getLayoutId() {
return R.layout.activity_before_eye_test;
}
@Override
protected void init() {
mHandler = new Handler();
mDaemonReceiver = new DaemonReceiver();
mDaemonReceiver.registerScreenActionReceiver(this);
mActionReceiver = new ActionReceiver();
mActionReceiver.registerScreenActionReceiver(this);
DaemonSender.startEyeTest(this);
}
@Override
protected void onResume() {
super.onResume();
NibiruUtils.switchVR(false);
}
@Override
protected void onDestroy() {
super.onDestroy();
DaemonSender.closeEyeTestMotor(this);
if(mDaemonReceiver != null){
mDaemonReceiver.unRegisterScreenActionReceiver(this);
}
if(mActionReceiver != null){
mActionReceiver.unRegisterScreenActionReceiver(this);
}
}
@OnClick(R2.id.tv_eye_test_start1)
public void click(View view){
startLayout1.setVisibility(View.GONE);
prepareLayout1.setVisibility(View.VISIBLE);
speak("调节测视距离,请等待");
DaemonSender.startEyeTestMotor(this);
// Intent intent2 = new Intent(BeforeEyeTestActivity.this,EyeTestActivity.class);
// startActivity(intent2);
// finish();
}
public class DaemonReceiver extends BroadcastReceiver {
private boolean isRegisterReceiver = false;
@Override
public void onReceive(Context context, Intent intent) {
if(intent != null){
int type = intent.getIntExtra(OOMsg.ARG_SEEX_ACTION,0);
switch (type){
case OOMsg.EYE_TEST_MOTOR_FINISH:
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent2 = new Intent(BeforeEyeTestActivity.this,EyeTestActivity.class);
startActivity(intent2);
finish();
}
},1000);
break;
}
}
}
public void registerScreenActionReceiver(Context mContext) {
if (!isRegisterReceiver) {
isRegisterReceiver = true;
IntentFilter filter = new IntentFilter();
filter.addAction(OOMsg.OO_INTENT_ACTION);
mContext.registerReceiver(DaemonReceiver.this, filter);
}
}
public void unRegisterScreenActionReceiver(Context mContext) {
if (isRegisterReceiver) {
isRegisterReceiver = false;
mContext.unregisterReceiver(DaemonReceiver.this);
}
}
}
class ActionReceiver extends BroadcastReceiver {
private String TAG = "TrainTaskService__ActionReceiver";
private boolean isRegisterReceiver = false;
@Override
public void onReceive(final Context context, Intent intent) {
String action = intent.getAction();
LogUtil.e(TAG, "action..." + action);
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
//如果,灭屏,就进行暂停操作。
startLayout1.setVisibility(View.VISIBLE);
prepareLayout1.setVisibility(View.GONE);
} else if (action.equals(Intent.ACTION_SCREEN_ON)) {
startLayout1.setVisibility(View.VISIBLE);
prepareLayout1.setVisibility(View.GONE);
}
}
public void registerScreenActionReceiver(Context mContext) {
if (!isRegisterReceiver) {
isRegisterReceiver = true;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
LogUtil.e(TAG, "reg broadcast...");
mContext.registerReceiver(ActionReceiver.this, filter);
}
}
public void unRegisterScreenActionReceiver(Context mContext) {
if (isRegisterReceiver) {
isRegisterReceiver = false;
LogUtil.e(TAG, "unReg broadcast...");
mContext.unregisterReceiver(ActionReceiver.this);
}
}
}
private void speak(String text){
DaemonSender.sendDBTTS(this,text);
}
@BindView(R.id.ll_before_eye_start1)
RelativeLayout mLlBeforeEyeStart1;
@BindView(R.id.ll_before_eye_prepare1)
LinearLayout mLlBeforeEyePrepare1;
// private DaemonReceiver mDaemonReceiver;
private ActionReceiver mActionReceiver;
private Handler mHandler;
@Override
protected int getLayoutId() {
return R.layout.activity_before_eye_test;
}
@Override
protected void init() {
mHandler = new Handler();
// mDaemonReceiver = new DaemonReceiver();
// mDaemonReceiver.registerScreenActionReceiver(this);
mActionReceiver = new ActionReceiver();
mActionReceiver.registerScreenActionReceiver(this);
DaemonSender.startEyeTest(this);
}
@Override
protected void onResume() {
super.onResume();
NibiruUtils.switchVR(false);
}
@Override
protected void onDestroy() {
super.onDestroy();
DaemonSender.closeEyeTestMotor(this);
// if (mDaemonReceiver != null) {
// mDaemonReceiver.unRegisterScreenActionReceiver(this);
// }
if (mActionReceiver != null) {
mActionReceiver.unRegisterScreenActionReceiver(this);
}
}
@OnClick(R2.id.tv_eye_test_start1)
public void click(View view) {
mLlBeforeEyeStart1.setVisibility(View.GONE);
mLlBeforeEyePrepare1.setVisibility(View.VISIBLE);
speak("调节测视距离,请等待");
// DaemonSender.startEyeTestMotor(this);
Intent intent2 = new Intent(BeforeEyeTestActivity.this,EyeTestActivity.class);
startActivity(intent2);
finish();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
// public class DaemonReceiver extends BroadcastReceiver {
// private boolean isRegisterReceiver = false;
//
// @Override
// public void onReceive(Context context, Intent intent) {
// if (intent != null) {
// int type = intent.getIntExtra(OOMsg.ARG_SEEX_ACTION, 0);
// switch (type) {
// case OOMsg.EYE_TEST_MOTOR_FINISH:
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// Intent intent2 = new Intent(BeforeEyeTestActivity.this, EyeTestActivity.class);
// startActivity(intent2);
// finish();
// }
// }, 1000);
// break;
// }
//
// }
//
// }
//
// public void registerScreenActionReceiver(Context mContext) {
// if (!isRegisterReceiver) {
// isRegisterReceiver = true;
//
// IntentFilter filter = new IntentFilter();
// filter.addAction(OOMsg.OO_INTENT_ACTION);
// mContext.registerReceiver(DaemonReceiver.this, filter);
// }
// }
//
// public void unRegisterScreenActionReceiver(Context mContext) {
// if (isRegisterReceiver) {
// isRegisterReceiver = false;
// mContext.unregisterReceiver(DaemonReceiver.this);
// }
// }
// }
class ActionReceiver extends BroadcastReceiver {
private String TAG = "TrainTaskService__ActionReceiver";
private boolean isRegisterReceiver = false;
@Override
public void onReceive(final Context context, Intent intent) {
String action = intent.getAction();
LogUtil.e(TAG, "action..." + action);
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
//如果,灭屏,就进行暂停操作。
mLlBeforeEyeStart1.setVisibility(View.VISIBLE);
mLlBeforeEyePrepare1.setVisibility(View.GONE);
} else if (action.equals(Intent.ACTION_SCREEN_ON)) {
mLlBeforeEyeStart1.setVisibility(View.VISIBLE);
mLlBeforeEyePrepare1.setVisibility(View.GONE);
}
}
public void registerScreenActionReceiver(Context mContext) {
if (!isRegisterReceiver) {
isRegisterReceiver = true;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
LogUtil.e(TAG, "reg broadcast...");
mContext.registerReceiver(ActionReceiver.this, filter);
}
}
public void unRegisterScreenActionReceiver(Context mContext) {
if (isRegisterReceiver) {
isRegisterReceiver = false;
LogUtil.e(TAG, "unReg broadcast...");
mContext.unregisterReceiver(ActionReceiver.this);
}
}
}
private void speak(String text) {
DaemonSender.sendDBTTS(this, text);
}
}
......@@ -42,7 +42,7 @@ public class EyeTestActivity extends BaseActivity{
private E mSelectE;
@BindView(R2.id.rl_eye_test_center_time1)
LinearLayout timeLayout1;
RelativeLayout timeLayout1;
@BindView(R2.id.tv_eye_test_center_time1)
TextView timeText1;
......@@ -59,7 +59,7 @@ public class EyeTestActivity extends BaseActivity{
View maskView2;
@BindView(R2.id.rl_eye_test_center_time2)
LinearLayout timeLayout2;
RelativeLayout timeLayout2;
@BindView(R2.id.tv_eye_test_center_time2)
TextView timeText2;
......
......@@ -38,5 +38,6 @@ public class SinglePeopleTestActivity extends BaseActivity {
@OnClick(R.id.begin_test)
public void onClick() {
startActivity(BeforeEyeTestActivity.class);
}
}
......@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="@color/gray_white" />
<solid android:color="#205B64" />
<corners android:radius="@dimen/dp_4"/>
</shape>
</item>
......@@ -15,7 +15,7 @@
<item>
<shape>
<solid android:color="@color/gray_white" />
<solid android:color="@color/e_test_color" />
<corners android:radius="@dimen/dp_4"/>
</shape>
</item>
......
......@@ -8,4 +8,5 @@
<size android:width="50dp"
android:height="50dp"/>
<stroke android:color="@color/text_color" android:width="1px"></stroke>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@drawable/etest_bg_default">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/line_color"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/tv_before_eye_top1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_centerHorizontal="true"
android:text="@string/before_eye_test_prepare"
android:textColor="@color/white"
android:textSize="16dp"/>
<LinearLayout
<RelativeLayout
android:id="@+id/ll_before_eye_start1"
android:layout_width="wrap_content"
android:layout_width="346dp"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_before_eye_top1"
android:layout_marginTop="29dp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="vertical">
android:layout_centerVertical="true"
android:background="@color/white"
android:orientation="vertical"
android:padding="@dimen/dp_20">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineSpacingExtra="3dp"
android:gravity="center"
android:text="@string/before_eye_test_prompt"
android:textColor="@color/white"
android:textSize="16dp"/>
<TextView
android:id="@+id/tv_after_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_20"
android:text="根据C视标开口方向
点击键盘相应按键"
android:textColor="@color/text_color"
android:textSize="@dimen/sp_24" />
<LinearLayout
android:id="@+id/test_result_lay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_after_title"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/dp_20"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_eye_test_start1"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_marginTop="13dp"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="@string/before_eye_test_start_btn"
android:textColor="@color/e_test_color"
android:textSize="16dp"
android:background="@drawable/white_bg"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/copy" />
<ImageView
android:layout_marginLeft="@dimen/dp_20"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guide" />
<ImageView
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/key" />
</LinearLayout>
<TextView
android:id="@+id/tv_eye_test_start1"
android:layout_width="120dip"
android:layout_height="@dimen/dp_40"
android:layout_below="@+id/test_result_lay"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/dp_22"
android:background="@drawable/after_btn_bg"
android:clickable="true"
android:gravity="center"
android:text="开始测试"
android:textColor="@color/white"
android:textSize="15dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_before_eye_prepare1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_before_eye_top1"
android:layout_centerInParent="true"
android:layout_marginTop="50dp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineSpacingExtra="@dimen/dp_6"
android:gravity="center"
android:text="@string/eye_test_prepare"
android:textColor="@color/white"
android:textSize="22dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:lineSpacingExtra="@dimen/dp_6"
android:text="@string/eye_test_prepare"
android:textColor="@color/white"
android:textSize="22dp" />
</LinearLayout>
......
......@@ -95,6 +95,8 @@
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:background="@drawable/white_bg"
android:orientation="vertical">
......@@ -108,8 +110,6 @@
<TextView
android:layout_width="@dimen/dimen_130"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="单人测试"
android:textColor="@color/e_test_color"
......@@ -124,6 +124,8 @@
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:background="@drawable/white_bg"
android:orientation="vertical">
......@@ -138,8 +140,6 @@
android:id="@+id/tv_eye_test_histroy"
android:layout_width="@dimen/dimen_130"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="多人测试"
android:textColor="@color/e_test_color"
......@@ -150,6 +150,8 @@
<LinearLayout
android:id="@+id/lin_eye_test_statistics"
android:layout_width="0dip"
android:clickable="true"
android:focusable="true"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_weight="1"
......@@ -166,8 +168,6 @@
<TextView
android:layout_width="@dimen/dimen_130"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="临时测试"
android:textColor="@color/e_test_color"
......@@ -181,6 +181,8 @@
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:background="@drawable/white_bg"
android:orientation="vertical">
......@@ -194,8 +196,6 @@
<TextView
android:layout_width="@dimen/dimen_130"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="结果报表"
android:textColor="@color/e_test_color"
......
......@@ -78,13 +78,14 @@
android:orientation="vertical">
<EditText
android:layout_width="120dip"
android:id="@+id/key_test"
android:layout_width="140dip"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_6"
android:background="@null"
android:hint="按关键词查找"
android:hint="输入学员编号后4位"
android:textColorHint="@color/hint_text_color"
android:textSize="@dimen/sp_18" />
android:textSize="@dimen/sp_16" />
<View
android:layout_width="match_parent"
......
......@@ -34,13 +34,14 @@
android:orientation="vertical">
<EditText
android:layout_width="120dip"
android:id="@+id/key_test"
android:layout_width="140dip"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_6"
android:background="@null"
android:hint="按关键词查找"
android:hint="输入学员编号后4位"
android:textColorHint="@color/hint_text_color"
android:textSize="@dimen/sp_18" />
android:textSize="@dimen/sp_16" />
<View
android:layout_width="match_parent"
......
......@@ -115,13 +115,14 @@
android:orientation="vertical">
<EditText
android:layout_width="120dip"
android:id="@+id/key_test"
android:layout_width="140dip"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_6"
android:background="@null"
android:hint="按关键词查找"
android:hint="输入学员编号后4位"
android:textColorHint="@color/hint_text_color"
android:textSize="@dimen/sp_18" />
android:textSize="@dimen/sp_16" />
<View
android:layout_width="match_parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment