Commit 4a086e97 authored by Evan W. Patton's avatar Evan W. Patton

Fix cast exception from ScaleDrawable to ClipDrawble

We grab the progress drawable and cast it to ClipDrawable. This causes
a ClassCastException on phones where the manufacturer provides custom
view hierarchies for the slider but do not use the same classes as the
original Android views. However, the only method we call is defined on
Drawable, so this commit switches to using the Drawable superclass and
removes the cast to ClipDrawable.

Fixes #912

Change-Id: I20b0691ca684a2e34140aafa9d3b04eb4adf7148
parent 1336ff9f
......@@ -2,7 +2,7 @@ package com.google.appinventor.components.runtime;
import android.R;
import android.graphics.PorterDuff;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.Log;
import android.view.View;
......@@ -59,7 +59,7 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha
// the total slider width
private LayerDrawable fullBar;
// the part of the slider to the left of the thumb
private ClipDrawable beforeThumb;
private Drawable beforeThumb;
// colors of the bar after and before the thumb position
private int rightColor;
......@@ -97,7 +97,8 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha
seekbar = new SeekBar(container.$context());
fullBar = (LayerDrawable) seekbar.getProgressDrawable();
beforeThumb = (ClipDrawable) fullBar.findDrawableByLayerId(R.id.progress);
beforeThumb = fullBar.findDrawableByLayerId(R.id.progress);
leftColor = initialLeftColor;
rightColor = initialRightColor;
setSliderColors();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment