yunjianwu / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

Compatibility issue: ClassCastException: org.achartengine.chart.DoughnutChar #149

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile chart, calling org.achartengine.chart.DoughnutChart in 
achartengine-0.7.0 with Android 2.3.3 (or 2.2.1) 
2. Try to run it on Android 1.6 emulator

What is the expected output? What do you see instead?
Instead of pretty BudgetDoughnutChart I got exception

E/AndroidRuntime(  428): java.lang.RuntimeException: Unable to start activity 
ComponentInfo{my.cashlogger/
org.achartengine.GraphicalActivity}: java.lang.ClassCastException:
org.achartengine.chart.DoughnutChart
E/AndroidRuntime(  428):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2401)
E/AndroidRuntime(  428):        at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2417)
E/AndroidRuntime(  428):        at android.app.ActivityThread.access
$2100(ActivityThread.java:116)
E/AndroidRuntime(  428):        at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1794)
E/AndroidRuntime(  428):        at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  428):        at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime(  428):        at
android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime(  428):        at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  428):        at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  428):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime(  428):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime(  428):        at
dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  428): Caused by: java.lang.ClassCastException:
org.achartengine.chart.DoughnutChart
E/AndroidRuntime(  428):        at
org.achartengine.TouchHandlerOld.<init>(TouchHandlerOld.java:61)
E/AndroidRuntime(  428):        at
org.achartengine.GraphicalView.<init>(GraphicalView.java:123)
E/AndroidRuntime(  428):        at
org.achartengine.GraphicalActivity.onCreate(GraphicalActivity.java:38)
E/AndroidRuntime(  428):        at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
E/AndroidRuntime(  428):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2364) 

Please provide a source code snippet that we can use to replicate the issue.

        public void onClick(View v) {
            super.onClick(v);
            Intent intent;
            BudgetDoughnutChart chart = new BudgetDoughnutChart();
            if (categoryValues.length > 1) {
                intent = chart.execute(SearchActivity.this, categoryValues, categoryNames, categoryType);//.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP );           
                startActivity(intent);
            }
        }
    }; 

    public Intent execute(Context context, double[] categoryValues, String[] categoryNames, String categoryType) {
        List<double[]> values = new ArrayList<double[]>();
        values.add(categoryValues);
        List<String[]> titles = new ArrayList<String[]>();
        titles.add(categoryNames);

        int size = categoryNames.length;
        int[] colors = getColors(categoryType, size);
        DefaultRenderer renderer = buildCategoryRenderer(colors);
        renderer.setApplyBackgroundColor(true);
        renderer.setLabelsColor(Color.GRAY);
        renderer.setLabelsTextSize(18);
        stringCategories = context.getString(R.string.categories);
        return ChartFactory.getDoughnutChartIntent(context, buildMultipleCategoryDataset(
                "Project " + DbAdapter.BACKUP_DIR, titles, values), renderer, context.getString(R.string.category_chart));
    }

What version of the product binary library are you using?
achartengine 0.7.0

Please provide any additional information below.

Original issue reported on code.google.com by isabs...@gmail.com on 25 Oct 2011 at 8:53

GoogleCodeExporter commented 9 years ago
I displays fine in the Android 1.6 emulator.

Original comment by dandrome...@gmail.com on 5 Jan 2012 at 3:55