diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2018-01-10 18:26:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-10 18:26:54 +0100 |
commit | 2c9582c947a4dcac567048e0445d83576fd22839 (patch) | |
tree | 3933fb45d817751a4ac5bd08152eeb5c9325eda9 /core | |
parent | 0614b534008770981b7d2fa08b43aec03158de9b (diff) | |
parent | 89366d97d18ac1132fabb6909cd46bcfa7a6e5ae (diff) | |
download | AntennaPod-2c9582c947a4dcac567048e0445d83576fd22839.zip |
Merge pull request #2534 from AntennaPod/sdk_int_lt_14
Replace code for SDK version lower than 14
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 50 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java | 58 |
2 files changed, 31 insertions, 77 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 75b706685..c600501c0 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -269,10 +269,8 @@ public class PlaybackService extends MediaBrowserServiceCompat { Intent.ACTION_HEADSET_PLUG)); registerReceiver(shutdownReceiver, new IntentFilter( ACTION_SHUTDOWN_PLAYBACK_SERVICE)); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - registerReceiver(bluetoothStateUpdated, new IntentFilter( - BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)); - } + registerReceiver(bluetoothStateUpdated, new IntentFilter( + BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)); registerReceiver(audioBecomingNoisy, new IntentFilter( AudioManager.ACTION_AUDIO_BECOMING_NOISY)); registerReceiver(skipCurrentEpisodeReceiver, new IntentFilter( @@ -342,9 +340,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { unregisterReceiver(autoStateUpdated); unregisterReceiver(headsetDisconnected); unregisterReceiver(shutdownReceiver); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - unregisterReceiver(bluetoothStateUpdated); - } + unregisterReceiver(bluetoothStateUpdated); unregisterReceiver(audioBecomingNoisy); unregisterReceiver(skipCurrentEpisodeReceiver); unregisterReceiver(pausePlayCurrentEpisodeReceiver); @@ -1196,21 +1192,19 @@ public class PlaybackService extends MediaBrowserServiceCompat { @Override public void run() { Log.d(TAG, "Starting background work"); - if (android.os.Build.VERSION.SDK_INT >= 11) { - if (info.playable != null) { - int iconSize = getResources().getDimensionPixelSize( - android.R.dimen.notification_large_icon_width); - try { - icon = Glide.with(PlaybackService.this) - .load(info.playable.getImageLocation()) - .asBitmap() - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .centerCrop() - .into(iconSize, iconSize) - .get(); - } catch (Throwable tr) { - Log.e(TAG, "Error loading the media icon for the notification", tr); - } + if (info.playable != null) { + int iconSize = getResources().getDimensionPixelSize( + android.R.dimen.notification_large_icon_width); + try { + icon = Glide.with(PlaybackService.this) + .load(info.playable.getImageLocation()) + .asBitmap() + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .centerCrop() + .into(iconSize, iconSize) + .get(); + } catch (Throwable tr) { + Log.e(TAG, "Error loading the media icon for the notification", tr); } } if (icon == null) { @@ -1471,13 +1465,11 @@ public class PlaybackService extends MediaBrowserServiceCompat { private final BroadcastReceiver bluetoothStateUpdated = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - if (TextUtils.equals(intent.getAction(), BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)) { - int state = intent.getIntExtra(BluetoothA2dp.EXTRA_STATE, -1); - if (state == BluetoothA2dp.STATE_CONNECTED) { - Log.d(TAG, "Received bluetooth connection intent"); - unpauseIfPauseOnDisconnect(true); - } + if (TextUtils.equals(intent.getAction(), BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)) { + int state = intent.getIntExtra(BluetoothA2dp.EXTRA_STATE, -1); + if (state == BluetoothA2dp.STATE_CONNECTED) { + Log.d(TAG, "Received bluetooth connection intent"); + unpauseIfPauseOnDisconnect(true); } } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index dc8692866..32cf44690 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -350,9 +350,7 @@ public class PodDBAdapter { SQLiteDatabase newDb = null; try { newDb = dbHelper.getWritableDatabase(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - newDb.enableWriteAheadLogging(); - } + newDb.enableWriteAheadLogging(); } catch (SQLException ex) { Log.e(TAG, Log.getStackTraceString(ex)); newDb = dbHelper.getReadableDatabase(); @@ -473,11 +471,7 @@ public class PodDBAdapter { try { if (!db.inTransaction()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); startedTransaction = true; } @@ -580,11 +574,7 @@ public class PodDBAdapter { */ public void setCompleteFeed(Feed... feeds) { try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); for (Feed feed : feeds) { setFeed(feed); if (feed.getItems() != null) { @@ -665,11 +655,7 @@ public class PodDBAdapter { public void setFeedItemlist(List<FeedItem> items) { try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); for (FeedItem item : items) { setFeedItem(item, true); } @@ -684,11 +670,7 @@ public class PodDBAdapter { public long setSingleFeedItem(FeedItem item) { long result = 0; try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); result = setFeedItem(item, true); db.setTransactionSuccessful(); } catch (SQLException e) { @@ -814,11 +796,7 @@ public class PodDBAdapter { public void setFeedItemRead(int played, long itemId, long mediaId, boolean resetMediaPosition) { try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); ContentValues values = new ContentValues(); values.put(KEY_READ, played); @@ -846,11 +824,7 @@ public class PodDBAdapter { */ public void setFeedItemRead(int read, long... itemIds) { try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); ContentValues values = new ContentValues(); for (long id : itemIds) { values.clear(); @@ -933,11 +907,7 @@ public class PodDBAdapter { public void setFavorites(List<FeedItem> favorites) { ContentValues values = new ContentValues(); try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); db.delete(TABLE_NAME_FAVORITES, null, null); for (int i = 0; i < favorites.size(); i++) { FeedItem item = favorites.get(i); @@ -1000,11 +970,7 @@ public class PodDBAdapter { public void setQueue(List<FeedItem> queue) { ContentValues values = new ContentValues(); try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); db.delete(TABLE_NAME_QUEUE, null, null); for (int i = 0; i < queue.size(); i++) { FeedItem item = queue.get(i); @@ -1066,11 +1032,7 @@ public class PodDBAdapter { */ public void removeFeed(Feed feed) { try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - db.beginTransactionNonExclusive(); - } else { - db.beginTransaction(); - } + db.beginTransactionNonExclusive(); if (feed.getImage() != null) { removeFeedImage(feed.getImage()); } |