Skip to content

Commit

Permalink
Put extensions in their own package
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinokuni committed Dec 10, 2024
1 parent 5f99afc commit fb49ffe
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/readrops/app/item/ItemScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import com.readrops.app.util.components.AndroidScreen
import com.readrops.app.util.components.CenteredProgressIndicator
import com.readrops.app.util.components.FeedIcon
import com.readrops.app.util.components.IconText
import com.readrops.app.util.openInCustomTab
import com.readrops.app.util.openUrl
import com.readrops.app.util.extensions.openInCustomTab
import com.readrops.app.util.extensions.openUrl
import com.readrops.app.util.theme.MediumSpacer
import com.readrops.app.util.theme.ShortSpacer
import com.readrops.app.util.theme.spacing
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/readrops/app/more/MoreTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import com.readrops.app.account.selection.adaptiveIconPainterResource
import com.readrops.app.more.preferences.PreferencesScreen
import com.readrops.app.util.components.IconText
import com.readrops.app.util.components.SelectableIconText
import com.readrops.app.util.openUrl
import com.readrops.app.util.extensions.openUrl
import com.readrops.app.util.theme.LargeSpacer
import com.readrops.app.util.theme.MediumSpacer
import com.readrops.app.util.theme.ShortSpacer
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/readrops/app/sync/SyncWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.readrops.app.MainActivity
import com.readrops.app.R
import com.readrops.app.ReadropsApp
import com.readrops.app.repositories.SyncResult
import com.readrops.app.util.putSerializable
import com.readrops.app.util.extensions.putSerializable
import com.readrops.db.Database
import com.readrops.db.entities.account.Account
import kotlinx.coroutines.flow.first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import com.readrops.app.repositories.ErrorResult
import com.readrops.app.repositories.GetFoldersWithFeeds
import com.readrops.app.sync.SyncWorker
import com.readrops.app.util.Preferences
import com.readrops.app.util.clearSerializables
import com.readrops.app.util.getSerializable
import com.readrops.app.util.extensions.clearSerializables
import com.readrops.app.util.extensions.getSerializable
import com.readrops.db.Database
import com.readrops.db.entities.Feed
import com.readrops.db.entities.Folder
Expand Down
19 changes: 6 additions & 13 deletions app/src/main/java/com/readrops/app/timelime/TimelineTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.paging.LoadState
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.itemKey
Expand All @@ -67,8 +66,11 @@ import com.readrops.app.util.components.CenteredProgressIndicator
import com.readrops.app.util.components.Placeholder
import com.readrops.app.util.components.RefreshScreen
import com.readrops.app.util.components.dialog.TwoChoicesDialog
import com.readrops.app.util.openInCustomTab
import com.readrops.app.util.openUrl
import com.readrops.app.util.extensions.isError
import com.readrops.app.util.extensions.isLoading
import com.readrops.app.util.extensions.isNotEmpty
import com.readrops.app.util.extensions.openInCustomTab
import com.readrops.app.util.extensions.openUrl
import com.readrops.app.util.theme.spacing
import com.readrops.db.entities.OpenIn
import com.readrops.db.filters.MainFilter
Expand Down Expand Up @@ -320,7 +322,7 @@ object TimelineTab : Tab {
isRefreshing = state.isRefreshing,
onRefresh = { screenModel.refreshTimeline() },
) {
if (items.itemCount > 0) {
if (items.isNotEmpty()) {
MarkItemsRead(
lazyListState = lazyListState,
items = items,
Expand Down Expand Up @@ -502,13 +504,4 @@ object TimelineTab : Tab {
}
}
}
}


fun <T : Any> LazyPagingItems<T>.isLoading(): Boolean {
return loadState.refresh is LoadState.Loading && itemCount == 0
}

fun <T : Any> LazyPagingItems<T>.isError(): Boolean {
return loadState.append is LoadState.Error //|| loadState.refresh is LoadState.Error
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import com.readrops.app.util.theme.spacing
import com.readrops.app.util.toDp
import com.readrops.app.util.extensions.toDp

@Composable
fun BaseText(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.readrops.app.util
package com.readrops.app.util.extensions

import android.content.Context
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.readrops.app.util
package com.readrops.app.util.extensions

import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
Expand All @@ -8,7 +8,6 @@ import java.io.Serializable

fun TextStyle.toDp(): Dp = fontSize.value.dp


val Data.serializables by lazy {
mutableMapOf<String, Serializable>()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.readrops.app.util.extensions

import androidx.paging.LoadState
import androidx.paging.compose.LazyPagingItems

fun <T : Any> LazyPagingItems<T>.isLoading(): Boolean {
return loadState.refresh is LoadState.Loading && itemCount == 0
}

fun <T : Any> LazyPagingItems<T>.isError(): Boolean {
return loadState.append is LoadState.Error //|| loadState.refresh is LoadState.Error
}

fun <T : Any> LazyPagingItems<T>.isNotEmpty(): Boolean {
return itemCount > 0
}

0 comments on commit fb49ffe

Please sign in to comment.