mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Improve: Fix weird behaviour on scroll
I wonder why nobody noticed but scrolling is weird in App Detail page
This commit is contained in:
parent
64a61da973
commit
c6ba8d72ed
@ -87,7 +87,7 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
data class Downloading(val read: Long, val total: Long?) : Status()
|
||||
}
|
||||
|
||||
enum class ViewType { APP_INFO, SWITCH, SECTION, EXPAND, TEXT, LINK, PERMISSIONS, RELEASE, EMPTY }
|
||||
enum class ViewType { APP_INFO, SCREENSHOT, SWITCH, SECTION, EXPAND, TEXT, LINK, PERMISSIONS, RELEASE, EMPTY }
|
||||
|
||||
private enum class SwitchType(val titleResId: Int) {
|
||||
IGNORE_ALL_UPDATES(R.string.ignore_all_updates),
|
||||
@ -105,7 +105,7 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
|
||||
internal enum class ExpandType {
|
||||
NOTHING, DESCRIPTION, CHANGES,
|
||||
LINKS, DONATES, PERMISSIONS, SCREENSHOTS, VERSIONS
|
||||
LINKS, DONATES, PERMISSIONS, VERSIONS
|
||||
}
|
||||
|
||||
private enum class TextType { DESCRIPTION, ANTI_FEATURES, CHANGES }
|
||||
@ -131,7 +131,6 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
val repository: Repository,
|
||||
val product: Product,
|
||||
val packageName: String,
|
||||
val screenshots: List<Product.Screenshot>,
|
||||
) : Item() {
|
||||
override val descriptor: String
|
||||
get() = "app_info.${product.name}"
|
||||
@ -140,6 +139,18 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
get() = ViewType.APP_INFO
|
||||
}
|
||||
|
||||
class ScreenshotItem(
|
||||
val screenshots: List<Product.Screenshot>,
|
||||
val packageName: String,
|
||||
val repository: Repository,
|
||||
) : Item() {
|
||||
override val descriptor: String
|
||||
get() = "screenshot.${screenshots.size}"
|
||||
override val viewType: ViewType
|
||||
get() = ViewType.SCREENSHOT
|
||||
|
||||
}
|
||||
|
||||
class SwitchItem(
|
||||
val switchType: SwitchType,
|
||||
val packageName: String,
|
||||
@ -314,12 +325,6 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
val statusLayout = itemView.findViewById<View>(R.id.status_layout)!!
|
||||
val status = itemView.findViewById<MaterialTextView>(R.id.status)!!
|
||||
val progress = itemView.findViewById<LinearProgressIndicator>(R.id.progress)!!
|
||||
val screenshotsSection =
|
||||
itemView.findViewById<LinearLayoutCompat>(R.id.screenshots_section)!!
|
||||
val screenshotsSectionIcon =
|
||||
itemView.findViewById<ShapeableImageView>(R.id.screenshots_section_icon)!!
|
||||
val screenshotsView = itemView.findViewById<NestedScrollView>(R.id.screenshots_view)!!
|
||||
val screenshotsRecycler = itemView.findViewById<RecyclerView>(R.id.screenshots_recycler)!!
|
||||
|
||||
val progressIcon: Drawable
|
||||
val defaultIcon: Drawable
|
||||
@ -346,6 +351,16 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
val dev = itemView.findViewById<MaterialCardView>(R.id.dev_block)!!
|
||||
}
|
||||
|
||||
private class ScreenShotViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
val screenshotsSection =
|
||||
itemView.findViewById<LinearLayoutCompat>(R.id.screenshots_section)!!
|
||||
val screenshotsSectionIcon =
|
||||
itemView.findViewById<ShapeableImageView>(R.id.screenshots_section_icon)!!
|
||||
val screenshotsView = itemView.findViewById<NestedScrollView>(R.id.screenshots_view)!!
|
||||
val screenshotsRecycler = itemView.findViewById<RecyclerView>(R.id.screenshots_recycler)!!
|
||||
}
|
||||
|
||||
private class SwitchViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val enabled = itemView.findViewById<SwitchMaterial>(R.id.enabled)!!
|
||||
|
||||
@ -554,8 +569,12 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
items += Item.AppInfoItem(
|
||||
productRepository.second,
|
||||
productRepository.first,
|
||||
packageName
|
||||
)
|
||||
items += Item.ScreenshotItem(
|
||||
productRepository.first.screenshots,
|
||||
packageName,
|
||||
productRepository.first.screenshots
|
||||
productRepository.second
|
||||
)
|
||||
|
||||
if (installedItem != null) {
|
||||
@ -892,6 +911,7 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
ViewType.APP_INFO -> AppInfoViewHolder(parent.inflate(R.layout.item_app_info_x)).apply {
|
||||
action.setOnClickListener { this@ProductAdapter.action?.let(callbacks::onActionClick) }
|
||||
}
|
||||
ViewType.SCREENSHOT -> ScreenShotViewHolder(parent.inflate(R.layout.screenshot_scrollview))
|
||||
ViewType.SWITCH -> SwitchViewHolder(parent.inflate(R.layout.switch_item)).apply {
|
||||
itemView.setOnClickListener {
|
||||
val switchItem = items[adapterPosition] as Item.SwitchItem
|
||||
@ -1074,25 +1094,6 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
iconTint = if (action == Action.CANCEL) holder.actionTintOnCancel
|
||||
else holder.actionTintOnNormal
|
||||
}
|
||||
if (item.screenshots.isEmpty()) {
|
||||
holder.screenshotsSection.visibility = View.GONE
|
||||
holder.screenshotsView.visibility = View.GONE
|
||||
} else {
|
||||
holder.screenshotsSection.visibility = View.VISIBLE
|
||||
holder.screenshotsView.visibility = View.VISIBLE
|
||||
holder.screenshotsSection.setOnClickListener {
|
||||
val isExpanded = holder.screenshotsView.visibility == View.VISIBLE
|
||||
holder.screenshotsSectionIcon.scaleY = if (isExpanded) -1f else 1f
|
||||
holder.screenshotsView.visibility =
|
||||
if (isExpanded) View.GONE else View.VISIBLE
|
||||
}
|
||||
holder.screenshotsRecycler.layoutManager =
|
||||
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
holder.screenshotsRecycler.adapter =
|
||||
ScreenshotsAdapter { callbacks.onScreenshotClick(it) }.apply {
|
||||
setScreenshots(item.repository, item.packageName, item.screenshots)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updateAll || updateStatus) {
|
||||
val status = status
|
||||
@ -1165,6 +1166,29 @@ class ProductAdapter(private val callbacks: Callbacks) :
|
||||
true
|
||||
}
|
||||
}
|
||||
ViewType.SCREENSHOT -> {
|
||||
holder as ScreenShotViewHolder
|
||||
item as Item.ScreenshotItem
|
||||
if (item.screenshots.isEmpty()) {
|
||||
holder.screenshotsSection.visibility = View.GONE
|
||||
holder.screenshotsView.visibility = View.GONE
|
||||
} else {
|
||||
holder.screenshotsSection.visibility = View.VISIBLE
|
||||
holder.screenshotsView.visibility = View.VISIBLE
|
||||
holder.screenshotsSection.setOnClickListener {
|
||||
val isExpanded = holder.screenshotsView.visibility == View.VISIBLE
|
||||
holder.screenshotsSectionIcon.scaleY = if (isExpanded) -1f else 1f
|
||||
holder.screenshotsView.visibility =
|
||||
if (isExpanded) View.GONE else View.VISIBLE
|
||||
}
|
||||
holder.screenshotsRecycler.layoutManager =
|
||||
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
holder.screenshotsRecycler.adapter =
|
||||
ScreenshotsAdapter { callbacks.onScreenshotClick(it) }.apply {
|
||||
setScreenshots(item.repository, item.packageName, item.screenshots)
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewType.SWITCH -> {
|
||||
holder as SwitchViewHolder
|
||||
item as Item.SwitchItem
|
||||
|
@ -235,54 +235,9 @@
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
app:iconGravity="textStart"
|
||||
app:layout_constraintBottom_toTopOf="@id/screenshots_section"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/status_layout"
|
||||
app:shapeAppearanceOverlay="@style/PillShapeAppearance" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/screenshots_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/action">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/screenshots"
|
||||
android:textColor="?attr/colorAccent" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/screenshots_section_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_arrow_down"
|
||||
android:tint="?attr/colorAccent"
|
||||
tools:ignore="ContentDescription" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/screenshots_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/screenshots_section">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/screenshots_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
47
src/main/res/layout/screenshot_scrollview.xml
Normal file
47
src/main/res/layout/screenshot_scrollview.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/screenshots_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/screenshots"
|
||||
android:textColor="?attr/colorAccent" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/screenshots_section_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_arrow_down"
|
||||
android:tint="?attr/colorAccent"
|
||||
tools:ignore="ContentDescription" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/screenshots_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/screenshots_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
Loading…
x
Reference in New Issue
Block a user