package com.desk.move.point.activity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.desk.move.point.R;
import com.desk.move.point.service.PointView;
import com.desk.move.point.utils.LoclScreenUtils;
// implements PointViewRemind
public class Main extends Activity implements OnClickListener{
Context context;
private Button startService;
private Button stopService;
private Button startDevice;
private LoclScreenUtils lock;
// private MovePoint myPoint;
// private EditText show;
// private ScreenSizeUtils screenSize;
// private int screenHeight;
// private int screenWidth;
// private MyHandler myHandler;
// private RelativeLayout.LayoutParams lp ;
// private void initViews(){
// myHandler = new MyHandler();
// screenSize = new ScreenSizeUtils(getWindowManager());
// screenHeight = screenSize.getHeight();
// screenWidth = screenSize.getWidth();
// myPoint = (MovePoint)findViewById(R.id.move_point);
// show = (EditText)findViewById(R.id.show);
// myPoint.setPointViewRemind(this);
// lp = (RelativeLayout.LayoutParams)myPoint.getLayoutParams();
// }
private void initViews(){
startService = (Button)findViewById(R.id.start);
stopService = (Button)findViewById(R.id.stop);
startDevice = (Button)findViewById(R.id.start_device);
startService.setOnClickListener(this);
stopService.setOnClickListener(this);
startDevice.setOnClickListener(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
context = Main.this;
initViews();
}
// @Override
// public void up(MovePoint point) {
// // TODO Auto-generated method stub
// //Toast.makeText(context, "上", Toast.LENGTH_SHORT).show();
// show.setText("上");
// }
// @Override
// public void down(MovePoint point) {
// // TODO Auto-generated method stub
// //Toast.makeText(context, "下", Toast.LENGTH_SHORT).show();
// show.setText("下");
// }
// @Override
// public void left(MovePoint point) {
// // TODO Auto-generated method stub
// show.setText("左");
// }
// @Override
// public void right(MovePoint point) {
// // TODO Auto-generated method stub
// show.setText("右");
// }
// @Override
// public void enterLongPress(MovePoint point) {
// // TODO Auto-generated method stub
// Toast.makeText(context, "enter", Toast.LENGTH_SHORT).show();
// }
// @Override
// public void getXYShow(int x, int y) {
// // TODO Auto-generated method stub
// sendMessgae(0,x,y);
// //Toast.makeText(context, , Toast.LENGTH_SHORT).show();
// }
// private void sendMessgae(int what,int x,int y){
// Message msg = new Message();
// msg.what = what;
// Bundle bd = new Bundle();
// bd.putInt("x", x);
// bd.putInt("y", y);
// msg.setData(bd);
// myHandler.sendMessage(msg);
// }
// class MyHandler extends Handler{
// public void handleMessage(Message msg){
// switch(msg.what){
// case 0:
// Bundle bd = msg.getData();
// int x = bd.getInt("x");
// int y = bd.getInt("y");
// show.setText("x="+x+","+"y="+y+","+"left"+myPoint.getLeft());
// lp.leftMargin =x;
// lp.topMargin = y;
// if(x<0){
// lp.leftMargin = 0;
// }
// if(y<0){
// lp.topMargin = 0;
// }
// if(x>screenWidth-myPoint.getSize()){
// lp.leftMargin = screenWidth-myPoint.getSize();
// }
// if(y>screenHeight-myPoint.getSize()){
// lp.topMargin = screenHeight-myPoint.getSize();
// }
// myPoint.setLayoutParams(lp);
// break;
// }
// }
// }
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.start:
startService(new Intent(context,PointView.class));
//Toast.makeText(context, "开", Toast.LENGTH_SHORT).show();
break;
case R.id.stop:
stopService(new Intent(context,PointView.class));
break;
case R.id.start_device:
lock = LoclScreenUtils.getInstance();
lock.initDevice(context);
lock.activeAdmin(context);
break;
}
}
}
|
|