Merge pull request #4481 from ByteHamster/lint-core

Lint core
This commit is contained in:
H. Lehmann 2020-10-01 12:57:57 +02:00 committed by GitHub
commit 3a888a2d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 28 deletions

View File

@ -90,7 +90,14 @@ workflows:
- run: - run:
name: Lint app name: Lint app
command: ./gradlew app:lintPlayRelease command: ./gradlew app:lintPlayRelease
- run:
name: Lint core
command: ./gradlew core:lintPlayRelease
- store_artifacts: - store_artifacts:
name: Uploading lint reports name: Uploading app lint reports
path: app/build/reports/lint-results-playRelease.html path: app/build/reports/lint-results-playRelease.html
destination: lint-results.html destination: lint-results-app.html
- store_artifacts:
name: Uploading core lint reports
path: core/build/reports/lint-results-playRelease.html
destination: lint-results-core.html

View File

@ -52,6 +52,16 @@ android {
dimension "market" dimension "market"
} }
} }
lintOptions {
disable "InvalidPeriodicWorkRequestInterval", "ObsoleteLintCustomCheck", "DefaultLocale", "UnusedAttribute",
"GradleDependency", "ParcelClassLoader", "Typos", "ExtraTranslation", "ImpliedQuantity",
"PluralsCandidate", "UnusedQuantity", "StringFormatCount", "TrustAllX509TrustManager",
"StaticFieldLeak", "TypographyEllipsis", "IconDensities", "IconDuplicates", "CheckResult"
warningsAsErrors true
abortOnError true
}
} }
dependencies { dependencies {

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.danoeh.antennapod.core"> xmlns:tools="http://schemas.android.com/tools" package="de.danoeh.antennapod.core">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@ -12,15 +12,19 @@
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher"
android:supportsRtl="true">
<service <service
android:name=".service.download.DownloadService" android:name=".service.download.DownloadService"
android:enabled="true" /> android:enabled="true" />
<service android:name=".service.playback.PlaybackService" <service android:name=".service.playback.PlaybackService"
android:label="@string/app_name" android:label="@string/app_name"
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true"
tools:ignore="ExportedService">
<intent-filter> <intent-filter>
<action android:name="android.media.browse.MediaBrowserService"/> <action android:name="android.media.browse.MediaBrowserService"/>
</intent-filter> </intent-filter>
@ -39,8 +43,8 @@
<receiver android:name=".receiver.FeedUpdateReceiver" <receiver android:name=".receiver.FeedUpdateReceiver"
android:label="@string/feed_update_receiver_name" android:label="@string/feed_update_receiver_name"
android:exported="true"> <!-- allow feeds update to be triggered by external apps --> android:exported="true"
</receiver> tools:ignore="ExportedReceiver" /> <!-- allow feeds update to be triggered by external apps -->
</application> </application>
</manifest> </manifest>

View File

@ -249,7 +249,7 @@ public class UserPreferences {
public static void setFeedOrder(String selected) { public static void setFeedOrder(String selected) {
prefs.edit() prefs.edit()
.putString(PREF_DRAWER_FEED_ORDER, selected) .putString(PREF_DRAWER_FEED_ORDER, selected)
.commit(); .apply();
} }
public static int getFeedCounterSetting() { public static int getFeedCounterSetting() {
@ -1054,7 +1054,7 @@ public class UserPreferences {
public static void setFeedFilter(String value) { public static void setFeedFilter(String value) {
prefs.edit() prefs.edit()
.putString(PREF_FILTER_FEED, value) .putString(PREF_FILTER_FEED, value)
.commit(); .apply();
} }
} }

View File

@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
import android.util.Log; import android.util.Log;
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences; import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
import io.reactivex.disposables.Disposable;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -57,7 +58,7 @@ public class PlaybackServiceTaskManager {
private ScheduledFuture<?> widgetUpdaterFuture; private ScheduledFuture<?> widgetUpdaterFuture;
private ScheduledFuture<?> sleepTimerFuture; private ScheduledFuture<?> sleepTimerFuture;
private volatile Future<List<FeedItem>> queueFuture; private volatile Future<List<FeedItem>> queueFuture;
private volatile Future<?> chapterLoaderFuture; private volatile Disposable chapterLoaderFuture;
private SleepTimer sleepTimer; private SleepTimer sleepTimer;
@ -102,7 +103,7 @@ public class PlaybackServiceTaskManager {
private synchronized void loadQueue() { private synchronized void loadQueue() {
if (!isQueueLoaderActive()) { if (!isQueueLoaderActive()) {
queueFuture = schedExecutor.submit(DBReader::getQueue); queueFuture = schedExecutor.submit(() -> DBReader.getQueue());
} }
} }
@ -289,28 +290,19 @@ public class PlaybackServiceTaskManager {
} }
} }
private synchronized void cancelChapterLoader() {
if (isChapterLoaderActive()) {
chapterLoaderFuture.cancel(true);
}
}
private synchronized boolean isChapterLoaderActive() {
return chapterLoaderFuture != null && !chapterLoaderFuture.isDone();
}
/** /**
* Starts a new thread that loads the chapter marks from a playable object. If another chapter loader is already active, * Starts a new thread that loads the chapter marks from a playable object. If another chapter loader is already active,
* it will be cancelled first. * it will be cancelled first.
* On completion, the callback's onChapterLoaded method will be called. * On completion, the callback's onChapterLoaded method will be called.
*/ */
public synchronized void startChapterLoader(@NonNull final Playable media) { public synchronized void startChapterLoader(@NonNull final Playable media) {
if (isChapterLoaderActive()) { if (chapterLoaderFuture != null) {
cancelChapterLoader(); chapterLoaderFuture.dispose();
chapterLoaderFuture = null;
} }
if (media.getChapters() == null) { if (media.getChapters() == null) {
Completable.create(emitter -> { chapterLoaderFuture = Completable.create(emitter -> {
media.loadChapterMarks(); media.loadChapterMarks();
emitter.onComplete(); emitter.onComplete();
}) })
@ -330,7 +322,11 @@ public class PlaybackServiceTaskManager {
cancelWidgetUpdater(); cancelWidgetUpdater();
disableSleepTimer(); disableSleepTimer();
cancelQueueLoader(); cancelQueueLoader();
cancelChapterLoader();
if (chapterLoaderFuture != null) {
chapterLoaderFuture.dispose();
chapterLoaderFuture = null;
}
} }
/** /**

View File

@ -257,7 +257,6 @@ public final class DBTasks {
EventBus.getDefault().post(new MessageEvent(context.getString(R.string.error_file_not_found))); EventBus.getDefault().post(new MessageEvent(context.getString(R.string.error_file_not_found)));
} }
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public static List<? extends FeedItem> enqueueFeedItemsToDownload(final Context context, public static List<? extends FeedItem> enqueueFeedItemsToDownload(final Context context,
List<? extends FeedItem> items) throws InterruptedException, ExecutionException { List<? extends FeedItem> items) throws InterruptedException, ExecutionException {
List<FeedItem> itemsToEnqueue = new ArrayList<>(); List<FeedItem> itemsToEnqueue = new ArrayList<>();

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="@dimen/widget_margin" > android:padding="@dimen/widget_margin" >
@ -8,8 +9,8 @@
android:id="@+id/widgetLayout" android:id="@+id/widgetLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#262C31" > android:background="#262C31"
tools:ignore="UselessParent">
<ImageButton <ImageButton
android:id="@+id/butPlay" android:id="@+id/butPlay"
@ -41,6 +42,7 @@
android:layout_width="@android:dimen/app_icon_size" android:layout_width="@android:dimen/app_icon_size"
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@mipmap/ic_launcher_round" android:src="@mipmap/ic_launcher_round"
android:importantForAccessibility="no"
android:layout_margin="12dp" /> android:layout_margin="12dp" />
<LinearLayout <LinearLayout