Skip to content

Instantly share code, notes, and snippets.

@EddieRingle
Created March 13, 2011 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EddieRingle/868250 to your computer and use it in GitHub Desktop.
Save EddieRingle/868250 to your computer and use it in GitHub Desktop.
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index 2a695e5..c38ffe6 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -210,7 +210,7 @@ public class ProgressBar extends View {
drawable = a.getDrawable(R.styleable.ProgressBar_indeterminateDrawable);
if (drawable != null) {
- drawable = tileifyIndeterminate(drawable);
+ //drawable = tileifyIndeterminate(drawable);
setIndeterminateDrawable(drawable);
}
@@ -835,21 +835,43 @@ public class ProgressBar extends View {
canvas.save();
canvas.translate(mPaddingLeft, mPaddingTop);
long time = getDrawingTime();
- if (mAnimation != null) {
- mAnimation.getTransformation(time, mTransformation);
- float scale = mTransformation.getAlpha();
- try {
- mInDrawing = true;
- d.setLevel((int) (scale * MAX_LEVEL));
- } finally {
- mInDrawing = false;
+ if (mIndeterminate && d instanceof BitmapDrawable) {
+ /* Calculate horizontal offset */
+ float timeDelta = (time - mLastDrawTime) / 1000.0f;
+ int pixelOffset = 20 * timeDelta;
+
+ Rect newBounds = d.copyBounds();
+ newBounds.offset(pixelOffset, 0);
+
+ /* Scroll off one edge and onto the other */
+ if (newBounds.left > newBounds.width()) {
+ newBounds.offset(newBounds.width() - newBounds.left, 0);
}
- if (SystemClock.uptimeMillis() - mLastDrawTime >= ANIMATION_RESOLUTION) {
- mLastDrawTime = SystemClock.uptimeMillis();
- postInvalidateDelayed(ANIMATION_RESOLUTION);
+
+ d.setBounds(newBounds);
+
+ /* Set new last draw time */
+ mLastDrawTime = SystemClock.uptimeMillis();
+
+ /* Draw to canvas */
+ d.draw(canvas);
+ } else {
+ if (mAnimation != null) {
+ mAnimation.getTransformation(time, mTransformation);
+ float scale = mTransformation.getAlpha();
+ try {
+ mInDrawing = true;
+ d.setLevel((int) (scale * MAX_LEVEL));
+ } finally {
+ mInDrawing = false;
+ }
+ if (SystemClock.uptimeMillis() - mLastDrawTime >= ANIMATION_RESOLUTION) {
+ mLastDrawTime = SystemClock.uptimeMillis();
+ postInvalidateDelayed(ANIMATION_RESOLUTION);
+ }
}
+ d.draw(canvas);
}
- d.draw(canvas);
canvas.restore();
if (mShouldStartAnimationDrawable && d instanceof Animatable) {
((Animatable) d).start();
diff --git a/core/res/res/drawable-hdpi/progressbar_indeterminate1.png b/core/res/res/drawable-hdpi/progressbar_indeterminate1.png
deleted file mode 100755
index 197b34d..0000000
Binary files a/core/res/res/drawable-hdpi/progressbar_indeterminate1.png and /dev/null differ
diff --git a/core/res/res/drawable-hdpi/progressbar_indeterminate2.png b/core/res/res/drawable-hdpi/progressbar_indeterminate2.png
deleted file mode 100755
index c6cf008..0000000
Binary files a/core/res/res/drawable-hdpi/progressbar_indeterminate2.png and /dev/null differ
diff --git a/core/res/res/drawable-hdpi/progressbar_indeterminate3.png b/core/res/res/drawable-hdpi/progressbar_indeterminate3.png
deleted file mode 100755
index bf129e0..0000000
Binary files a/core/res/res/drawable-hdpi/progressbar_indeterminate3.png and /dev/null differ
diff --git a/core/res/res/drawable-hdpi/progressbar_indeterminate_horizontal.png b/core/res/res/drawable-hdpi/progressbar_indeterminate_horizontal.png
new file mode 100755
index 0000000..197b34d
Binary files /dev/null and b/core/res/res/drawable-hdpi/progressbar_indeterminate_horizontal.png differ
diff --git a/core/res/res/drawable-ldpi/progressbar_indeterminate1.png b/core/res/res/drawable-ldpi/progressbar_indeterminate1.png
deleted file mode 100644
index 92a1aee..0000000
Binary files a/core/res/res/drawable-ldpi/progressbar_indeterminate1.png and /dev/null differ
diff --git a/core/res/res/drawable-ldpi/progressbar_indeterminate2.png b/core/res/res/drawable-ldpi/progressbar_indeterminate2.png
deleted file mode 100644
index 1fd2f37..0000000
Binary files a/core/res/res/drawable-ldpi/progressbar_indeterminate2.png and /dev/null differ
diff --git a/core/res/res/drawable-ldpi/progressbar_indeterminate3.png b/core/res/res/drawable-ldpi/progressbar_indeterminate3.png
deleted file mode 100644
index adb8022..0000000
Binary files a/core/res/res/drawable-ldpi/progressbar_indeterminate3.png and /dev/null differ
diff --git a/core/res/res/drawable-ldpi/progressbar_indeterminate_horizontal.png b/core/res/res/drawable-ldpi/progressbar_indeterminate_horizontal.png
new file mode 100644
index 0000000..92a1aee
Binary files /dev/null and b/core/res/res/drawable-ldpi/progressbar_indeterminate_horizontal.png differ
diff --git a/core/res/res/drawable-mdpi/progressbar_indeterminate1.png b/core/res/res/drawable-mdpi/progressbar_indeterminate1.png
deleted file mode 100644
index 71780ef..0000000
Binary files a/core/res/res/drawable-mdpi/progressbar_indeterminate1.png and /dev/null differ
diff --git a/core/res/res/drawable-mdpi/progressbar_indeterminate2.png b/core/res/res/drawable-mdpi/progressbar_indeterminate2.png
deleted file mode 100644
index 236988b..0000000
Binary files a/core/res/res/drawable-mdpi/progressbar_indeterminate2.png and /dev/null differ
diff --git a/core/res/res/drawable-mdpi/progressbar_indeterminate3.png b/core/res/res/drawable-mdpi/progressbar_indeterminate3.png
deleted file mode 100644
index 1570235..0000000
Binary files a/core/res/res/drawable-mdpi/progressbar_indeterminate3.png and /dev/null differ
diff --git a/core/res/res/drawable-mdpi/progressbar_indeterminate_horizontal.png b/core/res/res/drawable-mdpi/progressbar_indeterminate_horizontal.png
new file mode 100644
index 0000000..71780ef
Binary files /dev/null and b/core/res/res/drawable-mdpi/progressbar_indeterminate_horizontal.png differ
diff --git a/core/res/res/drawable/progress_indeterminate_horizontal.xml b/core/res/res/drawable/progress_indeterminate_horizontal.xml
deleted file mode 100644
index 66ed1f2..0000000
--- a/core/res/res/drawable/progress_indeterminate_horizontal.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/common/res/drawable/ic_popup_sync.xml
-**
-** Copyright 2008, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-<animation-list
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:oneshot="false">
- <item android:drawable="@drawable/progressbar_indeterminate1" android:duration="200" />
- <item android:drawable="@drawable/progressbar_indeterminate2" android:duration="200" />
- <item android:drawable="@drawable/progressbar_indeterminate3" android:duration="200" />
-</animation-list>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment