/** 自定义旋转 向左或右旋转45度 */ private void getPicRotate() { final float degrees = 45; view = (RelativeLayout) getLayoutInflater().inflate(R.layout.layout_image_rotate_cartoonreader, null); radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup); leftRotate = (RadioButton) view.findViewById(R.id.left); rightRotate = (RadioButton) view.findViewById(R.id.right); DefaultDialog rotate_dialog = new DefaultDialog(activity, null, true) { @Override protected void doPositive() { float angle; // 对旋转漫画图片的方法进行扩展 if (leftRotate.isChecked()) { angle = -degrees; } else { angle = degrees; } // 如果操作的不是同一张图片,重设矩阵 String picPath = Utils.getImagePath(imagePosition, imageList); if (!lastPic.equals(picPath)) { matrix.reset(); lastPic = picPath; } // 设置旋转矩阵 matrix.postRotate(angle, imageView.getWidth() / 2, imageView.getHeight() / 2); if (imageView != null) { imageView.setImageMatrix(matrix); } super.doPositive(); } @Override protected void doItems(int which) { super.doItems(which); } }; rotate_dialog.setTitle(R.string.picRotate); // 加载自定义对话框 rotate_dialog.setView(view); rotate_dialog.show(); }
/** 创建对话框 */ public void showDialog() { String[] setupArray = new String[] { activity.getString(R.string.orderTimeBrowse), activity.getString(R.string.bookmarkBrowse), activity.getString(R.string.pictureRotate) }; DefaultDialog more_dialog = new DefaultDialog(activity, setupArray) { @Override protected void doPositive() { super.doPositive(); } @Override protected void doItems(int which) { switch (which) { case 0: // 定时阅览 getFixedTime(); break; case 1: // 书签列表 Intent intent = new Intent(activity, BookMarkActivity.class); activity.startActivity(intent); activity.finish(); break; case 2: // 旋转 getPicRotate(); } super.doItems(which); } }; more_dialog.setTitle(R.string.bookmarkTitle); more_dialog.show(); }
/** 定时浏览图像 */ private void getFixedTime() { // 获取到保存的值 View view = activity.getLayoutInflater().inflate(R.layout.layout_image_fixedtime_cartoonreader, null); RadioGroup fixedtime_radioGroup = (RadioGroup) view.findViewById(R.id.fixedtime_radioGroup); second0 = (RadioButton) view.findViewById(R.id.second0); second3 = (RadioButton) view.findViewById(R.id.second3); second5 = (RadioButton) view.findViewById(R.id.second5); fixedtime_radioGroup.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // 手动 if (checkedId == second0.getId()) { flag = "second0"; } // 3秒 if (checkedId == second3.getId()) { flag = "second3"; } // 5秒 if (checkedId == second5.getId()) { flag = "second5"; } } }); second0.setChecked(true); DefaultDialog time_dialog = new DefaultDialog(activity, null) { @Override protected void doPositive() { handler.removeCallbacks(autoShow); // 实现RadioGroup的监听 Log.v(TAG, "执行定时阅览,flag值为 :" + flag); if (flag != null && flag.equals("second0")) { setAutoPlayTime(second0.getText().toString()); } if (flag != null && flag.equals("second3")) { setAutoPlayTime(second3.getText().toString()); autoTime = Integer.parseInt(second3.getText().toString()); Log.v(TAG, "执行时间为:" + autoTime + "秒"); handler.postDelayed(autoShow, autoTime * 1000); } if (flag != null && flag.equals("second5")) { setAutoPlayTime(second5.getText().toString()); autoTime = Integer.parseInt(second5.getText().toString()); Log.v(TAG, "执行时间为:" + autoTime + "秒"); handler.postDelayed(autoShow, autoTime * 1000); } flag = null; super.doPositive(); } @Override protected void doItems(int which) { super.doItems(which); } }; time_dialog.setTitle(R.string.fixedtimetobrowse); time_dialog.setView(view); time_dialog.show(); }