Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DROID-2815 Editor | Fix | Show loading state for image block #1917

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.anytypeio.anytype.core_ui.databinding.ItemBlockPictureBinding
import com.anytypeio.anytype.core_ui.features.editor.decoration.DecoratableCardViewHolder
import com.anytypeio.anytype.core_ui.features.editor.decoration.EditorDecorationContainer
import com.anytypeio.anytype.core_ui.features.editor.decoration.applySelectorOffset
import com.anytypeio.anytype.core_utils.ext.gone
import com.anytypeio.anytype.core_utils.ext.invisible
import com.anytypeio.anytype.core_utils.ext.visible
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
Expand All @@ -26,6 +27,7 @@ class Picture(val binding: ItemBlockPictureBinding) : Media(binding.root), Decor
override val clickContainer: View = root
private val image = binding.image
private val error = binding.error
private val loading = binding.progress

override val decoratableContainer: EditorDecorationContainer = binding.decorationContainer
override val decoratableCard: View = binding.card
Expand All @@ -42,6 +44,7 @@ class Picture(val binding: ItemBlockPictureBinding) : Media(binding.root), Decor
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
loading.gone()
error.visible()
Timber.w(e, "Error while loading picture with url: $model")
return false
Expand All @@ -54,13 +57,15 @@ class Picture(val binding: ItemBlockPictureBinding) : Media(binding.root), Decor
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
loading.gone()
error.invisible()
return false
}
}

fun bind(item: BlockView.Media.Picture, clicked: (ListenerType) -> Unit) {
super.bind(item, clicked)
loading.visible()
Glide
.with(image)
.load(item.url)
Expand Down
8 changes: 8 additions & 0 deletions core-ui/src/main/res/layout/item_block_picture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
app:cardElevation="0dp"
app:cardCornerRadius="8dp">

<androidx.core.widget.ContentLoadingProgressBar
android:layout_gravity="center"
android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall"
android:theme="@style/GreyProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<ImageView
android:adjustViewBounds="true"
android:id="@+id/image"
Expand Down
Loading