From 2db82269b26a477572811aa72a0268af9658c7ae Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Mon, 19 Dec 2011 17:27:13 +0400 Subject: [PATCH] fixes --- .../calculator/CalculatorActivity.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 9ec2ed5a..c31ce90c 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -80,10 +80,15 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh setLayout(preferences); if (customTitleSupported) { - getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.calc_title); - final CalculatorAdditionalTitle additionalAdditionalTitleText = (CalculatorAdditionalTitle)findViewById(R.id.additional_title_text); - additionalAdditionalTitleText.init(preferences); - preferences.registerOnSharedPreferenceChangeListener(additionalAdditionalTitleText); + try { + getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.calc_title); + final CalculatorAdditionalTitle additionalAdditionalTitleText = (CalculatorAdditionalTitle)findViewById(R.id.additional_title_text); + additionalAdditionalTitleText.init(preferences); + preferences.registerOnSharedPreferenceChangeListener(additionalAdditionalTitleText); + } catch (ClassCastException e) { + // super fix for issue with class cast in android.view.Window.setFeatureInt() (see app error reports) + Log.d(CalculatorActivity.class.getName(), e.getMessage(), e); + } } ResourceCache.instance.initCaptions(ApplicationContext.getInstance(), R.string.class); @@ -141,7 +146,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh final DragButton roundBracketsButton = (DragButton) findViewById(R.id.roundBracketsButton); if ( roundBracketsButton != null ) { - roundBracketsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new RoundBracketsDrgProcessor(), dragPreferences), vibrator, preferences)); + roundBracketsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new RoundBracketsDragProcessor(), dragPreferences), vibrator, preferences)); } @@ -592,7 +597,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh } } - private static class RoundBracketsDrgProcessor implements SimpleOnDragListener.DragProcessor { + private static class RoundBracketsDragProcessor implements SimpleOnDragListener.DragProcessor { @Override public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { boolean result = false; @@ -611,6 +616,8 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh } }); result = true; + } else { + result = new DigitButtonDragProcessor(CalculatorModel.instance).processDragEvent(dragDirection, dragButton, startPoint2d, motionEvent); } return result; }