From fd17784731143d2a262e9c8bbdb2baf5f7e9631c Mon Sep 17 00:00:00 2001 From: ShareASmile <60492161+ShareASmile@users.noreply.github.com> Date: Sat, 4 Nov 2023 06:34:56 -0700 Subject: [PATCH] Fix lint (second batch) --- .../newpipelegacy/database/AppDatabaseTest.kt | 89 +++++++++++-------- .../java/org/schabi/newpipelegacy/DebugApp.kt | 24 +++-- 2 files changed, 68 insertions(+), 45 deletions(-) diff --git a/app/src/androidTest/java/org/schabi/newpipelegacy/database/AppDatabaseTest.kt b/app/src/androidTest/java/org/schabi/newpipelegacy/database/AppDatabaseTest.kt index 442257fa7..064d431cc 100644 --- a/app/src/androidTest/java/org/schabi/newpipelegacy/database/AppDatabaseTest.kt +++ b/app/src/androidTest/java/org/schabi/newpipelegacy/database/AppDatabaseTest.kt @@ -31,49 +31,62 @@ class AppDatabaseTest { } @get:Rule - val testHelper = MigrationTestHelper(InstrumentationRegistry.getInstrumentation(), - AppDatabase::class.java.canonicalName, FrameworkSQLiteOpenHelperFactory()) + val testHelper = MigrationTestHelper( + InstrumentationRegistry.getInstrumentation(), + AppDatabase::class.java.canonicalName, FrameworkSQLiteOpenHelperFactory() + ) @Test fun migrateDatabaseFrom2to3() { val databaseInV2 = testHelper.createDatabase(AppDatabase.DATABASE_NAME, Migrations.DB_VER_2) databaseInV2.run { - insert("streams", SQLiteDatabase.CONFLICT_FAIL, ContentValues().apply { - // put("uid", null) - put("service_id", DEFAULT_SERVICE_ID) - put("url", DEFAULT_URL) - put("title", DEFAULT_TITLE) - put("stream_type", DEFAULT_TYPE.name) - put("duration", DEFAULT_DURATION) - put("uploader", DEFAULT_UPLOADER_NAME) - put("thumbnail_url", DEFAULT_THUMBNAIL) - }) - insert("streams", SQLiteDatabase.CONFLICT_FAIL, ContentValues().apply { - // put("uid", null) - put("service_id", DEFAULT_SECOND_SERVICE_ID) - put("url", DEFAULT_SECOND_URL) - // put("title", null) - // put("stream_type", null) - // put("duration", null) - // put("uploader", null) - // put("thumbnail_url", null) - }) - insert("streams", SQLiteDatabase.CONFLICT_FAIL, ContentValues().apply { - // put("uid", null) - put("service_id", DEFAULT_SERVICE_ID) - // put("url", null) - // put("title", null) - // put("stream_type", null) - // put("duration", null) - // put("uploader", null) - // put("thumbnail_url", null) - }) + insert( + "streams", SQLiteDatabase.CONFLICT_FAIL, + ContentValues().apply { + // put("uid", null) + put("service_id", DEFAULT_SERVICE_ID) + put("url", DEFAULT_URL) + put("title", DEFAULT_TITLE) + put("stream_type", DEFAULT_TYPE.name) + put("duration", DEFAULT_DURATION) + put("uploader", DEFAULT_UPLOADER_NAME) + put("thumbnail_url", DEFAULT_THUMBNAIL) + } + ) + insert( + "streams", SQLiteDatabase.CONFLICT_FAIL, + ContentValues().apply { + // put("uid", null) + put("service_id", DEFAULT_SECOND_SERVICE_ID) + put("url", DEFAULT_SECOND_URL) + // put("title", null) + // put("stream_type", null) + // put("duration", null) + // put("uploader", null) + // put("thumbnail_url", null) + } + ) + insert( + "streams", SQLiteDatabase.CONFLICT_FAIL, + ContentValues().apply { + // put("uid", null) + put("service_id", DEFAULT_SERVICE_ID) + // put("url", null) + // put("title", null) + // put("stream_type", null) + // put("duration", null) + // put("uploader", null) + // put("thumbnail_url", null) + } + ) close() } - testHelper.runMigrationsAndValidate(AppDatabase.DATABASE_NAME, Migrations.DB_VER_3, - true, Migrations.MIGRATION_2_3) + testHelper.runMigrationsAndValidate( + AppDatabase.DATABASE_NAME, Migrations.DB_VER_3, + true, Migrations.MIGRATION_2_3 + ) val migratedDatabaseV3 = getMigratedDatabase() val listFromDB = migratedDatabaseV3.streamDAO().all.blockingFirst() @@ -110,9 +123,11 @@ class AppDatabaseTest { } private fun getMigratedDatabase(): AppDatabase { - val database: AppDatabase = Room.databaseBuilder(ApplicationProvider.getApplicationContext(), - AppDatabase::class.java, AppDatabase.DATABASE_NAME) - .build() + val database: AppDatabase = Room.databaseBuilder( + ApplicationProvider.getApplicationContext(), + AppDatabase::class.java, AppDatabase.DATABASE_NAME + ) + .build() testHelper.closeWhenFinished(database) return database } diff --git a/app/src/debug/java/org/schabi/newpipelegacy/DebugApp.kt b/app/src/debug/java/org/schabi/newpipelegacy/DebugApp.kt index 5443eff90..470b46a61 100644 --- a/app/src/debug/java/org/schabi/newpipelegacy/DebugApp.kt +++ b/app/src/debug/java/org/schabi/newpipelegacy/DebugApp.kt @@ -10,21 +10,28 @@ import okhttp3.OkHttpClient import org.schabi.newpipe.extractor.downloader.Downloader class DebugApp : App() { - override fun onCreate() { super.onCreate() initStetho() // Give each object 10 seconds to be GC'ed, before LeakCanary gets nosy on it AppWatcher.config = AppWatcher.config.copy(watchDurationMillis = 10000) - LeakCanary.config = LeakCanary.config.copy(dumpHeap = PreferenceManager - .getDefaultSharedPreferences(this).getBoolean(getString( - R.string.allow_heap_dumping_key), false)) + LeakCanary.config = LeakCanary.config.copy( + dumpHeap = PreferenceManager + .getDefaultSharedPreferences(this).getBoolean( + getString( + R.string.allow_heap_dumping_key + ), + false + ) + ) } override fun getDownloader(): Downloader { - val downloader = DownloaderImpl.init(OkHttpClient.Builder() - .addNetworkInterceptor(StethoInterceptor())) + val downloader = DownloaderImpl.init( + OkHttpClient.Builder() + .addNetworkInterceptor(StethoInterceptor()) + ) setCookiesToDownloader(downloader) return downloader } @@ -44,7 +51,8 @@ class DebugApp : App() { // Enable command line interface initializerBuilder.enableDumpapp( - Stetho.defaultDumperPluginsProvider(applicationContext)) + Stetho.defaultDumperPluginsProvider(applicationContext) + ) // Use the InitializerBuilder to generate an Initializer val initializer = initializerBuilder.build() @@ -55,6 +63,6 @@ class DebugApp : App() { override fun isDisposedRxExceptionsReported(): Boolean { return PreferenceManager.getDefaultSharedPreferences(this) - .getBoolean(getString(R.string.allow_disposed_exceptions_key), false) + .getBoolean(getString(R.string.allow_disposed_exceptions_key), false) } }