diff --git a/app/build.gradle b/app/build.gradle index 728dc47ed..22ec6381a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,7 +66,7 @@ android { } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) - implementation 'com.github.nv95:kotatsu-parsers:6ab5743f66' + implementation 'com.github.nv95:kotatsu-parsers:fe243c8acf' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0' @@ -117,5 +117,4 @@ dependencies { androidTestImplementation 'androidx.test:core-ktx:1.4.0' androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3' androidTestImplementation 'androidx.room:room-testing:2.4.2' - androidTestImplementation 'com.google.truth:truth:1.1.3' } \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/core/prefs/SourceSettings.kt b/app/src/main/java/org/koitharu/kotatsu/core/prefs/SourceSettings.kt index aeb5ece17..ea14c7342 100644 --- a/app/src/main/java/org/koitharu/kotatsu/core/prefs/SourceSettings.kt +++ b/app/src/main/java/org/koitharu/kotatsu/core/prefs/SourceSettings.kt @@ -7,6 +7,7 @@ import org.koitharu.kotatsu.parsers.config.MangaSourceConfig import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.model.SortOrder import org.koitharu.kotatsu.utils.ext.getEnumValue +import org.koitharu.kotatsu.utils.ext.ifNullOrEmpty import org.koitharu.kotatsu.utils.ext.putEnumValue private const val KEY_SORT_ORDER = "sort_order" @@ -22,7 +23,7 @@ class SourceSettings(context: Context, source: MangaSource) : MangaSourceConfig @Suppress("UNCHECKED_CAST") override fun get(key: ConfigKey): T { return when (key) { - is ConfigKey.Domain -> prefs.getString(key.key, key.defaultValue) ?: key.defaultValue + is ConfigKey.Domain -> prefs.getString(key.key, key.defaultValue).ifNullOrEmpty { key.defaultValue } } as T } } \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/list/ui/MangaListFragment.kt b/app/src/main/java/org/koitharu/kotatsu/list/ui/MangaListFragment.kt index ccc92d08c..4658bc0a0 100644 --- a/app/src/main/java/org/koitharu/kotatsu/list/ui/MangaListFragment.kt +++ b/app/src/main/java/org/koitharu/kotatsu/list/ui/MangaListFragment.kt @@ -87,11 +87,11 @@ abstract class MangaListFragment : BaseFragment(), isEnabled = isSwipeRefreshEnabled } - viewModel.content.observe(viewLifecycleOwner, ::onListChanged) - viewModel.onError.observe(viewLifecycleOwner, ::onError) - viewModel.isLoading.observe(viewLifecycleOwner, ::onLoadingStateChanged) viewModel.listMode.observe(viewLifecycleOwner, ::onListModeChanged) viewModel.gridScale.observe(viewLifecycleOwner, ::onGridScaleChanged) + viewModel.isLoading.observe(viewLifecycleOwner, ::onLoadingStateChanged) + viewModel.content.observe(viewLifecycleOwner, ::onListChanged) + viewModel.onError.observe(viewLifecycleOwner, ::onError) } override fun onDestroyView() { @@ -185,12 +185,10 @@ abstract class MangaListFragment : BaseFragment(), right = insets.right, ) if (activity is MainActivity) { - val topOffsetDiff = binding.recyclerView.paddingTop - headerHeight binding.recyclerView.updatePadding( top = headerHeight, bottom = insets.bottom, ) - binding.recyclerView.scrollBy(0, topOffsetDiff) binding.swipeRefreshLayout.setProgressViewOffset( true, headerHeight + resources.resolveDp(-72), diff --git a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt index d2cc18795..ab424f25c 100644 --- a/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt +++ b/app/src/main/java/org/koitharu/kotatsu/list/ui/adapter/MangaListAdapter.kt @@ -2,7 +2,6 @@ package org.koitharu.kotatsu.list.ui.adapter import androidx.lifecycle.LifecycleOwner import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.RecyclerView import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.AsyncListDifferDelegationAdapter import org.koitharu.kotatsu.core.ui.DateTimeAgo diff --git a/app/src/main/java/org/koitharu/kotatsu/utils/ext/StringExt.kt b/app/src/main/java/org/koitharu/kotatsu/utils/ext/StringExt.kt new file mode 100644 index 000000000..48ba02122 --- /dev/null +++ b/app/src/main/java/org/koitharu/kotatsu/utils/ext/StringExt.kt @@ -0,0 +1,5 @@ +package org.koitharu.kotatsu.utils.ext + +inline fun String?.ifNullOrEmpty(defaultValue: () -> String): String { + return if (this.isNullOrEmpty()) defaultValue() else this +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_list.xml b/app/src/main/res/layout/fragment_list.xml index c7d669857..75194b71d 100644 --- a/app/src/main/res/layout/fragment_list.xml +++ b/app/src/main/res/layout/fragment_list.xml @@ -15,7 +15,7 @@ android:orientation="vertical" android:padding="@dimen/grid_spacing_outer" app:fastScrollEnabled="true" - app:layoutManager="org.koitharu.kotatsu.base.ui.list.FitHeightLinearLayoutManager" + tools:layoutManager="org.koitharu.kotatsu.base.ui.list.FitHeightLinearLayoutManager" tools:listitem="@layout/item_manga_list" /> \ No newline at end of file