*/
public void onEventMainThread(CustomEventBus event) {
if (event == null) {
return;
}
if (event.type == CustomEventBus.EventType.SHOW_PICTURE) {
bm = (Bitmap) event.obj;
showImage();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initData();
}
public void initData() {
// TODO Auto-generated method stub
bm = BitmapFactory.decodeResource(getResources(), R.drawable.alipay);
DisplayMetrics dm = getResources().getDisplayMetrics();
displayWidth = dm.widthPixels;
displayHeight = dm.heightPixels;
mImageView = (ImageView) findViewById(R.id.image_view);
mImageView.setOnTouchListener(this);
showImage();
//显示网络图片时使用
/*File file = MainApplication.getInstance().getImageCache()
.getDiskCache().get(图片路径);
if (!file.exists()) {
Toast.makeText(this, "图片路径错误", Toast.LENGTH_SHORT).show();
} else {
new MyTask().execute(file);
}*/
}
@Override
public boolean onTouch(View view, MotionEvent event) {
ImageView imageView = (ImageView) view;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
savedMatrix.set(matrix);
point0.set(event.getX(), event.getY());
mode = DRAG;
System.out.println("MotionEvent--ACTION_DOWN");
break;
case MotionEvent.ACTION_POINTER_DOWN:
oldDist = spacing(event);
oldRotation = rotation(event);
savedMatrix.set(matrix);
setMidPoint(pointM, event);
mode = ZOOM;
System.out.println("MotionEvent--ACTION_POINTER_DOWN---" + oldRotation);
break;
case MotionEvent.ACTION_UP:
if (mode == DRAG & (fingerNumMove this.finish();