Changed references to drawables in src to references to attr
This commit is contained in:
parent
e01a656e9e
commit
c1d24edb5f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue