[Android] ThumbnailerManager: No need to get the string from resources more than once
Ludovic Fauvet
git at videolan.org
Wed Oct 3 13:01:58 CEST 2012
vlc-ports/android | branch: master | Ludovic Fauvet <etix at videolan.org> | Wed Oct 3 12:58:25 2012 +0200| [74b767f6d0fdd4af9861323e87cddcb2049ca20a] | committer: Ludovic Fauvet
ThumbnailerManager: No need to get the string from resources more than once
This may fix the following crash:
java.lang.IllegalStateException: Fragment VideoListFragment{4130f1f0} not attached to Activity
at android.support.v4.app.Fragment.getResources(Fragment.java:555)
at org.videolan.vlc.betav7neon.ThumbnailerManager.run(ThumbnailerManager.java:113)
at java.lang.Thread.run(Thread.java:856)
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=74b767f6d0fdd4af9861323e87cddcb2049ca20a
---
vlc-android/src/org/videolan/vlc/ThumbnailerManager.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
index c9e76c6..efd9bf3 100644
--- a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
+++ b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
@@ -55,6 +55,7 @@ public class ThumbnailerManager implements Runnable {
private final Context mContext;
private int totalCount;
private final float mDensity;
+ private String mPrefix;
public ThumbnailerManager(Context context, Display display) {
try {
@@ -67,6 +68,7 @@ public class ThumbnailerManager implements Runnable {
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
mDensity = metrics.density;
+ mPrefix = mContext.getResources().getString(R.string.thumbnail);
}
public void start(VideoListFragment videoListFragment) {
@@ -118,8 +120,6 @@ public class ThumbnailerManager implements Runnable {
Log.d(TAG, "Thumbnailer started");
- String prefix = mContext.getResources().getString(R.string.thumbnail);
-
while (!isStopping) {
mVideoListFragment.resetBarrier();
lock.lock();
@@ -147,7 +147,7 @@ public class ThumbnailerManager implements Runnable {
MainActivity.showProgressBar(mContext);
- MainActivity.sendTextInfo(mContext, String.format("%s %s", prefix, item.getFileName()), count, total);
+ MainActivity.sendTextInfo(mContext, String.format("%s %s", mPrefix, item.getFileName()), count, total);
count++;
int width = (int) (120 * mDensity);
More information about the Android
mailing list