Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Upgrade to ktlint 0.37.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes authored and Chris Banes committed Jun 10, 2020
1 parent 25e36e3 commit 066ffd7
Show file tree
Hide file tree
Showing 172 changed files with 747 additions and 493 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class EmojiInitializer @Inject constructor() : AppInitializer {
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.com_google_android_gms_fonts_certs)
R.array.com_google_android_gms_fonts_certs
)

val config = FontRequestEmojiCompatConfig(application, fontRequest)
.setReplaceAll(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package app.tivi.appinitializers
import android.app.Application
import app.tivi.util.AppCoroutineDispatchers
import com.jakewharton.threetenabp.AndroidThreeTen
import javax.inject.Inject
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.threeten.bp.zone.ZoneRulesProvider
import javax.inject.Inject

class ThreeTenBpInitializer @Inject constructor(
private val dispatchers: AppCoroutineDispatchers
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/app/tivi/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import app.tivi.extensions.hideSoftInput
import app.tivi.extensions.setupWithNavController
import app.tivi.trakt.TraktConstants
import com.airbnb.mvrx.viewModel
import javax.inject.Inject
import net.openid.appauth.AuthorizationException
import net.openid.appauth.AuthorizationResponse
import net.openid.appauth.AuthorizationService
import javax.inject.Inject

class HomeActivity : TiviActivityMvRxView() {
private val authService by lazy(LazyThreadSafetyMode.NONE) {
Expand Down
24 changes: 13 additions & 11 deletions app/src/main/java/app/tivi/home/HomeInject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ import dagger.android.ContributesAndroidInjector

@Module
internal abstract class HomeBuilder {
@ContributesAndroidInjector(modules = [
HomeModule::class,
SearchBuilder::class,
DiscoverBuilder::class,
TrendingBuilder::class,
PopularBuilder::class,
WatchedBuilder::class,
FollowedBuilder::class,
RecommendedBuilder::class,
AccountUiBuilder::class
])
@ContributesAndroidInjector(
modules = [
HomeModule::class,
SearchBuilder::class,
DiscoverBuilder::class,
TrendingBuilder::class,
PopularBuilder::class,
WatchedBuilder::class,
FollowedBuilder::class,
RecommendedBuilder::class,
AccountUiBuilder::class
]
)
internal abstract fun homeActivity(): HomeActivity
}

Expand Down
36 changes: 19 additions & 17 deletions app/src/main/java/app/tivi/inject/AppComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,25 @@ import dagger.android.support.AndroidSupportInjectionModule
import javax.inject.Singleton

@Singleton
@Component(modules = [
AndroidSupportInjectionModule::class,
AppModule::class,
TasksModule::class,
AppAssistedModule::class,
DatabaseModule::class,
DataModule::class,
HomeBuilder::class,
ShowDetailsBuilder::class,
TraktModule::class,
TraktAuthModule::class,
TmdbModule::class,
NetworkModule::class,
ImageLoadingModule::class,
EpoxyModule::class,
SettingsPreferenceFragmentBuilder::class
])
@Component(
modules = [
AndroidSupportInjectionModule::class,
AppModule::class,
TasksModule::class,
AppAssistedModule::class,
DatabaseModule::class,
DataModule::class,
HomeBuilder::class,
ShowDetailsBuilder::class,
TraktModule::class,
TraktAuthModule::class,
TmdbModule::class,
NetworkModule::class,
ImageLoadingModule::class,
EpoxyModule::class,
SettingsPreferenceFragmentBuilder::class
]
)
interface AppComponent : AndroidInjector<TiviApplication> {
@Component.Factory
interface Factory {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/app/tivi/inject/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package app.tivi.inject
import android.content.Context
import android.content.SharedPreferences
import android.os.Build
import android.text.format.DateFormat as AndroidDateFormat
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.lifecycle.coroutineScope
import androidx.navigation.ui.AppBarConfiguration
Expand All @@ -33,16 +32,17 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics
import dagger.Module
import dagger.Provides
import io.reactivex.disposables.CompositeDisposable
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import org.threeten.bp.ZoneId
import org.threeten.bp.format.DateTimeFormatter
import java.io.File
import java.text.SimpleDateFormat
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import javax.inject.Named
import javax.inject.Singleton
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import org.threeten.bp.ZoneId
import org.threeten.bp.format.DateTimeFormatter
import android.text.format.DateFormat as AndroidDateFormat

@Module(includes = [AppModuleBinds::class])
class AppModule {
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/java/app/tivi/inject/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import android.content.Context
import app.tivi.BuildConfig
import dagger.Module
import dagger.Provides
import java.io.File
import java.util.concurrent.TimeUnit
import javax.inject.Singleton
import okhttp3.Cache
import okhttp3.ConnectionPool
import okhttp3.Dispatcher
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import okhttp3.logging.LoggingEventListener
import java.io.File
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

@Module
class NetworkModule {
Expand Down Expand Up @@ -75,10 +75,12 @@ class NetworkModule {
// Adjust the Connection pool to account for historical use of 3 separate clients
// but reduce the keepAlive to 2 minutes to avoid keeping radio open.
.connectionPool(ConnectionPool(10, 2, TimeUnit.MINUTES))
.dispatcher(Dispatcher().apply {
// Allow for high number of concurrent image fetches on same host.
maxRequestsPerHost = 15
})
.dispatcher(
Dispatcher().apply {
// Allow for high number of concurrent image fetches on same host.
maxRequestsPerHost = 15
}
)
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import dagger.android.support.AndroidSupportInjection
import javax.inject.Inject
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.flow.collect
import javax.inject.Inject

internal class SettingsPreferenceFragment : PreferenceFragmentCompat(), HasAndroidInjector {
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
Expand Down Expand Up @@ -85,8 +85,10 @@ internal class SettingsPreferenceFragment : PreferenceFragmentCompat(), HasAndro
}

findPreference<Preference>("version")?.apply {
summary = getString(R.string.settings_app_version_summary,
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
summary = getString(
R.string.settings_app_version_summary,
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE
)
}
}
}
6 changes: 4 additions & 2 deletions app/src/main/java/app/tivi/showdetails/ShowDetailsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ class ShowDetailsActivity : TiviActivity() {

override fun handleIntent(intent: Intent) {
supportFragmentManager.commit {
replace(R.id.details_content,
NavHostFragment.create(R.navigation.show_details_nav_graph, intent.extras))
replace(
R.id.details_content,
NavHostFragment.create(R.navigation.show_details_nav_graph, intent.extras)
)
}
}
}
12 changes: 7 additions & 5 deletions app/src/main/java/app/tivi/showdetails/ShowDetailsBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import dagger.android.ContributesAndroidInjector

@Module
internal abstract class ShowDetailsBuilder {
@ContributesAndroidInjector(modules = [
ShowDetailsModule::class,
ShowDetailsFragmentBuilder::class,
EpisodeDetailsFragmentBuilder::class
])
@ContributesAndroidInjector(
modules = [
ShowDetailsModule::class,
ShowDetailsFragmentBuilder::class,
EpisodeDetailsFragmentBuilder::class
]
)
internal abstract fun bindDetailsActivity(): ShowDetailsActivity
}
4 changes: 2 additions & 2 deletions app/src/main/java/app/tivi/util/AndroidPowerController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import android.os.PowerManager
import androidx.annotation.RequiresApi
import androidx.core.content.getSystemService
import app.tivi.settings.TiviPreferences
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onStart
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
internal class AndroidPowerController @Inject constructor(
Expand Down
2 changes: 1 addition & 1 deletion base-android/src/main/java/app/tivi/extensions/datetime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package app.tivi.extensions

import java.text.SimpleDateFormat
import org.threeten.bp.format.DateTimeFormatter
import java.text.SimpleDateFormat

fun SimpleDateFormat.toThreeTenDateTimeFormatter(): DateTimeFormatter {
return DateTimeFormatter.ofPattern(toPattern())
Expand Down
10 changes: 6 additions & 4 deletions base-android/src/main/java/app/tivi/util/TiviDateFormatter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import app.tivi.inject.MediumDate
import app.tivi.inject.MediumDateTime
import app.tivi.inject.ShortDate
import app.tivi.inject.ShortTime
import javax.inject.Inject
import javax.inject.Singleton
import org.threeten.bp.LocalTime
import org.threeten.bp.OffsetDateTime
import org.threeten.bp.format.DateTimeFormatter
import org.threeten.bp.temporal.Temporal
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class TiviDateFormatter @Inject constructor(
Expand All @@ -53,7 +53,8 @@ class TiviDateFormatter @Inject constructor(
dateTime.toInstant().toEpochMilli(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_SHOW_DATE).toString()
DateUtils.FORMAT_SHOW_DATE
).toString()
} else {
// More than 7 days ago
formatShortDate(dateTime)
Expand All @@ -65,7 +66,8 @@ class TiviDateFormatter @Inject constructor(
dateTime.toInstant().toEpochMilli(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_SHOW_DATE).toString()
DateUtils.FORMAT_SHOW_DATE
).toString()
} else {
// In the far future
formatShortDate(dateTime)
Expand Down
2 changes: 1 addition & 1 deletion base-android/src/main/java/app/tivi/util/TiviLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package app.tivi.util
import android.os.Build
import android.util.Log
import com.google.firebase.crashlytics.FirebaseCrashlytics
import timber.log.Timber
import java.util.regex.Pattern
import javax.inject.Inject
import timber.log.Timber

class TiviLogger @Inject constructor(
private val firebaseCrashlytics: FirebaseCrashlytics
Expand Down
4 changes: 2 additions & 2 deletions base/src/main/java/app/tivi/extensions/CoroutineExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package app.tivi.extensions

import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Job
Expand All @@ -33,6 +31,8 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean

suspend fun <A, B> Collection<A>.parallelMap(
concurrency: Int = defaultConcurrency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ package app.tivi.extensions
import app.tivi.data.entities.ErrorResult
import app.tivi.data.entities.Result
import app.tivi.data.entities.Success
import java.io.IOException
import kotlinx.coroutines.delay
import retrofit2.Call
import retrofit2.HttpException
import retrofit2.Response
import java.io.IOException

inline fun <T> Response<T>.bodyOrThrow(): T {
if (!isSuccessful) throw HttpException(this)
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ subprojects {
targetExclude('bin/**/*.kt')

ktlint(Versions.ktlint)
// Disable paren-spacing rule for NonParenthesizedAnnotationsOnFunctionalTypes
.userData(["disabled_rules": "paren-spacing"])
licenseHeaderFile rootProject.file('spotless/copyright.kt')
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/app/tivi/buildsrc/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package app.tivi.buildsrc

object Versions {
const val ktlint = "0.36.0"
const val ktlint = "0.37.0"
}

object Libs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import app.tivi.ui.SpacingItemDecorator
import app.tivi.ui.transitions.GridToGridTransitioner
import com.airbnb.mvrx.withState
import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject
import kotlinx.coroutines.flow.collect
import javax.inject.Inject

@SuppressLint("ValidFragment")
abstract class EntryGridFragment<LI, VM> : TiviFragmentWithBinding<FragmentEntryGridBinding>()
Expand Down Expand Up @@ -87,8 +87,10 @@ abstract class EntryGridFragment<LI, VM> : TiviFragmentWithBinding<FragmentEntry

binding.gridAppbar.doOnSizeChange {
binding.gridRecyclerview.updatePadding(top = it.height)
binding.gridSwipeRefresh.setProgressViewOffset(true, 0,
it.height + binding.gridSwipeRefresh.progressCircleDiameter / 2)
binding.gridSwipeRefresh.setProgressViewOffset(
true, 0,
it.height + binding.gridSwipeRefresh.progressCircleDiameter / 2
)
true
}

Expand Down Expand Up @@ -128,8 +130,10 @@ abstract class EntryGridFragment<LI, VM> : TiviFragmentWithBinding<FragmentEntry
}

if (currentActionMode != null) {
currentActionMode?.title = getString(R.string.selection_title,
state.selectedShowIds.size)
currentActionMode?.title = getString(
R.string.selection_title,
state.selectedShowIds.size
)
}

if (state.isLoaded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ fun RecyclerView.syncSpanSizes(controller: EpoxyController) {
val layout = layoutManager
if (layout is GridLayoutManager) {
if (controller.spanCount != layout.spanCount ||
layout.spanSizeLookup !== controller.spanSizeLookup) {
layout.spanSizeLookup !== controller.spanSizeLookup
) {
controller.spanCount = layout.spanCount
layout.spanSizeLookup = controller.spanSizeLookup
}
Expand Down
Loading

0 comments on commit 066ffd7

Please sign in to comment.