mirror of
https://github.com/PhilKes/NotallyX.git
synced 2025-06-28 20:29:54 +00:00
Merge pull request #28 from PhilKes/feat/display-image-position
Display image preview position in top right corner
This commit is contained in:
commit
1d84a1bf47
6 changed files with 87 additions and 42 deletions
|
@ -416,20 +416,39 @@ abstract class EditActivity(private val type: Type) : AppCompatActivity() {
|
|||
|
||||
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||
binding.ImagePreview.scrollToPosition(positionStart)
|
||||
binding.ImagePreviewPosition.text =
|
||||
"${positionStart + 1}/${imageAdapter.itemCount}"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.ImagePreview.apply {
|
||||
setHasFixedSize(true)
|
||||
adapter = imageAdapter
|
||||
layoutManager = LinearLayoutManager(this@EditActivity, RecyclerView.HORIZONTAL, false)
|
||||
PagerSnapHelper().attachToRecyclerView(this)
|
||||
|
||||
val pagerSnapHelper = PagerSnapHelper()
|
||||
pagerSnapHelper.attachToRecyclerView(this)
|
||||
addOnScrollListener(
|
||||
object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
super.onScrollStateChanged(recyclerView, newState)
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
val snappedView = pagerSnapHelper.findSnapView(layoutManager)
|
||||
if (snappedView != null) {
|
||||
val position = recyclerView.getChildAdapterPosition(snappedView)
|
||||
binding.ImagePreviewPosition.text =
|
||||
"${position + 1}/${imageAdapter.itemCount}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
model.images.observe(this) { list ->
|
||||
imageAdapter.submitList(list)
|
||||
binding.ImagePreview.isVisible = list.isNotEmpty()
|
||||
binding.ImagePreviewPosition.isVisible = list.size > 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -201,17 +201,14 @@ class BaseNoteVH(
|
|||
)
|
||||
.into(ImageView)
|
||||
if (images.size > 1) {
|
||||
Space.visibility = View.GONE
|
||||
ImageViewMore.apply {
|
||||
text = getQuantityString(R.plurals.more_images, images.size - 1)
|
||||
text = images.size.toString()
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
} else {
|
||||
ImageViewMore.visibility = View.GONE
|
||||
Space.visibility = View.VISIBLE
|
||||
}
|
||||
} else {
|
||||
Space.visibility = View.VISIBLE
|
||||
ImageView.visibility = View.GONE
|
||||
Message.visibility = View.GONE
|
||||
ImageViewMore.visibility = View.GONE
|
||||
|
|
|
@ -27,10 +27,38 @@
|
|||
android:orientation="vertical"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/ImageLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.philkes.notallyx.presentation.view.misc.AspectRatioRecyclerView
|
||||
android:id="@+id/ImagePreview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp" />
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/ImagePreviewPosition"
|
||||
style="@style/Preview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:gravity="top"
|
||||
android:stateListAnimator="@null"
|
||||
android:textAppearance="?attr/textAppearanceCaption"
|
||||
android:visibility="visible"
|
||||
app:chipIcon="@drawable/add_images"
|
||||
app:chipStartPadding="8dp"
|
||||
app:layout_constraintEnd_toEndOf="@id/ImagePreview"
|
||||
app:layout_constraintTop_toTopOf="@id/ImagePreview"
|
||||
app:textStartPadding="2dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/EnterTitle"
|
||||
|
|
|
@ -16,12 +16,41 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Colorless">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ImageView"
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/ImageLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintDimensionRatio="4:3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ImageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintDimensionRatio="4:3"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/ImageViewMore"
|
||||
style="@style/Preview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:gravity="top"
|
||||
android:stateListAnimator="@null"
|
||||
android:textAppearance="?attr/textAppearanceCaption"
|
||||
android:visibility="visible"
|
||||
app:chipIcon="@drawable/add_images"
|
||||
app:chipStartPadding="8dp"
|
||||
app:layout_constraintEnd_toEndOf="@id/ImageView"
|
||||
app:layout_constraintTop_toTopOf="@id/ImageView"
|
||||
app:textStartPadding="2dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Message"
|
||||
|
@ -31,31 +60,13 @@
|
|||
android:text="@string/cant_load_image"
|
||||
android:textAppearance="?attr/textAppearanceBody2"
|
||||
app:layout_constraintDimensionRatio="4:3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/ImageViewMore"
|
||||
style="@style/Preview"
|
||||
android:visibility="visible"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:clickable="false"
|
||||
android:layout_marginStart="6dp"
|
||||
android:textAppearance="?attr/textAppearanceCaption"
|
||||
android:stateListAnimator="@null"
|
||||
app:chipStartPadding="8dp"
|
||||
app:textStartPadding="2dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/ImageView"
|
||||
/>
|
||||
app:layout_constraintTop_toBottomOf="@id/ImageLayout" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/Space"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/ImageViewMore" />
|
||||
app:layout_constraintTop_toBottomOf="@id/Message" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Title"
|
||||
|
|
|
@ -152,11 +152,6 @@
|
|||
<item quantity="other">Kann %d Bilder nicht hinzufügen</item>
|
||||
</plurals>
|
||||
|
||||
<plurals name="more_images">
|
||||
<item quantity="one">…%d weiteres Bild</item>
|
||||
<item quantity="other">…%d weitere Bilder</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Files -->
|
||||
<plurals name="more_files">
|
||||
<item quantity="one">…%d weitere Datei</item>
|
||||
|
|
|
@ -165,11 +165,6 @@
|
|||
<item quantity="other">Can’t add %d images</item>
|
||||
</plurals>
|
||||
|
||||
<plurals name="more_images">
|
||||
<item quantity="one">…%d more image</item>
|
||||
<item quantity="other">…%d more images</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Files -->
|
||||
<string name="adding_files">Adding files</string>
|
||||
<string name="deleting_files">Deleting files</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue