Compare commits

..

No commits in common. "d81fb79b4f0334a93acf9fdcc096e7f59fc9c5eb" and "a76b3dd2a90a261a4cbbbdb3961e75afe0276cdc" have entirely different histories.

11 changed files with 25 additions and 24 deletions

View File

@ -143,13 +143,13 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
handleSwipeRefreshLayout()
getElementsAccordingToTab()
if (appSettingsService.isItemCachingEnabled()) {
CoroutineScope(Dispatchers.Main).launch {
repository.tryToCacheItemsAndGetNewOnes()
}
}
}
private fun handleSwipeRefreshLayout() {
binding.swipeRefreshLayout.setColorSchemeResources(

View File

@ -18,7 +18,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ToolBarStyle"
app:theme="@style/ToolBarStyle"
app:popupTheme="?attr/toolbarPopupTheme" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -32,7 +32,7 @@
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ToolBarStyle"
app:theme="@style/ToolBarStyle"
app:popupTheme="?attr/toolbarPopupTheme" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -17,7 +17,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="?attr/toolbarPopupTheme"
android:theme="@style/ToolBarStyle" />
app:theme="@style/ToolBarStyle" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -14,7 +14,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ToolBarStyle"
app:theme="@style/ToolBarStyle"
app:popupTheme="?attr/toolbarPopupTheme" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -18,7 +18,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="?attr/toolbarPopupTheme"
android:theme="@style/ToolBarStyle" />
app:theme="@style/ToolBarStyle" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -14,7 +14,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ToolBarStyle"
app:theme="@style/ToolBarStyle"
app:popupTheme="?attr/toolbarPopupTheme" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -6,7 +6,7 @@
</PreferenceCategory>
<EditTextPreference
android:defaultValue="20"
android:defaultValue="200"
android:inputType="number"
android:key="prefer_api_items_number"
android:selectAllOnFocus="true"

View File

@ -28,12 +28,12 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:2.1.1")
implementation("io.ktor:ktor-client-content-negotiation:2.1.1")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.1.1")
implementation("io.ktor:ktor-client-logging:2.1.1")
implementation("io.ktor:ktor-client-core:2.0.1")
implementation("io.ktor:ktor-client-content-negotiation:2.0.1")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.0.1")
implementation("io.ktor:ktor-client-logging:2.0.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("io.ktor:ktor-client-auth:2.1.1")
implementation("io.ktor:ktor-client-auth:2.0.1")
implementation("org.jsoup:jsoup:1.14.3")
//Dependency Injection
@ -60,7 +60,7 @@ kotlin {
}
val androidMain by getting {
dependencies {
implementation("io.ktor:ktor-client-okhttp:2.1.1")
implementation("io.ktor:ktor-client-android:2.0.1")
// Sql
implementation(SqlDelight.android)
@ -94,7 +94,7 @@ kotlin {
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
dependencies {
implementation("io.ktor:ktor-client-ios:2.1.1")
implementation("io.ktor:ktor-client-ios:2.0.1")
}
//iosSimulatorArm64Test.dependsOn(this)
}

View File

@ -48,7 +48,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
// TODO: Use the updatedSince parameter
var fetchedItems: SelfossModel.StatusAndData<List<SelfossModel.Item>> = SelfossModel.StatusAndData.error()
var fromDB = false
if (isNetworkAvailable()) {
fetchedItems = api.getItems(
displayedItems.type,
@ -60,7 +59,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
)
} else {
if (appSettingsService.isItemCachingEnabled()) {
fromDB = true
fetchedItems = SelfossModel.StatusAndData.succes(
getDBItems().filter {
displayedItems == ItemType.ALL ||
@ -73,9 +71,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
if (fetchedItems.success && fetchedItems.data != null) {
items = ArrayList(fetchedItems.data!!)
if (fromDB) {
items.sortByDescending { dateUtils.parseDate(it.datetime) }
}
sortItems()
}
return items
}
@ -96,6 +92,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
if (fetchedItems.success && fetchedItems.data != null) {
items.addAll(fetchedItems.data!!)
sortItems()
}
return items
}
@ -121,6 +118,10 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
}
}
private fun sortItems() {
items.sortByDescending { dateUtils.parseDate(it.datetime) }
}
suspend fun reloadBadges(): Boolean {
var success = false
if (isNetworkAvailable()) {

View File

@ -88,7 +88,7 @@ class AppSettingsService {
}
fun refreshItemsNumber() {
_itemsNumber = settings.getString("prefer_api_items_number", "20").toInt()
_itemsNumber = settings.getString("prefer_api_items_number", "200").toInt()
}
fun getApiTimeout(): Long {