diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-11-20 20:00:29 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-11-20 20:00:29 +0100 |
commit | c1d24edb5f4d3af66852145f301100c944b573de (patch) | |
tree | e6e15df9a880ebbae1ddb478853679ddceb1a5ac /src | |
parent | e01a656e9ee88a30b73159427db0ccce7c40fcd7 (diff) | |
download | AntennaPod-c1d24edb5f4d3af66852145f301100c944b573de.zip |
Changed references to drawables in src to references to attr
Diffstat (limited to 'src')
9 files changed, 66 insertions, 23 deletions
diff --git a/src/de/danoeh/antennapod/activity/DownloadActivity.java b/src/de/danoeh/antennapod/activity/DownloadActivity.java index d21fb1f91..fc466f7c4 100644 --- a/src/de/danoeh/antennapod/activity/DownloadActivity.java +++ b/src/de/danoeh/antennapod/activity/DownloadActivity.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; +import android.content.res.TypedArray; import android.os.AsyncTask; import android.os.Bundle; import android.os.IBinder; @@ -185,7 +186,8 @@ public class DownloadActivity extends SherlockListActivity implements switch (item.getItemId()) { case android.R.id.home: Intent intent = new Intent(this, MainActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP + | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); break; case MENU_SHOW_LOG: @@ -201,9 +203,10 @@ public class DownloadActivity extends SherlockListActivity implements @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { if (!selectedDownload.isDone()) { + TypedArray drawables = obtainStyledAttributes(new int[] { R.attr.navigation_cancel }); menu.add(Menu.NONE, R.id.cancel_download_item, Menu.NONE, R.string.cancel_download_label).setIcon( - R.drawable.navigation_cancel); + drawables.getDrawable(0)); } return true; } diff --git a/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java b/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java index f37d726cf..eca6cb003 100644 --- a/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java +++ b/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.activity; import android.annotation.SuppressLint; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.TypedArray; import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; @@ -76,8 +77,9 @@ public class FeedItemlistActivity extends SherlockFragmentActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { + TypedArray drawables = obtainStyledAttributes(new int[] { R.attr.action_search }); menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label) - .setIcon(R.drawable.action_search) + .setIcon(drawables.getDrawable(0)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); return FeedMenuHandler .onCreateOptionsMenu(new MenuInflater(this), menu); @@ -110,7 +112,8 @@ public class FeedItemlistActivity extends SherlockFragmentActivity { R.string.feed_delete_confirmation_msg) { @Override - public void onConfirmButtonPressed(DialogInterface dialog) { + public void onConfirmButtonPressed( + DialogInterface dialog) { dialog.dismiss(); remover.executeAsync(); } @@ -129,7 +132,8 @@ public class FeedItemlistActivity extends SherlockFragmentActivity { } } catch (DownloadRequestException e) { e.printStackTrace(); - DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, e.getMessage()); + DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, + e.getMessage()); } return true; } diff --git a/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java b/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java index 4d8c13491..8cc70a74b 100644 --- a/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java +++ b/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java @@ -128,7 +128,10 @@ public class MiroGuideMainActivity extends SherlockListActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label) - .setIcon(R.drawable.action_search) + .setIcon( + obtainStyledAttributes( + new int[] { R.attr.action_search }) + .getDrawable(0)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; } diff --git a/src/de/danoeh/antennapod/activity/MiroGuideSearchActivity.java b/src/de/danoeh/antennapod/activity/MiroGuideSearchActivity.java index d38c25992..240a99395 100644 --- a/src/de/danoeh/antennapod/activity/MiroGuideSearchActivity.java +++ b/src/de/danoeh/antennapod/activity/MiroGuideSearchActivity.java @@ -62,7 +62,10 @@ public class MiroGuideSearchActivity extends SherlockFragmentActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label) - .setIcon(R.drawable.action_search) + .setIcon( + obtainStyledAttributes( + new int[] { R.attr.action_search }) + .getDrawable(0)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; diff --git a/src/de/danoeh/antennapod/activity/SearchActivity.java b/src/de/danoeh/antennapod/activity/SearchActivity.java index 02804cddd..506bedad5 100644 --- a/src/de/danoeh/antennapod/activity/SearchActivity.java +++ b/src/de/danoeh/antennapod/activity/SearchActivity.java @@ -79,7 +79,10 @@ public class SearchActivity extends SherlockListActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label) - .setIcon(R.drawable.action_search) + .setIcon( + obtainStyledAttributes( + new int[] { R.attr.action_search }) + .getDrawable(0)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; } diff --git a/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java index 44e954b55..44418a2dd 100644 --- a/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java +++ b/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java @@ -4,6 +4,7 @@ import java.text.DateFormat; import java.util.List; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Typeface; import android.text.format.DateUtils; import android.view.LayoutInflater; @@ -92,7 +93,7 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { holder.feedtitle.setVisibility(View.VISIBLE); holder.feedtitle.setText(item.getFeed().getTitle()); } - + FeedItem.State state = item.getState(); switch (state) { case PLAYING: @@ -160,12 +161,14 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { holder.downloading.setVisibility(View.GONE); } + TypedArray typeDrawables = getContext().obtainStyledAttributes( + new int[] { R.attr.type_audio, R.attr.type_video }); MediaType mediaType = item.getMedia().getMediaType(); if (mediaType == MediaType.AUDIO) { - holder.type.setImageResource(R.drawable.type_audio); + holder.type.setImageDrawable(typeDrawables.getDrawable(0)); holder.type.setVisibility(View.VISIBLE); } else if (mediaType == MediaType.VIDEO) { - holder.type.setImageResource(R.drawable.type_video); + holder.type.setImageDrawable(typeDrawables.getDrawable(1)); holder.type.setVisibility(View.VISIBLE); } else { holder.type.setImageBitmap(null); diff --git a/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java b/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java index 68ef60287..c23c4c66a 100644 --- a/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java +++ b/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.asynctask; import java.io.File; +import android.content.res.TypedArray; import android.graphics.BitmapFactory; import android.os.Handler; import android.util.Log; @@ -24,6 +25,8 @@ public abstract class BitmapDecodeWorkerTask extends Thread { protected String fileUrl; private Handler handler; + + private final int defaultCoverResource; public BitmapDecodeWorkerTask(Handler handler, ImageView target, String fileUrl, int length, int imageType) { @@ -33,6 +36,9 @@ public abstract class BitmapDecodeWorkerTask extends Thread { this.fileUrl = fileUrl; this.PREFERRED_LENGTH = length; this.imageType = imageType; + TypedArray res = target.getContext().obtainStyledAttributes(new int[] {R.attr.default_cover}); + this.defaultCoverResource = res.getResourceId(0, 0); + res.recycle(); } /** @@ -64,7 +70,7 @@ public abstract class BitmapDecodeWorkerTask extends Thread { } else { Log.w(TAG, "Could not load bitmap. Using default image."); cBitmap = new CachedBitmap(BitmapFactory.decodeResource(target.getResources(), - R.drawable.default_cover), PREFERRED_LENGTH); + defaultCoverResource), PREFERRED_LENGTH); } if (AppConfig.DEBUG) Log.d(TAG, "Finished loading bitmaps"); @@ -93,7 +99,7 @@ public abstract class BitmapDecodeWorkerTask extends Thread { protected void onInvalidFileUrl() { Log.e(TAG, "FeedImage has no valid file url. Using default image"); cBitmap = new CachedBitmap(BitmapFactory.decodeResource(target.getResources(), - R.drawable.default_cover), PREFERRED_LENGTH); + defaultCoverResource), PREFERRED_LENGTH); } protected void storeBitmapInCache(CachedBitmap cb) { diff --git a/src/de/danoeh/antennapod/asynctask/FeedImageLoader.java b/src/de/danoeh/antennapod/asynctask/FeedImageLoader.java index 3070cbea7..5e1994adb 100644 --- a/src/de/danoeh/antennapod/asynctask/FeedImageLoader.java +++ b/src/de/danoeh/antennapod/asynctask/FeedImageLoader.java @@ -7,6 +7,7 @@ import java.util.concurrent.ThreadFactory; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.content.Context; +import android.content.res.TypedArray; import android.os.Handler; import android.support.v4.util.LruCache; import android.util.Log; @@ -102,18 +103,20 @@ public class FeedImageLoader { * posted to the ImageView's message queue. */ public void loadCoverBitmap(FeedImage image, ImageView target, int length) { + final int defaultCoverResource = getDefaultCoverResource(target.getContext()); + if (image != null && image.getFile_url() != null) { CachedBitmap cBitmap = getBitmapFromCoverCache(image.getFile_url()); if (cBitmap != null && cBitmap.getLength() >= length) { target.setImageBitmap(cBitmap.getBitmap()); } else { - target.setImageResource(R.drawable.default_cover); + target.setImageResource(defaultCoverResource); FeedImageDecodeWorkerTask worker = new FeedImageDecodeWorkerTask( handler, target, image, length, IMAGE_TYPE_COVER); executor.submit(worker); } } else { - target.setImageResource(R.drawable.default_cover); + target.setImageResource(defaultCoverResource); } } @@ -135,18 +138,20 @@ public class FeedImageLoader { */ public void loadThumbnailBitmap(FeedImage image, ImageView target, int length) { + final int defaultCoverResource = getDefaultCoverResource(target.getContext()); + if (image != null && image.getFile_url() != null) { CachedBitmap cBitmap = getBitmapFromThumbnailCache(image.getFile_url()); if (cBitmap != null && cBitmap.getLength() >= length) { target.setImageBitmap(cBitmap.getBitmap()); } else { - target.setImageResource(R.drawable.default_cover); + target.setImageResource(defaultCoverResource); FeedImageDecodeWorkerTask worker = new FeedImageDecodeWorkerTask( handler, target, image, length, IMAGE_TYPE_THUMBNAIL); executor.submit(worker); } } else { - target.setImageResource(R.drawable.default_cover); + target.setImageResource(defaultCoverResource); } } @@ -186,6 +191,13 @@ public class FeedImageLoader { public void addBitmapToCoverCache(String key, CachedBitmap bitmap) { coverCache.put(key, bitmap); } + + private int getDefaultCoverResource(Context context) { + TypedArray res = context.obtainStyledAttributes(new int[] {R.attr.default_cover}); + final int defaultCoverResource = res.getResourceId(0, 0); + res.recycle(); + return defaultCoverResource; + } class FeedImageDecodeWorkerTask extends BitmapDecodeWorkerTask { diff --git a/src/de/danoeh/antennapod/util/PlaybackController.java b/src/de/danoeh/antennapod/util/PlaybackController.java index e5eabb731..0afb0450c 100644 --- a/src/de/danoeh/antennapod/util/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/PlaybackController.java @@ -15,6 +15,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.content.res.TypedArray; import android.os.IBinder; import android.preference.PreferenceManager; import android.util.Log; @@ -354,6 +355,11 @@ public abstract class PlaybackController { * should be used to update the GUI or start/cancel background threads. */ private void handleStatus() { + TypedArray res = activity.obtainStyledAttributes(new int[] {R.attr.av_play, R.attr.av_pause}); + final int playResource = res.getResourceId(0, R.drawable.av_play); + final int pauseResource = res.getResourceId(1, R.drawable.av_pause); + res.recycle(); + switch (status) { case ERROR: @@ -363,22 +369,22 @@ public abstract class PlaybackController { clearStatusMsg(); checkMediaInfoLoaded(); cancelPositionObserver(); - updatePlayButtonAppearance(R.drawable.av_play); + updatePlayButtonAppearance(playResource); break; case PLAYING: clearStatusMsg(); checkMediaInfoLoaded(); setupPositionObserver(); - updatePlayButtonAppearance(R.drawable.av_pause); + updatePlayButtonAppearance(pauseResource); break; case PREPARING: postStatusMsg(R.string.player_preparing_msg); checkMediaInfoLoaded(); if (playbackService != null) { if (playbackService.isStartWhenPrepared()) { - updatePlayButtonAppearance(R.drawable.av_pause); + updatePlayButtonAppearance(pauseResource); } else { - updatePlayButtonAppearance(R.drawable.av_play); + updatePlayButtonAppearance(playResource); } } break; @@ -388,7 +394,7 @@ public abstract class PlaybackController { case PREPARED: checkMediaInfoLoaded(); postStatusMsg(R.string.player_ready_msg); - updatePlayButtonAppearance(R.drawable.av_play); + updatePlayButtonAppearance(playResource); break; case SEEKING: postStatusMsg(R.string.player_seeking_msg); @@ -399,7 +405,7 @@ public abstract class PlaybackController { case INITIALIZED: checkMediaInfoLoaded(); clearStatusMsg(); - updatePlayButtonAppearance(R.drawable.av_play); + updatePlayButtonAppearance(playResource); break; } } |