@Override public void onClick(View v) { // TODO Auto-generated method stub int id = v.getId(); if (id == R.id.button_camera) { String sdStatus = Environment.getExternalStorageState(); if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // Log.d("MainActivity", "SD card is not avaiable/writeable right now."); return; } try { File dir = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera"); if (!dir.exists()) dir.mkdirs(); String name = DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg"; File f = new File(dir, name); Intent intent0 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent0.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intent0.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); Intent intent = Intent.createChooser(intent0, null); mCameraPicPath = f.getAbsolutePath(); startActivityForResult(intent, req_capture); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } else if (id == R.id.button_op) { if (mIndex == view_all) { if (mViewAll.haveData()) mViewAll.setEditMode(true); } else if (mIndex == view_like) { if (mViewLike.haveData()) mViewLike.setEditMode(true); } } else if (id == R.id.button_menu) { { showSettingMenu(); } } else if (id == R.id.button_all) { mViewPager.setCurrentItem(view_all); } else if (id == R.id.button_dir) { mViewPager.setCurrentItem(view_dir); } else if (id == R.id.button_like) { mViewPager.setCurrentItem(view_like); } }
@Override public void onEditModeFinish() { // TODO Auto-generated method stub mBarBegin.setVisibility(View.VISIBLE); if (mIndex == view_all) mViewAll.setEditMode(false); else if (mIndex == view_like) mViewLike.setEditMode(false); }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK /* && event.getRepeatCount() == 0 */) { if (mIndex == view_all) { if (mViewAll.getEditMode() == true) { mViewAll.setEditMode(false); return true; } } else if (mIndex == view_like) { if (mViewLike.getEditMode() == true) { mViewLike.setEditMode(false); return true; } } } return super.onKeyDown(keyCode, event); }