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

Change continuation indent to 4 chars #548

Merged
merged 2 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions app/src/main/java/app/tivi/appinitializers/EmojiInitializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import javax.inject.Inject
class EmojiInitializer @Inject constructor() : AppInitializer {
override fun init(application: Application) {
val fontRequest = FontRequest(
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.com_google_android_gms_fonts_certs)
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.com_google_android_gms_fonts_certs)

val config = FontRequestEmojiCompatConfig(application, fontRequest)
.setReplaceAll(true)
.setReplaceAll(true)

EmojiCompat.init(config)
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/app/tivi/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class HomeActivity : TiviActivityMvRxView() {

private fun setupBottomNavigationBar() {
binding.homeBottomNavigation.setupWithNavController(
listOf(R.navigation.discover_nav_graph, R.navigation.watched_nav_graph,
R.navigation.following_nav_graph, R.navigation.search_nav_graph),
supportFragmentManager,
R.id.home_nav_container,
intent
listOf(R.navigation.discover_nav_graph, R.navigation.watched_nav_graph,
R.navigation.following_nav_graph, R.navigation.search_nav_graph),
supportFragmentManager,
R.id.home_nav_container,
intent
).observe(this) { navController ->
currentNavController = navController

Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/app/tivi/home/HomeActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ class HomeActivityViewModel @AssistedInject constructor(
}

companion object : MvRxViewModelFactory<HomeActivityViewModel, HomeActivityViewState> {
override fun create(viewModelContext: ViewModelContext, state: HomeActivityViewState): HomeActivityViewModel? {
override fun create(
viewModelContext: ViewModelContext,
state: HomeActivityViewState
): HomeActivityViewModel? {
val fragment: HomeActivity = viewModelContext.activity()
return fragment.homeNavigationViewModelFactory.create(state)
}
Expand Down
34 changes: 17 additions & 17 deletions app/src/main/java/app/tivi/inject/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ class AppModule {
@Singleton
@Provides
fun provideCoroutineDispatchers() = AppCoroutineDispatchers(
io = Dispatchers.IO,
computation = Dispatchers.Default,
main = Dispatchers.Main
io = Dispatchers.IO,
computation = Dispatchers.Default,
main = Dispatchers.Main
)

@Singleton
@Provides
fun provideBackgroundExecutor(): Executor {
val parallelism = (Runtime.getRuntime().availableProcessors() * 2)
.coerceIn(4, 32)
.coerceIn(4, 32)
return if (Build.VERSION.SDK_INT < 24) {
Executors.newFixedThreadPool(parallelism)
} else {
Expand Down Expand Up @@ -105,9 +105,9 @@ class AppModule {
fun provideMediumDateFormatter(application: TiviApplication): DateTimeFormatter {
@Suppress("DEPRECATION")
return (AndroidDateFormat.getMediumDateFormat(application) as SimpleDateFormat)
.toThreeTenDateTimeFormatter()
.withLocale(application.resources.configuration.locale)
.withZone(ZoneId.systemDefault())
.toThreeTenDateTimeFormatter()
.withLocale(application.resources.configuration.locale)
.withZone(ZoneId.systemDefault())
}

@Singleton
Expand All @@ -119,8 +119,8 @@ class AppModule {

@Suppress("DEPRECATION")
return DateTimeFormatter.ofPattern("${dateF.toPattern()} ${timeF.toPattern()}")
.withLocale(application.resources.configuration.locale)
.withZone(ZoneId.systemDefault())
.withLocale(application.resources.configuration.locale)
.withZone(ZoneId.systemDefault())
}

@Singleton
Expand All @@ -129,9 +129,9 @@ class AppModule {
fun provideShortDateFormatter(application: TiviApplication): DateTimeFormatter {
@Suppress("DEPRECATION")
return (AndroidDateFormat.getDateFormat(application) as SimpleDateFormat)
.toThreeTenDateTimeFormatter()
.withLocale(application.resources.configuration.locale)
.withZone(ZoneId.systemDefault())
.toThreeTenDateTimeFormatter()
.withLocale(application.resources.configuration.locale)
.withZone(ZoneId.systemDefault())
}

@Singleton
Expand All @@ -140,7 +140,7 @@ class AppModule {
fun provideShortTimeFormatter(application: TiviApplication): DateTimeFormatter {
@Suppress("DEPRECATION")
return (AndroidDateFormat.getTimeFormat(application) as SimpleDateFormat)
.toThreeTenDateTimeFormatter()
.toThreeTenDateTimeFormatter()
}

@Provides
Expand All @@ -152,9 +152,9 @@ class AppModule {
@Provides
@Singleton
fun provideAppBarConfiguration() = AppBarConfiguration.Builder(
R.id.navigation_followed,
R.id.navigation_watched,
R.id.navigation_discover,
R.id.navigation_search
R.id.navigation_followed,
R.id.navigation_watched,
R.id.navigation_discover,
R.id.navigation_search
).build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ internal class SettingsPreferenceFragment : PreferenceFragmentCompat() {

findPreference<Preference>("privacy_policy")?.setOnPreferenceClickListener {
CustomTabsIntent.Builder()
.setToolbarColor(requireContext().resolveThemeColor(R.attr.colorPrimaryVariant))
.build()
.launchUrl(requireContext(), getString(R.string.privacy_policy_url).toUri())
.setToolbarColor(requireContext().resolveThemeColor(R.attr.colorPrimaryVariant))
.build()
.launchUrl(requireContext(), getString(R.string.privacy_policy_url).toUri())
true
}

Expand All @@ -46,7 +46,7 @@ internal class SettingsPreferenceFragment : PreferenceFragmentCompat() {

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

findViewById<View>(R.id.details_root).apply {
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

doOnApplyWindowInsets { view, insets, initialState ->
view.updatePadding(
left = insets.systemWindowInsetLeft + initialState.paddings.left,
right = insets.systemWindowInsetRight + initialState.paddings.right
left = insets.systemWindowInsetLeft + initialState.paddings.left,
right = insets.systemWindowInsetRight + initialState.paddings.right
)
}
}
Expand All @@ -50,7 +50,7 @@ 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))
NavHostFragment.create(R.navigation.show_details_nav_graph, intent.extras))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ inline fun <T> LiveData<T>.observeK(owner: LifecycleOwner, crossinline observer:
this.observe(owner, Observer { observer(it) })
}

inline fun <T> LiveData<T>.observeNotNull(owner: LifecycleOwner, crossinline observer: (T) -> Unit) {
inline fun <T> LiveData<T>.observeNotNull(
owner: LifecycleOwner,
crossinline observer: (T) -> Unit
) {
this.observe(owner, Observer { it?.run(observer) })
}

Expand Down
5 changes: 4 additions & 1 deletion base-android/src/main/java/app/tivi/util/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Obser
}
}

inline fun <T> LiveData<Event<T>>.observeEvent(owner: LifecycleOwner, crossinline observer: (T) -> Unit) {
inline fun <T> LiveData<Event<T>>.observeEvent(
owner: LifecycleOwner,
crossinline observer: (T) -> Unit
) {
observe(owner, EventObserver { observer(it) })
}
16 changes: 8 additions & 8 deletions base-android/src/main/java/app/tivi/util/TiviDateFormatter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class TiviDateFormatter @Inject constructor(
if (dateTime.year == now.year || dateTime.isAfter(now.minusDays(7))) {
// Within the past week
DateUtils.getRelativeTimeSpanString(
dateTime.toInstant().toEpochMilli(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_SHOW_DATE)
dateTime.toInstant().toEpochMilli(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_SHOW_DATE)
} else {
// More than 7 days ago
formatShortDate(dateTime)
Expand All @@ -66,10 +66,10 @@ class TiviDateFormatter @Inject constructor(
if (dateTime.year == now.year || dateTime.isBefore(now.plusDays(14))) {
// In the near future (next 2 weeks)
DateUtils.getRelativeTimeSpanString(
dateTime.toInstant().toEpochMilli(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_SHOW_DATE)
dateTime.toInstant().toEpochMilli(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_SHOW_DATE)
} else {
// In the far future
formatShortDate(dateTime)
Expand Down
19 changes: 9 additions & 10 deletions base/src/main/java/app/tivi/extensions/CoroutineExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ suspend inline fun <T> asyncOrAwait(
crossinline action: suspend CoroutineScope.() -> T
): T = coroutineScope {
val deferred = deferreds[key]?.takeIf { it.isActive }
?: async { action() }
.also { deferreds[key] = it }
?: async { action() }.also { deferreds[key] = it }

if (deferreds.size > 100 && !deferredsCleanLaunched.getAndSet(true)) {
launch {
Expand All @@ -100,8 +99,8 @@ suspend inline fun launchOrJoin(
crossinline action: suspend CoroutineScope.() -> Unit
) = coroutineScope {
val job = jobs[key]?.takeIf { it.isActive }
?: launch { action() }
.also { jobs[key] = it }
?: launch { action() }
.also { jobs[key] = it }

if (jobs.size > 100 && !jobsCleanLaunched.getAndSet(true)) {
launch {
Expand Down Expand Up @@ -131,11 +130,11 @@ inline fun <T1, T2, T3, T4, T5, T6, R> combine(
crossinline transform: suspend (T1, T2, T3, T4, T5, T6) -> R
): Flow<R> = kotlinx.coroutines.flow.combine(flow, flow2, flow3, flow4, flow5, flow6) { args: Array<*> ->
transform(
args[0] as T1,
args[1] as T2,
args[2] as T3,
args[3] as T4,
args[4] as T5,
args[5] as T6
args[0] as T1,
args[1] as T2,
args[2] as T3,
args[3] as T4,
args[4] as T5,
args[5] as T6
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ abstract class TiviFragmentWithBinding<V : ViewDataBinding> : TiviFragment() {
var binding: V? = null
private set

final override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
final override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return createBinding(inflater, container, savedInstanceState)
.also { binding = it }
.root
.also { binding = it }
.root
}

final override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ fun roundedCornerOutlineProvider(view: View, oldRadius: Float, radius: Float) {
}

@BindingAdapter("textAppearanceAttr")
fun textAppearanceAttr(view: TextView, oldTextAppearanceStyleAttr: Int, textAppearanceStyleAttr: Int) {
fun textAppearanceAttr(
view: TextView,
oldTextAppearanceStyleAttr: Int,
textAppearanceStyleAttr: Int
) {
if (oldTextAppearanceStyleAttr != textAppearanceStyleAttr) {
view.setTextAppearance(view.context.resolveThemeReferenceResId(textAppearanceStyleAttr))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import app.tivi.ui.widget.PopupMenuButton

@BindingMethods(
BindingMethod(type = View::class, attribute = "outlineProviderInstance", method = "setOutlineProvider"),
BindingMethod(type = SwipeRefreshLayout::class, attribute = "isRefreshing", method = "setRefreshing"),
BindingMethod(type = View::class, attribute = "clipToOutline", method = "setClipToOutline"),
BindingMethod(type = View::class, attribute = "activated", method = "setActivated"),
BindingMethod(type = View::class, attribute = "selected", method = "setSelected"),
BindingMethod(type = View::class, attribute = "onLongClick", method = "setOnLongClickListener"),
BindingMethod(type = PopupMenuButton::class, attribute = "popupMenuClickListener", method = "setMenuItemClickListener"),
BindingMethod(type = PopupMenuButton::class, attribute = "popupMenuListener", method = "setPopupMenuListener")
BindingMethod(type = View::class, attribute = "outlineProviderInstance", method = "setOutlineProvider"),
BindingMethod(type = SwipeRefreshLayout::class, attribute = "isRefreshing", method = "setRefreshing"),
BindingMethod(type = View::class, attribute = "clipToOutline", method = "setClipToOutline"),
BindingMethod(type = View::class, attribute = "activated", method = "setActivated"),
BindingMethod(type = View::class, attribute = "selected", method = "setSelected"),
BindingMethod(type = View::class, attribute = "onLongClick", method = "setOnLongClickListener"),
BindingMethod(type = PopupMenuButton::class, attribute = "popupMenuClickListener", method = "setMenuItemClickListener"),
BindingMethod(type = PopupMenuButton::class, attribute = "popupMenuListener", method = "setPopupMenuListener")
)
class TiviBindingMethods
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ abstract class EntryGridEpoxyController<LI : EntryWithShow<out Entry>> :

protected open fun buildItemPlaceholder(index: Int): PosterGridItemBindingModel_ {
return PosterGridItemBindingModel_()
.id("placeholder_$index")
.id("placeholder_$index")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import kotlinx.coroutines.flow.collect

@SuppressLint("ValidFragment")
abstract class EntryGridFragment<LI, VM> : TiviFragmentWithBinding<FragmentEntryGridBinding>()
where LI : EntryWithShow<out Entry>, VM : EntryViewModel<LI, *> {
where LI : EntryWithShow<out Entry>, VM : EntryViewModel<LI, *> {
protected abstract val viewModel: VM

private lateinit var swipeRefreshLatch: ProgressTimeLatch
Expand Down Expand Up @@ -88,7 +88,7 @@ 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)
it.height + binding.gridSwipeRefresh.progressCircleDiameter / 2)
true
}

Expand All @@ -115,9 +115,9 @@ abstract class EntryGridFragment<LI, VM> : TiviFragmentWithBinding<FragmentEntry
is UiError -> {
swipeRefreshLatch.refreshing = false
Snackbar.make(requireView(),
status.exception?.localizedMessage
?: getString(R.string.error_generic),
Snackbar.LENGTH_SHORT
status.exception?.localizedMessage
?: getString(R.string.error_generic),
Snackbar.LENGTH_SHORT
).show()
}
is UiLoading -> swipeRefreshLatch.refreshing = status.fullRefresh
Expand All @@ -133,7 +133,7 @@ abstract class EntryGridFragment<LI, VM> : TiviFragmentWithBinding<FragmentEntry

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

if (state.isLoaded) {
Expand Down
Loading