From 3064b3b8358d29c5faec97ee2003ea6d100703ad Mon Sep 17 00:00:00 2001 From: Amine Date: Wed, 17 Oct 2018 19:46:30 +0200 Subject: [PATCH] Closes #228 by removing the list action bar. Action buttons are exclusively on the card view from now on. --- CHANGELOG.md | 2 + .../adapters/ItemListAdapter.kt | 88 +------------------ app/src/main/res/layout/list_item.xml | 66 +------------- 3 files changed, 4 insertions(+), 152 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62a0f72..5b95f0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - Closing #1. Initial article caching. +- Closing #228 by removing the list action bar. Action buttons are exclusively on the card view from now on. + **1.6.x** - Handling hidden tags. diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt index 107efb6..4c93235 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt @@ -49,7 +49,6 @@ class ItemListAdapter( ) : ItemsAdapter() { private val generator: ColorGenerator = ColorGenerator.MATERIAL private val c: Context = app.baseContext - private val bars: ArrayList = ArrayList(Collections.nCopies(items.size + 1, false)) override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val v = LayoutInflater.from(c).inflate( @@ -105,19 +104,6 @@ class ItemListAdapter( } else { c.bitmapCenterCrop(itm.getThumbnail(c), holder.mView.itemImage) } - - // TODO: maybe handle this differently. It crashes when changing tab - try { - if (bars[position]) { - holder.mView.actionBar.visibility = View.VISIBLE - } else { - holder.mView.actionBar.visibility = View.GONE - } - } catch (e: IndexOutOfBoundsException) { - holder.mView.actionBar.visibility = View.GONE - } - - holder.mView.favButton.isLiked = itm.starred } override fun getItemCount(): Int = items.size @@ -125,76 +111,14 @@ class ItemListAdapter( inner class ViewHolder(val mView: ConstraintLayout) : RecyclerView.ViewHolder(mView) { init { - handleClickListeners() handleCustomTabActions() } - private fun handleClickListeners() { - - mView.favButton.setOnLikeListener(object : OnLikeListener { - override fun liked(likeButton: LikeButton) { - val (id) = items[adapterPosition] - api.starrItem(id).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - } - - override fun onFailure( - call: Call, - t: Throwable - ) { - mView.favButton.isLiked = false - Toast.makeText( - c, - R.string.cant_mark_favortie, - Toast.LENGTH_SHORT - ).show() - } - }) - } - - override fun unLiked(likeButton: LikeButton) { - val (id) = items[adapterPosition] - api.unstarrItem(id).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - } - - override fun onFailure( - call: Call, - t: Throwable - ) { - mView.favButton.isLiked = true - Toast.makeText( - c, - R.string.cant_unmark_favortie, - Toast.LENGTH_SHORT - ).show() - } - }) - } - }) - - mView.shareBtn.setOnClickListener { - c.shareLink(items[adapterPosition].getLinkDecoded()) - } - - mView.browserBtn.setOnClickListener { - c.openInBrowserAsNewTask(items[adapterPosition]) - - } - } - private fun handleCustomTabActions() { val customTabsIntent = c.buildCustomTabsIntent() helper.bindCustomTabsService(app) - mView.setOnClickListener { actionBarShowHide() } - mView.setOnLongClickListener { + mView.setOnClickListener { c.openItemUrl( items, adapterPosition, @@ -204,16 +128,6 @@ class ItemListAdapter( articleViewer, app ) - true - } - } - - private fun actionBarShowHide() { - bars[adapterPosition] = true - if (mView.actionBar.visibility == View.GONE) { - mView.actionBar.visibility = View.VISIBLE - } else { - mView.actionBar.visibility = View.GONE } } } diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml index 2b03650..7415fe5 100644 --- a/app/src/main/res/layout/list_item.xml +++ b/app/src/main/res/layout/list_item.xml @@ -11,7 +11,6 @@ android:id="@+id/itemImage" android:layout_width="88dp" android:layout_height="88dp" - app:layout_constraintBottom_toBottomOf="@+id/actionBar" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -40,79 +39,16 @@ android:id="@+id/sourceTitleAndDate" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:layout_marginEnd="16dp" android:layout_marginStart="16dp" android:layout_marginTop="8dp" + android:layout_marginEnd="16dp" android:gravity="start" android:textAlignment="viewStart" android:textSize="14sp" - app:layout_constraintBottom_toBottomOf="@+id/actionBar" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toEndOf="@+id/itemImage" app:layout_constraintTop_toBottomOf="@+id/title" tools:text="Google Actualité Il y a 5h" /> - - - - - - - - - - \ No newline at end of file